Tip
EASY GUIDE BRO! 🧠
Here is the super simple way to understand KernelWeave:
- What is it? It's a smart layer that sits on top of your AI. Instead of letting the AI guess and figure things out every time (which is slow and expensive), KernelWeave saves successful "recipes" (called Kernels) for tasks it did well.
- Why use it?
- Saves Money: It uses tiny, cheap models to do the routine work.
- Guarantees Quality: It checks the AI's answer against rules to make sure it didn't hallucinate or lie.
- How to test it right now?
Run this in your terminal:
python samples/product_test.py - How to train it?
Run this to teach it new skills:
python KernelWeave_LLM_Product_Train.py
Welcome to the comprehensive guide for KernelWeave. This document combines all spread-out documentation into a single, cohesive reference.
KernelWeave aims to be the Neuro-Symbolic Operating System for language models. The core idea is to shift from unstructured, token-by-token generation to verifiable reasoning patterns stored as "kernels".
When a language model solves a task successfully, KernelWeave:
- Stores the reasoning pattern as a typed kernel.
- Verifies future outputs against postconditions before caching.
- Routes similar prompts to cached kernels.
- Accumulates verified competence over time.
KernelWeave has four main layers:
- Trace capture — stores solved behaviors as structured events.
- Kernel compilation — distills a trace into a reusable, typed kernel.
- Kernel runtime — selects kernels for future prompts.
- Regression gate — rejects kernels that fail evidence or output tests.
flowchart LR
P[Prompt] --> R[Kernel runtime]
R -->|match| K[Kernel]
R -->|no match| G[Raw generation]
G --> T[Trace]
T --> C[Kernel compiler]
C --> S[Kernel store]
S --> R
The kernelweave.llm module is a routing and simulation layer, not a neural network.
- There are NO model weights in this repository's core.
- There is NO PyTorch, JAX, or tensor framework required for the core logic (check
pyproject.toml, it has zero dependencies). - The
KernelWeaveLLMclass routes prompts to skill kernels stored as JSON; it does NOT run inference. - The "LLM" naming is legacy — the module is fundamentally a routing layer.
The intelligence comes from the structure and verification, not from massive parameter counts.
KernelWeave_LLM_Product_Train.py— Full training + benchmark + realtime demo runner (uses external ML libraries to train the router).standalone_train.py— A standalone version of the training script.
- Run the training script (e.g., on Kaggle or a local GPU machine) to train the router adapter.
- Open the generated artifacts:
kernelweave_llm_bundle/benchmark/benchmark.mdkernelweave_llm_bundle/realtime_demo.md
- Share the results using the export zip in
kernelweave_llm_export/.
- Semantic routing — Embedding-based similarity + calibration scoring.
- Postcondition verification — Checks outputs against kernel constraints (currently prototype-level with retries).
- Feedback accumulation — Records success/failure for each kernel.
- Auto-promotion — High-confidence repeated successes become candidate kernels.
- Smart Compilation — The compiler can use an LLM to extract real preconditions and postconditions from traces (Newly implemented!).
- True Constrained Decoding: Moving from regex and retries to token-level logit masking to guarantee outputs match the schema.
- Kernel Composition Algebra: Developing operations (like sequence and parallel) to combine kernels dynamically.
- Self-Compilation: Enhancing the compiler to automatically extract general patterns from successful traces.
kernelweave/— Core source code.compiler.py— Trace to kernel compiler.runtime.py— Execution and routing.constrained.py— Structured decoding (Prototype).compose/— Kernel composition logic.
store/— JSON store for kernels and traces.tests/— Regression suite.phasecd/— Dataset specs and benchmark harness.