.env → choose providers → handle pruning.Supported Providers
Cognee supports multiple embedding providers:- OpenAI — Text embedding models via OpenAI API (default)
- Azure OpenAI — Text embedding models via Azure OpenAI Service
- Google Gemini — Embedding models via Google AI
- Mistral — Embedding models via Mistral AI
- AWS Bedrock — Embedding models via AWS Bedrock
- Ollama — Local embedding models via Ollama
- LM Studio — Local embedding models via LM Studio
- Fastembed — CPU-friendly local embeddings
- HuggingFace — Embedding models via HuggingFace Inference API or Inference Endpoints
- vLLM — Self-hosted embedding models via vLLM
- OpenAI-Compatible — Direct OpenAI SDK for llama.cpp, vLLM, TEI, and any
/v1/embeddingsserver (bypasses LiteLLM) - Custom — OpenAI-compatible embedding endpoints routed through LiteLLM (DeepInfra, company-internal)
Configuration
Environment Variables
Environment Variables
.env file:EMBEDDING_PROVIDER— The provider to use:openai,gemini,mistral,bedrock,ollama,fastembed,openai_compatible,custom. These are not the same valuesLLM_PROVIDERaccepts — see Valid EMBEDDING_PROVIDER values and endpoint URL formsEMBEDDING_MODEL— The specific embedding model to useEMBEDDING_DIMENSIONS— The vector dimension size (must match your vector store)EMBEDDING_API_KEY— Your API key (falls back toLLM_API_KEYif not set — with one exception whenLLM_PROVIDER="custom")EMBEDDING_ENDPOINT— Custom endpoint URL (for Azure, Ollama, or custom providers)EMBEDDING_API_VERSION— API version (for Azure OpenAI)EMBEDDING_MAX_COMPLETION_TOKENS— Maximum input tokens per embedded text; used for tokenizer-based chunk sizing (optional, default8191). Set it to your embedding model’s real input limit — see Max Completion TokensHUGGINGFACE_TOKENIZER— HuggingFace Hub model ID that overrides the tokenizer Cognee uses for token counting when the embedding model is not itself a HuggingFace repo. Commonly used with Ollama embeddings (for example,nomic-ai/nomic-embed-text-v1.5).
Provider Setup Guides
OpenAI (Default)
OpenAI (Default)
Azure OpenAI Embeddings
Azure OpenAI Embeddings
KeyError: 'Could not automatically map text-embedding-3-large to a tokeniser.', the installed tiktoken is too old to recognise the model. Cognee strips the azure/ prefix and asks TikToken for the encoding of text-embedding-3-large, which requires tiktoken>=0.5.2 (Cognee pins >=0.8.0). Upgrade in your environment:Google Gemini
Google Gemini
Mistral
Mistral
AWS Bedrock
AWS Bedrock
Ollama (Local)
Ollama (Local)
HUGGINGFACE_TOKENIZER is the HuggingFace repo ID of the tokenizer used for token-length counting when sending requests to the Ollama embedding endpoint.Installation: Install Ollama from ollama.ai and pull your desired embedding model:HUGGINGFACE_TOKENIZER is optional. It is no longer part of Cognee’s required startup validation, so setting EMBEDDING_PROVIDER, EMBEDDING_MODEL, and EMBEDDING_DIMENSIONS without it no longer raises a ValidationError on import. It is still recommended for Ollama: set it to the HuggingFace repo ID for the tokenizer that matches your embedding model so token-length counts stay accurate. See the HUGGINGFACE_TOKENIZER environment variable section below for how to find the correct value for your model.If HUGGINGFACE_TOKENIZER is unset or points at a repo that cannot be loaded, tokenizer resolution no longer raises — Cognee logs an advisory warning and falls back to the TikToken tokenizer, so ingestion continues with approximate token counts. Cognee also logs an advisory warning whenever the HUGGINGFACE_TOKENIZER value differs from the EMBEDDING_MODEL id, so a genuine mismatch is not silent. Because an Ollama tag such as nomic-embed-text:latest is never identical to its HuggingFace repo id (nomic-ai/nomic-embed-text-v1.5), you will see this advisory even for a correct setup — it is a reminder to confirm the two share a tokenizer, not an error.If a text input exceeds the model’s context window, the Ollama embedding engine automatically falls back by splitting the batch in half and retrying both halves. For a single overlong text, it splits the string into two overlapping segments and averages the resulting embeddings. Cognee no longer pre-truncates text before sending it to Ollama, so this fallback only activates when the server returns a context-length error..env example.LM Studio (Local)
LM Studio (Local)
Fastembed (Local)
Fastembed (Local)
cognee install. Add it with:fastembed and a compatible onnxruntime build. The first call downloads and caches the model weights from Hugging Face, so the initial run needs network access and a few hundred MB of disk for the model cache.Supported models: Any model listed by fastembed’s TextEmbedding.list_supported_models(). Common choices:EMBEDDING_DIMENSIONS is omitted, Cognee tries to auto-derive it from the fastembed model registry; set it explicitly to avoid a fallback to 3072 if lookup fails.EmbeddingContextWindowTooSmallError instead of retrying (see Timeout and Retry Behavior). This mirrors the behavior of the OpenAI-compatible engine.gpt-4o BPE tokenizer, which mis-sized chunks and skewed the --dry-run token estimate. You do not need to set HUGGINGFACE_TOKENIZER for Fastembed. If a model is not in the known list, Cognee logs an advisory warning and falls back to the TikToken tokenizer.HuggingFace
HuggingFace
- Serverless
- Dedicated Endpoint
EMBEDDING_PROVIDER="custom" with a huggingface/ model, Cognee automatically attempts to load a HuggingFace tokenizer from the model repo for token counting. If that fails, it falls back to the TikToken tokenizer. You do not need to set HUGGINGFACE_TOKENIZER manually for this provider — it is only required when using EMBEDDING_PROVIDER="ollama" (see the Ollama section above).vLLM
vLLM
hosted_vllm/ prefix when loading the HuggingFace tokenizer, so no separate HUGGINGFACE_TOKENIZER setting is needed as long as the model name after the prefix is a valid HuggingFace model ID.To verify the model name your vLLM server exposes, run:OpenAI-Compatible Local Servers (llama.cpp, TEI, vLLM)
OpenAI-Compatible Local Servers (llama.cpp, TEI, vLLM)
EMBEDDING_PROVIDER="openai_compatible" for any local inference server that exposes the standard /v1/embeddings endpoint. This provider talks directly to OpenAI-compatible embedding servers via the OpenAI Python SDK, bypassing LiteLLM.Use this provider for: llama.cpp (llama-server --embedding), vLLM, Hugging Face TEI, LocalAI, Infinity, and similar servers.- llama.cpp
- vLLM
- Hugging Face TEI
/v1 to EMBEDDING_ENDPOINT if it is missing, and strips a trailing /embeddings suffix. You can pass either http://localhost:8080 or http://localhost:8080/v1 — both work.openai_compatible engine automatically loads a tokenizer for chunk sizing. It first tries to load a HuggingFace tokenizer matching EMBEDDING_MODEL; if that fails (for example, because the model name is a local alias not on the HuggingFace Hub), it falls back to the TikToken tokenizer. The token limit passed to the tokenizer is controlled by EMBEDDING_MAX_COMPLETION_TOKENS (default 8191). Set this to match your server’s input length limit if it differs from the default:/v1/embeddings endpoints, which usually enforce a smaller input length than the model’s advertised context. See Max Completion Tokens for how to pick the value and how it interacts with EMBEDDING_BATCH_SIZE.BAAI/bge-large-en-v1.5) for token counting. If that fails — for example when using EMBEDDING_MODEL="default" with llama.cpp — Cognee logs an advisory warning and falls back to TikToken, so token counts become approximate but ingestion continues. You do not need to set HUGGINGFACE_TOKENIZER when using EMBEDDING_PROVIDER="openai_compatible".Custom Providers
Custom Providers
EMBEDDING_PROVIDER="custom", EMBEDDING_MODEL (with a LiteLLM provider prefix such as openrouter/, deepinfra/, or openai/), EMBEDDING_API_KEY, and EMBEDDING_DIMENSIONS (set it explicitly — custom models are not in the auto-derive registry, so it otherwise falls back to 3072 and causes a vector-store shape mismatch). EMBEDDING_ENDPOINT is optional: omit it for a named LiteLLM prefix like openrouter/ (LiteLLM supplies the base URL), and set it only when pointing at a specific api_base such as DeepInfra or a self-hosted server.- DeepInfra
- OpenRouter
- Self-Hosted
custom: Unlike openai_compatible, the custom provider passes EMBEDDING_ENDPOINT directly to LiteLLM as api_base with no automatic /v1 appending or /embeddings stripping — and LiteLLM appends /embeddings itself, so http://localhost:1234/v1/embeddings is requested as .../v1/embeddings/embeddings and returns 404. Set the endpoint to exactly the base URL your provider expects (e.g., https://api.deepinfra.com/v1/openai), or omit it entirely when using a named LiteLLM prefix such as openrouter/.Additional Information
Valid EMBEDDING_PROVIDER values and endpoint URL forms
Valid EMBEDDING_PROVIDER values and endpoint URL forms
EMBEDDING_PROVIDER and LLM_PROVIDER are configured independently and do not accept the same values. LLM_PROVIDER is checked against a fixed set of providers, while EMBEDDING_PROVIDER simply selects an embedding engine:fastembed, ollama, and openai_compatible select a dedicated engine. Any other value — including a typo — falls through to the LiteLLM engine without an error.EMBEDDING_PROVIDER="openai_compatible"has no LLM counterpart. SettingLLM_PROVIDER="openai_compatible"fails withValueError: 'openai_compatible' is not a valid LLMProvider— useLLM_PROVIDER="custom"instead (LM Studio, vLLM).anthropic,llama_cpp, andmcp-samplingare LLM-only: they provide no embeddings, so pair them with one of the values above.
EMBEDDING_MODEL can look like it is ignored: the EMBEDDING_PROVIDER string is never sent to LiteLLM — it picks the engine (and, for openrouter, enables the automatic encoding_format guard described in Custom Providers), nothing more. With EMBEDDING_PROVIDER="custom", routing is decided entirely by the EMBEDDING_MODEL prefix, so an unprefixed model id is treated as an OpenAI model and the request goes to OpenAI (or fails on the missing key) instead of your server. Either add the matching prefix, or use openai_compatible, which sends the model id to your endpoint verbatim.Endpoint URL form — the two OpenAI-compatible providers expect different things:LLM_PROVIDER="custom", EMBEDDING_API_KEY does not fall back to LLM_API_KEY for LiteLLM-routed embeddings — set it explicitly (use "." when your server needs no auth). The openai_compatible engine does fall back to LLM_API_KEY..env covering both halves, see LM Studio or the Local Setup guide.Which embedding models are supported?
Which embedding models are supported?
EMBEDDING_PROVIDER; Cognee forwards the embedding request to that provider and stores the returned vectors.fastembed: any model returned byTextEmbedding.list_supported_models(), such assentence-transformers/all-MiniLM-L6-v2. See the Fastembed section for the common list.ollama/ LM Studio: any embedding model loaded locally, such asbge-m3:latestorall-minilm:latest.openai_compatible: any model exposed by a local/v1/embeddingsserver, including llama.cpp, TEI, vLLM, LocalAI, and Infinity.openai/gemini/mistral/bedrock/custom: any model available through the configured provider API, using the corresponding LiteLLM prefix such asopenai/orgemini/.
EMBEDDING_DIMENSIONS to match the model output size:EMBEDDING_DIMENSIONS for models the fastembed or LiteLLM registries know; for anything else — local aliases, custom or openai_compatible endpoints — set it explicitly. See How do I determine EMBEDDING_DIMENSIONS? for how to find the value and what a mismatch does, and Important Notes.How do I determine EMBEDDING_DIMENSIONS?
How do I determine EMBEDDING_DIMENSIONS?
EMBEDDING_DIMENSIONS is the length of the vector your embedding model returns. It is a property of the model, not a free choice. Determine it in this order:- Read the model card or provider docs — for example
text-embedding-3-large→3072,nomic-embed-text-v1.5→768,BAAI/bge-m3→1024. See the table in Which embedding models are supported? for more. - Measure it — embed one string and count the floats. This works for local aliases and self-hosted models that no registry knows:
custom) models: the engine sends the currently configured dimensions value as a request parameter, so an endpoint that rejects that parameter raises UnsupportedParamsError instead of returning a vector. openai_compatible and ollama never send it and always measure cleanly.If you leave it unset, Cognee derives it from the fastembed model registry (for EMBEDDING_PROVIDER="fastembed"), otherwise from LiteLLM’s model metadata (output_vector_size), trying the model id, the id without its provider prefix, and provider/model. When neither knows the model it logs a warning and falls back to 3072:custom / openai_compatible models are usually unknown, so set the value explicitly for them.What a mismatch does: Cognee creates every vector collection using the configured size (Vector(N) in LanceDB, vector(N) in PGVector), so the first write of a differently sized vector fails with a shape/dimension error — the vectors are not silently truncated or padded. Because the size is baked into the collection schema, correcting the value also requires recreating the collections with await cognee.prune.prune_system() and re-ingesting. See Dimension Consistency.text-embedding-3-* models are the exception where a smaller value is legitimate: Cognee forwards EMBEDDING_DIMENSIONS as the dimensions request parameter, and OpenAI returns shortened vectors. Most other models reject that parameter — see UnsupportedParamsError.Batch Size
Batch Size
EMBEDDING_BATCH_SIZE controls how many text chunks are grouped into a single embedding API call. Cognee splits all chunks into batches of this size and sends them concurrently to the embedding engine.36 can overwhelm them. Reduce the batch size if you see errors or slowdowns:36 suits most cloud providers.Relationship to rate limiting: Each batch counts as one request toward EMBEDDING_RATE_LIMIT_REQUESTS. A single file may produce many chunks — with EMBEDDING_BATCH_SIZE=36, a document split into 360 chunks generates 10 requests.Max Completion Tokens
Max Completion Tokens
EMBEDDING_MAX_COMPLETION_TOKENS is the per-text input token budget Cognee’s tokenizer uses to size chunks for the embedding model. It should reflect your embedding model’s maximum input length.- Chunk size, cost and latency. Chunks are sized as
min(EMBEDDING_MAX_COMPLETION_TOKENS, LLM_MAX_COMPLETION_TOKENS // 2). A lower value forces smaller chunks, so a document produces more chunks → more embedding requests (and more LLM extraction calls) → higher latency and cost. A higher value (within the model’s real limit) produces fewer, larger chunks. See Chunkers for how chunk size shapes the graph. - Over-length requests. Setting this above the embedding model’s real input limit can make individual texts exceed the limit. Cognee no longer fails outright — it splits the batch (or mean-pools an over-length string, see Timeout and Retry Behavior) — but that recovery adds latency, so it is not free. “Higher” is only better up to the model’s actual limit.
8191 fits OpenAI’s text-embedding-3-* models. For models with a smaller limit, lower it so chunks fit without triggering the split-and-pool fallback; the related LLM_MAX_COMPLETION_TOKENS (LLM Providers) caps the other half of the formula. With hosted third-party /v1/embeddings endpoints, use the limit the endpoint enforces per text — often smaller than the model’s advertised context — and leave headroom: token counts for these endpoints are usually approximate, because the model id is rarely a loadable HuggingFace repo and Cognee falls back to the TikToken tokenizer (see How Cognee selects the tokenizer).It is a chunk-sizing hint, not an enforced cap
Cognee never sendsEMBEDDING_MAX_COMPLETION_TOKENS to the provider and never truncates text at request time — it only hands the value to the tokenizer that sizes chunks during cognify(). Two consequences:- Setting it too high silently produces over-length requests. The provider rejects them; whether Cognee recovers depends on the error message (see below).
- Setting it above
LLM_MAX_COMPLETION_TOKENS // 2has no effect. With the defaultLLM_MAX_COMPLETION_TOKENS=16384, chunks are capped at8192regardless —EMBEDDING_MAX_COMPLETION_TOKENS=131072and=8192behave identically until you also raise the LLM value.
Chunk size vs. embedding request size
One embedding request carriesEMBEDDING_BATCH_SIZE chunks (default 36, see Batch Size), so the payload is roughly chunk tokens × batch size. Providers that cap the whole request rather than each text will reject a request built from chunks that each fit comfortably. If you hit a length error even though your chunks are within the model’s per-text limit, lower EMBEDDING_BATCH_SIZE rather than EMBEDDING_MAX_COMPLETION_TOKENS.Recovery only fires on recognized error messages
The split-and-pool recovery is triggered by string matching on the provider’s error, so a provider that phrases the limit differently gets no recovery — the run fails withEmbeddingException on openai_compatible, or with the provider’s original error (re-raised after the retry window) on the LiteLLM engines:<400> InternalError.Algo.InvalidParameter: Range of input length should be [1, 33000] matches none of these phrases, so Cognee raises instead of splitting. Configure the limits correctly rather than relying on the fallback.Timeout and Retry Behavior
Timeout and Retry Behavior
LiteLLMEmbeddingEngine applies two layers of protection against slow or unreachable endpoints:- A request that fails fast (connection refused, rate limit,
5xx) is retried repeatedly until the 128-second window is exhausted, exactly as before. - A request that genuinely hangs consumes the full 300 seconds on its first attempt. By the time it is cancelled the 128-second window has already elapsed, so it is not retried — the
EmbeddingExceptionis raised directly. A single hung request therefore blocks its task for up to 5 minutes.
OpenAICompatibleEmbeddingEngine, so both engines now behave the same way.What is not retried:404 Not Founderrors are raised immediately — they indicate a configuration problem (wrong model name or endpoint) rather than a transient failure.asyncio.CancelledErroris treated as terminal and re-raised without retrying, so cancelled tasks unwind promptly instead of consuming the full retry window. The same exclusion applies to theFastembedEmbeddingEngine,OllamaEmbeddingEngine, andOpenAICompatibleEmbeddingEngineretry decorators.EmbeddingContextWindowTooSmallErroris treated as terminal and raised immediately. It is thrown when a single embedding text still exceeds the model’s context window but can no longer be split (the string is too short to divide further), so retrying would deterministically fail again. This exclusion applies to theLiteLLMEmbeddingEngine,FastembedEmbeddingEngine, andOpenAICompatibleEmbeddingEngineretry decorators; the failure returns at once instead of consuming the full 128-second retry window. The exception subclassesEmbeddingException(default messageText is too short to split further but exceeds context window.), so code that already catchesEmbeddingExceptioncontinues to catch it — catchEmbeddingContextWindowTooSmallErrorspecifically to distinguish this deterministic, non-retryable case and shorten or pre-split the offending input.
LiteLLMEmbeddingEngine no longer fails the request. This covers both LiteLLM’s ContextWindowExceededError and a plain 400 BadRequestError whose message matches maximum input length (for example OpenAI’s maximum input length is 8192 tokens, which is returned as a plain 400 by the embeddings API). On either of these:- If the batch contains more than one text, it is split in half and each half is embedded in parallel, then the results are concatenated.
- If a single over-length string is left, it is split into two overlapping segments (the first two-thirds and the last two-thirds of the string), each segment is embedded, and the two vectors are averaged (mean-pooled) into one.
EmbeddingContextWindowTooSmallError instead of retrying — this deterministic failure returns at once rather than consuming the full retry window (see What is not retried). Any other 400 BadRequestError (one whose message does not indicate an over-length input) is re-raised unchanged so genuinely malformed requests still fail fast. The exact error phrasings that trigger this recovery — for this engine and for openai_compatible — are listed under Max Completion Tokens.Common error messages and causes:EmbeddingException: Embedding request timed out. Check EMBEDDING_ENDPOINT connectivity.— The attempt did not complete within 300 seconds. Verify thatEMBEDDING_ENDPOINTis reachable from your network. Since the deadline also covers time spent queued client-side, check that your embedding concurrency is bounded before assuming the endpoint itself is at fault.EmbeddingException: Cannot connect to embedding endpoint. Check EMBEDDING_ENDPOINT.— TCP connection was refused or the server closed the connection before responding. Confirm the server is running and the URL is correct.EmbeddingException: Failed to index data points using model <model>— The provider returned a404 Not Found. Common causes: wrong model name, missinghosted_vllm/prefix for vLLM, or an unsupported model at that endpoint. Non-over-length400 BadRequestErrorresponses are re-raised unchanged.400 invalid_valueonencoding_formatfrom OpenRouter — Older LiteLLM releases serialize an omittedencoding_formatas JSONnull, which OpenRouter rejects. Cognee now forcesencoding_format="float"on detected OpenRouter routes (see the Custom Providers accordion under Provider Setup Guides), so this should no longer occur; if you still see it, upgrade Cognee to a version that includes this guard.
EMBEDDING_BATCH_SIZE to send fewer texts per request:LiteLLMEmbeddingEngine and cannot be changed via environment variables. To use different limits, subclass LiteLLMEmbeddingEngine and override embed_text with a custom @retry decorator.UnsupportedParamsError: passing the dimensions parameter to LiteLLM
UnsupportedParamsError: passing the dimensions parameter to LiteLLM
openai, gemini, mistral, bedrock, and custom), Cognee sends the OpenAI-style dimensions parameter to litellm.aembedding() whenever an embedding dimension is configured. In the .env flow documented on this page, EMBEDDING_DIMENSIONS is required, so this parameter is normally present. Only some models accept dimensions (notably OpenAI’s text-embedding-3-*). Other models — and some LiteLLM proxies — reject it with:dimensions or to forward extra LiteLLM params. The intended fix is LiteLLM’s own drop_params switch, which makes LiteLLM silently drop any parameter the target model does not support (including dimensions) instead of raising — so you can keep routing embeddings through your LiteLLM proxy:- Python (LiteLLM SDK)
- LiteLLM proxy (config.yaml)
openai_compatible provider talks to any /v1/embeddings server directly through the OpenAI SDK and never sends the dimensions parameter, so it avoids this error entirely — at the cost of bypassing LiteLLM.Rate Limiting
Rate Limiting
embed_text() API call = one batch of chunks (not one chunk). With the default EMBEDDING_BATCH_SIZE=36, processing 360 chunks produces 10 requests. See the Batch Size section for how to tune batch size.Sizing guidance:Set EMBEDDING_RATE_LIMIT_REQUESTS to your provider’s RPM limit and EMBEDDING_RATE_LIMIT_INTERVAL to 60. Use ~80–90% of your provider’s advertised limit to leave headroom.Example configurations for common provider tiersThese examples target embedding endpoints, such as OpenAI embedding models like text-embedding-3-large.OpenAI - Tier 1
OpenAI - Tier 1
OpenAI - Free / Very Low Tier
OpenAI - Free / Very Low Tier
Google Gemini - Free Tier
Google Gemini - Free Tier
Conservative Default
Conservative Default
Testing and Development
Testing and Development
HUGGINGFACE_TOKENIZER environment variable
HUGGINGFACE_TOKENIZER environment variable
HUGGINGFACE_TOKENIZER environment variable specifies which Hugging Face tokenizer to use for counting tokens before sending text to the embedding model. It is optional — Cognee no longer requires it at startup, so omitting it does not raise a ValidationError on import — but it is recommended when using the Ollama provider for accurate token counting.Value format: The value is the Hugging Face model repository ID — the {organization}/{model-name} path that appears in the URL on huggingface.co/models. This should match the underlying model used by your Ollama embedding.For example, if the Ollama model nomic-embed-text:latest is built from nomic-ai/nomic-embed-text-v1.5 on Hugging Face, set:Common model-to-tokenizer mappings
Finding the tokenizer for any model
- Look up the model on huggingface.co/models.
- The repository ID is the
{organization}/{model-name}part of the URL (e.g.,huggingface.co/BAAI/bge-m3→BAAI/bge-m3). - Use the repository ID that corresponds to the model your Ollama tag is built from. The Ollama model page typically links to the original Hugging Face repository.
HUGGINGFACE_TOKENIZER is only used by the Ollama embedding engine. It is not needed for OpenAI, Fastembed, openai_compatible, or other providers. For openai_compatible, the engine automatically tries the model name as a HuggingFace tokenizer ID and falls back to TikToken if unavailable — no separate HUGGINGFACE_TOKENIZER value is required.Troubleshooting dependency errors
The HuggingFace tokenizer (HuggingFaceTokenizer, which wraps transformers.AutoTokenizer) backs token counting for the Ollama embedding engine. Cognee also attempts to use it for custom and openai_compatible chunk sizing; if it cannot load, Cognee falls back to TikToken. transformers is not part of the base cognee install — it is an optional dependency shipped by the huggingface and ollama extras (both pin transformers>=4.46.3,<5).ModuleNotFoundError: No module named 'transformers'The tokenizer was triggered (most often by EMBEDDING_PROVIDER="ollama") but transformers is missing. This typically surfaces as Connection to Embedding handler could not be established. Install the extra:cannot import name 'is_offline_mode' from 'huggingface_hub'This is a version mismatch: an old transformers (older than 4.46) is paired with a newer huggingface_hub that no longer exports is_offline_mode. Cognee’s transformers>=4.46.3,<5 pin is compatible with current huggingface_hub (Cognee resolves huggingface_hub 0.36.x). If you previously installed transformers manually, upgrade it into Cognee’s supported range:huggingface / ollama extra pulls in a compatible huggingface_hub automatically, so prefer the extra over pinning huggingface_hub by hand.Important Notes
- Dimension Consistency:
EMBEDDING_DIMENSIONSmust match your vector store collection schema - API Key Fallback: If
EMBEDDING_API_KEYis not set, Cognee usesLLM_API_KEY(except for custom providers) - Tokenization:
HUGGINGFACE_TOKENIZERis optional and no longer enforced by Cognee’s startup validation — but it is recommended for the Ollama provider; set it to the HuggingFace model repo ID that matches your embedding model for accurate token counting - Performance: Local providers (Ollama, Fastembed) are slower but offer privacy and cost benefits
How Cognee selects the tokenizer
How Cognee selects the tokenizer
--dry-run token estimate, so Cognee auto-selects a tokenizer that matches your embedding model:openai— the model’s TikToken (BPE) encoding.gemini— the default TikToken encoding (Gemini has no local tokenizer, so counts are approximate).mistral— the Mistral tokenizer.fastembed— the model’s own HuggingFace (wordpiece) tokenizer, resolved from the fastembed model list.ollama— the tokenizer named byHUGGINGFACE_TOKENIZER.openai_compatible/custom— the embedding model id used as a HuggingFace repo (e.g.BAAI/bge-large-en-v1.5); when that is not a loadable repo — such as a local alias or a LiteLLM-prefixed id — Cognee falls back to TikToken.
--dry-run estimate), it does not stop ingestion.The “could not load a matching tokenizer” warning is benign
A repeated log line such as:openai/..., lm_studio/..., openrouter/...), Ollama tags, and local aliases such as default. Embedding and ingestion continue normally — only chunk sizing and the --dry-run token estimate become approximate.To silence it:ollama— setHUGGINGFACE_TOKENIZERto the HuggingFace repo your Ollama model is built from (see the mappings earlier in this section).openai_compatible— setEMBEDDING_MODELto the served model’s real HuggingFace repo id (for exampleQwen/Qwen3-Embedding-4Binstead ofdefault). This provider needs no LiteLLM prefix, so the id can be the repo id directly.customwithhosted_vllm/— the prefix is stripped automatically before tokenizer resolution, so the warning does not appear as long as the model name after the prefix is a valid HuggingFace repo id (see the vLLM accordion).customwith any other prefix (openai/,lm_studio/,openrouter/, …) — the prefix is required for routing and is passed to tokenizer resolution whole, so the warning cannot be avoided; treat it as informational. If your endpoint is OpenAI-compatible, switching toopenai_compatiblewith the plain repo id removes it.