<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chinmay Bhosale</title>
    <description>The latest articles on DEV Community by Chinmay Bhosale (@chinmay_bhosale_9ceed796b).</description>
    <link>https://dev.to/chinmay_bhosale_9ceed796b</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3568996%2F93ec9796-db63-4293-bd59-6c1ddc8b7fca.png</url>
      <title>DEV Community: Chinmay Bhosale</title>
      <link>https://dev.to/chinmay_bhosale_9ceed796b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chinmay_bhosale_9ceed796b"/>
    <language>en</language>
    <item>
      <title>Search Types in Cognee</title>
      <dc:creator>Chinmay Bhosale</dc:creator>
      <pubDate>Mon, 20 Oct 2025 12:20:56 +0000</pubDate>
      <link>https://dev.to/chinmay_bhosale_9ceed796b/search-types-in-cognee-1jo7</link>
      <guid>https://dev.to/chinmay_bhosale_9ceed796b/search-types-in-cognee-1jo7</guid>
      <description>&lt;p&gt;In my &lt;a href="https://dev.to/chinmay_bhosale_9ceed796b/cognee-with-ollama-3pp8"&gt;previous blog on Building 100% local AI memory with cognee&lt;/a&gt;, we explored setting up a completely local AI memory system. But one of Cognee's most powerful features is its &lt;strong&gt;flexibility&lt;/strong&gt;—you're not locked into a single provider. You can mix and match LLM providers, embedding models, and databases to fit your specific needs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/topoteretes/cognee" rel="noopener noreferrer"&gt;Cognee&lt;/a&gt; is an open-source memory framework that replaces traditional RAG systems with a structured knowledge graph approach, achieving 92.5% accuracy compared to RAG's 60%. Whether you're building locally or in the cloud, Cognee adapts to your infrastructure.&lt;/p&gt;

&lt;p&gt;This blog demonstrates Cognee's &lt;strong&gt;cross-platform capabilities&lt;/strong&gt; by using OpenAI's GPT models for high-quality entity extraction while keeping embeddings local with Ollama. More importantly, we'll dive deep into the &lt;strong&gt;different search types&lt;/strong&gt; Cognee offers—from simple vector similarity to advanced graph traversal—each optimized for specific use cases. Understanding these search modes is crucial for getting accurate, relevant results from your knowledge graphs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Primary Search Types (User-Facing)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. SUMMARIES
&lt;/h3&gt;

&lt;p&gt;Returns pre-generated hierarchical summaries that were created during the cognify process. When you query with this type, it performs a vector similarity search against stored summary nodes and returns the most relevant pre-computed summaries without requiring LLM processing at query time. This makes it extremely fast for getting quick overviews of content, as the summarization work was already done during data processing.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. INSIGHTS
&lt;/h3&gt;

&lt;p&gt;Retrieves structured entity relationships and semantic connections directly from the knowledge graph. It performs vector search to find relevant entities, then traverses the graph to extract their relationships (edges) and returns them in a human-readable format showing how concepts connect to each other. This is ideal for understanding the structure of knowledge without needing natural language generation - you get raw relationship data like "Entity A --[relationship_type]--&amp;gt; Entity B".&lt;/p&gt;

&lt;h3&gt;
  
  
  3. CHUNKS
&lt;/h3&gt;

&lt;p&gt;Performs pure vector similarity search to find and return raw text segments that semantically match your query. It searches the vector database for document chunks with embeddings similar to your query embedding, then returns the actual text content of those chunks along with their metadata (source document, position, etc.). This is the fastest search type because it bypasses both graph traversal and LLM processing, making it perfect for finding specific passages or citations.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. RAG_COMPLETION
&lt;/h3&gt;

&lt;p&gt;Traditional Retrieval-Augmented Generation that retrieves relevant document chunks via vector search, then feeds them as context to an LLM to generate a natural language answer. Unlike graph-based approaches, this treats documents as flat collections of chunks without leveraging the knowledge graph structure. It's useful when you want LLM-generated answers but don't need the deeper semantic understanding that comes from graph relationships.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. GRAPH_COMPLETION (Default)
&lt;/h3&gt;

&lt;p&gt;The most sophisticated search type that combines vector search, graph traversal, and LLM reasoning. It first finds relevant entities through vector search, then traverses the knowledge graph to gather connected information (relationships, related entities), and finally uses an LLM to synthesize this graph-structured context into a coherent natural language answer. This provides the most intelligent and contextually-aware responses because it understands how concepts relate to each other through the graph structure.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. CODE
&lt;/h3&gt;

&lt;p&gt;Specialized search for code repositories that understands programming language syntax and semantics. It searches through code-specific knowledge graphs built by the codify process, returning structured information about functions, classes, methods, and their relationships. The results include code context, implementation details, and how different code elements connect, making it ideal for understanding codebases. &lt;/p&gt;

&lt;h3&gt;
  
  
  7. FEELING_LUCKY
&lt;/h3&gt;

&lt;p&gt;An intelligent meta-search type that automatically selects the most appropriate search type for your query. It uses an LLM to analyze your query and determine whether it's best answered by graph completion, insights, chunks, or another search type, then executes that search. This is perfect when you're unsure which search type to use or want the system to make the best choice automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advanced/Specialized Search Types
&lt;/h2&gt;

&lt;h3&gt;
  
  
  8. GRAPH_SUMMARY_COMPLETION
&lt;/h3&gt;

