Views
No views yet
1from transformers import DistilBertTokenizer, DistilBertForSequenceClassification
2import torch
3import json
4
5tokenizer = DistilBertTokenizer.from_pretrained("./distilbert-intent-classifier-v1")
6model = DistilBertForSequenceClassification.from_pretrained("./distilbert-intent-classifier-v1")
7
8text = "I updated my package.json to lock the Express version to 4.18.0"
9inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
10
11with torch.no_grad():
12 outputs = model(**inputs)
13 logits = outputs.logits
14 predicted_class_id = logits.argmax(-1).item()
15
16# Map ID back to label
17label_config = json.load(open("label_config.json"))
18predicted_label = label_config["id_to_label"][str(predicted_class_id)]
19print(f"Predicted Intent: {predicted_label}")pytorch_model.bin: Fine-tuned model weightsconfig.json: Model configurationvocab.txt: Tokenizer vocabularylabel_config.json: Intent class mappingsREADME.md: This file