SAGE Libs Intent (L3) - Keyword-based and LLM-based intent classification for conversational AI
Project description
SAGE Intent Recognition
Independent package for intent recognition and classification in conversational AI systems
🎯 Overview
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
📦 Installation
# Basic installation (keyword-based only)
pip install isage-intent
# With LLM support
pip install isage-intent[llm]
# Development installation
pip install isage-intent[dev]
🚀 Quick Start
Keyword-Based Recognition
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.85
LLM-Based Recognition
from 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"
Hybrid Classifier
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")
📚 Key Components
1. Intent Catalog (catalog.py)
Manages intent definitions:
- Intent registration with keywords and descriptions
- Hierarchical intent organization
- Intent metadata and examples
2. Keyword Recognizer (keyword_recognizer.py)
Fast rule-based matching:
- Multiple keyword patterns per intent
- Fuzzy matching support
- Priority-based disambiguation
3. LLM Recognizer (llm_recognizer.py)
Semantic understanding with LLMs:
- Zero-shot intent classification
- Few-shot with examples
- Confidence scoring
4. Classifier (classifier.py)
Combines multiple recognizers:
- Voting strategies
- Confidence-based selection
- Cascade fallback
5. Factory (factory.py)
Easy recognizer creation:
- Pre-configured recognizers
- Custom recognizer registration
- Dynamic loading
🔧 Architecture
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
🎓 Use Cases
- 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
🔗 Integration with SAGE
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)
📖 Documentation
- Repository: https://github.com/intellistream/sage-intent
- SAGE Documentation: https://intellistream.github.io/SAGE-Pub/
- Issues: https://github.com/intellistream/sage-intent/issues
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
MIT License - see LICENSE file for details.
🙏 Acknowledgments
Originally part of the SAGE framework, now maintained as an independent package for broader community use.
📧 Contact
- Team: IntelliStream Team
- Email: shuhao_zhang@hust.edu.cn
- GitHub: https://github.com/intellistream
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file isage_libs_intent-0.1.0.2.tar.gz.
File metadata
- Download URL: isage_libs_intent-0.1.0.2.tar.gz
- Upload date:
- Size: 37.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59abf9dfa72fb49caf46fedd3bd27583c55c7b8f2b99fd7472e6a8029ead73dd
|
|
| MD5 |
b61013c09b0c2d6ca8ee805439c5b179
|
|
| BLAKE2b-256 |
1c191fe61a354581bba8af5bc0db9ab7c70b38bc95fbb02b3695723bf175245d
|
File details
Details for the file isage_libs_intent-0.1.0.2-py2.py3-none-any.whl.
File metadata
- Download URL: isage_libs_intent-0.1.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 51.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15cb2201a15b62e6ac5a7118835e787a95d4ab4e2546599bf79b1aff5be63fd8
|
|
| MD5 |
e08524e1ef4200d9ec8dc02a3d7c9874
|
|
| BLAKE2b-256 |
2d7eb947ee14f0dc4e949188c77f99dce8bc72635f3bb365028d799d1e428db0
|