RichardErkhov commited on
Commit
5cd5cbf
1 Parent(s): e85ebe5

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +95 -0
README.md ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ bart-squadv2 - bnb 4bits
11
+ - Model creator: https://huggingface.co/aware-ai/
12
+ - Original model: https://huggingface.co/aware-ai/bart-squadv2/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ datasets:
20
+ - squad_v2
21
+ ---
22
+
23
+ # BART-LARGE finetuned on SQuADv2
24
+
25
+ This is bart-large model finetuned on SQuADv2 dataset for question answering task
26
+
27
+ ## Model details
28
+ 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**.
29
+ BART is a seq2seq model intended for both NLG and NLU tasks.
30
+
31
+ To use BART for question answering tasks, we feed the complete document into the encoder and decoder, and use the top
32
+ hidden state of the decoder as a representation for each
33
+ word. This representation is used to classify the token. As given in the paper bart-large achives comparable to ROBERTa on SQuAD.
34
+ Another notable thing about BART is that it can handle sequences with upto 1024 tokens.
35
+
36
+ | Param | #Value |
37
+ |---------------------|--------|
38
+ | encoder layers | 12 |
39
+ | decoder layers | 12 |
40
+ | hidden size | 4096 |
41
+ | num attetion heads | 16 |
42
+ | on disk size | 1.63GB |
43
+
44
+
45
+ ## Model training
46
+ This model was trained with following parameters using simpletransformers wrapper:
47
+ ```
48
+ train_args = {
49
+ 'learning_rate': 1e-5,
50
+ 'max_seq_length': 512,
51
+ 'doc_stride': 512,
52
+ 'overwrite_output_dir': True,
53
+ 'reprocess_input_data': False,
54
+ 'train_batch_size': 8,
55
+ 'num_train_epochs': 2,
56
+ 'gradient_accumulation_steps': 2,
57
+ 'no_cache': True,
58
+ 'use_cached_eval_features': False,
59
+ 'save_model_every_epoch': False,
60
+ 'output_dir': "bart-squadv2",
61
+ 'eval_batch_size': 32,
62
+ 'fp16_opt_level': 'O2',
63
+ }
64
+ ```
65
+
66
+ [You can even train your own model using this colab notebook](https://colab.research.google.com/drive/1I5cK1M_0dLaf5xoewh6swcm5nAInfwHy?usp=sharing)
67
+
68
+ ## Results
69
+ ```{"correct": 6832, "similar": 4409, "incorrect": 632, "eval_loss": -14.950117511952177}```
70
+
71
+ ## Model in Action 🚀
72
+ ```python3
73
+ from transformers import BartTokenizer, BartForQuestionAnswering
74
+ import torch
75
+
76
+ tokenizer = BartTokenizer.from_pretrained('a-ware/bart-squadv2')
77
+ model = BartForQuestionAnswering.from_pretrained('a-ware/bart-squadv2')
78
+
79
+ question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
80
+ encoding = tokenizer(question, text, return_tensors='pt')
81
+ input_ids = encoding['input_ids']
82
+ attention_mask = encoding['attention_mask']
83
+
84
+ start_scores, end_scores = model(input_ids, attention_mask=attention_mask, output_attentions=False)[:2]
85
+
86
+ all_tokens = tokenizer.convert_ids_to_tokens(input_ids[0])
87
+ answer = ' '.join(all_tokens[torch.argmax(start_scores) : torch.argmax(end_scores)+1])
88
+ answer = tokenizer.convert_tokens_to_ids(answer.split())
89
+ answer = tokenizer.decode(answer)
90
+ #answer => 'a nice puppet'
91
+ ```
92
+
93
+ > 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)
94
+
95
+