Welcome to Kern
Build robust, lightweight AI agents optimized for small language models (1-7B parameters).
Kern is a lightweight Python framework designed specifically for building AI agents that run efficiently on small language models (1-7B parameters).
While general agent frameworks assume massive cloud LLMs (like GPT-4), Kern is built from the ground up for resource-constrained environments (like running Ollama or llama.cpp on your laptop). It provides structured outputs, automatic JSON repair, tool use, and rich workflow visualization—all tuned to work reliably with smaller models.

Why Kern?
1. Optimized for Small Models (1-7B)
Every design choice in Kern prioritizes running local, small models (such as Llama 3.2 3B, Qwen 2.5 3B, and Phi-4 Mini). Prompts, defaults, and parameters are tuned to maximize the reasoning capabilities of models running locally.
2. Template-Based Structured Output
Small models struggle with abstract JSON Schemas and get confused by deep nesting. Kern uses intuitive fill-in-the-blank templates instead. This mirrors how text-completion models naturally think, dramatically improving structured output accuracy.
3. Automatic JSON Repair
When small models omit closing braces, add trailing commas, or prefix JSON with conversational commentary, Kern's built-in repair engine intercepts the output, fixes the structure, and returns valid JSON.
4. Rich Visualization & Reliability Dashboard
Kern features native Mermaid workflow visualization and a dynamic trace viewer. Build complex multi-agent teams and visualize the execution pipeline, tool calls, and data flow in real time without relying on cloud observability services.
Core Capabilities
Local Model First
Connect to Ollama, llama.cpp, vLLM, and LM Studio in seconds.
Structured Outputs
Template-based generation and automatic JSON repair.
Workflow Visualization
Generate Mermaid flowcharts from your agent execution chains.
Getting Started
-
Install Kern:
1pip install kern-ai -
Run your first local agent: