This document describes the integration test suite for enterprise classifiers hosted on Hugging Face Hub.
The integration tests (tests/test_enterprise_classifiers_integration.py) verify that all 17 enterprise classifiers maintain their expected performance and behavior. These tests serve as regression tests to ensure code changes don't break the published models.
The integration test suite covers:
- Model Loading: Can each model be loaded from HuggingFace Hub?
- Prediction Functionality: Do models make valid predictions?
- k-Parameter Consistency: Do k=1 and k=2 produce consistent results? (regression test for the k parameter bug)
- Prediction Stability: Are repeated predictions consistent?
- Performance: Does inference complete within reasonable time?
- Class Coverage: Do models know about all expected classes?
- Health Check: Overall ecosystem health assessment
pytest tests/test_enterprise_classifiers_integration.py -vpytest tests/ -m "not integration" -vpytest tests/test_enterprise_classifiers_integration.py -k "fraud-detection" -v# Test k-parameter consistency for all classifiers
pytest tests/test_enterprise_classifiers_integration.py::TestEnterpriseClassifiers::test_k_parameter_consistency -v
# Test model loading for all classifiers
pytest tests/test_enterprise_classifiers_integration.py::TestEnterpriseClassifiers::test_model_loading -vThe CI/CD pipeline runs integration tests automatically:
- Unit Tests Job: Runs all unit tests first
- Integration Tests Job: Runs only if unit tests pass
- 30-minute timeout for model downloads
- Tests all 17 enterprise classifiers
- Reports detailed results
The following 17 enterprise classifiers are tested:
| Classifier | Expected Accuracy | Classes | Use Case |
|---|---|---|---|
| business-sentiment | 98.8% | 4 | Business text sentiment analysis |
| compliance-classification | 65.3% | 5 | Regulatory compliance categorization |
| content-moderation | 100.0% | 3 | Content filtering and moderation |
| customer-intent | 85.2% | 4 | Customer service intent detection |
| document-quality | 100.0% | 2 | Document quality assessment |
| document-type | 98.0% | 5 | Document type classification |
| email-priority | 83.9% | 3 | Email priority triage |
| email-security | 93.8% | 4 | Email security threat detection |
| escalation-detection | 97.6% | 2 | Support ticket escalation detection |
| expense-category | 84.2% | 5 | Business expense categorization |
| fraud-detection | 92.7% | 2 | Financial fraud detection |
| language-detection | 100.0% | 4 | Text language identification |
| pii-detection | 100.0% | 2 | Personal information detection |
| product-category | 85.2% | 4 | E-commerce product categorization |
| risk-assessment | 75.6% | 2 | Security risk assessment |
| support-ticket | 82.9% | 4 | Support ticket categorization |
| vendor-classification | 92.7% | 2 | Vendor relationship classification |
Each classifier is tested against:
- Minimum Accuracy Thresholds: Must meet or exceed defined minimums
- k-Parameter Consistency: k=1 and k=2 must produce identical top predictions
- Response Time: Inference must complete within 2 seconds
- Class Completeness: Must know about all expected classes
- Prediction Validity: All predictions must be properly formatted
Tests will fail if:
- Model cannot be loaded from HuggingFace Hub
- Accuracy drops below minimum threshold
- k=1 and k=2 produce different top predictions (regression)
- Inference takes longer than 2 seconds
- Predicted classes don't match expected class set
- Prediction format is invalid
To add a new enterprise classifier to the test suite:
- Update
CLASSIFIER_METRICSdictionary with expected metrics - Add domain-specific test sentences to
TEST_SENTENCES - Ensure the model is available on HuggingFace Hub as
adaptive-classifier/{name}
- Check that the model exists on HuggingFace Hub
- Verify network connectivity
- Check for authentication issues (if model is private)
- Compare actual vs expected accuracy in test output
- Check if model was retrained recently
- Verify test sentences are appropriate for the domain
- This indicates a regression in the k parameter fix
- Check prediction logic in
_predict_regularmethod - Verify prototype and neural head prediction combination
- Check system resources during testing
- Consider network latency for model downloads
- Verify model size hasn't increased significantly
For faster local testing, you can:
# Skip integration tests during development
pytest tests/ -m "not integration"
# Test specific classifier during debugging
pytest tests/test_enterprise_classifiers_integration.py -k "fraud-detection" -v -sThe integration test suite should be updated when:
- New enterprise classifiers are published
- Expected accuracy thresholds change
- New test dimensions are needed
- Test sentences need updating for better coverage
This ensures the test suite remains comprehensive and valuable for regression detection.