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 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

Core Workflow

from src.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=10),
    ],
    wiki_dir="data/wikis",
)

# Evolve: Build a solution through experimentation
solution = kapso.evolve(
    goal="Fine-tune Llama-3.1-8B for legal contract risk classification using DPO alignment, target F1 > 0.85 on high-risk clause detection",
    output_path="./models/legal_risk_v1",
    evaluator="regex_pattern",
    evaluator_params={"pattern": r"F1: ([\d.]+)"},
    stop_condition="threshold",
    stop_condition_params={"threshold": 0.85},
    context=[
        research_findings.ideas(top_k=20)
    ],
)

# Deploy: Turn solution into running deployed_program
deployed_program = kapso.deploy(solution, strategy=DeployStrategy.MODAL)
result = deployed_program.run({"contract_path": "./contracts/sample.pdf"})

# 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 and stopping conditions
Search StrategyExplores solutions via tree search or linear search
Coding AgentsPluggable code generators: Aider, Gemini, Claude Code, OpenHands
Knowledge PipelineTwo-stage learning: Ingestors extract WikiPages → Merger integrates into KG
Knowledge SearchHybrid retrieval using Weaviate (semantic) + Neo4j (graph structure)
EvaluatorsScore solutions: regex patterns, JSON files, LLM judges
Stop ConditionsControl when to stop: threshold, plateau, cost/time limits
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