Expand description
§Intent Classification Library
A flexible few-shot intent classification library for natural language processing. 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
§Quick Start
use intent_classifier::{IntentClassifier, TrainingExample, TrainingSource, IntentId};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new classifier
let classifier = IntentClassifier::new().await?;
// Predict an intent
let prediction = classifier.predict_intent("merge these JSON files together").await?;
println!("Intent: {}, Confidence: {:.3}",
prediction.intent, prediction.confidence.value());
// Add custom training data
let example = TrainingExample {
text: "calculate the sum of these numbers".to_string(),
intent: IntentId::from("math_operation"),
confidence: 1.0,
source: TrainingSource::Programmatic,
};
classifier.add_training_example(example).await?;
// Get statistics
let stats = classifier.get_stats().await;
println!("Training examples: {}", stats.training_examples);
Ok(())
}
§Examples
For more examples, see the examples/
directory in the repository.
Re-exports§
pub use classifier::IntentClassifier;
pub use types::IntentId;
pub use types::Confidence;
pub use types::IntentPrediction;
pub use types::TrainingExample;
pub use types::TrainingSource;
pub use types::ClassificationRequest;
pub use types::ClassificationResponse;
pub use types::IntentFeedback;
pub use types::ClassifierConfig;
pub use types::ClassifierStats;
pub use types::IntentError;
pub use types::Result;
pub use types::*;
Modules§
- classifier
- Intent Classification Library
- types
- Core types for intent classification