semantic-router  by aurelio-labs

Decision-making layer for LLMs and agents

created 1 year ago
2,698 stars

Top 17.9% on sourcepulse

GitHubView on GitHub
Project Summary

Semantic Router provides a high-speed decision-making layer for LLMs and AI agents, enabling efficient routing of requests based on semantic meaning rather than slow LLM generations. It's designed for developers building AI applications who need to quickly direct user queries or data to appropriate tools or responses, particularly in scenarios requiring low latency.

How It Works

The core of Semantic Router is its RouteLayer, which leverages semantic vector spaces to make routing decisions. Users define Route objects, each associated with a list of example utterances. These utterances are embedded into a vector space. When a new query arrives, it's also embedded, and the system finds the closest matching Route based on vector similarity. This approach offers significant speed advantages over traditional LLM-based decision-making for tool use or intent recognition.

Quick Start & Requirements

  • Install: pip install -qU semantic-router
  • Local execution: pip install -qU "semantic-router[local]"
  • Hybrid features: pip install -qU "semantic-router[hybrid]"
  • Encoders: Requires API keys for services like Cohere or OpenAI, or local models via Hugging Face.
  • Resources: Official Docs, Notebook, and LangChain integration examples are available.

Highlighted Details

  • Supports multiple encoders including Cohere, OpenAI, Hugging Face, and FastEmbed.
  • Integrates with vector databases like Pinecone and Qdrant for utterance storage.
  • Offers multi-modal routing capabilities.
  • Claims local models like Mistral 7B can outperform GPT-3.5 for certain tasks.

Maintenance & Community

The project is associated with Aurelio Labs and has contributions from researchers like Dimitrios Manias and Ali Chouman. Mentions in Geeky Gadgets and AI Insights suggest community interest.

Licensing & Compatibility

The README does not explicitly state a license. Compatibility for commercial use or closed-source linking is not specified.

Limitations & Caveats

The project appears to be under active development, with mentions of "more encoders will be added soon" and "dynamic routes" suggesting ongoing feature expansion. The lack of a specified license could be a concern for commercial adoption.

Health Check
Last commit

2 days ago

Responsiveness

Inactive

Pull Requests (30d)
11
Issues (30d)
10
Star History
137 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.