Anshoo Mehra
commited on
Commit
·
a735c83
1
Parent(s):
0649182
Update README.md
Browse files
README.md
CHANGED
@@ -4,43 +4,53 @@ tags:
|
|
4 |
metrics:
|
5 |
- rouge
|
6 |
model-index:
|
7 |
-
- name: t5-v1-base-s-q-c
|
8 |
results: []
|
9 |
---
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
### Training hyperparameters
|
39 |
|
40 |
The following hyperparameters were used during training:
|
41 |
- learning_rate: 0.0003
|
42 |
-
- train_batch_size:
|
43 |
-
- eval_batch_size:
|
44 |
- seed: 42
|
45 |
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
46 |
- lr_scheduler_type: linear
|
|
|
4 |
metrics:
|
5 |
- rouge
|
6 |
model-index:
|
7 |
+
- name: question-answering-generative-t5-v1-base-s-q-c
|
8 |
results: []
|
9 |
---
|
10 |
|
11 |
+
# Question Answering Generative
|
12 |
+
The model is intended to be used for Q&A task, given the question & context, the model would attempt to infer the answer text.<br>
|
13 |
+
Model is generative (t5-v1-base), fine-tuned from [question-generation-auto-hints-t5-v1-base-s-q-c](https://huggingface.co/anshoomehra/question-generation-auto-hints-t5-v1-base-s-q-c) with - **Loss:** 0.6751 & **Rougel:** 0.8022 performance scores.
|
14 |
+
|
15 |
+
Please follow this link for [Encoder based Question Answering](https://huggingface.co/anshoomehra/question-answering-roberta-base-s/blob/main/README.md)
|
16 |
+
|
17 |
+
Example code:
|
18 |
+
|
19 |
+
```
|
20 |
+
from transformers import (
|
21 |
+
AutoModelForSeq2SeqLM,
|
22 |
+
AutoTokenizer
|
23 |
+
)
|
24 |
+
|
25 |
+
def _generate(query, context, model, device):
|
26 |
+
|
27 |
+
FT_MODEL = AutoModelForSeq2SeqLM.from_pretrained(model).to(device)
|
28 |
+
FT_MODEL_TOKENIZER = AutoTokenizer.from_pretrained(model)
|
29 |
+
input_text = "question: " + query + "</s> question_context: " + context
|
30 |
+
|
31 |
+
input_tokenized = FT_MODEL_TOKENIZER.encode(input_text, return_tensors='pt', truncation=True, padding='max_length', max_length=1024).to(device)
|
32 |
+
_tok_count_assessment = FT_MODEL_TOKENIZER.encode(input_text, return_tensors='pt', truncation=True).to(device)
|
33 |
+
|
34 |
+
summary_ids = FT_MODEL.generate(input_tokenized,
|
35 |
+
max_length=30,
|
36 |
+
min_length=5,
|
37 |
+
num_beams=2,
|
38 |
+
early_stopping=True,
|
39 |
+
)
|
40 |
+
output = [FT_MODEL_TOKENIZER.decode(id, clean_up_tokenization_spaces=True, skip_special_tokens=True) for id in summary_ids]
|
41 |
+
|
42 |
+
return str(output[0])
|
43 |
+
|
44 |
+
device = [0 if torch.cuda.is_available() else 'cpu'][0]
|
45 |
+
_generate(query, context, model="anshoomehra/t5-v1-base-s-q-c-multi-task-qgen-v2", device=device)
|
46 |
+
```
|
47 |
|
48 |
### Training hyperparameters
|
49 |
|
50 |
The following hyperparameters were used during training:
|
51 |
- learning_rate: 0.0003
|
52 |
+
- train_batch_size: 3
|
53 |
+
- eval_batch_size: 3
|
54 |
- seed: 42
|
55 |
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
56 |
- lr_scheduler_type: linear
|