vishnun commited on
Commit
8edec6e
·
1 Parent(s): deb4f7d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +53 -13
README.md CHANGED
@@ -3,20 +3,60 @@ library_name: peft
3
  ---
4
  ## Training procedure
5
 
6
- Used PEFT library from huggingface and leveraged LoRA procedure to tune the model. Below are the training metrics.
7
-
8
- Epoch Training Loss Validation Loss Precision Recall F1 Accuracy
9
- 1 0.392600 0.347941 0.762406 0.631506 0.690810 0.882263
10
- 2 0.336300 0.302746 0.775583 0.702650 0.737317 0.897062
11
- 3 0.309500 0.294454 0.817472 0.701828 0.755249 0.905303
12
- 4 0.296700 0.281895 0.839335 0.695757 0.760831 0.905240
13
- 5 0.281700 0.273324 0.816995 0.752103 0.783207 0.914322
14
- 6 0.257300 0.262116 0.813662 0.758553 0.785142 0.915958
15
- 7 0.241200 0.255580 0.819946 0.764308 0.791150 0.918980
16
- 8 0.229900 0.255078 0.819697 0.771074 0.794643 0.919821
17
- 9 0.212800 0.248312 0.830942 0.776450 0.802772 0.922594
18
- 10 0.200900 0.245995 0.831402 0.780244 0.805011 0.923544
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  ### Framework versions
21
 
22
 
 
3
  ---
4
  ## Training procedure
5
 
6
+ - Used PEFT library from huggingface and leveraged LoRA procedure to tune the model. Below are the training metrics.
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
+ | Epoch | Training Loss | Validation Loss | Precision | Recall | F1 | Accuracy |
9
+ |------:|--------------:|----------------:|----------:|---------:|---------:|---------:|
10
+ | 1 | 0.392600 | 0.347941 | 0.762406 | 0.631506 | 0.690810 | 0.882263 |
11
+ | 2 | 0.336300 | 0.302746 | 0.775583 | 0.702650 | 0.737317 | 0.897062 |
12
+ | 3 | 0.309500 | 0.294454 | 0.817472 | 0.701828 | 0.755249 | 0.905303 |
13
+ | 4 | 0.296700 | 0.281895 | 0.839335 | 0.695757 | 0.760831 | 0.905240 |
14
+ | 5 | 0.281700 | 0.273324 | 0.816995 | 0.752103 | 0.783207 | 0.914322 |
15
+ | 6 | 0.257300 | 0.262116 | 0.813662 | 0.758553 | 0.785142 | 0.915958 |
16
+ | 7 | 0.241200 | 0.255580 | 0.819946 | 0.764308 | 0.791150 | 0.918980 |
17
+ | 8 | 0.229900 | 0.255078 | 0.819697 | 0.771074 | 0.794643 | 0.919821 |
18
+ | 9 | 0.212800 | 0.248312 | 0.830942 | 0.776450 | 0.802772 | 0.922594 |
19
+ | 10 | 0.200900 | 0.245995 | 0.831402 | 0.780244 | 0.805011 | 0.923544 |
20
+
21
+ - Model got shrunk by nearly 60 times and with the same efficiency as distilbert-base-uncased
22
+
23
+ ## Inference
24
+
25
+ ```python
26
+
27
+ from transformers import AutoTokenizer, AutoModel
28
+ from peft import get_peft_config, PeftModel, PeftConfig, get_peft_model, LoraConfig, TaskType
29
+
30
+ peft_model_id = "vishnun/lora-NLIGraph"
31
+ config = PeftConfig.from_pretrained(peft_model_id)
32
+ inference_model = AutoModelForTokenClassification.from_pretrained(
33
+ config.base_model_name_or_path, num_labels=4, id2label=id2lab, label2id=lab2id
34
+ )
35
+ tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
36
+ model = PeftModel.from_pretrained(inference_model, peft_model_id)
37
+
38
+ text = "Arsenal will win the Premier League"
39
+ inputs = tokenizer(text, return_tensors="pt")
40
+
41
+ with torch.no_grad():
42
+ logits = model(**inputs).logits
43
+
44
+ tokens = inputs.tokens()
45
+ predictions = torch.argmax(logits, dim=2)
46
+
47
+ for token, prediction in zip(tokens, predictions[0].numpy()):
48
+ print((token, model.config.id2label[prediction]))
49
+
50
+ ## results : ('<s>', 'O')
51
+ ('Arsenal', 'SRC')
52
+ ('Ġwill', 'O')
53
+ ('Ġwin', 'REL')
54
+ ('Ġthe', 'O')
55
+ ('ĠPremier', 'TGT')
56
+ ('ĠLeague', 'O')
57
+ ('</s>', 'O')
58
+
59
+ ```
60
  ### Framework versions
61
 
62