Mohammed Aly commited on
Commit
069a73b
·
verified ·
1 Parent(s): 0c75ac4

Update README.md

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