pangpang666
commited on
Commit
•
af21b1e
1
Parent(s):
c611a53
Update README.md
Browse files
README.md
CHANGED
@@ -1,170 +1,52 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
##
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
# Training Details
|
49 |
-
|
50 |
-
## Training Data
|
51 |
-
|
52 |
-
More information needed
|
53 |
-
|
54 |
-
## Training Procedure
|
55 |
-
|
56 |
-
|
57 |
-
### Preprocessing
|
58 |
-
|
59 |
-
More information needed
|
60 |
-
|
61 |
-
### Speeds, Sizes, Times
|
62 |
-
|
63 |
-
More information needed
|
64 |
-
|
65 |
-
# Evaluation
|
66 |
-
|
67 |
-
|
68 |
-
## Testing Data, Factors & Metrics
|
69 |
-
|
70 |
-
### Testing Data
|
71 |
-
|
72 |
-
More information needed
|
73 |
-
|
74 |
-
### Factors
|
75 |
-
|
76 |
-
|
77 |
-
### Metrics
|
78 |
-
|
79 |
-
More information needed
|
80 |
-
## Results
|
81 |
-
|
82 |
-
More information needed
|
83 |
-
|
84 |
-
# Model Examination
|
85 |
-
|
86 |
-
More information needed
|
87 |
-
|
88 |
-
# Environmental Impact
|
89 |
-
|
90 |
-
|
91 |
-
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).
|
92 |
-
|
93 |
-
- **Hardware Type:** More information needed
|
94 |
-
- **Hours used:** More information needed
|
95 |
-
- **Cloud Provider:** More information needed
|
96 |
-
- **Compute Region:** More information needed
|
97 |
-
- **Carbon Emitted:** More information needed
|
98 |
-
|
99 |
-
# Technical Specifications [optional]
|
100 |
-
|
101 |
-
## Model Architecture and Objective
|
102 |
-
|
103 |
-
More information needed
|
104 |
-
|
105 |
-
## Compute Infrastructure
|
106 |
-
|
107 |
-
More information needed
|
108 |
-
|
109 |
-
### Hardware
|
110 |
-
|
111 |
-
More information needed
|
112 |
-
|
113 |
-
### Software
|
114 |
-
More information needed
|
115 |
-
|
116 |
-
# Citation
|
117 |
-
|
118 |
-
|
119 |
-
**BibTeX:**
|
120 |
-
```
|
121 |
@misc{susstmobilebert,
|
122 |
author = {Su, Yixuan},
|
123 |
title = {A MobileBERT Fine-tuned on SST},
|
124 |
howpublished = {\url{https://huggingface.co/cambridgeltl/sst_mobilebert-uncased}},
|
125 |
-
year =
|
126 |
}
|
127 |
-
|
128 |
-
@misc{https://doi.org/10.48550/arxiv.2004.02984,
|
129 |
-
doi = {10.48550/ARXIV.2004.02984},
|
130 |
-
url = {https://arxiv.org/abs/2004.02984},
|
131 |
-
author = {Sun, Zhiqing and Yu, Hongkun and Song, Xiaodan and Liu, Renjie and Yang, Yiming and Zhou, Denny},
|
132 |
-
keywords = {Computation and Language (cs.CL), Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},
|
133 |
-
title = {MobileBERT: a Compact Task-Agnostic BERT for Resource-Limited Devices},
|
134 |
-
publisher = {arXiv},
|
135 |
-
year = {2020}}
|
136 |
-
```
|
137 |
-
|
138 |
-
|
139 |
-
# Glossary [optional]
|
140 |
-
More information needed
|
141 |
-
|
142 |
-
# More Information [optional]
|
143 |
-
|
144 |
-
More information needed
|
145 |
-
|
146 |
-
# Model Card Authors [optional]
|
147 |
-
|
148 |
-
|
149 |
-
Language Technology Lab @University of Cambridge in collaboration with Ezi Ozoani and the Hugging Face team
|
150 |
-
|
151 |
-
# Model Card Contact
|
152 |
-
|
153 |
-
More information needed
|
154 |
-
|
155 |
-
# How to Get Started with the Model
|
156 |
-
|
157 |
-
Use the code below to get started with the model.
|
158 |
-
|
159 |
-
<details>
|
160 |
-
<summary> Click to expand </summary>
|
161 |
-
|
162 |
-
```python
|
163 |
-
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
164 |
-
|
165 |
-
tokenizer = AutoTokenizer.from_pretrained("cambridgeltl/sst_mobilebert-uncased")
|
166 |
-
|
167 |
-
model = AutoModelForSequenceClassification.from_pretrained("cambridgeltl/sst_mobilebert-uncased")
|
168 |
-
|
169 |
-
```
|
170 |
-
</details>
|
|
|
1 |
+
This model provides a MobileBERT [(Sun et al., 2020)](https://arxiv.org/abs/2004.02984) fine-tuned on the SST data with three sentiments (0 -- negative, 1 -- neutral, and 2 -- positive).
|
2 |
+
|
3 |
+
## Example Usage
|
4 |
+
|
5 |
+
Below, we provide illustrations on how to use this model to make sentiment predictions.
|
6 |
+
|
7 |
+
|
8 |
+
```python
|
9 |
+
import torch
|
10 |
+
from transformers import AutoTokenizer, AutoConfig, MobileBertForSequenceClassification
|
11 |
+
# load model
|
12 |
+
model_name = r'cambridgeltl/sst_mobilebert-uncased'
|
13 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
14 |
+
config = AutoConfig.from_pretrained(model_name)
|
15 |
+
model = MobileBertForSequenceClassification.from_pretrained(model_name, config=config)
|
16 |
+
model.eval()
|
17 |
+
'''
|
18 |
+
labels:
|
19 |
+
0 -- negative
|
20 |
+
1 -- neutral
|
21 |
+
2 -- positive
|
22 |
+
'''
|
23 |
+
|
24 |
+
# prepare exemplar sentences
|
25 |
+
batch_sentences = [
|
26 |
+
"in his first stab at the form , jacquot takes a slightly anarchic approach that works only sporadically .",
|
27 |
+
"a valueless kiddie paean to pro basketball underwritten by the nba .",
|
28 |
+
"a very well-made , funny and entertaining picture .",
|
29 |
+
]
|
30 |
+
|
31 |
+
# prepare input
|
32 |
+
inputs = tokenizer(batch_sentences, max_length=256, truncation=True, padding=True, return_tensors='pt')
|
33 |
+
input_ids, attention_mask = inputs.input_ids, inputs.attention_mask
|
34 |
+
|
35 |
+
# make predictions
|
36 |
+
outputs = model(input_ids=input_ids, attention_mask=attention_mask)
|
37 |
+
predictions = torch.argmax(outputs.logits, dim = -1)
|
38 |
+
print (predictions)
|
39 |
+
# tensor([1, 0, 2])
|
40 |
+
```
|
41 |
+
|
42 |
+
## Citation:
|
43 |
+
If you find this model useful, please kindly cite our model as
|
44 |
+
|
45 |
+
```bibtex
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
@misc{susstmobilebert,
|
47 |
author = {Su, Yixuan},
|
48 |
title = {A MobileBERT Fine-tuned on SST},
|
49 |
howpublished = {\url{https://huggingface.co/cambridgeltl/sst_mobilebert-uncased}},
|
50 |
+
year = 2022
|
51 |
}
|
52 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|