Skip to main content
A minimal guide to running a complete cognee pipeline on your own machine: Ollama for both generation and embeddings, and cognee’s embedded stores for the graph, vectors, and metadata. Use it when you want the whole rememberrecall round trip to run without any hosted API call, in a throwaway directory you can delete afterwards.

Before You Start

  • Complete Quickstart to understand basic operations
  • Install Ollama, start it with ollama serve, and pull the two models the script uses:
  • Read Local Setup (No API Key) for the equivalent .env configuration and the local-run troubleshooting list
  • Check LLM Providers and Embedding Providers if you want to point the script at a different local model
  • Nothing else to install: the graph, vector, and relational stores this script selects are embedded and ship with cognee

Code in Action

What Just Happened

Step 1: Isolate the Example’s Storage

A fresh temporary directory keeps this run’s databases away from your default cognee directories, so the example leaves nothing behind. Access control stays off because the script runs as a plain single-user script, and caching stays off so every run really exercises the local models instead of replaying earlier answers.

Step 2: Point Cognee at Ollama

Both halves have to be set together: configuring only the LLM leaves embeddings falling back to OpenAI, which would need an API key. The two endpoints differ because generation goes to Ollama’s OpenAI-compatible path and embeddings go to its native one, LLM_API_KEY is a placeholder Ollama never validates, and EMBEDDING_DIMENSIONS plus HUGGINGFACE_TOKENIZER describe nomic-embed-text so cognee sizes its vectors and counts tokens correctly. The environment is set before import cognee so the configuration is in place when cognee reads it — hence the # noqa: E402 markers on the imports that follow.

Step 3: Pin the Embedded Local Stack

These four calls make the storage side local too: an embedded graph database, LanceDB for vectors, and SQLite metadata, all written under the temporary directory from Step 1. Both calls select what cognee already uses out of the box (kuzu is an accepted alias for the default embedded graph store, and LanceDB is the default vector store), so they are explicit rather than required — they keep the script behaving the same way even if GRAPH_DATABASE_PROVIDER or VECTOR_DB_PROVIDER is set in your environment. See Graph Stores for the other providers these names select between.

Step 4: Remember the Sample Text

remember() runs the whole extraction pipeline against the local models: llama3.1:8b pulls entities and relationships out of the text and nomic-embed-text embeds the chunks. Three sentences is deliberately small — an 8B model on CPU is far slower than a hosted one, so keep test inputs short. llama3.1 is on cognee’s recommended list for structured extraction, so this script runs without warnings; swap in a model cognee hasn’t validated and the log opens with an advisory model-support warning instead — not a failure, extraction continues either way.

Step 5: Recall From the Local Graph

SearchType.GRAPH_COMPLETION retrieves the triplets around the query and asks the local LLM to answer from them, which is the search type that proves the graph was actually populated. datasets=["ollama_local_demo"] scopes the search to the dataset built above, and printing results[0].text shows the generated answer rather than the raw result object.

Local Setup (No API Key)

The same configuration as .env variables, plus local-run troubleshooting.

LLM Providers

Swap in another local or hosted model for generation.

Embedding Providers

Pick a different embedding model and its matching dimensions.