Text Classification
Scikit-learn
scikit-learn
skops
intent-classification
selective-classification
error-prediction
banking
advisory
PolyAI/banking77
Instructions to use ITheEqualizer/banking77-intent-error-predictor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use ITheEqualizer/banking77-intent-error-predictor with Scikit-learn:
# ⚠️ Model filename not specified in config.json
- Notebooks
- Google Colab
- Kaggle
| from __future__ import annotations | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| from typing import Any | |
| from banking_intent_error_predictor.predict import predict_text | |
| def route_query( | |
| text: str, | |
| *, | |
| primary_path: Path, | |
| risk_path: Path, | |
| config_path: Path, | |
| ) -> dict[str, Any]: | |
| prediction = predict_text( | |
| text, | |
| primary_path=primary_path, | |
| risk_path=risk_path, | |
| config_path=config_path, | |
| ) | |
| action = ( | |
| "enqueue_human_review" | |
| if prediction["review"] | |
| else f"route_to_{prediction['intent']}_handler" | |
| ) | |
| return {"action": action, "prediction": prediction, "executes_action": False} | |
| def main() -> None: | |
| parser = argparse.ArgumentParser( | |
| description="Demonstrate advisory routing without executing an action" | |
| ) | |
| parser.add_argument("text") | |
| parser.add_argument("--primary", type=Path, default=Path("primary_baseline.skops")) | |
| parser.add_argument("--risk-model", type=Path, default=Path("model.skops")) | |
| parser.add_argument("--config", type=Path, default=Path("config.json")) | |
| args = parser.parse_args() | |
| result = route_query( | |
| args.text, | |
| primary_path=args.primary, | |
| risk_path=args.risk_model, | |
| config_path=args.config, | |
| ) | |
| print(json.dumps(result, indent=2, sort_keys=True)) | |
| if __name__ == "__main__": | |
| main() | |