&lt;p&gt;An enhanced version of GRAPH_COMPLETION that adds an intermediate summarization step. After retrieving graph edges through vector search and traversal, it summarizes the retrieved context before passing it to the LLM for final answer generation. This reduces redundancy in the context and can improve answer quality when dealing with large amounts of retrieved information.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. GRAPH_COMPLETION_COT (Chain-of-Thought)
&lt;/h3&gt;

&lt;p&gt;Implements iterative reasoning by generating follow-up questions and refining answers through multiple rounds. After an initial graph completion, it validates the answer, generates follow-up questions based on reasoning gaps, retrieves additional context for those questions, and produces a refined final answer. This mimics human-like reasoning by breaking down complex questions into steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  10. GRAPH_COMPLETION_CONTEXT_EXTENSION
&lt;/h3&gt;

&lt;p&gt;Iteratively expands the context by retrieving related graph triplets over multiple rounds. It starts with initial context, generates a completion, uses that completion to query for more related triplets, adds them to the context, and repeats until no new information is found or a maximum number of rounds is reached. This ensures comprehensive context gathering by following chains of relationships in the graph.&lt;/p&gt;

&lt;h3&gt;
  
  
  11. FEEDBACK
&lt;/h3&gt;

&lt;p&gt;Not actually a search type but a mechanism to save user feedback on search results. It records whether an answer was helpful or not, connecting this feedback to the query, answer, and graph triplets that were used. This enables learning from user interactions to improve future search quality.&lt;/p&gt;

&lt;h3&gt;
  
  
  12. TEMPORAL
&lt;/h3&gt;

&lt;p&gt;Time-aware search that extracts temporal constraints from queries and filters results accordingly. It parses time expressions in your query (like "last week" or "in 2023"), converts them to time intervals, and filters graph nodes/events that fall within those time ranges. This is essential for queries about when things happened or finding information from specific time periods.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the Hybrid Environment
&lt;/h2&gt;

&lt;p&gt;This setup demonstrates Cognee's flexibility by combining OpenAI's GPT models with local Ollama embeddings—getting the best of both worlds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Ollama
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;For Windows and macOS&lt;/strong&gt;: Visit &lt;code&gt;ollama.com&lt;/code&gt; and download the installer. Run it and follow the prompts—the server starts automatically on &lt;code&gt;http://localhost:11434&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Linux&lt;/strong&gt;: Run this command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://ollama.com/install.sh | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify the installation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ollama &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pulling the Embedding Model
&lt;/h3&gt;

&lt;p&gt;We'll use OpenAI for LLM tasks but keep embeddings local for cost efficiency. Pull the embedding model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ollama pull avr/sfr-embedding-mistral:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify it's ready:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ollama list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see &lt;code&gt;avr/sfr-embedding-mistral:latest&lt;/code&gt; in the output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Cognee
&lt;/h3&gt;

&lt;p&gt;Install Cognee with Ollama support:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="s2"&gt;"cognee[ollama]"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Configuring the Hybrid Setup
&lt;/h3&gt;

&lt;p&gt;Create a &lt;code&gt;.env&lt;/code&gt; file in your project directory with this configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# LLM Configuration - OpenAI&lt;/span&gt;
&lt;span class="nv"&gt;LLM_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your_openai_api_key"&lt;/span&gt;  
&lt;span class="nv"&gt;LLM_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gpt-4o-mini"&lt;/span&gt;  
&lt;span class="nv"&gt;LLM_PROVIDER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"openai"&lt;/span&gt;  

&lt;span class="c"&gt;# Embedding Configuration - Local Ollama&lt;/span&gt;
&lt;span class="nv"&gt;EMBEDDING_PROVIDER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ollama"&lt;/span&gt;  
&lt;span class="nv"&gt;EMBEDDING_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"avr/sfr-embedding-mistral:latest"&lt;/span&gt;  
&lt;span class="nv"&gt;EMBEDDING_ENDPOINT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"http://localhost:11434/api/embeddings"&lt;/span&gt;  
&lt;span class="nv"&gt;EMBEDDING_API_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;  
&lt;span class="nv"&gt;EMBEDDING_DIMENSIONS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;4096  
&lt;span class="nv"&gt;HUGGINGFACE_TOKENIZER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Salesforce/SFR-Embedding-Mistral"&lt;/span&gt;  

&lt;span class="c"&gt;# Database Settings (defaults)&lt;/span&gt;
&lt;span class="nv"&gt;DB_PROVIDER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"sqlite"&lt;/span&gt;  
&lt;span class="nv"&gt;DB_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"cognee_db"&lt;/span&gt;  
&lt;span class="nv"&gt;VECTOR_DB_PROVIDER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"lancedb"&lt;/span&gt;  
&lt;span class="nv"&gt;GRAPH_DATABASE_PROVIDER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"kuzu"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Configuration Notes&lt;/strong&gt;: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Replace &lt;code&gt;"your_openai_api_key"&lt;/code&gt; with your actual OpenAI API key from &lt;code&gt;platform.openai.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;LLM_PROVIDER&lt;/code&gt; is set to &lt;code&gt;"openai"&lt;/code&gt; for entity extraction and reasoning&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;EMBEDDING_PROVIDER&lt;/code&gt; is set to &lt;code&gt;"ollama"&lt;/code&gt; for local vector generation&lt;/li&gt;
&lt;li&gt;This hybrid approach uses OpenAI's intelligence while keeping embeddings private and cost-effective&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cognee automatically loads this configuration when imported. You're now ready to build knowledge graphs with the best of both worlds!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. SUMMARIES Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SearchType&lt;/span&gt;

