sevensense-interpretation
Evidence-based interpretation and explanation generation for bioacoustic AI.
sevensense-interpretation generates human-readable explanations for AI predictions. Using the RAB (Reasoning, Accountability, Believability) framework, it produces "evidence packs" that document why a species was identified, what features contributed to the decision, and how confident the system is—essential for scientific credibility and regulatory compliance.
Features
- RAB Evidence Packs: Structured explanation documents
- Confidence Scoring: Multi-factor confidence with breakdowns
- Feature Attribution: Which acoustic features drove predictions
- Uncertainty Quantification: Epistemic vs. aleatoric uncertainty
- Natural Language: Human-readable narratives
- Audit Trails: Complete decision provenance
Use Cases
| Use Case | Description | Key Functions |
|---|---|---|
| Evidence Generation | Create explanation packs | EvidencePack::generate() |
| Confidence Scoring | Multi-factor confidence | ConfidenceScorer::score() |
| Feature Attribution | Explain which features matter | attribute_features() |
| Narrative Generation | Human-readable explanations | generate_narrative() |
| Audit Export | Compliance documentation | export_audit_trail() |
Installation
Add to your Cargo.toml:
[]
= "0.1"
Quick Start
use ;
Basic Evidence Generation
use ;
let config = EvidenceConfig ;
let generator = new;
// Prediction to explain
let prediction = Prediction ;
// Generate evidence
let evidence = generator.generate?;
println!;
Evidence Pack Structure
// The EvidencePack contains:
println!;
println!;
println!;
println!;
println!;
println!;
println!;
println!;
for in evidence.neighbors.iter.take.enumerate
println!;
println!;
Multi-Factor Confidence
use ;
let config = ConfidenceConfig ;
let scorer = new;
let score = scorer.score?;
println!;
println!;
println!;
println!;
println!;
Confidence Calibration
use ;
// Calibrate confidence scores using validation data
let calibrator = train?;
// Apply calibration
let raw_confidence = 0.85;
let calibrated = calibrator.calibrate;
println!;
// Calibration diagnostics
let diagnostics = calibrator.diagnostics;
println!;
println!;
Uncertainty Decomposition
use ;
let estimator = new;
let uncertainty = estimator.estimate?;
println!;
println!;
println!;
// Interpretation
if uncertainty.epistemic > uncertainty.aleatoric else
Identifying Important Features
use ;
let attributor = new;
// Get feature importance scores
let attributions = attributor.attribute?;
println!;
let mut sorted: = attributions.iter.enumerate.collect;
sorted.sort_by;
for in sorted.iter.take
Acoustic Feature Mapping
use ;
let mapper = new;
// Map embedding dimensions to acoustic features
let acoustic_attributions = mapper.map_to_acoustic?;
println!;
for in acoustic_attributions.iter.take
// Output example:
// Frequency Range (2-4 kHz): 0.342
// Temporal Modulation: 0.287
// Harmonic Structure: 0.156
Contrastive Explanations
use ContrastiveExplainer;
let explainer = new;
// Why species A and not species B?
let explanation = explainer.explain?;
println!;
println!;
for diff in &explanation.differences
Scientific Narratives
use ;
let generator = new;
let narrative = generator.generate?;
println!;
// Output:
// "The audio segment was classified as Turdus merula (Eurasian Blackbird)
// with 94.2% confidence. This classification is supported by high similarity
// (>0.90) to 8 confirmed Turdus merula recordings in the reference database.
// The embedding falls within the core region of the Turdus merula cluster
// (silhouette score: 0.87). Key discriminating features include the
// characteristic frequency range (2.1-4.3 kHz) and the presence of
// melodic phrases with harmonic structure typical of the species."
Conversational Narratives
let generator = new;
let narrative = generator.generate?;
println!;
// Output:
// "This sounds like a Eurasian Blackbird! I'm 94% confident because
// it matches several confirmed blackbird recordings in our database.
// The distinctive melodic whistling in the 2-4 kHz range is a classic
// blackbird signature."
Template-Based Narratives
use ;
let template = new;
let engine = new;
let narrative = engine.render?;
Creating Audit Records
use ;
let mut audit = new;
// Record prediction event
audit.record;
// Record evidence generation
audit.record;
Exporting for Compliance
use ;
let exporter = new;
// Export to JSON
let json = exporter.export?;
write?;
// Export to CSV (for spreadsheet analysis)
let csv = exporter.export?;
write?;
// Export to PDF report
let pdf = exporter.export?;
write?;
Provenance Tracking
use ProvenanceTracker;
let tracker = new;
// Track data lineage
tracker.record_input?;
tracker.record_processing?;
tracker.record_processing?;
tracker.record_prediction?;
// Generate provenance graph
let graph = tracker.to_graph?;
println!; // GraphViz format
Configuration
EvidenceConfig Parameters
| Parameter | Default | Description |
|---|---|---|
include_neighbors |
true | Include similar examples |
include_features |
true | Include feature attribution |
include_uncertainty |
true | Include uncertainty estimates |
narrative_style |
Scientific | Narrative style |
max_neighbors |
10 | Max neighbors to include |
ConfidenceConfig Parameters
| Parameter | Default | Description |
|---|---|---|
neighbor_weight |
0.4 | Neighbor agreement weight |
cluster_weight |
0.3 | Cluster membership weight |
quality_weight |
0.3 | Embedding quality weight |
RAB Framework
| Component | Description | Implementation |
|---|---|---|
| Reasoning | Why was this prediction made? | Feature attribution, neighbors |
| Accountability | Who/what is responsible? | Audit trails, model versions |
| Believability | How trustworthy is this? | Confidence, uncertainty |
Links
- Homepage: ruv.io
- Repository: github.com/ruvnet/ruvector
- Crates.io: crates.io/crates/sevensense-interpretation
- Documentation: docs.rs/sevensense-interpretation
License
MIT License - see LICENSE for details.
Part of the 7sense Bioacoustic Intelligence Platform by rUv