julien-c HF staff commited on
Commit
1e4c70c
1 Parent(s): 28faf4e

Migrate model card from transformers-repo

Browse files

Read 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/a-ware/bart-squadv2/README.md

Files changed (1) hide show
  1. README.md +76 -0
README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - squad_v2
4
+ ---
5
+
6
+ # BART-LARGE finetuned on SQuADv2
7
+
8
+ This is bart-large model finetuned on SQuADv2 dataset for question answering task
9
+
10
+ ## Model details
11
+ BART was propsed in the [paper](https://arxiv.org/abs/1910.13461) **BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension**.
12
+ BART is a seq2seq model intended for both NLG and NLU tasks.
13
+
14
+ To use BART for question answering tasks, we feed the complete document into the encoder and decoder, and use the top
15
+ hidden state of the decoder as a representation for each
16
+ word. This representation is used to classify the token. As given in the paper bart-large achives comparable to ROBERTa on SQuAD.
17
+ Another notable thing about BART is that it can handle sequences with upto 1024 tokens.
18
+
19
+ | Param | #Value |
20
+ |---------------------|--------|
21
+ | encoder layers | 12 |
22
+ | decoder layers | 12 |
23
+ | hidden size | 4096 |
24
+ | num attetion heads | 16 |
25
+ | on disk size | 1.63GB |
26
+
27
+
28
+ ## Model training
29
+ This model was trained with following parameters using simpletransformers wrapper:
30
+ ```
31
+ train_args = {
32
+ 'learning_rate': 1e-5,
33
+ 'max_seq_length': 512,
34
+ 'doc_stride': 512,
35
+ 'overwrite_output_dir': True,
36
+ 'reprocess_input_data': False,
37
+ 'train_batch_size': 8,
38
+ 'num_train_epochs': 2,
39
+ 'gradient_accumulation_steps': 2,
40
+ 'no_cache': True,
41
+ 'use_cached_eval_features': False,
42
+ 'save_model_every_epoch': False,
43
+ 'output_dir': "bart-squadv2",
44
+ 'eval_batch_size': 32,
45
+ 'fp16_opt_level': 'O2',
46
+ }
47
+ ```
48
+
49
+ [You can even train your own model using this colab notebook](https://colab.research.google.com/drive/1I5cK1M_0dLaf5xoewh6swcm5nAInfwHy?usp=sharing)
50
+
51
+ ## Results
52
+ ```{"correct": 6832, "similar": 4409, "incorrect": 632, "eval_loss": -14.950117511952177}```
53
+
54
+ ## Model in Action 🚀
55
+ ```python3
56
+ from transformers import BartTokenizer, BartForQuestionAnswering
57
+ import torch
58
+
59
+ tokenizer = BartTokenizer.from_pretrained('a-ware/bart-squadv2')
60
+ model = BartForQuestionAnswering.from_pretrained('a-ware/bart-squadv2')
61
+
62
+ question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
63
+ encoding = tokenizer(question, text, return_tensors='pt')
64
+ input_ids = encoding['input_ids']
65
+ attention_mask = encoding['attention_mask']
66
+
67
+ start_scores, end_scores = model(input_ids, attention_mask=attention_mask, output_attentions=False)[:2]
68
+
69
+ all_tokens = tokenizer.convert_ids_to_tokens(input_ids[0])
70
+ answer = ' '.join(all_tokens[torch.argmax(start_scores) : torch.argmax(end_scores)+1])
71
+ answer = tokenizer.convert_tokens_to_ids(answer.split())
72
+ answer = tokenizer.decode(answer)
73
+ #answer => 'a nice puppet'
74
+ ```
75
+
76
+ > Created with ❤️ by A-ware UG [![Github icon](https://cdn0.iconfinder.com/data/icons/octicons/1024/mark-github-32.png)](https://github.com/aware-ai)