&lt;span class="c1"&gt;# Sample data: Article about artificial intelligence
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
Artificial Intelligence (AI) has revolutionized modern technology. Machine learning, 
a subset of AI, enables computers to learn from data without explicit programming. 
Deep learning, using neural networks, has achieved breakthroughs in image recognition, 
natural language processing, and autonomous vehicles. Companies worldwide are investing 
billions in AI research to stay competitive in the digital age.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# Add data
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ai_articles&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Process into knowledge graph
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cognify&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ai_articles&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Search for summaries
&lt;/span&gt;&lt;span class="n"&gt;search_results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SUMMARIES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What are the main topics about AI?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Display results
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;search_results&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. INSIGHTS Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SearchType&lt;/span&gt;

&lt;span class="c1"&gt;# Sample data: Scientific explanation
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
Quantum computing leverages quantum mechanics principles like superposition and entanglement. 
Unlike classical bits, qubits can exist in multiple states simultaneously. This enables 
quantum computers to solve certain problems exponentially faster than classical computers. 
Major tech companies like IBM, Google, and Microsoft are racing to build practical quantum 
computers for cryptography, drug discovery, and optimization problems.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# Add and process data
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;quantum_dataset&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cognify&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;quantum_dataset&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Search for entity relationships
&lt;/span&gt;&lt;span class="n"&gt;search_results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;INSIGHTS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;quantum computing&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Results show entity relationships
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;search_results&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. CHUNKS Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SearchType&lt;/span&gt;

&lt;span class="c1"&gt;# Sample data: Historical text
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
The Renaissance was a period of cultural rebirth in Europe from the 14th to 17th century. 
It began in Italy and spread throughout Europe, marking the transition from medieval to 
modern times. Key figures included Leonardo da Vinci, Michelangelo, and Galileo. The 
Renaissance saw advances in art, science, literature, and philosophy. The printing press, 
invented by Gutenberg, revolutionized information dissemination.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# Add and process
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;history_dataset&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cognify&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;history_dataset&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Search for specific text chunks
&lt;/span&gt;&lt;span class="n"&gt;search_results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CHUNKS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Renaissance art and science&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;datasets&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;history_dataset&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Display chunks
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;search_results&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. RAG_COMPLETION Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SearchType&lt;/span&gt;

&lt;span class="c1"&gt;# Sample data: Business report
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
The global e-commerce market reached $5.7 trillion in 2023, growing 15% year-over-year. 
Mobile commerce accounts for 72% of all e-commerce sales. Amazon dominates with 38% 
market share, followed by Alibaba and JD.com. Key trends include AI-powered personalization, 
voice commerce, and sustainable packaging. Experts predict the market will exceed $8 trillion 
by 2027, driven by emerging markets and technological innovation.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# Add and process
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;business_reports&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cognify&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;business_reports&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# RAG completion with LLM
&lt;/span&gt;&lt;span class="n"&gt;search_results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RAG_COMPLETION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What are the key trends in e-commerce?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Returns LLM-generated answer
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;search_results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. GRAPH_COMPLETION Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SearchType&lt;/span&gt;

&lt;span class="c1"&gt;# Sample data: Geographic information
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
Germany is located in Central Europe, bordered by nine countries. To the north lies Denmark, 
to the east are Poland and Czech Republic, to the south are Austria and Switzerland, and to 
the west are France, Luxembourg, Belgium, and the Netherlands. Berlin is the capital and 
largest city. Germany is the most populous country in the European Union with over 83 million 
inhabitants. It has the largest economy in Europe and is a founding member of the EU.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# Add and process
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;geography_dataset&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cognify&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;geography_dataset&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Most sophisticated search with graph context
&lt;/span&gt;&lt;span class="n"&gt;graph_completion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GRAPH_COMPLETION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Which countries border Germany?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;datasets&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;geography_dataset&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;save_interaction&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Completion result:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;graph_completion&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. CODE Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SearchType&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cognee.api.v1.cognify.code_graph_pipeline&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;run_code_graph_pipeline&lt;/span&gt;

&lt;span class="c1"&gt;# Sample code repository structure
# Create a test Python file with sample code
&lt;/span&gt;&lt;span class="n"&gt;sample_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
class UserAuthentication:
    &lt;/span&gt;&lt;span class="sh"&gt;'''&lt;/span&gt;&lt;span class="s"&gt;Handles user authentication and session management.&lt;/span&gt;&lt;span class="sh"&gt;'''&lt;/span&gt;&lt;span class="s"&gt;

    def __init__(self, database):
        self.db = database
        self.session_timeout = 3600

    def login(self, username, password):
        &lt;/span&gt;&lt;span class="sh"&gt;'''&lt;/span&gt;&lt;span class="s"&gt;Authenticate user credentials.&lt;/span&gt;&lt;span class="sh"&gt;'''&lt;/span&gt;&lt;span class="s"&gt;
        user = self.db.find_user(username)
        if user and self.verify_password(password, user.password_hash):
            return self.create_session(user)
        return None

    def verify_password(self, password, hash):
        &lt;/span&gt;&lt;span class="sh"&gt;'''&lt;/span&gt;&lt;span class="s"&gt;Verify password against stored hash.&lt;/span&gt;&lt;span class="sh"&gt;'''&lt;/span&gt;&lt;span class="s"&gt;
        return bcrypt.checkpw(password.encode(), hash)
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# First, process code repository
&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;run_status&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;run_code_graph_pipeline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/path/to/your/repo&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;run_status&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pipeline_run_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;run_status&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Search code
&lt;/span&gt;&lt;span class="n"&gt;search_results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CODE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;authentication functions&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Display code results
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nb"&gt;file&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;search_results&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7. FEELING_LUCKY Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SearchType&lt;/span&gt;

