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/electra-base-finetuned-squadv1/README.md
README.md
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: en
|
3 |
+
---
|
4 |
+
|
5 |
+
# Electra base ⚡ + SQuAD v1 ❓
|
6 |
+
|
7 |
+
[Electra-base-discriminator](https://huggingface.co/google/electra-base-discriminator) fine-tuned on [SQUAD v1.1 dataset](https://rajpurkar.github.io/SQuAD-explorer/explore/1.1/dev/) for **Q&A** downstream task.
|
8 |
+
|
9 |
+
## Details of the downstream task (Q&A) - Model 🧠
|
10 |
+
|
11 |
+
**ELECTRA** is a new method for self-supervised language representation learning. It can be used to pre-train transformer networks using relatively little compute. ELECTRA models are trained to distinguish "real" input tokens vs "fake" input tokens generated by another neural network, similar to the discriminator of a [GAN](https://arxiv.org/pdf/1406.2661.pdf). At small scale, ELECTRA achieves strong results even when trained on a single GPU. At large scale, ELECTRA achieves state-of-the-art results on the [SQuAD 2.0](https://rajpurkar.github.io/SQuAD-explorer/) dataset.
|
12 |
+
|
13 |
+
|
14 |
+
## Details of the downstream task (Q&A) - Dataset 📚
|
15 |
+
|
16 |
+
**S**tanford **Q**uestion **A**nswering **D**ataset (SQuAD) is a reading comprehension dataset, consisting of questions posed by crowdworkers on a set of Wikipedia articles, where the answer to every question is a segment of text, or span, from the corresponding reading passage, or the question might be unanswerable.
|
17 |
+
SQuAD v1.1 contains **100,000+** question-answer pairs on **500+** articles.
|
18 |
+
|
19 |
+
## Model training 🏋️
|
20 |
+
|
21 |
+
The model was trained on a Tesla P100 GPU and 25GB of RAM with the following command:
|
22 |
+
|
23 |
+
```bash
|
24 |
+
python transformers/examples/question-answering/run_squad.py \
|
25 |
+
--model_type electra \
|
26 |
+
--model_name_or_path 'google/electra-base-discriminator' \
|
27 |
+
--do_eval \
|
28 |
+
--do_train \
|
29 |
+
--do_lower_case \
|
30 |
+
--train_file '/content/dataset/train-v1.1.json' \
|
31 |
+
--predict_file '/content/dataset/dev-v1.1.json' \
|
32 |
+
--per_gpu_train_batch_size 16 \
|
33 |
+
--learning_rate 3e-5 \
|
34 |
+
--num_train_epochs 10 \
|
35 |
+
--max_seq_length 384 \
|
36 |
+
--doc_stride 128 \
|
37 |
+
--output_dir '/content/output' \
|
38 |
+
--overwrite_output_dir \
|
39 |
+
--save_steps 1000
|
40 |
+
```
|
41 |
+
|
42 |
+
## Test set Results 🧾
|
43 |
+
|
44 |
+
| Metric | # Value |
|
45 |
+
| ------ | --------- |
|
46 |
+
| **EM** | **83.03** |
|
47 |
+
| **F1** | **90.77** |
|
48 |
+
| **Size**| **+ 400 MB** |
|
49 |
+
|
50 |
+
Very good metrics for such a "small" model!
|
51 |
+
|
52 |
+
```json
|
53 |
+
{
|
54 |
+
'exact': 83.03689687795648,
|
55 |
+
'f1': 90.77486052446231,
|
56 |
+
'total': 10570,
|
57 |
+
'HasAns_exact': 83.03689687795648,
|
58 |
+
'HasAns_f1': 90.77486052446231,
|
59 |
+
'HasAns_total': 10570,
|
60 |
+
'best_exact': 83.03689687795648,
|
61 |
+
'best_exact_thresh': 0.0,
|
62 |
+
'best_f1': 90.77486052446231,
|
63 |
+
'best_f1_thresh': 0.0
|
64 |
+
}
|
65 |
+
```
|
66 |
+
|
67 |
+
### Model in action 🚀
|
68 |
+
|
69 |
+
Fast usage with **pipelines**:
|
70 |
+
|
71 |
+
```python
|
72 |
+
from transformers import pipeline
|
73 |
+
|
74 |
+
QnA_pipeline = pipeline('question-answering', model='mrm8488/electra-base-finetuned-squadv1')
|
75 |
+
|
76 |
+
QnA_pipeline({
|
77 |
+
'context': 'A new strain of flu that has the potential to become a pandemic has been identified in China by scientists.',
|
78 |
+
'question': 'What has been discovered by scientists from China ?'
|
79 |
+
})
|
80 |
+
# Output:
|
81 |
+
{'answer': 'A new strain of flu', 'end': 19, 'score': 0.9995211430099182, 'start': 0}
|
82 |
+
```
|
83 |
+
|
84 |
+
> Created by [Manuel Romero/@mrm8488](https://twitter.com/mrm8488) | [LinkedIn](https://www.linkedin.com/in/manuel-romero-cs/)
|
85 |
+
> Made with <span style="color: #e25555;">♥</span> in Spain
|