File size: 3,367 Bytes
0a30334
 
0338ce8
0a30334
 
 
1bebca4
0a30334
 
 
0338ce8
 
 
1bebca4
0a30334
0338ce8
0a30334
1bebca4
0a30334
1bebca4
0a30334
1bebca4
0a30334
1bebca4
0a30334
0338ce8
0a30334
0338ce8
 
 
 
 
 
1bebca4
0338ce8
 
 
 
 
 
 
0a30334
0338ce8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a30334
5042941
0a30334
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
tags:
- Question(s) Generation
metrics:
- rouge
model-index:
- name: consciousAI/question-generation-auto-t5-v1-base-s-q-c
  results: []
---

# Auto Question Generation  
The model is intended to be used for Auto Question Generation task i.e. no hint are required as input. The model is expected to produce one or possibly more than one question from the provided context.
 
[Live Demo: Question Generation](https://huggingface.co/spaces/consciousAI/question_generation)

Including this there are four models trained with different training sets, demo provide comparison to all in one go. However, you can reach individual projects at below links:

[Auto Question Generation v1](https://huggingface.co/consciousAI/question-generation-auto-t5-v1-base-s)

[Auto Question Generation v2](https://huggingface.co/consciousAI/question-generation-auto-t5-v1-base-s-q)

[Auto/Hints based Question Generation v1](https://huggingface.co/consciousAI/question-generation-auto-hints-t5-v1-base-s-q)

[Auto/Hints based Question Generation v2](https://huggingface.co/consciousAI/question-generation-auto-hints-t5-v1-base-s-q-c)

This model can be used as below:

```
from transformers import (
    AutoModelForSeq2SeqLM,
    AutoTokenizer
)

model_checkpoint = "consciousAI/question-generation-auto-t5-v1-base-s-q-c"

model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)

## Input with prompt
context="question_context: <context>"
encodings = tokenizer.encode(context, return_tensors='pt', truncation=True, padding='max_length').to(device)

## You can play with many hyperparams to condition the output, look at demo
output = model.generate(encodings, 
                        #max_length=300, 
                        #min_length=20, 
                        #length_penalty=2.0, 
                        num_beams=4,
                        #early_stopping=True,
                        #do_sample=True,
                        #temperature=1.1
                       )

## Multiple questions are expected to be delimited by '?' You can write a small wrapper to elegantly format. Look at the demo.
questions = [tokenizer.decode(id, clean_up_tokenization_spaces=False, skip_special_tokens=False) for id in output]
```

## Training and evaluation data

Squad & QNLi combo.

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 0.0003
- train_batch_size: 6
- eval_batch_size: 6
- seed: 42
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 5

### Training results

| Training Loss | Epoch | Step | Validation Loss | Rouge1 | Rouge2 | Rougel | Rougelsum |
|:-------------:|:-----:|:----:|:---------------:|:------:|:------:|:------:|:---------:|
| 1.8732        | 1.0   | 942  | 1.4330          | 0.5558 | 0.3857 | 0.5219 | 0.5231    |
| 1.2361        | 2.0   | 1884 | 1.3720          | 0.5649 | 0.4042 | 0.5332 | 0.5338    |
| 0.9515        | 3.0   | 2826 | 1.3703          | 0.5699 | 0.4044 | 0.5373 | 0.5385    |
| 0.7383        | 4.0   | 3768 | 1.4039          | 0.5753 | 0.4159 | 0.5414 | 0.5426    |
| 0.6291        | 5.0   | 4710 | 1.4661          | 0.5809 | 0.4227 | 0.5488 | 0.5498    |


### Framework versions

- Transformers 4.23.0.dev0
- Pytorch 1.12.1+cu113
- Datasets 2.5.2
- Tokenizers 0.13.0