&lt;span class="c1"&gt;# Sample data: Technology news
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
Apple announced its new Vision Pro mixed reality headset at WWDC 2023. The device features 
dual 4K displays, spatial audio, and hand tracking. Priced at $3,499, it targets professional 
users and early adopters. The Vision Pro runs visionOS, a new operating system designed for 
spatial computing. Analysts predict it will create a new product category, though mainstream 
adoption may take years due to the high price point.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# Add and process
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tech_news&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cognify&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tech_news&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Let the system choose the best search type
&lt;/span&gt;&lt;span class="n"&gt;search_results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FEELING_LUCKY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What is Apple&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s new product?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Returns results in format of auto-selected type
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;search_results&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  8. GRAPH_SUMMARY_COMPLETION Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SearchType&lt;/span&gt;

&lt;span class="c1"&gt;# Sample data: Medical information
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
Type 2 diabetes is a chronic condition affecting how the body processes blood sugar. 
Risk factors include obesity, physical inactivity, family history, and age over 45. 
Symptoms include increased thirst, frequent urination, fatigue, and blurred vision. 
Treatment involves lifestyle changes, medication like metformin, and blood sugar monitoring. 
Complications can include heart disease, kidney damage, and nerve problems. Prevention 
focuses on maintaining healthy weight, regular exercise, and balanced diet.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# Add and process
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;medical_info&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cognify&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;medical_info&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Graph completion with summarization
&lt;/span&gt;&lt;span class="n"&gt;completion_sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GRAPH_SUMMARY_COMPLETION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What are the risk factors for Type 2 diabetes?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;save_interaction&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Returns summarized LLM response
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;completion_sum&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  9. GRAPH_COMPLETION_COT Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SearchType&lt;/span&gt;

&lt;span class="c1"&gt;# Sample data: Complex problem
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
Climate change is caused by greenhouse gas emissions from human activities. The primary 
source is burning fossil fuels for energy, transportation, and industry. Deforestation 
reduces CO2 absorption capacity. Rising temperatures cause ice cap melting, sea level rise, 
and extreme weather events. Solutions include renewable energy adoption, carbon capture 
technology, reforestation, and international cooperation through agreements like the Paris 
Climate Accord. Individual actions like reducing consumption and using public transport also help.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# Add and process
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;climate_dataset&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cognify&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;climate_dataset&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Chain-of-thought reasoning
&lt;/span&gt;&lt;span class="n"&gt;completion_cot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GRAPH_COMPLETION_COT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;How can we address climate change?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;save_interaction&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Returns refined answer after iterative reasoning
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;completion_cot&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  10. GRAPH_COMPLETION_CONTEXT_EXTENSION Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SearchType&lt;/span&gt;

&lt;span class="c1"&gt;# Sample data: Historical events
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
World War II began in 1939 when Germany invaded Poland. The war involved most of the world&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s 
nations, divided into Allies and Axis powers. Major battles included Stalingrad, D-Day, and 
Midway. The Holocaust resulted in the genocide of six million Jews. The war ended in 1945 
with Germany&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s surrender in May and Japan&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s surrender in August after atomic bombs were 
dropped on Hiroshima and Nagasaki. The war reshaped global politics, leading to the United 
Nations and the Cold War.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# Add and process
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;history_ww2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cognify&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;history_ww2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Context extension through multiple rounds
&lt;/span&gt;&lt;span class="n"&gt;completion_ext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GRAPH_COMPLETION_CONTEXT_EXTENSION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What were the major events of World War II?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;save_interaction&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Returns answer with expanded context
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;completion_ext&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  11. FEEDBACK Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SearchType&lt;/span&gt;

&lt;span class="c1"&gt;# Sample data: Product information
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
The iPhone 15 Pro features a titanium design, A17 Pro chip, and improved camera system. 
The main camera is 48MP with advanced computational photography. Battery life is up to 
29 hours video playback. It supports USB-C charging and has an Action button replacing 
the mute switch. Available in four colors: Natural Titanium, Blue Titanium, White Titanium, 
and Black Titanium. Storage options range from 128GB to 1TB.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# Add and process
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;products&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cognify&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;products&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# First, perform a search with save_interaction=True
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GRAPH_COMPLETION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What are the features of iPhone 15 Pro?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;save_interaction&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Then provide feedback on the last interaction
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FEEDBACK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;This answer was very helpful and accurate&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;last_k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  12. TEMPORAL Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SearchType&lt;/span&gt;

&lt;span class="c1"&gt;# Sample data: Timeline of events
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
In January 2023, ChatGPT reached 100 million users. In March 2023, GPT-4 was released. 
In May 2023, Google announced Bard AI. In July 2023, Meta released Llama 2 as open source. 
In September 2023, Amazon announced AI coding assistant CodeWhisperer. In November 2023, 
OpenAI held its first DevDay conference. In December 2023, Google released Gemini, its 
most capable AI model. These events marked 2023 as a breakthrough year for AI technology.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# Add and process
&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ai_timeline&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cognify&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ai_timeline&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Time-aware search
&lt;/span&gt;&lt;span class="n"&gt;search_results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;SearchType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TEMPORAL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;query_text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What AI events happened in 2023?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Returns time-filtered results
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;search_results&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To find more about cognee visit &lt;a href="https://www.cognee.ai/" rel="noopener noreferrer"&gt;cognee&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Building 100% local AI memory with cognee</title>
      <dc:creator>Chinmay Bhosale</dc:creator>
      <pubDate>Sat, 18 Oct 2025 09:21:55 +0000</pubDate>
      <link>https://dev.to/chinmay_bhosale_9ceed796b/cognee-with-ollama-3pp8</link>
      <guid>https://dev.to/chinmay_bhosale_9ceed796b/cognee-with-ollama-3pp8</guid>
      <description>&lt;p&gt;If you've explored AI memory frameworks, you've probably encountered Cognee 

