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
File size: 1,379 Bytes
74b8664 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 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()
|