Commit
•
06f5efb
1
Parent(s):
8f523c5
update constructor
Browse files- README.md +6 -307
- config.json +4 -2
- model.safetensors +1 -1
README.md
CHANGED
@@ -1,310 +1,9 @@
|
|
1 |
---
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
tags: []
|
6 |
-
base_model: BAAI/bge-m3
|
7 |
-
datasets: philipp-zettl/GGU-xx
|
8 |
-
metrics:
|
9 |
-
- accuracy
|
10 |
-
- f1
|
11 |
-
- recall
|
12 |
-
model_name: GGU-CLF
|
13 |
-
pipeline_tag: text-classification
|
14 |
-
widget:
|
15 |
-
- name: test1
|
16 |
-
text: hello world
|
17 |
---
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
## Model Details
|
26 |
-
|
27 |
-
### Model Description
|
28 |
-
|
29 |
-
<!-- Provide a longer summary of what this model is. -->
|
30 |
-
|
31 |
-
|
32 |
-
This is a simple classification model trained on a custom dataset.
|
33 |
-
It is used to classify user text into the following classes:
|
34 |
-
- 0: Greeting
|
35 |
-
- 1: Gratitude
|
36 |
-
- 2: Unknown
|
37 |
-
|
38 |
-
**Note**: To use this model please remember the following things
|
39 |
-
1. The model is based on BAAI/bge-m3; You need to obtain the weights of this model before you can use the classifier
|
40 |
-
2. To load the model weights you need to pass the base model and tokenizer to the classifiers constructor
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
- **Developed by:** [philipp-zettl](https://huggingface.co/philipp-zettl/)
|
46 |
-
- **Funded by [optional]:** [More Information Needed]
|
47 |
-
- **Shared by [optional]:** [More Information Needed]
|
48 |
-
- **Model type:** [More Information Needed]
|
49 |
-
- **Language(s) (NLP):** multilingual
|
50 |
-
- **License:** mit
|
51 |
-
- **Finetuned from model [optional]:** BAAI/bge-m3
|
52 |
-
|
53 |
-
### Model Sources [optional]
|
54 |
-
|
55 |
-
<!-- Provide the basic links for the model. -->
|
56 |
-
|
57 |
-
- **Repository:** [philipp-zettl/GGU-CLF](https://huggingface.co/philipp-zettl/GGU-CLF)
|
58 |
-
- **Paper [optional]:** [More Information Needed]
|
59 |
-
- **Demo [optional]:** [More Information Needed]
|
60 |
-
|
61 |
-
## Uses
|
62 |
-
|
63 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
64 |
-
|
65 |
-
### Direct Use
|
66 |
-
|
67 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
68 |
-
|
69 |
-
Use this model to classify messages from natural language chats.
|
70 |
-
|
71 |
-
### Downstream Use [optional]
|
72 |
-
|
73 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
74 |
-
|
75 |
-
[More Information Needed]
|
76 |
-
|
77 |
-
### Out-of-Scope Use
|
78 |
-
|
79 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
80 |
-
|
81 |
-
|
82 |
-
The model was not trained on multi-sentence samples. **You should avoid those.**
|
83 |
-
|
84 |
-
Oficially tested and supported languages are **english and german** any other language is considered out of scope.
|
85 |
-
|
86 |
-
|
87 |
-
## Bias, Risks, and Limitations
|
88 |
-
|
89 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
90 |
-
|
91 |
-
[More Information Needed]
|
92 |
-
|
93 |
-
### Recommendations
|
94 |
-
|
95 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
96 |
-
|
97 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
98 |
-
|
99 |
-
## How to Get Started with the Model
|
100 |
-
|
101 |
-
Use the code below to get started with the model.
|
102 |
-
|
103 |
-
|
104 |
-
```python
|
105 |
-
from transformers import AutoModel, AutoTokenizer
|
106 |
-
|
107 |
-
base = AutoModel.from_pretrained('BAAI/bge-m3')
|
108 |
-
tokenizer = AutoTokenizer.from_pretrained('BAAI/bge-m3')
|
109 |
-
|
110 |
-
model = EmbClf.from_pretrained("philipp-zettl/GGU-xx", base_model=base.to(torch.float16), tokenizer=tokenizer).to('cuda').to(torch.float16)
|
111 |
-
|
112 |
-
model([
|
113 |
-
'Hi was geht?',
|
114 |
-
'Greetings, friendo!',
|
115 |
-
'I highly appreciate this gesture.',
|
116 |
-
'Merci beaucoup, nous espérons que tout se passera bien'
|
117 |
-
]).argmax(dim=1)
|
118 |
-
```
|
119 |
-
|
120 |
-
|
121 |
-
## Training Details
|
122 |
-
|
123 |
-
### Training Data
|
124 |
-
|
125 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
126 |
-
|
127 |
-
|
128 |
-
This model was trained using the [philipp-zettl/GGU-xx](https://huggingface.co/dataset/philipp-zettl/GGU-xx) dataset.
|
129 |
-
|
130 |
-
You can find it's performance metrics under [Evaluation Results](#evaluation-results).
|
131 |
-
|
132 |
-
|
133 |
-
### Training Procedure
|
134 |
-
|
135 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
136 |
-
|
137 |
-
#### Preprocessing [optional]
|
138 |
-
|
139 |
-
|
140 |
-
The following code was used to create the data set as well as split the data set into training and validation sets.
|
141 |
-
|
142 |
-
```python
|
143 |
-
from datasets import load_dataset
|
144 |
-
|
145 |
-
class Dataset:
|
146 |
-
def __init__(self, dataset, target_names=None):
|
147 |
-
self.data = list(map(lambda x: x[0], dataset))
|
148 |
-
self.target = list(map(lambda x: x[1], dataset))
|
149 |
-
self.target_names = target_names
|
150 |
-
|
151 |
-
|
152 |
-
ds = load_dataset('philipp-zettl/GGU-xx')
|
153 |
-
data = Dataset([[e['sample'], e['label']] for e in ds['train']], ['greeting', 'gratitude', 'unknown'])
|
154 |
-
X_train, X_test, y_train, y_test = train_test_split(data.data, data.target, test_size=0.2, random_state=42)
|
155 |
-
```
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
#### Training Hyperparameters
|
160 |
-
|
161 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
162 |
-
|
163 |
-
#### Speeds, Sizes, Times [optional]
|
164 |
-
|
165 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
166 |
-
|
167 |
-
[More Information Needed]
|
168 |
-
|
169 |
-
## Evaluation
|
170 |
-
|
171 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
172 |
-
|
173 |
-
### Testing Data, Factors & Metrics
|
174 |
-
|
175 |
-
#### Testing Data
|
176 |
-
|
177 |
-
<!-- This should link to a Dataset Card if possible. -->
|
178 |
-
|
179 |
-
[More Information Needed]
|
180 |
-
|
181 |
-
#### Factors
|
182 |
-
|
183 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
184 |
-
|
185 |
-
[More Information Needed]
|
186 |
-
|
187 |
-
#### Metrics
|
188 |
-
|
189 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
### Results
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
#### Summary
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
## Model Examination [optional]
|
202 |
-
|
203 |
-
<!-- Relevant interpretability work for the model goes here -->
|
204 |
-
|
205 |
-
|
206 |
-
You can find the initial implementation of the classification model here:
|
207 |
-
|
208 |
-
```python
|
209 |
-
from huggingface_hub import PyTorchModelHubMixin
|
210 |
-
import torch
|
211 |
-
import torch.nn as nn
|
212 |
-
|
213 |
-
class EmbClf(nn.Module, PyTorchModelHubMixin):
|
214 |
-
def __init__(self, base_model, tokenizer, num_classes, dropout=0.0, l2_reg=0.01, device=None):
|
215 |
-
super().__init__()
|
216 |
-
|
217 |
-
self.tokenizer = tokenizer
|
218 |
-
self.base = base_model
|
219 |
-
self.fc = nn.Linear(base.config.hidden_size, num_classes)
|
220 |
-
self.do = nn.Dropout(dropout)
|
221 |
-
self.device = device
|
222 |
-
self.l2_reg = l2_reg
|
223 |
-
|
224 |
-
def forward(self, X):
|
225 |
-
encoding = self.tokenizer(X, return_tensors='pt', padding=True, truncation=True).to(self.device)
|
226 |
-
input_ids = encoding['input_ids']
|
227 |
-
attention_mask = encoding['attention_mask']
|
228 |
-
emb = self.base(
|
229 |
-
input_ids,
|
230 |
-
attention_mask=attention_mask,
|
231 |
-
return_dict=True,
|
232 |
-
output_hidden_states=True
|
233 |
-
).last_hidden_state[:, 0, :]
|
234 |
-
return self.fc(self.do(emb))
|
235 |
-
|
236 |
-
def train(self, set_val=True):
|
237 |
-
self.base.train(False)
|
238 |
-
for param in self.base.parameters():
|
239 |
-
param.requires_grad = False
|
240 |
-
for param in self.fc.parameters():
|
241 |
-
param.requires_grad = set_val
|
242 |
-
|
243 |
-
def get_l2_loss(self):
|
244 |
-
l2_loss = torch.tensor(0.).to('cuda')
|
245 |
-
for param in self.parameters():
|
246 |
-
if param.requires_grad:
|
247 |
-
l2_loss += torch.norm(param, 2)
|
248 |
-
return self.l2_reg * l2_loss
|
249 |
-
```
|
250 |
-
|
251 |
-
|
252 |
-
## Environmental Impact
|
253 |
-
|
254 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
255 |
-
|
256 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
257 |
-
|
258 |
-
- **Hardware Type:** [More Information Needed]
|
259 |
-
- **Hours used:** [More Information Needed]
|
260 |
-
- **Cloud Provider:** [More Information Needed]
|
261 |
-
- **Compute Region:** [More Information Needed]
|
262 |
-
- **Carbon Emitted:** [More Information Needed]
|
263 |
-
|
264 |
-
## Technical Specifications [optional]
|
265 |
-
|
266 |
-
### Model Architecture and Objective
|
267 |
-
|
268 |
-
[More Information Needed]
|
269 |
-
|
270 |
-
### Compute Infrastructure
|
271 |
-
|
272 |
-
[More Information Needed]
|
273 |
-
|
274 |
-
#### Hardware
|
275 |
-
|
276 |
-
[More Information Needed]
|
277 |
-
|
278 |
-
#### Software
|
279 |
-
|
280 |
-
[More Information Needed]
|
281 |
-
|
282 |
-
## Citation [optional]
|
283 |
-
|
284 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
285 |
-
|
286 |
-
**BibTeX:**
|
287 |
-
|
288 |
-
[More Information Needed]
|
289 |
-
|
290 |
-
**APA:**
|
291 |
-
|
292 |
-
[More Information Needed]
|
293 |
-
|
294 |
-
## Glossary [optional]
|
295 |
-
|
296 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
297 |
-
|
298 |
-
[More Information Needed]
|
299 |
-
|
300 |
-
## More Information [optional]
|
301 |
-
|
302 |
-
[More Information Needed]
|
303 |
-
|
304 |
-
## Model Card Authors [optional]
|
305 |
-
|
306 |
-
[More Information Needed]
|
307 |
-
|
308 |
-
## Model Card Contact
|
309 |
-
|
310 |
-
[More Information Needed]
|
|
|
1 |
---
|
2 |
+
tags:
|
3 |
+
- pytorch_model_hub_mixin
|
4 |
+
- model_hub_mixin
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
---
|
6 |
|
7 |
+
This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration:
|
8 |
+
- Library: [More Information Needed]
|
9 |
+
- Docs: [More Information Needed]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
3 |
-
"dropout": 0.
|
4 |
"l2_reg": 0.25,
|
5 |
-
"num_classes": 3
|
|
|
6 |
}
|
|
|
1 |
{
|
2 |
+
"base_model": null,
|
3 |
"device": "cuda",
|
4 |
+
"dropout": 0.25,
|
5 |
"l2_reg": 0.25,
|
6 |
+
"num_classes": 3,
|
7 |
+
"tokenizer": null
|
8 |
}
|
model.safetensors
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 1135562582
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a4dd2198b8802c39c9fc97bb04b9b83542c3d5163238047cfb39a727d6eee5a3
|
3 |
size 1135562582
|