&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/topoteretes" rel="noopener noreferrer"&gt;
        topoteretes
      &lt;/a&gt; / &lt;a href="https://github.com/topoteretes/cognee" rel="noopener noreferrer"&gt;
        cognee
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Knowledge Engine for AI Agent Memory in 6 lines of code
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
  &lt;a href="https://github.com/topoteretes/cognee" rel="noopener noreferrer"&gt;
    &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Ftopoteretes%2Fcognee%2Frefs%2Fheads%2Fdev%2Fassets%2Fcognee-logo-transparent.png" alt="Cognee Logo" height="60"&gt;
  &lt;/a&gt;
  &lt;br&gt;
&lt;p&gt;Cognee - Build AI memory with a Knowledge Engine that learns&lt;/p&gt;
  &lt;p&gt;
  &lt;a href="https://www.youtube.com/watch?v=8hmqS2Y5RVQ&amp;amp;t=13s" rel="nofollow noopener noreferrer"&gt;Demo&lt;/a&gt;
  &lt;a href="https://docs.cognee.ai/" rel="nofollow noopener noreferrer"&gt;Docs&lt;/a&gt;
  &lt;a href="https://cognee.ai" rel="nofollow noopener noreferrer"&gt;Learn More&lt;/a&gt;
  ·
  &lt;a href="https://discord.gg/NQPKmU5CCg" rel="nofollow noopener noreferrer"&gt;Join Discord&lt;/a&gt;
  ·
  &lt;a href="https://www.reddit.com/r/AIMemory/" rel="nofollow noopener noreferrer"&gt;Join r/AIMemory&lt;/a&gt;
  &lt;a href="https://github.com/topoteretes/cognee-community" rel="noopener noreferrer"&gt;Community Plugins &amp;amp; Add-ons&lt;/a&gt;
  &lt;/p&gt;
&lt;p&gt;&lt;a href="https://GitHub.com/topoteretes/cognee/network/" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/50e679badfb235cd68a58f6589546d57426071c8546d9b02e3f6fa76ce4ae473/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f746f706f746572657465732f636f676e65652e7376673f7374796c653d736f6369616c266c6162656c3d466f726b266d61784167653d32353932303030" alt="GitHub forks"&gt;&lt;/a&gt;
&lt;a href="https://GitHub.com/topoteretes/cognee/stargazers/" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/f2ee9f9317c6e19cf0d9e6c9cd19661806edb4d8c28a5fbb202432981661ddce/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f746f706f746572657465732f636f676e65652e7376673f7374796c653d736f6369616c266c6162656c3d53746172266d61784167653d32353932303030" alt="GitHub stars"&gt;&lt;/a&gt;
&lt;a href="https://GitHub.com/topoteretes/cognee/commit/" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/1b089528bc3b3aa9a1a9cfb5af2b844cd5e9c97f181bbbc2a9f206b7cc3b00f6/68747470733a2f2f62616467656e2e6e65742f6769746875622f636f6d6d6974732f746f706f746572657465732f636f676e6565" alt="GitHub commits"&gt;&lt;/a&gt;
&lt;a href="https://github.com/topoteretes/cognee/tags/" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/aa80d55949aff4ca36a80b156e881dacde7d9f00a49af21518b99c5059135f31/68747470733a2f2f62616467656e2e6e65742f6769746875622f7461672f746f706f746572657465732f636f676e6565" alt="GitHub tag"&gt;&lt;/a&gt;
&lt;a href="https://pepy.tech/project/cognee" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/86e76666cf5164611a1a6c17e8b463cb0f8091395c46121d6ba7a6d6abec05c2/68747470733a2f2f7374617469632e706570792e746563682f62616467652f636f676e6565" alt="Downloads"&gt;&lt;/a&gt;
&lt;a href="https://github.com/topoteretes/cognee/blob/main/LICENSE" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/401f5d9889bcd07208f46bb1665885a58a996c064ea27d8e84b6a11b2f22cd8b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f746f706f746572657465732f636f676e65653f636f6c6f72413d30304335383626636f6c6f72423d303030303030" alt="License"&gt;&lt;/a&gt;
&lt;a href="https://github.com/topoteretes/cognee/graphs/contributors" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/af847a558ecbc7664dc33f3393075ae5489dd93db8819ca4bea2fd75477a5701/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f746f706f746572657465732f636f676e65653f636f6c6f72413d30304335383626636f6c6f72423d303030303030" alt="Contributors"&gt;&lt;/a&gt;
&lt;a href="https://github.com/sponsors/topoteretes" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/59186c64d39de9cb1644eac16a729dea31f43b4c4611b2d8860e827387bab100/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722de29da4efb88f2d6666363962342e737667" alt="Sponsor"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;a href="https://trendshift.io/repositories/13955" rel="nofollow noopener noreferrer"&gt;
    &lt;img src="https://camo.githubusercontent.com/a25794050cd24daac0c052053f44d2d83c99c2ce43fe673dcad23b3dd6ec91e4/68747470733a2f2f7472656e6473686966742e696f2f6170692f62616467652f7265706f7369746f726965732f3133393535" alt="topoteretes%2Fcognee | Trendshift" width="250" height="55"&gt;
  &lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Use our knowledge engine to build personalized and dynamic memory for AI Agents.&lt;/p&gt;


