Lightning fast context engine for AI apps **100x faster** than vector RAG fully local private.
2.6K
ContextLite is a Go-based context assembly engine that uses Satisfiability Modulo Theories (SMT) optimization to select the perfect set of documents for AI context windows. Built for speed, privacy, and local operation.
# Build main contextlite binary
make build
# Build SOTA evaluation tool
make build-sota
# Build both binaries
make build-all-local
# Or with custom config
./build/contextlite -config configs/custom.yaml
# Run SOTA evaluation
./build/sota-eval
# Development mode with hot reload
make dev
The server starts on http://localhost:8080 by default.
contextlite/
โโโ cmd/ # Executable applications
โ โโโ contextlite/ # HTTP sidecar server
โ โโโ sota-eval/ # SOTA comparison CLI tool
โโโ internal/ # Private implementation
โ โโโ smt/ # SMT solver integration (Z3)
โ โโโ storage/ # SQLite + FTS5 storage layer
โ โโโ features/ # 7D feature extraction & scoring
โ โโโ pipeline/ # Main assembly pipeline
โ โโโ cache/ # Multi-level caching system
โ โโโ api/ # HTTP API handlers
โ โโโ evaluation/ # SOTA evaluation framework
โโโ pkg/ # Public API packages
โ โโโ types/ # Core data structures
โ โโโ config/ # Configuration management
โ โโโ tokens/ # Token estimation utilities
โโโ docs/ # Technical documentation
โโโ archive/ # Historical development artifacts
โโโ test/ # Integration tests
โโโ configs/ # Default configuration files
โโโ migrations/ # Database schema migrations
See configs/default.yaml for full configuration options:
# Core SMT optimization settings
smt:
solver_timeout_ms: 250 # Hard timeout for SMT solver
max_opt_gap: 0.05 # 5% optimality gap acceptable
objective_style: "weighted-sum" # weighted-sum | lexicographic | epsilon-constraint
# 7D Feature weights (adaptive per workspace)
weights:
relevance: 0.30 # Query match strength
recency: 0.20 # Time-based decay
entanglement: 0.15 # Cross-document concept density
prior: 0.15 # Historical selection likelihood
authority: 0.10 # Document importance
specificity: 0.05 # Query-document topic alignment
uncertainty: 0.05 # Score variance (subtracted)
curl -X POST http://localhost:8080/api/v1/context/assemble \
-H "Content-Type: application/json" \
-d '{
"query": "How does user authentication work?",
"max_tokens": 4000,
"max_documents": 10,
"use_smt": true,
"workspace_path": "/path/to/project"
}'
# Add document
curl -X POST http://localhost:8080/api/v1/documents \
-H "Content-Type: application/json" \
-d '{
"content": "...",
"path": "src/auth.go",
"language": "go"
}'
# Search documents
curl "http://localhost:8080/api/v1/documents/search?q=authentication&limit=20"
# Get workspace weights
curl "http://localhost:8080/api/v1/weights?workspace=/path/to/project"
# Update weights based on feedback
curl -X POST http://localhost:8080/api/v1/weights/update \
-H "Content-Type: application/json" \
-d '{
"workspace_path": "/path/to/project",
"accepted_docs": ["doc1", "doc2"],
"rejected_docs": ["doc3"]
}'
ContextLite uses three SMT optimization formulations:
Balances all 7D features with learned workspace-specific weights:
maximize: ฮฃ(ฮฑโยทRel + ฮฑโยทRec + ฮฑโยทEnt + ฮฑโยทPrior + ฮฑโ
ยทAuth + ฮฑโยทSpec - ฮฑโยทUnc)
subject to: token_budget, max_documents, coherence_constraints
Strict priority ordering (relevance first, then recency, etc.):
objective_style: "lexicographic"
Optimize primary objective with secondary constraints:
objective_style: "epsilon-constraint"
ContextLite includes a comprehensive evaluation framework comparing against state-of-the-art retrieval systems:
# Run full SOTA comparison
./build/sota-eval
# With custom parameters
./build/sota-eval -queries 1000 -docs 100 -verbose
Evaluation Metrics:
Baseline Comparisons:
See docs/GOLDEN_RECORD_STEP5.mdโ for current evaluation status and identified areas for improvement.
Benchmarked on NVMe SSD, 100k documents, K=200 candidates:
| Operation | p50 | p95 | p99 |
|---|---|---|---|
| Cached Query | 15ms | 30ms | 45ms |
| Cold Query | 180ms | 350ms | 500ms |
| SMT Solve | 50ms | 150ms | 250ms |
| Feature Extract | 25ms | 80ms | 120ms |
# Install dependencies
make deps
# Build main binary
make build
# Build SOTA evaluation tool
make build-sota
# Build both binaries locally
make build-all-local
# Build for all platforms
make build-all
# Run tests
make test
# Run with coverage
make coverage
# Run benchmarks
make bench
# Code quality checks
make check
# Development with hot reload
make dev
# Clean build artifacts
make clean
# Build image
make docker-build
# Run container
make docker-run
The API provides comprehensive metrics:
# Health check
curl http://localhost:8080/health
# Storage statistics
curl http://localhost:8080/api/v1/storage/info
# SMT solver performance
curl http://localhost:8080/api/v1/smt/stats
# Cache performance
curl http://localhost:8080/api/v1/cache/stats
This project is licensed under the MIT License - see the LICENSEโ file for details.
For complete implementation details, algorithms, and architecture decisions, see the documentation in the docs/ directory.
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)docs/ directory for technical detailsContextLite - Making AI context assembly fast, local, and intelligent.
ContextLite - Because context matters, and speed matters more. ๐
Content type
Image
Digest
sha256:e5f649294โฆ
Size
10.4 MB
Last updated
about 1 year ago
docker pull makuykendall/contextlite