WaveformRAG is a modular Semantic Routing Engine designed for RAG-based code generation. It uses neural embeddings and advanced retrieval techniques to map natural language user intent to specific API tools, followed by an LLM-powered generation stage with "MAKER-style" voting.
Version: 2.1.0
Author: Jordan Elevons
WaveformRAG acts as a bridge between high-level user goals (e.g., "smoothly move an object") and low-level API implementations (e.g., Vector3.Lerp). Unlike traditional RAG, it focuses on semantic routing—identifying the exact "tool" or code pattern needed before involving an LLM for final code assembly.
- 🔬 Neural Semantic Routing: Uses subspace projection and orthogonalized concept vectors (Intent, Motion, Dimension, Domain) to filter and rank candidates.
- 🗳️ MAKER-Style Voting: A multi-round voting process where the LLM selects the best tool from a list of candidates to eliminate position bias and improve accuracy.
- 🌍 Multi-Language Support: Easily switch between frameworks (Unity C#, BabylonJS, etc.) using modular JSON profiles.
- 🧠 Advanced Retrieval: Features query decomposition, semantic expansion, and inverse filtering to handle complex or noisy user prompts.
- 🏗️ Dataset Pipeline: Includes a full suite of tools for scraping API docs, mining user phrases, synthesizing tool definitions, and calibrating search thresholds.
The project has been consolidated into a modular package for ease of use and maintainability:
waveform_rag/: Core packageconfig.py: Centralized configuration for models, paths, and query processing.engine.py: Core logic for vector mathematics, retrieval, and re-ranking.llm.py: Interface for LLM interaction and MAKER voting.dataset.py: Comprehensive tools for building and calibrating the knowledge base.main.py: Command-line interface and interactive shell.
run_waveform.py: Convenient entry point script (run from project root).requirements.txt: Python dependencies for easy installation.Benchmarking/: Evaluation suite to compare WaveformRAG against raw LLM baselines.waveform_rag/Dataset/: Storage for tool libraries (unity_textbook.json), neural caches, and scraped source files.waveform_rag/language_profiles/: JSON profiles for different programming environments.
-
Clone the repository:
git clone <your-repo-url> cd <repo-name>
-
Install dependencies:
pip install -r requirements.txt
-
Configure your LLM server (see Configuration below)
-
Run WaveformRAG:
python run_waveform.py -i
- Python 3.9+
- Ollama or another OpenAI-compatible local LLM server.
- Anthropic API Key (for tool synthesis and benchmarking).
Install all required dependencies using the provided requirements.txt:
pip install -r requirements.txtThis will install:
sentence-transformers- For neural embeddingsnumpy- For vector operationsrequests- For HTTP requests to LLM serversanthropic- For Anthropic API (tool synthesis & benchmarking)beautifulsoup4- For HTML parsing (dataset generation)
Edit waveform_rag/config.py to match your local setup:
LLM_HOST = "http://127.0.0.1:1234" # Your LLM server URL
LLM_MODEL = "granite4:tiny-h" # Your generation model
MODEL_NAME = "all-MiniLM-L6-v2" # Your embedding modelAll commands should be run from the project root directory.
Interactive Mode:
python run_waveform.py -iSingle Query:
python run_waveform.py "make the player jump when I press space"Module Mode (Alternative):
python -m waveform_rag.main -iWaveformRAG provides a automated pipeline to build your own "textbook" of tools:
- Scraping:
APIScraperextracts class/method info from local HTML documentation. - Mining:
mine_corpusextracts realistic user phrases from chat logs. - Synthesis:
ToolSynthesizeruses Claude to generate full JSON tool definitions (patterns, code, metadata). - Calibration:
calibrate_librarycomputes neural centroids and optimal search thresholds.
The Benchmarking/ folder contains scripts to grade WaveformRAG's output using Claude-4 Sonnet, comparing it against a raw LLM baseline across multiple criteria:
- Correctness
- API Usage
- Completeness
- Code Quality
python Benchmarking/benchmark_waveform.py --limit 10This project is licensed under the MIT License - see the LICENSE file for details.