&lt;p&gt;&lt;br&gt;
  🌐 Available Languages&lt;br&gt;
  :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.readme-i18n.com/topoteretes/cognee?lang=de" rel="nofollow noopener noreferrer"&gt;Deutsch&lt;/a&gt; |&lt;br&gt;
  &lt;a href="https://www.readme-i18n.com/topoteretes/cognee?lang=es" rel="nofollow noopener noreferrer"&gt;Español&lt;/a&gt; |&lt;br&gt;
  &lt;a href="https://www.readme-i18n.com/topoteretes/cognee?lang=fr" rel="nofollow noopener noreferrer"&gt;Français&lt;/a&gt; |&lt;br&gt;
  &lt;a href="https://www.readme-i18n.com/topoteretes/cognee?lang=ja" rel="nofollow noopener noreferrer"&gt;日本語&lt;/a&gt; |&lt;br&gt;
  &lt;a href="https://github.com/topoteretes/cognee/README_ko.md" rel="noopener noreferrer"&gt;한국어&lt;/a&gt; |&lt;br&gt;
  &lt;a href="https://www.readme-i18n.com/topoteretes/cognee?lang=pt" rel="nofollow noopener noreferrer"&gt;Português&lt;/a&gt; |&lt;br&gt;
  &lt;a href="https://www.readme-i18n.com/topoteretes/cognee?lang=ru" rel="nofollow noopener noreferrer"&gt;Русский&lt;/a&gt; |&lt;br&gt;
  &lt;a href="https://www.readme-i18n.com/topoteretes/cognee?lang=zh" rel="nofollow noopener noreferrer"&gt;中文&lt;/a&gt;&lt;br&gt;
  &lt;/p&gt;

&lt;div&gt;
  &lt;a rel="noopener noreferrer nofollow" href="https://raw.githubusercontent.com/topoteretes/cognee/refs/heads/main/assets/cognee_benefits.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Ftopoteretes%2Fcognee%2Frefs%2Fheads%2Fmain%2Fassets%2Fcognee_benefits.png" alt="Why cognee?" width="80%"&gt;&lt;/a&gt;
&lt;/div&gt;


&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;About Cognee&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;Cognee is an open-source knowledge engine that lets you ingest data in any format or structure and continuously learns to provide the right context for AI agents. It combines vector search, graph databases and cognitive science approaches to make your documents both searchable by meaning and connected by relationships as they change and evolve.&lt;/p&gt;

&lt;p&gt;⭐ &lt;em&gt;Help us reach more developers and grow the cognee community. Star this repo!&lt;/em&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Why use Cognee:&lt;/h3&gt;

&lt;/div&gt;


&lt;ul&gt;

&lt;li&gt;Knowledge infrastructure — unified ingestion, graph/vector search, runs locally, ontology grounding, multimodal&lt;/li&gt;

&lt;li&gt;Persistent and Learning Agents -…&lt;/li&gt;

&lt;/ul&gt;
&lt;/div&gt;
&lt;br&gt;
  &lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/topoteretes/cognee" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;



&lt;p&gt;&lt;br&gt;&lt;br&gt;
—an open-source memory engine that's transforming how AI agents handle information. While there's plenty of content online showing how to use Cognee with OpenAI and other paid models, comprehensive guides for running Cognee entirely locally with Ollama are surprisingly scarce. This blog fills that gap by walking you through a complete local setup using Ollama, covering everything from model selection to knowledge graph generation—all without  external API dependencies or subscription costs&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Cognee?
&lt;/h2&gt;

&lt;p&gt;Cognee is an &lt;strong&gt;open-source AI memory engine&lt;/strong&gt; that transforms how AI agents handle information. Unlike traditional large language models that treat every interaction as a blank slate, Cognee provides persistent, structured memory that allows AI systems to remember, reason, and build upon previous context across sessions.&lt;/p&gt;

&lt;p&gt;At its core, Cognee addresses a fundamental limitation of modern AI systems—they forget everything. Ask an LLM a follow-up question, and it acts like you've never spoken before. That's not intelligence; that's mimicry. For production-grade applications requiring contextual continuity, consistency, and personalized responses, this ephemeral nature becomes a critical bottleneck.&lt;/p&gt;

&lt;p&gt;Cognee solves this through a &lt;strong&gt;memory-first architecture&lt;/strong&gt; that combines embeddings with graph-based triplet extraction (subject-relation-object) stored in knowledge graphs. When you feed documents into Cognee, it doesn't just store text chunks—it extracts entities, identifies relationships, and links everything into a queryable graph structure that serves as a persistent memory layer. This approach achieves &lt;strong&gt;92.5% accuracy&lt;/strong&gt; compared to traditional RAG's 60%, making it solid enough for decision-making rather than guesswork.&lt;/p&gt;

&lt;p&gt;The framework operates through three core operations: &lt;code&gt;.add()&lt;/code&gt; to ingest and prepare your data, &lt;code&gt;.cognify()&lt;/code&gt; to build the knowledge graph with embeddings, and &lt;code&gt;.search()&lt;/code&gt; to query with context using a combination of vector similarity and graph traversal. This hybrid approach enables &lt;strong&gt;context-aware recall&lt;/strong&gt; where entities are represented with granular, context-rich connections rather than flat vector similarities.&lt;/p&gt;

