AdamCodd commited on
Commit
c40ac66
·
1 Parent(s): 8b1a86a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +111 -1
README.md CHANGED
@@ -2,4 +2,114 @@
2
  datasets:
3
  - snli
4
  - multi_nli
5
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  datasets:
3
  - snli
4
  - multi_nli
5
+ metrics:
6
+ - accuracy
7
+ - f1
8
+ - precision
9
+ - recall
10
+ inference: false
11
+ model-index:
12
+ - name: distilroberta-nli
13
+ results:
14
+ - task:
15
+ type: text-classification
16
+ name: Text Classification
17
+ metrics:
18
+ - type: loss
19
+ value: 0.438475
20
+ - type: accuracy
21
+ value: 0.829536
22
+ name: Accuracy
23
+ - type: f1
24
+ value: 0.828703
25
+ name: F1
26
+ - type: precision
27
+ value: 0.828907
28
+ name: Precision
29
+ - type: recall
30
+ value: 0.828617
31
+ name: Recall
32
+ language:
33
+ - en
34
+ ---
35
+ ## DistilRoBERTa-NLI
36
+
37
+ This model utilizes the [Distilroberta base](https://huggingface.co/distilroberta-base) architecture, which has been fine-tuned for NLI tasks on the [MultiNLI](https://huggingface.co/datasets/multi_nli) and [SNLI](https://huggingface.co/datasets/snli) datasets.
38
+
39
+ ## Model description
40
+
41
+ The SNLI corpus (version 1.0) is a collection of 570k human-written English sentence pairs manually labeled for balanced classification with the labels entailment, contradiction, and neutral, supporting the task of natural language inference (NLI), also known as recognizing textual entailment (RTE).
42
+
43
+ The Multi-Genre Natural Language Inference (MultiNLI) corpus is a crowd-sourced collection of 433k sentence pairs annotated with textual entailment information. The corpus is modeled on the SNLI corpus, but differs in that covers a range of genres of spoken and written text, and supports a distinctive cross-genre generalization evaluation.
44
+
45
+ ## Usage
46
+ Inference API has been disabled as it is not suitable for this kind of task.
47
+
48
+ ```python
49
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
50
+ import torch
51
+
52
+ # Load model and tokenizer
53
+ model_checkpoint = 'AdamCodd/Distilroberta-NLI'
54
+ model = AutoModelForSequenceClassification.from_pretrained(model_checkpoint)
55
+ tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
56
+
57
+ # Set device
58
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
59
+ model.to(device)
60
+
61
+ # Sample premise and hypothesis
62
+ premise = "The cat is sleeping under the sun."
63
+ hypothesis = "It's raining, and the cat is getting wet."
64
+
65
+ # Tokenize and predict
66
+ input = tokenizer(premise, hypothesis, truncation=True, padding=True, return_tensors="pt").to(device)
67
+ with torch.no_grad():
68
+ output = model(**input)
69
+ probabilities = torch.softmax(output.logits, dim=-1)[0].tolist()
70
+
71
+ # Output prediction
72
+ label_names = ["Entailment", "Neutral", "Contradiction"]
73
+ prediction = {name: round(prob * 100, 1) for name, prob in zip(label_names, probabilities)}
74
+ print(prediction)
75
+ # {'Entailment': 1.3, 'Neutral': 8.2, 'Contradiction': 90.5}
76
+ ```
77
+
78
+ ## Training and evaluation data
79
+
80
+ More information needed
81
+
82
+ ## Training procedure
83
+
84
+ ### Training hyperparameters
85
+
86
+ The following hyperparameters were used during training:
87
+ - learning_rate: 3e-05
88
+ - train_batch_size: 32
89
+ - eval_batch_size: 32
90
+ - seed: 42
91
+ - optimizer: AdamW with betas=(0.9,0.999) and epsilon=1e-08
92
+ - lr_scheduler_type: linear
93
+ - lr_scheduler_warmup_steps: 150
94
+ - num_epochs: 1
95
+ - weight_decay: 0.01
96
+
97
+ ### Training results
98
+
99
+ Metrics: Accuracy, F1, Precision, Recall
100
+
101
+ ```
102
+ 'eval_loss': 0.438475,
103
+ 'eval_accuracy': 0.829536,
104
+ 'eval_f1': 0.828703,
105
+ 'eval_precision': 0.828907,
106
+ 'eval_recall': 0.828617
107
+ ```
108
+
109
+ ### Framework versions
110
+
111
+ - Transformers 4.36.0
112
+ - Datasets 2.15.0
113
+ - Tokenizers 0.15.0
114
+
115
+ If you want to support me, you can [here](https://ko-fi.com/adamcodd).