atulgupta002 commited on
Commit
6ab048f
·
verified ·
1 Parent(s): 134a694

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +13 -10
README.md CHANGED
@@ -65,17 +65,20 @@ id2label = {idx: label for label, idx in label2id.items()}
65
  model = AutoModelForSequenceClassification.from_pretrained("atulgupta002/banking_customer_service_query_intent_classifier")
66
  tokenizer = AutoTokenizer.from_pretrained("atulgupta002/banking_customer_service_query_intent_classifier")
67
 
68
- # Example text input
69
- query = "I want to apply for a new credit card"
 
 
 
 
 
70
 
71
- # Tokenize input text
72
- inputs = tokenizer(query, return_tensors="pt", truncation=True, padding=True)
73
 
74
- # Get model prediction
75
- outputs = model(**inputs)
76
- logits = outputs.logits
77
 
78
- # Get predicted intent class
79
- predicted_class = logits.argmax().item()
80
- print(f"Predicted intent: {id2label[predicted_class]}")
81
 
 
 
65
  model = AutoModelForSequenceClassification.from_pretrained("atulgupta002/banking_customer_service_query_intent_classifier")
66
  tokenizer = AutoTokenizer.from_pretrained("atulgupta002/banking_customer_service_query_intent_classifier")
67
 
68
+ def predict(text):
69
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
70
+
71
+ with torch.no_grad():
72
+ outputs = model(**inputs)
73
+ logits = outputs.logits
74
+ predicted_class_id = logits.argmax().item()
75
 
76
+ return id2label[predicted_class_id]
 
77
 
78
+ query = "I want to apply for a new credit card"
79
+ print(predict(query))
80
+ ```
81
 
82
+ ## Sample output
 
 
83
 
84
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/643c6f86ae8d93dc39515286/2Y4ty_VgbvBOigWAQwHIS.png)