ptrdvn commited on
Commit
01e4c53
1 Parent(s): 7749d67

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +470 -7
README.md CHANGED
@@ -16,28 +16,491 @@ Kurage is a multipurpose RAG model from [Lightblue](https://huggingface.co/light
16
 
17
  This version of the model has been trained to perform RAG in Japanese.
18
 
19
- # Features / How to use
20
 
21
- * **Multi-chunk RAG**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  This model can take multiple contexts and a question as input, and it will first output the references of the relevant contexts before outputting an answer to the question.
24
 
25
- * **Single-chunk RAG**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  This model can also take a single context and a question as input, and it will determine whether it can answer the question based on the context, outputting an answer if it can. This allows for parallel computing of multiple contexts at the same time.
28
 
29
- * **Answer extension**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  By default, this model is trained to output the shortest possible answer to a question. However, if you require a longer answer, you can prompt the model to write a longer answer by writing " <<Long>>" after your question.
32
 
33
- * **Multilinguality**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  We have trained our model to be able to answer questions in Japanese based on texts in other languages too!
36
-
37
- * **Q&A generation**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  This model can also generate questions and answers based on a piece of text. This can be useful for pre-indexing a database or fine-tuning IR models that will then be used for RAG.
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  # Training data
43
 
 
16
 
17
  This version of the model has been trained to perform RAG in Japanese.
18
 
19
+ Features of these models include:
20
 
21
+ * **Multi-chunk RAG** - Performs RAG using multiple contexts at once.
22
+ * **Single-chunk RAG** - Performs RAG using one context at a time, allowing for parallel computing.
23
+ * **Answer extension** - Prompts the model to write a longer answer to a given question.
24
+ * **Multilingual RAG** - Performs RAG using contexts in languages different to the language of the question.
25
+ * **Q&A generation** - Generates questions and answers from a reference text in order to pre-index a set of texts.
26
+
27
+ Find out how to use these features below.
28
+
29
+ For models in other languages check [our Kurage collection]. A multilingual model is coming soon!
30
+
31
+ # Basic usage
32
+
33
+ To use the model for basic multi-chunk RAG, you can use the following code:
34
+
35
+ ```python
36
+ from vllm import LLM, SamplingParams
37
+
38
+ llm = LLM(model="lightblue/kurage-ja")
39
+ sampling_params = SamplingParams(temperature=0.2, top_p=0.95, max_tokens=128)
40
+
41
+ def create_rag_prompt(contexts, question):
42
+
43
+ context_str = "\n\n".join([f"<<Chunk {i+1}>>\n{x}" for i, x in enumerate(contexts)])
44
+
45
+ str_inputs = f"""{context_str}
46
+
47
+ <<Question>>
48
+ {question}"""
49
+
50
+ chat = [
51
+ {"role": "user", "content": str_inputs},
52
+ ]
53
+
54
+ return llm.llm_engine.tokenizer.tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
55
+
56
+ contexts = [
57
+ "日銀の中川順子審議委員は11日、実質金利は現在きわめて低い水準にあるとした上で、先行き日銀の経済・物価見通しが実現していくとすれば、物価目標実現の観点から金融緩和の度合いを調整していくことになると述べた。",
58
+ "7月の日本の経常収支は3.2兆円の黒字となり、7月としては過去最高の黒字額を記録した。しかし、黒字に貢献しているのは相変わらず第一次所得収支の黒字で、7月は4.4兆円の黒字を記録し、1カ月の黒字額としては過去最高を記録した。",
59
+ "鈴木俊一財務相は10日付で元財務省関税局長の諏訪園健司氏を新しい日銀理事に任命した。9日に任期満了で退任した貝塚正彰前理事の後任で、任期は4年。",
60
+ "8月の円高局面で、日本の機関投資家が過去最大の対外証券投資に動いていたことが、外為市場で話題となっている。"
61
+ ]
62
+
63
+ question = "現在、日本の第一次所得収支はいくらですか?"
64
+
65
+ inputs = create_rag_prompt(contexts, question)
66
+
67
+ outputs = llm.generate([inputs], sampling_params)
68
+
69
+ print(outputs[0].outputs[0].text)
70
+ # <<References>>
71
+ # 2
72
+ #
73
+ # <<Answer>>
74
+ # 4.4兆円
75
+ ```
76
+
77
+ # Feature: Multi-chunk RAG
78
 
79
  This model can take multiple contexts and a question as input, and it will first output the references of the relevant contexts before outputting an answer to the question.
80
 
81
+ <details>
82
+ <summary>Prompt style</summary>
83
+
84
+ ### Input:
85
+ ```markdown
86
+ <<Chunk 1>>
87
+ Junko Nakagawa, a member of the Bank of Japan's Policy Board, stated on the 11th that real interest rates are currently at an extremely low level.
88
+ She mentioned that if the BOJ's economic and price outlook materializes in the future, the degree of monetary easing would be adjusted from the perspective of achieving the price target.
89
+
90
+ <<Chunk 2>>
91
+ Japan's current account surplus in July was 3.2 trillion yen, the highest monthly surplus on record for the month of July.
92
+ However, the surplus continues to be driven by the primary income balance, which recorded a surplus of 4.4 trillion yen in July, the highest monthly figure on record.
93
+
94
+ <<Chunk 3>>
95
+ Finance Minister Shunichi Suzuki appointed Kenji Suwazono, former Director-General of the Customs and Tariff Bureau at the Ministry of Finance, as the new Executive Director of the Bank of Japan effective the 10th. Suwazono succeeds Masaaki Kaizuka, whose term ended on the 9th, and his term will last for four years.
96
+
97
+ <<Chunk 4>>
98
+ In the yen appreciation phase of August, it has become a topic in the foreign exchange market that Japanese institutional investors engaged in the largest-ever outward securities investment.
99
+
100
+ <<Question>>
101
+ What is Japan's primary income balance currently?
102
+ ```
103
+
104
+ ### Output:
105
+
106
+ ```markdown
107
+ <<References>>
108
+ 2
109
+
110
+ <<Answer>>
111
+ 4.4 trillion yen
112
+ ```
113
+
114
+ </details>
115
+
116
+ <details>
117
+ <summary>Python code</summary>
118
+
119
+ ```python
120
+ from vllm import LLM, SamplingParams
121
+
122
+ llm = LLM(model="lightblue/kurage-ja")
123
+ sampling_params = SamplingParams(temperature=0.2, top_p=0.95, max_tokens=128)
124
+
125
+ def create_rag_prompt(contexts, question):
126
+
127
+ context_str = "\n\n".join([f"<<Chunk {i+1}>>\n{x}" for i, x in enumerate(contexts)])
128
+
129
+ str_inputs = f"""{context_str}
130
+
131
+ <<Question>>
132
+ {question}"""
133
+
134
+ chat = [
135
+ {"role": "user", "content": str_inputs},
136
+ ]
137
+
138
+ return llm.llm_engine.tokenizer.tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
139
+
140
+ contexts = [
141
+ "Junko Nakagawa, a member of the Bank of Japan's Policy Board, stated on the 11th that real interest rates are currently at an extremely low level. She mentioned that if the BOJ's economic and price outlook materializes in the future, the degree of monetary easing would be adjusted from the perspective of achieving the price target.",
142
+ "Japan's current account surplus in July was 3.2 trillion yen, the highest monthly surplus on record for the month of July. However, the surplus continues to be driven by the primary income balance, which recorded a surplus of 4.4 trillion yen in July, the highest monthly figure on record.",
143
+ "Finance Minister Shunichi Suzuki appointed Kenji Suwazono, former Director-General of the Customs and Tariff Bureau at the Ministry of Finance, as the new Executive Director of the Bank of Japan effective the 10th. Suwazono succeeds Masaaki Kaizuka, whose term ended on the 9th, and his term will last for four years.",
144
+ "In the yen appreciation phase of August, it has become a topic in the foreign exchange market that Japanese institutional investors engaged in the largest-ever outward securities investment."
145
+ ]
146
+
147
+ question = "What is Japan's primary income balance currently?"
148
+
149
+ inputs = create_rag_prompt(contexts, question)
150
+
151
+ outputs = llm.generate([inputs], sampling_params)
152
+
153
+ print(outputs[0].outputs[0].text)
154
+ # <<References>>
155
+ # 2
156
+ #
157
+ # <<Answer>>
158
+ # 4.4 trillion yen.
159
+
160
+ ```
161
+
162
+ </details>
163
+
164
+ <br/>
165
+
166
+ # Feature: Single-chunk RAG
167
 
168
  This model can also take a single context and a question as input, and it will determine whether it can answer the question based on the context, outputting an answer if it can. This allows for parallel computing of multiple contexts at the same time.
169
 
170
+ <details>
171
+ <summary>Prompt style</summary>
172
+
173
+
174
+
175
+ ### Irrelevant context input:
176
+ ```markdown
177
+ <<Chunk 1>>
178
+ Junko Nakagawa, a member of the Bank of Japan's Policy Board, stated on the 11th that real interest rates are currently at an extremely low level.
179
+ She mentioned that if the BOJ's economic and price outlook materializes in the future, the degree of monetary easing would be adjusted from the perspective of achieving the price target.
180
+
181
+ <<Question>>
182
+ What is Japan's primary income balance currently?
183
+ ```
184
+
185
+ ### Irrelevant context output:
186
+
187
+ ```markdown
188
+ <<References>>
189
+ None
190
+ ```
191
+
192
+
193
+ ### Relevant context input:
194
+ ```markdown
195
+ <<Chunk 1>>
196
+ Japan's current account surplus in July was 3.2 trillion yen, the highest monthly surplus on record for the month of July.
197
+ However, the surplus continues to be driven by the primary income balance, which recorded a surplus of 4.4 trillion yen in July, the highest monthly figure on record.
198
+
199
+ <<Question>>
200
+ What is Japan's primary income balance currently?
201
+ ```
202
+
203
+ ### Relevant context output:
204
+
205
+ ```markdown
206
+ <<References>>
207
+ 1
208
+
209
+ <<Answer>>
210
+ 4.4 trillion yen
211
+ ```
212
+
213
+ </details>
214
+
215
+ <details>
216
+ <summary>Python code</summary>
217
+
218
+ ```python
219
+ from vllm import LLM, SamplingParams
220
+
221
+ llm = LLM(model="lightblue/kurage-ja")
222
+ sampling_params = SamplingParams(temperature=0.2, top_p=0.95, max_tokens=128)
223
+
224
+ def create_rag_prompt(contexts, question):
225
+
226
+ context_str = "\n\n".join([f"<<Chunk {i+1}>>\n{x}" for i, x in enumerate(contexts)])
227
+
228
+ str_inputs = f"""{context_str}
229
+
230
+ <<Question>>
231
+ {question}"""
232
+
233
+ chat = [
234
+ {"role": "user", "content": str_inputs},
235
+ ]
236
+
237
+ return llm.llm_engine.tokenizer.tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
238
+
239
+ contexts = [
240
+ "Junko Nakagawa, a member of the Bank of Japan's Policy Board, stated on the 11th that real interest rates are currently at an extremely low level. She mentioned that if the BOJ's economic and price outlook materializes in the future, the degree of monetary easing would be adjusted from the perspective of achieving the price target.",
241
+ "Japan's current account surplus in July was 3.2 trillion yen, the highest monthly surplus on record for the month of July. However, the surplus continues to be driven by the primary income balance, which recorded a surplus of 4.4 trillion yen in July, the highest monthly figure on record.",
242
+ "Finance Minister Shunichi Suzuki appointed Kenji Suwazono, former Director-General of the Customs and Tariff Bureau at the Ministry of Finance, as the new Executive Director of the Bank of Japan effective the 10th. Suwazono succeeds Masaaki Kaizuka, whose term ended on the 9th, and his term will last for four years.",
243
+ "In the yen appreciation phase of August, it has become a topic in the foreign exchange market that Japanese institutional investors engaged in the largest-ever outward securities investment."
244
+ ]
245
+
246
+ question = "What is Japan's primary income balance currently?"
247
+
248
+ outputs = llm.generate([create_rag_prompt([x], question) for x in contexts], sampling_params)
249
+
250
+ print("\n\n".join([f"{i+1}.\n{o.outputs[0].text}" for i, o in enumerate(outputs)]))
251
+ # 1.
252
+ # <<References>>
253
+ # None
254
+
255
+ # 2.
256
+ # <<References>>
257
+ # 1
258
+ #
259
+ # <<Answer>>
260
+ # 4.4 trillion yen.
261
+
262
+ # 3.
263
+ # <<References>>
264
+ # None
265
+
266
+ # 4.
267
+ # <<References>>
268
+ # None
269
+
270
+ ```
271
+
272
+ </details>
273
+ <br/>
274
+
275
+ # Feature: Answer extension
276
 
277
  By default, this model is trained to output the shortest possible answer to a question. However, if you require a longer answer, you can prompt the model to write a longer answer by writing " <<Long>>" after your question.
278
 
279
+ <details>
280
+ <summary>Prompt style</summary>
281
+
282
+ ### Input:
283
+ ```markdown
284
+ <<Chunk 1>>
285
+ Japan's current account surplus in July was 3.2 trillion yen, the highest monthly surplus on record for the month of July.
286
+ However, the surplus continues to be driven by the primary income balance, which recorded a surplus of 4.4 trillion yen in July, the highest monthly figure on record.
287
+
288
+ <<Question>>
289
+ What is Japan's primary income balance currently? <<Long>>
290
+ ```
291
+
292
+ ### Relevant context output:
293
+
294
+ ```markdown
295
+ <<References>>
296
+ 1
297
+
298
+ <<Answer>>
299
+ 4.4 trillion yen
300
+ ```
301
+
302
+ </details>
303
+
304
+ <details>
305
+ <summary>Python code</summary>
306
+
307
+ ```python
308
+ from vllm import LLM, SamplingParams
309
+
310
+ llm = LLM(model="lightblue/kurage-ja")
311
+ sampling_params = SamplingParams(temperature=0.2, top_p=0.95, max_tokens=128)
312
+
313
+ def create_rag_prompt(contexts, question):
314
+
315
+ context_str = "\n\n".join([f"<<Chunk {i+1}>>\n{x}" for i, x in enumerate(contexts)])
316
+
317
+ str_inputs = f"""{context_str}
318
+
319
+ <<Question>>
320
+ {question}"""
321
+
322
+ chat = [
323
+ {"role": "user", "content": str_inputs},
324
+ ]
325
+
326
+ return llm.llm_engine.tokenizer.tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
327
+
328
+ contexts = [
329
+ "Junko Nakagawa, a member of the Bank of Japan's Policy Board, stated on the 11th that real interest rates are currently at an extremely low level. She mentioned that if the BOJ's economic and price outlook materializes in the future, the degree of monetary easing would be adjusted from the perspective of achieving the price target.",
330
+ "Japan's current account surplus in July was 3.2 trillion yen, the highest monthly surplus on record for the month of July. However, the surplus continues to be driven by the primary income balance, which recorded a surplus of 4.4 trillion yen in July, the highest monthly figure on record.",
331
+ "Finance Minister Shunichi Suzuki appointed Kenji Suwazono, former Director-General of the Customs and Tariff Bureau at the Ministry of Finance, as the new Executive Director of the Bank of Japan effective the 10th. Suwazono succeeds Masaaki Kaizuka, whose term ended on the 9th, and his term will last for four years.",
332
+ "In the yen appreciation phase of August, it has become a topic in the foreign exchange market that Japanese institutional investors engaged in the largest-ever outward securities investment."
333
+ ]
334
+
335
+ question = "What is Japan's primary income balance currently? <<Long>>"
336
+
337
+ inputs = create_rag_prompt(contexts, question)
338
+
339
+ outputs = llm.generate([inputs], sampling_params)
340
+
341
+ print(outputs[0].outputs[0].text)
342
+
343
+ # <<References>>
344
+ # 2
345
+ #
346
+ # <<Answer>>
347
+ # Japan's primary income balance recorded a surplus of 4.4 trillion yen in July.
348
+ ```
349
+
350
+ </details>
351
+ <br/>
352
+
353
+ # Feature: Multilinguality
354
 
355
  We have trained our model to be able to answer questions in Japanese based on texts in other languages too!
356
+
357
+ (Note - this is still giving variable results depending on the question and the language of the correct reference. Stay tuned for further improvements in the future.)
358
+
359
+ <details>
360
+ <summary>Prompt style</summary>
361
+
362
+ ### Input:
363
+ ```markdown
364
+ <<Chunk 1>>
365
+ Junko Nakagawa, a member of the Bank of Japan's Policy Board, stated on the 11th that real interest rates are currently at an extremely low level.
366
+ She mentioned that if the BOJ's economic and price outlook materializes in the future, the degree of monetary easing would be adjusted from the perspective of achieving the price target.
367
+
368
+ <<Chunk 2>>
369
+ 7月の日本の経常収支は3.2兆円の黒字となり、7月としては過去最高の黒字額を記録した。しかし、黒字に貢献しているのは相変わらず第一次所得収支の黒字で、7月は4.4兆円の黒字を記録し、1カ月の黒字額としては過去最高を記録した。
370
+
371
+ <<Chunk 3>>
372
+ รัฐมนตรีว่าการกระทรวงการคลัง ชุนอิจิ สุซูกิ ได้แต่งตั้ง เค็นจิ สุวาโซโนะ อดีตอธิบดีกรมศุลกากรและภาษีสิ่งนำเข้าแห่งกระทรวงการคลัง เป็นกรรมการบริหารธนาคารแห่งประเทศญี่ปุ่นคนใหม่ มีผลตั้งแต่วันที่ 10 สุวาโซโนะจะมาแทน มาซาอะกิ ไคซูกะ ที่พ้นวาระไปในวันที่ 9 โดยมีวาระ 4 ปี
373
+
374
+ <<Chunk 4>>
375
+ In the yen appreciation phase of August, it has become a topic in the foreign exchange market that Japanese institutional investors engaged in the largest-ever outward securities investment.
376
+
377
+ <<Question>>
378
+ What is Japan's primary income balance currently?
379
+ ```
380
+
381
+ ### Output:
382
+
383
+ ```markdown
384
+ <<References>>
385
+ 2
386
+
387
+ <<Answer>>
388
+ 4.4 trillion yen
389
+ ```
390
+
391
+ </details>
392
+
393
+ <details>
394
+ <summary>Python code</summary>
395
+
396
+ ```python
397
+
398
+ from vllm import LLM, SamplingParams
399
+
400
+ llm = LLM(model="lightblue/kurage-ja")
401
+ sampling_params = SamplingParams(temperature=0.2, top_p=0.95, max_tokens=128)
402
+
403
+ def create_rag_prompt(contexts, question):
404
+
405
+ context_str = "\n\n".join([f"<<Chunk {i+1}>>\n{x}" for i, x in enumerate(contexts)])
406
+
407
+ str_inputs = f"""{context_str}
408
+
409
+ <<Question>>
410
+ {question}"""
411
+
412
+ chat = [
413
+ {"role": "user", "content": str_inputs},
414
+ ]
415
+
416
+ return llm.llm_engine.tokenizer.tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
417
+
418
+ contexts = [
419
+ "นากากาวะ จุนโกะ สมาชิกคณะกรรมการนโยบายการเงิน ธนาคารแห่งประเทศญี่ปุ่น กล่าวในวันที่ 11 ว่า อัตราดอกเบี้ยที่แท้จริงอยู่ในระดับต่ำมากในปัจจุบัน และกล่าวว่า หากแนวโน้มเศรษฐกิจและราคาของธนาคารกลางญี่ปุ่นเป็นจริงในอนาคต การผ่อนคลายนโยบายการเงินจะถูกปรับโดยพิจารณาจากการบรรลุเป้าหมายด้านราคา",
420
+ "Der Leistungsbilanzüberschuss Japans betrug im Juli 3,2 Billionen Yen, der höchste monatliche Überschuss aller Zeiten für den Monat Juli. Dieser Überschuss wird jedoch weiterhin durch das positive Primäreinkommen unterstützt, das im Juli einen Überschuss von 4,4 Billionen Yen verzeichnete, die höchste monatliche Zahl in der Geschichte.",
421
+ "鈴木俊一財務相は10日付で元財務省関税局長の諏訪園健司氏を新しい日銀理事に任命した。9日に任期満了で退任した貝塚正彰前理事の後任で、任期は4年。",
422
+ "Lors de la phase d'appréciation du yen en août, il est devenu un sujet dans le marché des changes que les investisseurs institutionnels japonais ont réalisé la plus grande investissement en titres à l'étranger jamais enregistré."
423
+ ]
424
+
425
+ question = "What is Japan's primary income balance currently?"
426
+
427
+ inputs = create_rag_prompt(contexts, question)
428
+
429
+ outputs = llm.generate([inputs], sampling_params)
430
+
431
+ print(outputs[0].outputs[0].text)
432
+ # <<References>>
433
+ # 2
434
+ #
435
+ # <<Answer>>
436
+ # The primary income balance of Japan is currently 4.4 billion yen.
437
+
438
+ ```
439
+
440
+ </details>
441
+ <br/>
442
+
443
+ # Feature: Q&A generation
444
 
445
  This model can also generate questions and answers based on a piece of text. This can be useful for pre-indexing a database or fine-tuning IR models that will then be used for RAG.
446
 
447
+ <details>
448
+ <summary>Prompt style</summary>
449
+
450
+ ### Input:
451
+ ```markdown
452
+ <<Q&A Generation Context>>
453
+ Japan's current account surplus in July was 3.2 trillion yen, the highest monthly surplus on record for the month of July.
454
+ However, the surplus continues to be driven by the primary income balance, which recorded a surplus of 4.4 trillion yen in July, the highest monthly figure on record.
455
+ ```
456
+
457
+ ### Output:
458
+
459
+ ```markdown
460
+ <<Question>>
461
+ What is Japan's current account surplus in July?
462
+
463
+ <<Answer>>
464
+ 3.2 trillion yen
465
+ ```
466
+
467
+ </details>
468
+
469
+ <details>
470
+ <summary>Python code</summary>
471
+
472
+ ```python
473
+ from vllm import LLM, SamplingParams
474
+
475
+ llm = LLM(model="lightblue/kurage-ja")
476
+ sampling_params = SamplingParams(temperature=0.2, top_p=0.95, max_tokens=128)
477
+
478
+ context = "Finance Minister Shunichi Suzuki appointed Kenji Suwazono, former Director-General of the Customs and Tariff Bureau at the Ministry of Finance, as the new Executive Director of the Bank of Japan effective the 10th. Suwazono succeeds Masaaki Kaizuka, whose term ended on the 9th, and his term will last for four years.",
479
+
480
+ def create_qagen_prompt(context):
481
+
482
+ str_inputs = f"""<<Q&A Generation Context>>
483
+ {context}"""
484
+
485
+ chat = [
486
+ {"role": "user", "content": str_inputs},
487
+ ]
488
+
489
+ return llm.llm_engine.tokenizer.tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
490
+
491
+ outputs = llm.generate([create_qagen_prompt(context)], sampling_params)
492
+
493
+ print("\n\n".join([o.outputs[0].text for o in outputs]))
494
+ # <<Question>>
495
+ # Who was appointed as the new Executive Director of the Bank of Japan by Finance Minister Shunichi Suzuki?
496
+ #
497
+ # <<Answer>>
498
+ # Kenji Suwazono
499
+ ```
500
+
501
+ </details>
502
+
503
+ <br/>
504
 
505
  # Training data
506