rag.embed
Backward-compatibility shim. Embeddings has moved to ffai.core.embeddings.
Backward-compatibility shim. Embeddings has moved to ffai.core.embeddings.
- class Embeddings(model='mistral/mistral-embed', api_key=None, api_base=None, cache_enabled=True, cache_size=256, device='cpu', **kwargs)[source]
Bases:
objectCompute text embeddings using local or remote models.
Supports local sentence-transformer models (prefix
local/) and remote providers via LiteLLM (e.g.mistral/mistral-embed,openai/text-embedding-3-small). Results are optionally cached in an LRU-style in-memory cache.- Parameters:
model (str) – Model identifier. Use
local/<name>for local sentence-transformer models, or<provider>/<model>for remote APIs.api_key (str | None) – API key for the remote provider. If None, the key is read from a provider-specific environment variable.
api_base (str | None) – Optional custom API base URL.
cache_enabled (bool) – Whether to cache embedding results in memory.
cache_size (int) – Maximum number of entries in the embedding cache.
device (str) – Torch device for local models (e.g.
"cpu","cuda").**kwargs (Any) – Extra keyword arguments forwarded to the LiteLLM embedding call.
- clear_cache()[source]
Clear the embedding cache.
- Returns:
Number of entries that were in the cache before clearing.
- Return type: