High-performance semantic routing - 10x faster than semantic-router
StrataRouter is a Rust-powered semantic routing framework that delivers 10-20x better performance than semantic-router.
pip install stratarouterWith encoder support:
# HuggingFace (local, fast, free!)
pip install stratarouter[huggingface]
# OpenAI
pip install stratarouter[openai]
# All encoders
pip install stratarouter[all]from stratarouter import Route, RouteLayer
from stratarouter.encoders import HuggingFaceEncoder
# Define routes
routes = [
Route(
name="billing",
utterances=["invoice", "payment", "refund"]
),
Route(
name="support",
utterances=["help", "question", "issue"]
)
]
# Create router
encoder = HuggingFaceEncoder()
router = RouteLayer(encoder=encoder, routes=routes)
# Route queries
result = router("I need my invoice")
print(f"Route: {result.name}, Score: {result.score:.2f}")| Metric | semantic-router | StrataRouter | Improvement |
|---|---|---|---|
| Latency | 42ms | 3ms | 14x faster |
| Memory | 2.1GB | 64MB | 33x less |
| Throughput | 450/s | 18K/s | 40x higher |
Start the server:
# From repository root
cd server
uvicorn main:app --reload
# Or using Docker
docker-compose upAPI will be available at:
- API: http://localhost:8000
- Docs: http://localhost:8000/docs (Swagger UI)
- ReDoc: http://localhost:8000/redoc
Test it:
curl -X POST http://localhost:8000/route \
-H "Content-Type: application/json" \
-d '{"text": "I need my invoice", "top_k": 3}'# Clone repository
git clone https://github.com/stratarouter/stratarouter
cd stratarouter
# Install development dependencies
./scripts/install_dev.sh
# Build Rust core
cd core && cargo build --release && cd ..
# Install Python package
cd python && maturin develop --release && cd ..
# Run tests
./scripts/test_all.shMIT License - see LICENSE
---