&lt;p&gt;Cognee has gained significant traction in the open-source community with over 7,000 GitHub stars, thousands of library downloads, and adoption across 200-300 projects. Its flexible architecture supports multiple backends—Neo4j, FalkorDB, KuzuDB, and NetworkX for graphs; Redis, Qdrant, and Weaviate for vectors; plus SQLite or Postgres for relational metadata. This poly-store design allows developers to deploy everything from simple chatbots to complex multi-agent systems with memory that scales from gigabytes to terabytes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up Ollama
&lt;/h2&gt;

&lt;p&gt;Ollama provides the easiest way to run large language models locally on your machine. The installation process is straightforward and works across Windows, macOS, and Linux.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Ollama
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;For Windows and macOS&lt;/strong&gt;: Visit the official Ollama website at &lt;code&gt;ollama.com&lt;/code&gt; and download the installer for your operating system. Run the installer and follow the on-screen prompts—the process takes just a few minutes. The installer automatically starts the Ollama server in the background and sets it to start on system boot.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Linux&lt;/strong&gt;: Open your terminal and run the following command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://ollama.com/install.sh | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Once installed, verify the installation by running:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ollama &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The Ollama server runs automatically on &lt;code&gt;http://localhost:11434&lt;/code&gt; after installation. You can verify it's running with:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl http://localhost:11434
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If the server is running, you'll see the response: &lt;code&gt;Ollama is running&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Pulling Required Models
&lt;/h3&gt;

&lt;p&gt;For this tutorial, we'll need two models: one for language processing and one for generating embeddings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Language Model - gpt-oss:20b&lt;/strong&gt;: A compact yet capable model that balances performance with resource requirements :&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ollama pull gpt-oss:20b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Embedding Model - avr/sfr-embedding-mistral&lt;/strong&gt;: This model will handle text embeddings for Cognee's vector search capabilities:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ollama pull avr/sfr-embedding-mistral:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Both downloads may take a few minutes depending on your internet connection. To verify the models are ready, list all downloaded models:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ollama list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You should see both &lt;code&gt;gpt-oss:20b&lt;/code&gt; and &lt;code&gt;avr/sfr-embedding-mistral:latest&lt;/code&gt; in the output.&lt;/p&gt;
&lt;h3&gt;
  
  
  Installing Cognee
&lt;/h3&gt;

&lt;p&gt;With Ollama running, install Cognee with Ollama support :​&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="s2"&gt;"cognee[ollama]"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The [ollama] extras package includes all dependencies needed for local Ollama integration.&lt;/p&gt;
&lt;h2&gt;
  
  
  Installing BAML for Structured Output
&lt;/h2&gt;

&lt;p&gt;Cognee uses specialized libraries to extract structured output from LLMs—primarily &lt;strong&gt;Instructor&lt;/strong&gt; and &lt;strong&gt;BAML&lt;/strong&gt; (BoundaryML). While both libraries serve the same purpose of ensuring LLMs return valid, structured data, BAML works more reliably with Ollama.&lt;/p&gt;

&lt;p&gt;For our local Ollama setup, install Cognee with BAML support:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="s2"&gt;"cognee[baml]"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Configuring Cognee for Ollama
&lt;/h2&gt;

&lt;p&gt;Create a &lt;code&gt;.env&lt;/code&gt; file in your project directory to configure Cognee for local Ollama models :&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Use BAML for structured outputs  &lt;/span&gt;
&lt;span class="nv"&gt;STRUCTURED_OUTPUT_FRAMEWORK&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"BAML"&lt;/span&gt;  

&lt;span class="c"&gt;# LLM Configuration &lt;/span&gt;
&lt;span class="nv"&gt;LLM_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ollama"&lt;/span&gt;  
&lt;span class="nv"&gt;LLM_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gpt-oss:20b"&lt;/span&gt;  
&lt;span class="nv"&gt;LLM_PROVIDER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ollama"&lt;/span&gt;  
&lt;span class="nv"&gt;LLM_ENDPOINT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"http://localhost:11434/v1"&lt;/span&gt;  

&lt;span class="c"&gt;# Embedding Configuration&lt;/span&gt;
&lt;span class="nv"&gt;EMBEDDING_PROVIDER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ollama"&lt;/span&gt;  
&lt;span class="nv"&gt;EMBEDDING_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"avr/sfr-embedding-mistral:latest"&lt;/span&gt;  
&lt;span class="nv"&gt;EMBEDDING_ENDPOINT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"http://localhost:11434/api/embeddings"&lt;/span&gt;  
&lt;span class="nv"&gt;EMBEDDING_DIMENSIONS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;4096  
&lt;span class="nv"&gt;HUGGINGFACE_TOKENIZER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Salesforce/SFR-Embedding-Mistral"&lt;/span&gt;  

&lt;span class="c"&gt;# BAML Configuration&lt;/span&gt;
&lt;span class="nv"&gt;BAML_LLM_PROVIDER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ollama"&lt;/span&gt;  
&lt;span class="nv"&gt;BAML_LLM_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gpt-oss:20b"&lt;/span&gt;  
&lt;span class="nv"&gt;BAML_LLM_ENDPOINT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"http://localhost:11434/v1"&lt;/span&gt;  
&lt;span class="nv"&gt;BAML_LLM_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ollama"&lt;/span&gt;  

