Views
No views yet
| Epoch | Training Loss | Validation Loss | Precision | Recall | F1 | Accuracy |
|---|---|---|---|---|---|---|
| 1 | 0.392600 | 0.347941 | 0.762406 | 0.631506 | 0.690810 | 0.882263 |
| 2 | 0.336300 | 0.302746 | 0.775583 | 0.702650 | 0.737317 | 0.897062 |
| 3 | 0.309500 | 0.294454 | 0.817472 | 0.701828 | 0.755249 | 0.905303 |
| 4 | 0.296700 | 0.281895 | 0.839335 | 0.695757 | 0.760831 | 0.905240 |
| 5 | 0.281700 | 0.273324 | 0.816995 | 0.752103 | 0.783207 | 0.914322 |
| 6 | 0.257300 | 0.262116 | 0.813662 | 0.758553 | 0.785142 | 0.915958 |
| 7 | 0.241200 | 0.255580 | 0.819946 | 0.764308 | 0.791150 | 0.918980 |
| 8 | 0.229900 | 0.255078 | 0.819697 | 0.771074 | 0.794643 | 0.919821 |
| 9 | 0.212800 | 0.248312 | 0.830942 | 0.776450 | 0.802772 | 0.922594 |
| 10 | 0.200900 | 0.245995 | 0.831402 | 0.780244 | 0.805011 | 0.923544 |
1
2from transformers import AutoTokenizer, AutoModel
3from peft import get_peft_config, PeftModel, PeftConfig, get_peft_model, LoraConfig, TaskType
4
5peft_model_id = "vishnun/lora-NLIGraph"
6config = PeftConfig.from_pretrained(peft_model_id)
7inference_model = AutoModelForTokenClassification.from_pretrained(
8 config.base_model_name_or_path, num_labels=4, id2label=id2lab, label2id=lab2id
9)
10tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
11model = PeftModel.from_pretrained(inference_model, peft_model_id)
12
13text = "Arsenal will win the Premier League"
14inputs = tokenizer(text, return_tensors="pt")
15
16with torch.no_grad():
17 logits = model(**inputs).logits
18
19tokens = inputs.tokens()
20predictions = torch.argmax(logits, dim=2)
21
22for token, prediction in zip(tokens, predictions[0].numpy()):
23 print((token, model.config.id2label[prediction]))
24
25## results : ('<s>', 'O')
26('Arsenal', 'SRC')
27('Ġwill', 'O')
28('Ġwin', 'REL')
29('Ġthe', 'O')
30('ĠPremier', 'TGT')
31('ĠLeague', 'O')
32('</s>', 'O')
33