julien-c HF staff commited on
Commit
c3dc743
1 Parent(s): 9b9c733

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/xlmroberta-squadv2/README.md

Files changed (1) hide show
  1. README.md +59 -0
README.md ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - squad_v2
4
+ ---
5
+
6
+ # XLM-ROBERTA-LARGE finetuned on SQuADv2
7
+
8
+ This is xlm-roberta-large model finetuned on SQuADv2 dataset for question answering task
9
+
10
+ ## Model details
11
+ XLM-Roberta was propsed in the [paper](https://arxiv.org/pdf/1911.02116.pdf) **XLM-R: State-of-the-art cross-lingual understanding through self-supervision
12
+
13
+ ## Model training
14
+ This model was trained with following parameters using simpletransformers wrapper:
15
+ ```
16
+ train_args = {
17
+ 'learning_rate': 1e-5,
18
+ 'max_seq_length': 512,
19
+ 'doc_stride': 512,
20
+ 'overwrite_output_dir': True,
21
+ 'reprocess_input_data': False,
22
+ 'train_batch_size': 8,
23
+ 'num_train_epochs': 2,
24
+ 'gradient_accumulation_steps': 2,
25
+ 'no_cache': True,
26
+ 'use_cached_eval_features': False,
27
+ 'save_model_every_epoch': False,
28
+ 'output_dir': "bart-squadv2",
29
+ 'eval_batch_size': 32,
30
+ 'fp16_opt_level': 'O2',
31
+ }
32
+ ```
33
+
34
+ ## Results
35
+ ```{"correct": 6961, "similar": 4359, "incorrect": 553, "eval_loss": -12.177856394381962}```
36
+
37
+ ## Model in Action 🚀
38
+ ```python3
39
+ from transformers import XLMRobertaTokenizer, XLMRobertaForQuestionAnswering
40
+ import torch
41
+
42
+ tokenizer = XLMRobertaTokenizer.from_pretrained('a-ware/xlmroberta-squadv2')
43
+ model = XLMRobertaForQuestionAnswering.from_pretrained('a-ware/xlmroberta-squadv2')
44
+
45
+ question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
46
+ encoding = tokenizer(question, text, return_tensors='pt')
47
+ input_ids = encoding['input_ids']
48
+ attention_mask = encoding['attention_mask']
49
+
50
+ start_scores, end_scores = model(input_ids, attention_mask=attention_mask, output_attentions=False)[:2]
51
+
52
+ all_tokens = tokenizer.convert_ids_to_tokens(input_ids[0])
53
+ answer = ' '.join(all_tokens[torch.argmax(start_scores) : torch.argmax(end_scores)+1])
54
+ answer = tokenizer.convert_tokens_to_ids(answer.split())
55
+ answer = tokenizer.decode(answer)
56
+ #answer => 'a nice puppet'
57
+ ```
58
+
59
+ > 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)