Skip to main content

Overview

The Knowledge System provides domain-specific guidance during problem-solving. It helps the agent recommend proven approaches and avoid common pitfalls by learning from repositories, research, and past experiments.

Key Concepts

Knowledge Graph (KG)

The KG stores domain knowledge in a structured format:
  • Vector Storage: Weaviate for semantic embeddings and similarity search
  • Graph Storage: Neo4j for relationships and graph traversal
  • Content: Wiki pages with overviews, detailed content, and connections

Learning Pipeline

A two-stage process for acquiring knowledge from sources:
  1. Stage 1 (Ingestors): Extract structured wiki pages from sources
  2. Stage 2 (Merger): Hierarchical sub-graph-aware merge into the existing KG
Hybrid retrieval that combines multiple approaches:
  • Semantic search: Vector similarity in Weaviate
  • Graph traversal: Connected pages from Neo4j
  • LLM reranking: Relevance scoring for better results

Using Knowledge in Kapso

Option 1: Pre-indexed KG

from kapso.kapso import Kapso

# One-time: Index wiki pages
kapso = Kapso()
kapso.index_kg(
    wiki_dir="data/wikis_llm_finetuning",
    save_to="data/indexes/llm_finetuning.index",
)

# Every time: Load existing index
kapso = Kapso(kg_index="data/indexes/llm_finetuning.index")
solution = kapso.evolve(goal="Fine-tune LLaMA with QLoRA")

Option 2: Learn from Sources

from kapso.kapso import Kapso, Source

kapso = Kapso()

# Learn from a repository
kapso.learn(
    Source.Repo("https://github.com/huggingface/transformers"),
    wiki_dir="data/wikis",
)

# Learn from web research
findings = kapso.research("QLoRA best practices", mode="idea")
kapso.learn(*findings.ideas, wiki_dir="data/wikis")

Option 3: Research as Context

from kapso.kapso import Kapso

kapso = Kapso()

# Research without persisting to KG
findings = kapso.research(
    "unsloth FastLanguageModel example",
    mode="implementation",
    depth="deep",
)

# Use research as context
solution = kapso.evolve(
    goal="Fine-tune with Unsloth + LoRA",
    context=[findings.to_string()],
)

Search Backends

BackendData FormatStorageUse Case
kg_graph_searchWiki pages (.md)Weaviate + Neo4jSemantic search with reranking
kg_llm_navigationJSON (nodes/edges)Neo4j onlyLLM-guided graph navigation

Infrastructure Requirements

Both backends require database infrastructure:
# Start Weaviate and Neo4j
./scripts/start_infra.sh

# Stop infrastructure
./scripts/stop_infra.sh

Next Steps