agentlans commited on
Commit
2b18686
·
verified ·
1 Parent(s): e8e04d9

Upload 8 files

Browse files
README.md CHANGED
@@ -1,3 +1,129 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: mit
4
+ tags:
5
+ - natural-language-inference
6
+ - sentence-transformers
7
+ - transformers
8
+ - nlp
9
+ - model-card
10
+ ---
11
+
12
+ # NoInstruct-small-Embedding-v0-nli
13
+
14
+ - **Base Model:** [avsolatorio/NoInstruct-small-Embedding-v0](https://huggingface.co/avsolatorio/NoInstruct-small-Embedding-v0)
15
+ - **Task:** Natural Language Inference (NLI)
16
+ - **Framework:** Hugging Face Transformers, Sentence Transformers
17
+
18
+ NoInstruct-small-Embedding-v0-nli is a fine-tuned NLI model that classifies the relationship between pairs of sentences into three categories: entailment, neutral, and contradiction. It enhances the capabilities of [avsolatorio/NoInstruct-small-Embedding-v0](https://huggingface.co/avsolatorio/NoInstruct-small-Embedding-v0) for improved performance on NLI tasks.
19
+
20
+ ## Intended Use
21
+ NoInstruct-small-Embedding-v0-nli is ideal for applications requiring understanding of logical relationships between sentences, including:
22
+
23
+ - Semantic textual similarity
24
+ - Question answering
25
+ - Dialogue systems
26
+ - Content moderation
27
+
28
+ ## Performance
29
+ NoInstruct-small-Embedding-v0-nli was trained on the [sentence-transformers/all-nli](https://huggingface.co/datasets/sentence-transformers/all-nli) dataset, achieving competitive results in sentence pair classification.
30
+
31
+ Performance on the MNLI matched validation set:
32
+ - Accuracy: 0.7687
33
+ - Precision: 0.77
34
+ - Recall: 0.77
35
+ - F1-score: 0.77
36
+
37
+ ## Training details
38
+
39
+ <details>
40
+ <summary><strong>Training Details</strong></summary>
41
+
42
+ - **Dataset:**
43
+ - Used [sentence-transformers/all-nli](https://huggingface.co/datasets/sentence-transformers/all-nli).
44
+
45
+ - **Sampling:**
46
+ - 100 000 training samples and 10 000 evaluation samples.
47
+
48
+ - **Fine-tuning Process:**
49
+ - Custom Python script with adaptive precision training (bfloat16).
50
+ - Early stopping based on evaluation loss.
51
+
52
+ - **Hyperparameters:**
53
+ - **Learning Rate:** 2e-5
54
+ - **Batch Size:** 64
55
+ - **Optimizer:** AdamW (weight decay: 0.01)
56
+ - **Training Duration:** Up to 10 epochs
57
+
58
+ </details>
59
+
60
+ <details>
61
+ <summary><strong>Reproducibility</strong></summary>
62
+
63
+ To ensure reproducibility:
64
+ - Fixed random seed: 42
65
+ - Environment:
66
+ - Python: 3.10.12
67
+ - PyTorch: 2.5.1
68
+ - Transformers: 4.44.2
69
+
70
+ </details>
71
+
72
+ ## Usage Instructions
73
+
74
+ ## Using Sentence Transformers
75
+ ```python
76
+ from sentence_transformers import CrossEncoder
77
+
78
+ model_name = "agentlans/NoInstruct-small-Embedding-v0-nli"
79
+ model = CrossEncoder(model_name)
80
+ scores = model.predict(
81
+ [
82
+ ("A man is eating pizza", "A man eats something"),
83
+ (
84
+ "A black race car starts up in front of a crowd of people.",
85
+ "A man is driving down a lonely road.",
86
+ ),
87
+ ]
88
+ )
89
+
90
+ label_mapping = ["entailment", "neutral", "contradiction"]
91
+ labels = [label_mapping[score_max] for score_max in scores.argmax(axis=1)]
92
+ print(labels)
93
+ ```
94
+
95
+ ## Using Transformers Library
96
+ ```python
97
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
98
+ import torch
99
+
100
+ model_name = "agentlans/NoInstruct-small-Embedding-v0-nli"
101
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
102
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
103
+
104
+ features = tokenizer(
105
+ [
106
+ "A man is eating pizza",
107
+ "A black race car starts up in front of a crowd of people.",
108
+ ],
109
+ ["A man eats something", "A man is driving down a lonely road."],
110
+ padding=True,
111
+ truncation=True,
112
+ return_tensors="pt",
113
+ )
114
+
115
+ model.eval()
116
+ with torch.no_grad():
117
+ scores = model(**features).logits
118
+ label_mapping = ["entailment", "neutral", "contradiction"]
119
+ labels = [label_mapping[score_max] for score_max in scores.argmax(dim=1)]
120
+ print(labels)
121
+ ```
122
+
123
+ ## Limitations and Ethical Considerations
124
+ NoInstruct-small-Embedding-v0-nli may reflect biases present in the training data. Users should evaluate its performance in specific contexts to ensure fairness and accuracy.
125
+
126
+ ## Conclusion
127
+ NoInstruct-small-Embedding-v0-nli offers a robust solution for NLI tasks, enhancing [avsolatorio/NoInstruct-small-Embedding-v0](https://huggingface.co/avsolatorio/NoInstruct-small-Embedding-v0)'s capabilities with straightforward integration into existing frameworks. It aids developers in building intelligent applications that require nuanced language understanding.
128
+
129
+
config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "avsolatorio/NoInstruct-small-Embedding-v0",
3
+ "architectures": [
4
+ "BertForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 384,
11
+ "id2label": {
12
+ "0": "LABEL_0",
13
+ "1": "LABEL_1",
14
+ "2": "LABEL_2"
15
+ },
16
+ "initializer_range": 0.02,
17
+ "intermediate_size": 1536,
18
+ "label2id": {
19
+ "LABEL_0": 0,
20
+ "LABEL_1": 1,
21
+ "LABEL_2": 2
22
+ },
23
+ "layer_norm_eps": 1e-12,
24
+ "max_position_embeddings": 512,
25
+ "model_type": "bert",
26
+ "num_attention_heads": 12,
27
+ "num_hidden_layers": 12,
28
+ "output_hidden_states": true,
29
+ "pad_token_id": 0,
30
+ "position_embedding_type": "absolute",
31
+ "problem_type": "single_label_classification",
32
+ "torch_dtype": "float32",
33
+ "transformers_version": "4.44.2",
34
+ "type_vocab_size": 2,
35
+ "use_cache": true,
36
+ "vocab_size": 30522
37
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82774c4e12aadcf05aae9037e19d21dc00b1e27493c08696b5600170051cc37d
3
+ size 133467916
special_tokens_map.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "never_split": null,
51
+ "pad_token": "[PAD]",
52
+ "sep_token": "[SEP]",
53
+ "strip_accents": null,
54
+ "tokenize_chinese_chars": true,
55
+ "tokenizer_class": "BertTokenizer",
56
+ "unk_token": "[UNK]"
57
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0dd3a70001121e0260fa0d5930c4b6964393c8348ec5d8596611fc5bc98cf97
3
+ size 5240
vocab.txt ADDED
The diff for this file is too large to render. See raw diff