Skip to content

API Reference parrot.embeddings.base

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.embeddings.base

View source

Alias CUDA_DEFAULT_DEVICE

Re-exported from parrot.conf.CUDA_DEFAULT_DEVICE.

Alias EMBEDDING_DEVICE

Re-exported from parrot.conf.EMBEDDING_DEVICE.

Class EmbeddingModel

Abstract base class for embedding models. It ensures that embedding models can be used interchangeably.

Parameter Type Default Description
model_name str
**kwargs {}

Attributes:

Attribute Type Description
device
model Return the raw library model (e.g. SentenceTransformer), never a wrapper. Resolution order: 1. Use cached _model if already set. 2. Ask the registry for a cached EmbeddingModel wrapper, then extract or lazily create its underlying raw model. 3. Fallback: call _create_embedding() directly.

Method EmbeddingModel.get_embedding_dimension

get_embedding_dimension() -> int

Returns: int

Method EmbeddingModel.initialize_model

Async model initialization with GPU optimization.

Prefers the registry's async get_or_create() path for deduplication. Falls back to direct _create_embedding() if the registry is unavailable.

initialize_model()

Method EmbeddingModel.embed_documents

Generates embeddings for a list of documents.

embed_documents(texts: List[str], batch_size: Optional[int] = None) -> List[List[float]]

Parameter Type Default Description
texts List[str] A list of document strings.
batch_size Optional[int] None

Returns: List[List[float]] — A list of embedding vectors.

Method EmbeddingModel.embed_query

Generates an embedding for a single query string.

embed_query(text: str, as_nparray: bool = False) -> Union[List[float], List[np.ndarray]]

Parameter Type Default Description
text str The query string.
as_nparray bool False

Returns: Union[List[float], List[np.ndarray]] — The embedding vector for the query.

Method EmbeddingModel.free

Frees up resources used by the model.

free()

Method EmbeddingModel.encode

encode(texts: List[str], **kwargs) -> np.ndarray

Parameter Type Default Description
texts List[str]
**kwargs {}

Returns: np.ndarray

Alias lazy_import

Re-exported from parrot._imports.lazy_import.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally