Mohammed Aly commited on
Commit
5bcec25
1 Parent(s): 5170a2e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +99 -5
README.md CHANGED
@@ -6,6 +6,16 @@ tags:
6
  model-index:
7
  - name: t5-small-squad-qg-v2
8
  results: []
 
 
 
 
 
 
 
 
 
 
9
  ---
10
 
11
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
@@ -13,17 +23,101 @@ should probably proofread and complete it, then remove this comment. -->
13
 
14
  # t5-small-squad-qg-v2
15
 
16
- This model is a fine-tuned version of [t5-small](https://huggingface.co/t5-small) on the None dataset.
17
  It achieves the following results on the evaluation set:
18
  - Loss: 1.6608
 
 
 
 
 
 
 
19
 
20
  ## Model description
21
 
22
- More information needed
23
 
24
  ## Intended uses & limitations
25
-
26
- More information needed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  ## Training and evaluation data
29
 
@@ -70,4 +164,4 @@ The following hyperparameters were used during training:
70
  - Transformers 4.38.1
71
  - Pytorch 2.1.2
72
  - Datasets 2.13.1
73
- - Tokenizers 0.15.2
 
6
  model-index:
7
  - name: t5-small-squad-qg-v2
8
  results: []
9
+ datasets:
10
+ - rajpurkar/squad
11
+ language:
12
+ - en
13
+ metrics:
14
+ - bleu
15
+ - rouge
16
+ - meteor
17
+ - bertscore
18
+ pipeline_tag: text2text-generation
19
  ---
20
 
21
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
 
23
 
24
  # t5-small-squad-qg-v2
25
 
26
+ This model is a fine-tuned version of [t5-small](https://huggingface.co/t5-small) on the SQuAD dataset.
27
  It achieves the following results on the evaluation set:
28
  - Loss: 1.6608
29
+ - BLEU: 20.00
30
+ - Rouge1: 47.69
31
+ - Rouge2: 26.43
32
+ - RougeL: 44.15
33
+ - RougeLSum: 44.15
34
+ - METEOR: 45.84
35
+ - BertScore: 91.82
36
 
37
  ## Model description
38
 
 
39
 
40
  ## Intended uses & limitations
41
+ 1. Define some useful functions for highlighting the answer in the paragraph and preparing the instruction prompt that will be fed to the model:
42
+
43
+ ```Python
44
+ def highlight_answer(context, answer):
45
+ context_splits = context.split(answer)
46
+
47
+ text = ""
48
+ for split in context_splits:
49
+ text += split
50
+ text += ' <h> '
51
+ text += answer
52
+ text += ' <h> '
53
+ text += split
54
+
55
+ return text
56
+
57
+ def prepare_instruction(answer_highlighted_context):
58
+ instruction_prompt = f"""Generate a question whose answer is highlighted by <h> from the context delimited by the triple backticks.
59
+ context:
60
+ ```
61
+ {answer_highlighted_context}
62
+ ```
63
+ """
64
+
65
+ return instruction_prompt
66
+ ```
67
+
68
+ 2. Use the model as a Hugging Face Pipeline:
69
+
70
+ ```Python
71
+ from transformers import pipeline
72
+
73
+ pipe = pipeline('text2text-generation', model='mohammedaly2222002/t5-small-squad-qg')
74
+
75
+ context = """During the 2011–12 season, he set the La Liga and European records\
76
+ for most goals scored in a single season, while establishing himself as Barcelona's\
77
+ all-time top scorer. The following two seasons, Messi finished second for the Ballon\
78
+ d'Or behind Cristiano Ronaldo (his perceived career rival), before regaining his best\
79
+ form during the 2014–15 campaign, becoming the all-time top scorer in La Liga and \
80
+ leading Barcelona to a historic second treble, after which he was awarded a fifth \
81
+ Ballon d'Or in 2015. Messi assumed captaincy of Barcelona in 2018, and won a record \
82
+ sixth Ballon d'Or in 2019. Out of contract, he signed for French club Paris Saint-Germain\
83
+ in August 2021, spending two seasons at the club and winning Ligue 1 twice. Messi \
84
+ joined American club Inter Miami in July 2023, winning the Leagues Cup in August of that year.
85
+ """
86
+
87
+ answer_highlighted_context = highlight_answer(context=context, answer='Inter Miami')
88
+ prompt = prepare_instruction(answer_highlighted_context)
89
+ ```
90
+
91
+ This will be the final prompt:
92
+ ```
93
+ Generate a question whose answer is highlighted by <h> from the context delimited by the triple backticks
94
+ context:
95
+ ```During the 2011–12 season, he set the La Liga and European records\
96
+ for most goals scored in a single season, while establishing himself as Barcelona's\
97
+ all-time top scorer. The following two seasons, Messi finished second for the Ballon\
98
+ d'Or behind Cristiano Ronaldo (his perceived career rival), before regaining his best\
99
+ form during the 2014–15 campaign, becoming the all-time top scorer in La Liga and \
100
+ leading Barcelona to a historic second treble, after which he was awarded a fifth \
101
+ Ballon d'Or in 2015. Messi assumed captaincy of Barcelona in 2018, and won a record\
102
+ sixth Ballon d'Or in 2019. Out of contract, he signed for French club Paris Saint-Germain\
103
+ in August 2021, spending two seasons at the club and winning Ligue 1 twice. Messi \
104
+ joined American club <h> Inter Miami <h> in July 2023, winning the Leagues Cup in August of that year.```
105
+ ```
106
+
107
+ 3. Use the loaded `pipeline` to generate questions their answer is `Inter Miami`:
108
+
109
+ ```Python
110
+ outputs = pipe(prompt, num_return_sequences=3, num_beams=5, num_beam_groups=5, diversity_penalty=1.0)
111
+ for output in outputs:
112
+ print(output['generated_text'])
113
+ ```
114
+
115
+ Result:
116
+ ```
117
+ 1. What club did Messi join in the 2023 season?
118
+ 2. What was Messi's name of the club that won the Leagues Cup on July 20?
119
+ 3. What club did Messi join in the Leagues Cup in July 2023?
120
+ ```
121
 
122
  ## Training and evaluation data
123
 
 
164
  - Transformers 4.38.1
165
  - Pytorch 2.1.2
166
  - Datasets 2.13.1
167
+ - Tokenizers 0.15.2