Embedding Reference¶
bear.embedding
¶
TextType
¶
Provider
¶
Embedder
¶
Bases: Protocol
Protocol for embedding text into vector representations.
Example
Source code in bear/embedding.py
OpenAIEmbedder
¶
Embedder using OpenAI's API.
Source code in bear/embedding.py
info
property
¶
Return information about the OpenAI embedder.
from_config(embedding_config)
classmethod
¶
Create an OpenAIEmbedder instance from configuration.
Source code in bear/embedding.py
get_dimensions()
cached
¶
embed(text, text_type)
¶
Use OpenAI to embed text into a vector representation.
Source code in bear/embedding.py
TEIEmbedder
¶
Embedder using Text Embedding Inference API (via OpenAI python client).
Source code in bear/embedding.py
info
property
¶
Return information about the TEI embedder.
from_config(embedding_config)
classmethod
¶
Create a TEIEmbedder instance from configuration.
Source code in bear/embedding.py
get_dimensions()
cached
¶
embed(text, text_type)
¶
Use Text Embedding Inference to embed text into a vector representation.
Source code in bear/embedding.py
append_prefix(text, prefix)
¶
Append a prefix to the text or each item in the list.
get_embedder(embedding_config=config.default_embedding_config)
¶
Get the embedder instance based on configuration.
Source code in bear/embedding.py
embed_query(query, embedding_config=config.default_embedding_config)
¶
Embed a query string into a vector representation.
Source code in bear/embedding.py
embed_resources(resources, batch_size=256, embedding_config=config.default_embedding_config, embedding_field='embedding')
¶
Embed a list of resources in batch.
Source code in bear/embedding.py
Embedding Generation¶
The embedding module handles text vectorization using OpenAI's embedding models.
Features¶
- OpenAI API integration
- Batch processing
- Error handling and retries
- Multiple embedding model support
Supported Models¶
- text-embedding-3-large (default)
- text-embedding-3-small
- text-embedding-ada-002
Usage¶
Embeddings are automatically generated during the ingestion process.