Intent Classification Library
A flexible few-shot intent classification library for natural language processing in Rust. This library provides a simple API for classifying user intents from text using machine learning and rule-based approaches.
Features
- Few-shot learning: Train the classifier with minimal examples
- Bootstrap data: Comes with pre-trained examples for common intents
- Feedback learning: Improve accuracy through user feedback
- Async support: Fully async API for non-blocking operations
- Serializable: Export/import training data as JSON
- Configurable: Customize behavior through configuration
- High performance: Built with Rust for speed and safety
Installation
Add this to your Cargo.toml
:
[]
= "0.1.0"
Quick Start
use ;
async
Built-in Intent Categories
The library comes with bootstrap training data for common intent categories:
Data Operations
data_merge
- Combining multiple data filesdata_split
- Splitting large files into smaller onesdata_transform
- Converting between data formatsdata_analyze
- Analyzing datasets for patterns
File Operations
file_read
- Reading file contentsfile_write
- Writing data to filesfile_convert
- Converting file formatsfile_compare
- Comparing files
Network Operations
network_request
- Making HTTP/API requestsnetwork_download
- Downloading files from URLsnetwork_monitor
- Monitoring network services
Processing Operations
extraction
- Extracting information from documentsvalidation
- Validating data against schemasgeneration
- Generating reports or documentationclassification
- Categorizing content
Code Operations
code_analyze
- Analyzing source codetext_process
- Processing text documents
Configuration
Customize the classifier behavior:
use ;
let config = ClassifierConfig ;
let classifier = with_config.await?;
Advanced Usage
Adding Custom Training Data
let example = TrainingExample ;
classifier.add_training_example.await?;
Feedback Learning
use IntentFeedback;
let feedback = IntentFeedback ;
classifier.add_feedback.await?;
Structured Classification Requests
use ClassificationRequest;
let request = ClassificationRequest ;
let response = classifier.classify.await?;
println!;
Export/Import Training Data
// Export training data
let exported = classifier.export_training_data.await?;
write?;
// Import training data
let imported = read_to_string?;
let new_classifier = new.await?;
new_classifier.import_training_data.await?;
Use Cases
Multi-LLM Orchestration
Route different types of tasks to specialized language models:
async
Chatbot Intent Recognition
async
Command-Line Tool Classification
async
Examples
Run the examples to see the library in action:
# Basic usage example
# Multi-LLM orchestration example
Performance
The library is designed for high performance:
- Async operations: Non-blocking API for concurrent processing
- Efficient data structures: Uses
DashMap
for thread-safe concurrent access - Minimal allocations: Optimized for low memory usage
- Fast feature extraction: Efficient text processing and vectorization
Architecture
The library consists of several key components:
- IntentClassifier: Main classifier engine
- Types: Core data structures and error types
- Feature Extraction: Text processing and vectorization
- Training: Learning from examples and feedback
- Prediction: Intent classification and confidence scoring
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
v0.1.0
- Initial release
- Basic intent classification functionality
- Bootstrap training data for common intents
- Feedback learning system
- Async API
- Export/import functionality
- Configuration support
- Comprehensive examples and documentation