&lt;span class="c"&gt;# Database Settings (defaults)&lt;/span&gt;
&lt;span class="nv"&gt;DB_PROVIDER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"sqlite"&lt;/span&gt;  
&lt;span class="nv"&gt;VECTOR_DB_PROVIDER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"lancedb"&lt;/span&gt;  
&lt;span class="nv"&gt;GRAPH_DATABASE_PROVIDER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"kuzu"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Key Points&lt;/strong&gt;: Both LLM and embedding providers must be configured separately. The embedding dimensions (4096) match the model's output size. Cognee automatically loads this file when imported.&lt;/p&gt;
&lt;h2&gt;
  
  
  Building Your First Knowledge Graph with Cognee
&lt;/h2&gt;

&lt;p&gt;Now that we have everything set up, let's create a simple example that demonstrates Cognee's core functionality. We'll add some text, process it into a knowledge graph, search it, and visualize the results.&lt;/p&gt;
&lt;h3&gt;
  
  
  The Complete Code
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;  
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;  

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;  
    &lt;span class="c1"&gt;# Sample text to process
&lt;/span&gt;    &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Quantum computing represents a revolutionary approach to computation 
    that leverages quantum mechanical phenomena like superposition and 
    entanglement. Unlike classical computers that use bits (0 or 1), 
    quantum computers use qubits that can exist in multiple states 
    simultaneously. This allows quantum computers to solve certain 
    problems exponentially faster than classical computers, particularly 
    in areas like cryptography, drug discovery, and optimization problems.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

    &lt;span class="c1"&gt;# Add the text to Cognee
&lt;/span&gt;    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dataset_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;quantum_computing&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  

    &lt;span class="c1"&gt;# Process the data into a knowledge graph  
&lt;/span&gt;    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cognify&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;quantum_computing&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;  

    &lt;span class="c1"&gt;# Search the knowledge graph  
&lt;/span&gt;    &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What is quantum computing&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  

    &lt;span class="c1"&gt;# Visualize the knowledge graph
&lt;/span&gt;    &lt;span class="n"&gt;html_file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cognee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;visualize_graph&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;./graph_visualization.html&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;✅ Graph visualization saved to: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;html_file&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 

    &lt;span class="c1"&gt;# Display search results  
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;=== Search Results ===&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  
    &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Understanding the Code
&lt;/h3&gt;

&lt;p&gt;The code follows Cognee's three core operations we mentioned earlier:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding Data&lt;/strong&gt;: The &lt;code&gt;cognee.add()&lt;/code&gt; function ingests your text and prepares it for processing. The &lt;code&gt;dataset_name&lt;/code&gt; parameter organizes your data into logical collections—in this case, "quantum_computing". You can add multiple documents to the same dataset.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cognifying&lt;/strong&gt;: The &lt;code&gt;cognee.cognify()&lt;/code&gt; function is where the magic happens. It processes your text using the local Ollama models we configured earlier, extracting entities (like "quantum computing," "qubits," "superposition") and their relationships (like "quantum computers use qubits," "qubits enable superposition"). These are structured into a knowledge graph with both vector embeddings and graph connections.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Searching&lt;/strong&gt;: The &lt;code&gt;cognee.search()&lt;/code&gt; function performs hybrid retrieval—combining vector similarity search with graph traversal to find contextually relevant information. Unlike simple keyword matching, it understands the semantic meaning and relationships in your query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Visualizing&lt;/strong&gt;: The &lt;code&gt;cognee.visualize_graph()&lt;/code&gt; function generates an interactive HTML visualization of your knowledge graph. Simply open the generated &lt;code&gt;graph_visualization.html&lt;/code&gt; file in your browser to explore the entities and relationships Cognee extracted from your text.&lt;/p&gt;
&lt;h3&gt;
  
  
  Running the Code
&lt;/h3&gt;

&lt;p&gt;Save the code to a file (e.g., &lt;code&gt;cognee_demo.py&lt;/code&gt;) and run it:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python cognee_demo.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You'll see Cognee processing your text using the local Ollama models. Once complete, open &lt;code&gt;graph_visualization.html&lt;/code&gt; in your browser to see the knowledge graph—nodes represent entities like "quantum computing" and "qubits," while edges show their relationships.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzuhd0t3c12zvhk0203x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzuhd0t3c12zvhk0203x.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Find more about cognee at 

&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
        &lt;div class="c-embed__cover"&gt;
          &lt;a href="https://www.cognee.ai/" class="c-link align-middle" rel="noopener noreferrer"&gt;
            &lt;img alt="" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cognee.ai%2Fimages%2Fmeta%2Fcognee-logo-text-on-gradient.png" height="auto" class="m-0"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="c-embed__body"&gt;
        &lt;h2 class="fs-xl lh-tight"&gt;
          &lt;a href="https://www.cognee.ai/" rel="noopener noreferrer" class="c-link"&gt;
            Improve your AI infrastructure - AI memory engine
          &lt;/a&gt;
        &lt;/h2&gt;
          &lt;p class="truncate-at-3"&gt;
            Cognee is an open source AI memory engine. Try it today to find hidden connections in your data and improve your AI infrastructure.
          &lt;/p&gt;
        &lt;div class="color-secondary fs-s flex items-center"&gt;
            &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cognee.ai%2Ffavicon.ico"&gt;
          cognee.ai
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;





</description>
      <category>knowledgegraphs</category>
      <category>ollama</category>
      <category>cognee</category>
      <category>python</category>
    </item>
  </channel>
</rss>
