Migrate model card from transformers-repo
Browse filesRead announcement at https://discuss.huggingface.co/t/announcement-all-model-cards-will-be-migrated-to-hf-co-model-repos/2755
Original file history: https://github.com/huggingface/transformers/commits/master/model_cards/mrm8488/t5-base-finetuned-imdb-sentiment/README.md
README.md
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: en
|
3 |
+
datasets:
|
4 |
+
- imdb
|
5 |
+
---
|
6 |
+
|
7 |
+
# T5-base fine-tuned for Sentiment Anlalysis 🎞️👍👎
|
8 |
+
|
9 |
+
|
10 |
+
[Google's T5](https://ai.googleblog.com/2020/02/exploring-transfer-learning-with-t5.html) base fine-tuned on [IMDB](https://huggingface.co/datasets/imdb) dataset for **Sentiment Analysis** downstream task.
|
11 |
+
|
12 |
+
## Details of T5
|
13 |
+
|
14 |
+
The **T5** model was presented in [Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer](https://arxiv.org/pdf/1910.10683.pdf) by *Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J. Liu* in Here the abstract:
|
15 |
+
|
16 |
+
Transfer learning, where a model is first pre-trained on a data-rich task before being fine-tuned on a downstream task, has emerged as a powerful technique in natural language processing (NLP). The effectiveness of transfer learning has given rise to a diversity of approaches, methodology, and practice. In this paper, we explore the landscape of transfer learning techniques for NLP by introducing a unified framework that converts every language problem into a text-to-text format. Our systematic study compares pre-training objectives, architectures, unlabeled datasets, transfer approaches, and other factors on dozens of language understanding tasks. By combining the insights from our exploration with scale and our new “Colossal Clean Crawled Corpus”, we achieve state-of-the-art results on many benchmarks covering summarization, question answering, text classification, and more. To facilitate future work on transfer learning for NLP, we release our dataset, pre-trained models, and code.
|
17 |
+
|
18 |
+
![model image](https://camo.githubusercontent.com/623b4dea0b653f2ad3f36c71ebfe749a677ac0a1/68747470733a2f2f6d69726f2e6d656469756d2e636f6d2f6d61782f343030362f312a44304a31674e51663876727255704b657944387750412e706e67)
|
19 |
+
|
20 |
+
## Details of the downstream task (Sentiment analysis) - Dataset 📚
|
21 |
+
|
22 |
+
[IMDB](https://huggingface.co/datasets/imdb)
|
23 |
+
|
24 |
+
This is a dataset for binary sentiment classification containing substantially more data than previous benchmark datasets. We provide a set of **25,000** highly polar movie reviews for training, and **25,000** for testing.
|
25 |
+
|
26 |
+
## Model fine-tuning 🏋️
|
27 |
+
|
28 |
+
The training script is a slightly modified version of [this Colab Notebook](https://github.com/patil-suraj/exploring-T5/blob/master/t5_fine_tuning.ipynb) created by [Suraj Patil](https://github.com/patil-suraj), so all credits to him!
|
29 |
+
|
30 |
+
## Test set metrics 🧾
|
31 |
+
|
32 |
+
|precision | recall | f1-score |support|
|
33 |
+
|----------|----------|---------|----------|-------|
|
34 |
+
|negative | 0.95 | 0.95| 0.95| 12500|
|
35 |
+
|positive | 0.95 | 0.95| 0.95| 12500|
|
36 |
+
|----------|----------|---------|----------|-------|
|
37 |
+
|accuracy| | | 0.95| 25000|
|
38 |
+
|macro avg| 0.95| 0.95| 0.95| 25000|
|
39 |
+
|weighted avg| 0.95| 0.95| 0.95 | 25000|
|
40 |
+
|
41 |
+
|
42 |
+
## Model in Action 🚀
|
43 |
+
|
44 |
+
```python
|
45 |
+
from transformers import AutoTokenizer, AutoModelWithLMHead
|
46 |
+
|
47 |
+
tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-imdb-sentiment")
|
48 |
+
|
49 |
+
model = AutoModelWithLMHead.from_pretrained("mrm8488/t5-base-finetuned-imdb-sentiment")
|
50 |
+
|
51 |
+
def get_sentiment(text):
|
52 |
+
input_ids = tokenizer.encode(text + '</s>', return_tensors='pt')
|
53 |
+
|
54 |
+
output = model.generate(input_ids=input_ids,
|
55 |
+
max_length=2)
|
56 |
+
|
57 |
+
dec = [tokenizer.decode(ids) for ids in output]
|
58 |
+
label = dec[0]
|
59 |
+
return label
|
60 |
+
|
61 |
+
get_sentiment("I dislike a lot that film")
|
62 |
+
|
63 |
+
# Output: 'negative'
|
64 |
+
```
|
65 |
+
|
66 |
+
> Created by [Manuel Romero/@mrm8488](https://twitter.com/mrm8488) | [LinkedIn](https://www.linkedin.com/in/manuel-romero-cs/)
|
67 |
+
|
68 |
+
> Made with <span style="color: #e25555;">♥</span> in Spain
|