Skip to main content

What is Kapso?

Kapso combines iterative experimentation with a knowledge base of best practices, domain knowledge, and implementation patterns to discover and validate ML/AI code improvements. It automates the cycle of designing, running, evaluating, and refining solutions, eventually adapting the optimized solution for deployment on your chosen infrastructure.
Kapso Framework Architecture

Leeroopedia MCP Integration

Connect Kapso to Leeroopedia — a curated knowledge base of 1000+ ML/AI frameworks. Kapso agents use it during ideation and implementation to search docs, build plans, diagnose failures, and look up hyperparameter defaults.
pip install leeroopedia-mcp
Sign up at leeroopedia.com for an API key ($20 free credit on sign-up). See the Leeroopedia MCP docs for setup details.

Core Workflow

from kapso.kapso import Kapso, Source, DeployStrategy

# Initialize Kapso with legal domain knowledge
kapso = Kapso(kg_index="data/indexes/legal_contracts.index")

# Research: Gather domain-specific alignment techniques
research_findings = kapso.research(
    "RLHF and DPO fine-tuning for legal contract analysis",
    depth="deep",
)

# Learn: Ingest knowledge from repositories
kapso.learn(
    sources=[
        Source.Repo("https://github.com/huggingface/trl"),
        *research_findings.repos(top_k=5),
    ],
    wiki_dir="data/wikis",
)

# Evolve: Build a solution through experimentation
# The agent writes evaluate.py to compute F1 score and signal when target is reached
solution = kapso.evolve(
    goal="Fine-tune Llama-3.1-8B on the CUAD dataset (https://huggingface.co/datasets/theatticusproject/cuad) for legal clause risk classification, target F1 > 0.85 on high-risk clause detection",
    output_path="./models/legal_risk_v1",
    context=[research_findings.ideas(top_k=10)],
)

# Deploy: Turn solution into running deployed_program
deployed_program = kapso.deploy(solution, strategy=DeployStrategy.MODAL)

# Cleanup
deployed_program.stop()

The Four Pillars

Evolve

.evolve() : Run iterative evaluation grounded experiments to build the optimum solution for a goal. Uses tree search, coding agents, and KG context to generate ideas and refine solutions.

Learn

.learn() : Ingest knowledge from repositories, past solutions, or written knowledge. Extracts patterns and best practices into the Knowledge Graph.

Research

.research() : Run deep web research to gather ideas, implementation references and releveant repositories. Returns structured findings you can pass to learning or use as context for evolving solutions.

Deploy

.deploy() : Turn a solution into running app. Supports local execution, Docker containers, or cloud platforms like Modal.

Core Components

ComponentDescription
KapsoMain API class — orchestrates research, learn, evolve, and deploy
OrchestratorAgentRuns the experimentation loop with budget tracking
Search StrategyExplores solutions via tree search (generic, benchmark_tree_search)
Coding AgentsPluggable code generators: Aider, Gemini, Claude Code, OpenHands
Feedback GeneratorValidates evaluation results and decides when to stop
Knowledge PipelineTwo-stage learning: Ingestors extract WikiPages → Merger integrates into KG
Knowledge SearchHybrid retrieval using Weaviate (semantic) + Neo4j (graph structure)
Repo MemoryEvidence-backed understanding of repository structure
DeploymentTurn solutions into running software: Local, Docker, Modal, BentoML

Supported Benchmarks

Why Kapso?

  • Knowledge-Grounded: Solutions are informed by domain knowledge, not just LLM priors
  • Iterative Refinement: Tree search explores multiple approaches, learns from failures
  • Pluggable Components: Swap coding agents, evaluators, and search strategies
  • Full Lifecycle: From research to deployment in a single framework