Independent package for intent recognition and classification in conversational AI systems
sage-intent provides flexible intent recognition capabilities for conversational AI:
- Keyword-Based Recognition: Fast, rule-based intent matching
- LLM-Based Recognition: Semantic intent understanding with LLMs
- Hybrid Classification: Combine multiple recognizers
- Extensible Architecture: Easy to add custom recognizers
# Basic installation (keyword-based only)
pip install isage-intent
# With LLM support
pip install isage-intent[llm]
# Development installation
pip install isage-intent[dev]from sage_intent import KeywordIntentRecognizer, IntentCatalog
# Create intent catalog
catalog = IntentCatalog()
catalog.add_intent(
name="search",
keywords=["find", "search", "look for", "query"],
description="Search for information"
)
catalog.add_intent(
name="greeting",
keywords=["hello", "hi", "hey"],
description="Greet the user"
)
# Create recognizer
recognizer = KeywordIntentRecognizer(catalog)
# Recognize intent
intent = recognizer.recognize("Can you help me search for papers?")
print(intent.name) # "search"
print(intent.confidence) # 0.85from sage_intent import LLMIntentRecognizer, IntentCatalog
# Create catalog with descriptions
catalog = IntentCatalog()
catalog.add_intent(
name="data_analysis",
description="Analyze data, generate visualizations, compute statistics"
)
catalog.add_intent(
name="code_generation",
description="Write code, create functions, implement algorithms"
)
# Create LLM recognizer
recognizer = LLMIntentRecognizer(
catalog=catalog,
llm_client=your_llm_client
)
# Recognize with semantic understanding
intent = recognizer.recognize(
"I need a function to calculate the mean and standard deviation"
)
print(intent.name) # "code_generation"from sage_intent import IntentClassifier, KeywordIntentRecognizer, LLMIntentRecognizer
# Create classifier with multiple recognizers
classifier = IntentClassifier(
recognizers=[
KeywordIntentRecognizer(catalog),
LLMIntentRecognizer(catalog, llm_client)
],
strategy="vote" # or "confidence", "cascade"
)
# Classify with combined approach
intent = classifier.classify("Find research papers about transformers")Manages intent definitions:
- Intent registration with keywords and descriptions
- Hierarchical intent organization
- Intent metadata and examples
Fast rule-based matching:
- Multiple keyword patterns per intent
- Fuzzy matching support
- Priority-based disambiguation
Semantic understanding with LLMs:
- Zero-shot intent classification
- Few-shot with examples
- Confidence scoring
Combines multiple recognizers:
- Voting strategies
- Confidence-based selection
- Cascade fallback
Easy recognizer creation:
- Pre-configured recognizers
- Custom recognizer registration
- Dynamic loading
sage_intent/
βββ base.py # Base classes and protocols
βββ types.py # Common types
βββ catalog.py # Intent catalog management
βββ keyword_recognizer.py # Keyword-based recognition
βββ llm_recognizer.py # LLM-based recognition
βββ classifier.py # Multi-recognizer classification
βββ factory.py # Recognizer factory
βββ __init__.py # Public API exports
- Chatbots: Route user queries to appropriate handlers
- Voice Assistants: Understand user commands
- Customer Support: Classify support tickets
- Search Systems: Detect search intent for better results
- Agent Systems: Determine agent actions based on user intent
This package is part of the SAGE ecosystem but can be used independently:
# Standalone usage
from sage_intent import KeywordIntentRecognizer, IntentCatalog
# With SAGE agentic (optional)
from sage_agentic import Agent
from sage_intent import IntentClassifier
agent = Agent()
classifier = IntentClassifier(catalog)
def process_query(query):
intent = classifier.classify(query)
return agent.execute(intent)- Repository: https://github.com/intellistream/sage-intent
- SAGE Documentation: https://intellistream.github.io/SAGE-Pub/
- Issues: https://github.com/intellistream/sage-intent/issues
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details.
Originally part of the SAGE framework, now maintained as an independent package for broader community use.
- Team: IntelliStream Team
- Email: shuhao_zhang@hust.edu.cn
- GitHub: https://github.com/intellistream