Bảo Mai Chí
commited on
Add SetFit model
Browse files- 1_Pooling/config.json +1 -1
- README.md +41 -34
- config.json +16 -16
- model.safetensors +2 -2
- model_head.pkl +2 -2
- modules.json +2 -2
- sentence_bert_config.json +1 -1
- tokenizer.json +0 -0
- tokenizer_config.json +3 -5
- vocab.txt +0 -0
1_Pooling/config.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
{
|
2 |
-
"word_embedding_dimension":
|
3 |
"pooling_mode_cls_token": false,
|
4 |
"pooling_mode_mean_tokens": true,
|
5 |
"pooling_mode_max_tokens": false,
|
|
|
1 |
{
|
2 |
+
"word_embedding_dimension": 384,
|
3 |
"pooling_mode_cls_token": false,
|
4 |
"pooling_mode_mean_tokens": true,
|
5 |
"pooling_mode_max_tokens": false,
|
README.md
CHANGED
@@ -5,14 +5,11 @@ tags:
|
|
5 |
- sentence-transformers
|
6 |
- text-classification
|
7 |
- generated_from_setfit_trainer
|
8 |
-
base_model: sentence-transformers/
|
9 |
metrics:
|
10 |
- accuracy
|
11 |
widget:
|
12 |
-
- text:
|
13 |
-
- text: The p success of karger min cut after k steps
|
14 |
-
- text: Giải thích sự khác biệt giữa mô hình học có giám sát và không giám sát. Cung
|
15 |
-
cấp ví dụ cho từng loại. (ít nhất 150 từ)
|
16 |
- text: 'Which of the following is a Code-Based Test Coverage Metrics(E. F. Miller,
|
17 |
1977 dissertation)?
|
18 |
|
@@ -37,11 +34,21 @@ widget:
|
|
37 |
d.
|
38 |
|
39 |
C2: C0 coverage + loop coverage'
|
40 |
-
- text:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
pipeline_tag: text-classification
|
42 |
inference: true
|
43 |
model-index:
|
44 |
-
- name: SetFit with sentence-transformers/
|
45 |
results:
|
46 |
- task:
|
47 |
type: text-classification
|
@@ -52,13 +59,13 @@ model-index:
|
|
52 |
split: test
|
53 |
metrics:
|
54 |
- type: accuracy
|
55 |
-
value: 0.
|
56 |
name: Accuracy
|
57 |
---
|
58 |
|
59 |
-
# SetFit with sentence-transformers/
|
60 |
|
61 |
-
This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/
|
62 |
|
63 |
The model has been trained using an efficient few-shot learning technique that involves:
|
64 |
|
@@ -69,9 +76,9 @@ The model has been trained using an efficient few-shot learning technique that i
|
|
69 |
|
70 |
### Model Description
|
71 |
- **Model Type:** SetFit
|
72 |
-
- **Sentence Transformer body:** [sentence-transformers/
|
73 |
- **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
|
74 |
-
- **Maximum Sequence Length:**
|
75 |
- **Number of Classes:** 2 classes
|
76 |
<!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
|
77 |
<!-- - **Language:** Unknown -->
|
@@ -84,17 +91,17 @@ The model has been trained using an efficient few-shot learning technique that i
|
|
84 |
- **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
|
85 |
|
86 |
### Model Labels
|
87 |
-
| Label | Examples
|
88 |
-
|
89 |
-
| 0 | <ul><li>'What is the capital of France?'</li><li>'
|
90 |
-
| 1 | <ul><li>'What is White-box testing?\nCâu hỏi 7Trả lời\n\na.\nAll of the other answers.\n\nb.\nA testing technique in which internal structure, design and coding of software are tested.\n\nc.\nIts foundation is to execute every part of the code at least once.\n\nd.\nIn this technique, code is visible to testers.'</li><li>'
|
91 |
|
92 |
## Evaluation
|
93 |
|
94 |
### Metrics
|
95 |
| Label | Accuracy |
|
96 |
|:--------|:---------|
|
97 |
-
| **all** | 0.
|
98 |
|
99 |
## Uses
|
100 |
|
@@ -114,7 +121,7 @@ from setfit import SetFitModel
|
|
114 |
# Download from the 🤗 Hub
|
115 |
model = SetFitModel.from_pretrained("chibao24/model_routing_few_shot")
|
116 |
# Run inference
|
117 |
-
preds = model("
|
118 |
```
|
119 |
|
120 |
<!--
|
@@ -146,7 +153,7 @@ preds = model("What is software testing?")
|
|
146 |
### Training Set Metrics
|
147 |
| Training set | Min | Median | Max |
|
148 |
|:-------------|:----|:--------|:----|
|
149 |
-
| Word count | 3 | 20.
|
150 |
|
151 |
| Label | Training Sample Count |
|
152 |
|:------|:----------------------|
|
@@ -173,21 +180,21 @@ preds = model("What is software testing?")
|
|
173 |
### Training Results
|
174 |
| Epoch | Step | Training Loss | Validation Loss |
|
175 |
|:-------:|:-------:|:-------------:|:---------------:|
|
176 |
-
| 0.0078 | 1 | 0.
|
177 |
-
| 0.3906 | 50 | 0.
|
178 |
-
| 0.7812 | 100 | 0.
|
179 |
-
| **1.0** | **128** | **-** | **0.
|
180 |
-
| 1.1719 | 150 | 0.
|
181 |
-
| 1.5625 | 200 | 0.
|
182 |
-
| 1.9531 | 250 | 0.
|
183 |
-
| 2.0 | 256 | - | 0.
|
184 |
-
| 2.3438 | 300 | 0.
|
185 |
-
| 2.7344 | 350 | 0.
|
186 |
-
| 3.0 | 384 | - | 0.
|
187 |
-
| 3.125 | 400 | 0.
|
188 |
-
| 3.5156 | 450 | 0.
|
189 |
-
| 3.9062 | 500 | 0.
|
190 |
-
| 4.0 | 512 | - | 0.
|
191 |
|
192 |
* The bold row denotes the saved checkpoint.
|
193 |
### Framework Versions
|
|
|
5 |
- sentence-transformers
|
6 |
- text-classification
|
7 |
- generated_from_setfit_trainer
|
8 |
+
base_model: sentence-transformers/all-MiniLM-L6-v2
|
9 |
metrics:
|
10 |
- accuracy
|
11 |
widget:
|
12 |
+
- text: What are the benefits of using cloud storage?
|
|
|
|
|
|
|
13 |
- text: 'Which of the following is a Code-Based Test Coverage Metrics(E. F. Miller,
|
14 |
1977 dissertation)?
|
15 |
|
|
|
34 |
d.
|
35 |
|
36 |
C2: C0 coverage + loop coverage'
|
37 |
+
- text: 'Gọi X là dòng đời (thời gian làm việc tốt) của sản phẩm ổ cứng máy tính (tính
|
38 |
+
theo năm). Một ổ cứng loại
|
39 |
+
|
40 |
+
ABC có xác suất làm việc tốt sau 9 năm là 0.1. Giả sử hàm mật độ xác suất của
|
41 |
+
X là f(x) = a
|
42 |
+
|
43 |
+
(x+1)b cho x ≥ 0
|
44 |
+
|
45 |
+
với a > 0 và b > 1. Hãy Tính a, b?'
|
46 |
+
- text: Thủ đô của nước Pháp là gì?
|
47 |
+
- text: How to prove a problem is NP complete problem
|
48 |
pipeline_tag: text-classification
|
49 |
inference: true
|
50 |
model-index:
|
51 |
+
- name: SetFit with sentence-transformers/all-MiniLM-L6-v2
|
52 |
results:
|
53 |
- task:
|
54 |
type: text-classification
|
|
|
59 |
split: test
|
60 |
metrics:
|
61 |
- type: accuracy
|
62 |
+
value: 0.6666666666666666
|
63 |
name: Accuracy
|
64 |
---
|
65 |
|
66 |
+
# SetFit with sentence-transformers/all-MiniLM-L6-v2
|
67 |
|
68 |
+
This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) as the Sentence Transformer embedding model. A [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance is used for classification.
|
69 |
|
70 |
The model has been trained using an efficient few-shot learning technique that involves:
|
71 |
|
|
|
76 |
|
77 |
### Model Description
|
78 |
- **Model Type:** SetFit
|
79 |
+
- **Sentence Transformer body:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)
|
80 |
- **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
|
81 |
+
- **Maximum Sequence Length:** 256 tokens
|
82 |
- **Number of Classes:** 2 classes
|
83 |
<!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
|
84 |
<!-- - **Language:** Unknown -->
|
|
|
91 |
- **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
|
92 |
|
93 |
### Model Labels
|
94 |
+
| Label | Examples |
|
95 |
+
|:------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
96 |
+
| 0 | <ul><li>'what is microservices'</li><li>'What is the capital of France?'</li><li>'Write a Python function that calculates the factorial of a number.'</li></ul> |
|
97 |
+
| 1 | <ul><li>'Tell me the difference between microservice and service based architecture'</li><li>'What is White-box testing?\nCâu hỏi 7Trả lời\n\na.\nAll of the other answers.\n\nb.\nA testing technique in which internal structure, design and coding of software are tested.\n\nc.\nIts foundation is to execute every part of the code at least once.\n\nd.\nIn this technique, code is visible to testers.'</li><li>'Analyze the time complexity of the merge sort algorithm.'</li></ul> |
|
98 |
|
99 |
## Evaluation
|
100 |
|
101 |
### Metrics
|
102 |
| Label | Accuracy |
|
103 |
|:--------|:---------|
|
104 |
+
| **all** | 0.6667 |
|
105 |
|
106 |
## Uses
|
107 |
|
|
|
121 |
# Download from the 🤗 Hub
|
122 |
model = SetFitModel.from_pretrained("chibao24/model_routing_few_shot")
|
123 |
# Run inference
|
124 |
+
preds = model("Thủ đô của nước Pháp là gì?")
|
125 |
```
|
126 |
|
127 |
<!--
|
|
|
153 |
### Training Set Metrics
|
154 |
| Training set | Min | Median | Max |
|
155 |
|:-------------|:----|:--------|:----|
|
156 |
+
| Word count | 3 | 20.1613 | 115 |
|
157 |
|
158 |
| Label | Training Sample Count |
|
159 |
|:------|:----------------------|
|
|
|
180 |
### Training Results
|
181 |
| Epoch | Step | Training Loss | Validation Loss |
|
182 |
|:-------:|:-------:|:-------------:|:---------------:|
|
183 |
+
| 0.0078 | 1 | 0.5129 | - |
|
184 |
+
| 0.3906 | 50 | 0.2717 | - |
|
185 |
+
| 0.7812 | 100 | 0.0941 | - |
|
186 |
+
| **1.0** | **128** | **-** | **0.1068** |
|
187 |
+
| 1.1719 | 150 | 0.0434 | - |
|
188 |
+
| 1.5625 | 200 | 0.0075 | - |
|
189 |
+
| 1.9531 | 250 | 0.005 | - |
|
190 |
+
| 2.0 | 256 | - | 0.1193 |
|
191 |
+
| 2.3438 | 300 | 0.0088 | - |
|
192 |
+
| 2.7344 | 350 | 0.0027 | - |
|
193 |
+
| 3.0 | 384 | - | 0.1587 |
|
194 |
+
| 3.125 | 400 | 0.0023 | - |
|
195 |
+
| 3.5156 | 450 | 0.0013 | - |
|
196 |
+
| 3.9062 | 500 | 0.0011 | - |
|
197 |
+
| 4.0 | 512 | - | 0.1103 |
|
198 |
|
199 |
* The bold row denotes the saved checkpoint.
|
200 |
### Framework Versions
|
config.json
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
{
|
2 |
"_name_or_path": "checkpoints/step_128",
|
3 |
-
"activation": "gelu",
|
4 |
"architectures": [
|
5 |
-
"
|
6 |
],
|
7 |
-
"
|
8 |
-
"
|
9 |
-
"
|
10 |
-
"
|
|
|
|
|
11 |
"initializer_range": 0.02,
|
|
|
|
|
12 |
"max_position_embeddings": 512,
|
13 |
-
"model_type": "
|
14 |
-
"
|
15 |
-
"
|
16 |
-
"output_hidden_states": true,
|
17 |
-
"output_past": true,
|
18 |
"pad_token_id": 0,
|
19 |
-
"
|
20 |
-
"seq_classif_dropout": 0.2,
|
21 |
-
"sinusoidal_pos_embds": false,
|
22 |
-
"tie_weights_": true,
|
23 |
"torch_dtype": "float32",
|
24 |
"transformers_version": "4.41.2",
|
25 |
-
"
|
|
|
|
|
26 |
}
|
|
|
1 |
{
|
2 |
"_name_or_path": "checkpoints/step_128",
|
|
|
3 |
"architectures": [
|
4 |
+
"BertModel"
|
5 |
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"classifier_dropout": null,
|
8 |
+
"gradient_checkpointing": false,
|
9 |
+
"hidden_act": "gelu",
|
10 |
+
"hidden_dropout_prob": 0.1,
|
11 |
+
"hidden_size": 384,
|
12 |
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 1536,
|
14 |
+
"layer_norm_eps": 1e-12,
|
15 |
"max_position_embeddings": 512,
|
16 |
+
"model_type": "bert",
|
17 |
+
"num_attention_heads": 12,
|
18 |
+
"num_hidden_layers": 6,
|
|
|
|
|
19 |
"pad_token_id": 0,
|
20 |
+
"position_embedding_type": "absolute",
|
|
|
|
|
|
|
21 |
"torch_dtype": "float32",
|
22 |
"transformers_version": "4.41.2",
|
23 |
+
"type_vocab_size": 2,
|
24 |
+
"use_cache": true,
|
25 |
+
"vocab_size": 30522
|
26 |
}
|
model.safetensors
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c468dfd44193ef693a8d09bce5c59d85fc8a9aa41218a2ec86ab04225765fb05
|
3 |
+
size 90864192
|
model_head.pkl
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e40b9d894c95698d7361aabf58fa14f74ab3965a57923f78d7294efa2db4e5a4
|
3 |
+
size 3935
|
modules.json
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
{
|
15 |
"idx": 2,
|
16 |
"name": "2",
|
17 |
-
"path": "
|
18 |
-
"type": "sentence_transformers.models.
|
19 |
}
|
20 |
]
|
|
|
14 |
{
|
15 |
"idx": 2,
|
16 |
"name": "2",
|
17 |
+
"path": "2_Normalize",
|
18 |
+
"type": "sentence_transformers.models.Normalize"
|
19 |
}
|
20 |
]
|
sentence_bert_config.json
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
{
|
2 |
-
"max_seq_length":
|
3 |
"do_lower_case": false
|
4 |
}
|
|
|
1 |
{
|
2 |
+
"max_seq_length": 256,
|
3 |
"do_lower_case": false
|
4 |
}
|
tokenizer.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
CHANGED
@@ -44,12 +44,10 @@
|
|
44 |
"clean_up_tokenization_spaces": true,
|
45 |
"cls_token": "[CLS]",
|
46 |
"do_basic_tokenize": true,
|
47 |
-
"do_lower_case":
|
48 |
-
"full_tokenizer_file": null,
|
49 |
"mask_token": "[MASK]",
|
50 |
-
"max_len": 512,
|
51 |
"max_length": 128,
|
52 |
-
"model_max_length":
|
53 |
"never_split": null,
|
54 |
"pad_to_multiple_of": null,
|
55 |
"pad_token": "[PAD]",
|
@@ -59,7 +57,7 @@
|
|
59 |
"stride": 0,
|
60 |
"strip_accents": null,
|
61 |
"tokenize_chinese_chars": true,
|
62 |
-
"tokenizer_class": "
|
63 |
"truncation_side": "right",
|
64 |
"truncation_strategy": "longest_first",
|
65 |
"unk_token": "[UNK]"
|
|
|
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 |
"max_length": 128,
|
50 |
+
"model_max_length": 256,
|
51 |
"never_split": null,
|
52 |
"pad_to_multiple_of": null,
|
53 |
"pad_token": "[PAD]",
|
|
|
57 |
"stride": 0,
|
58 |
"strip_accents": null,
|
59 |
"tokenize_chinese_chars": true,
|
60 |
+
"tokenizer_class": "BertTokenizer",
|
61 |
"truncation_side": "right",
|
62 |
"truncation_strategy": "longest_first",
|
63 |
"unk_token": "[UNK]"
|
vocab.txt
CHANGED
The diff for this file is too large to render.
See raw diff
|
|