From 13a8588f2d70fe78dc36d84829c04fa9d39572d1 Mon Sep 17 00:00:00 2001 From: Manuel Romero Date: Thu, 2 Jul 2020 16:16:30 +0200 Subject: [PATCH] Create model card (#5432) Create model card for electra-base-discriminator fine-tuned on SQUAD v1.1 --- .../electra-base-finetuned-squadv1/README.md | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 model_cards/mrm8488/electra-base-finetuned-squadv1/README.md diff --git a/model_cards/mrm8488/electra-base-finetuned-squadv1/README.md b/model_cards/mrm8488/electra-base-finetuned-squadv1/README.md new file mode 100644 index 0000000000..00cdef9a7f --- /dev/null +++ b/model_cards/mrm8488/electra-base-finetuned-squadv1/README.md @@ -0,0 +1,85 @@ +--- +language: english +--- + +# Electra base โšก + SQuAD v1 โ“ + +[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. + +## Details of the downstream task (Q&A) - Model ๐Ÿง  + +**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. + + +## Details of the downstream task (Q&A) - Dataset ๐Ÿ“š + +**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. +SQuAD v1.1 contains **100,000+** question-answer pairs on **500+** articles. + +## Model training ๐Ÿ‹๏ธโ€ + +The model was trained on a Tesla P100 GPU and 25GB of RAM with the following command: + +```bash +python transformers/examples/question-answering/run_squad.py \ + --model_type electra \ + --model_name_or_path 'google/electra-base-discriminator' \ + --do_eval \ + --do_train \ + --do_lower_case \ + --train_file '/content/dataset/train-v1.1.json' \ + --predict_file '/content/dataset/dev-v1.1.json' \ + --per_gpu_train_batch_size 16 \ + --learning_rate 3e-5 \ + --num_train_epochs 10 \ + --max_seq_length 384 \ + --doc_stride 128 \ + --output_dir '/content/output' \ + --overwrite_output_dir \ + --save_steps 1000 +``` + +## Test set Results ๐Ÿงพ + +| Metric | # Value | +| ------ | --------- | +| **EM** | **83.03** | +| **F1** | **90.77** | +| **Size**| **+ 400 MB** | + +Very good metrics for such a "small" model! + +```json +{ +'exact': 83.03689687795648, +'f1': 90.77486052446231, +'total': 10570, +'HasAns_exact': 83.03689687795648, +'HasAns_f1': 90.77486052446231, +'HasAns_total': 10570, +'best_exact': 83.03689687795648, +'best_exact_thresh': 0.0, +'best_f1': 90.77486052446231, +'best_f1_thresh': 0.0 +} +``` + +### Model in action ๐Ÿš€ + +Fast usage with **pipelines**: + +```python +from transformers import pipeline + +QnA_pipeline = pipeline('question-answering', model='mrm8488/electra-base-finetuned-squadv1') + +QnA_pipeline({ + 'context': 'A new strain of flu that has the potential to become a pandemic has been identified in China by scientists.', + 'question': 'What has been discovered by scientists from China ?' +}) +# Output: +{'answer': 'A new strain of flu', 'end': 19, 'score': 0.9995211430099182, 'start': 0} +``` + +> Created by [Manuel Romero/@mrm8488](https://twitter.com/mrm8488) | [LinkedIn](https://www.linkedin.com/in/manuel-romero-cs/) +> Made with in Spain