ptrdvn commited on
Commit
afed35f
1 Parent(s): 713ec04

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +520 -0
README.md ADDED
@@ -0,0 +1,520 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - ar
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - RAG
8
+ ---
9
+ # Kurage
10
+
11
+ <p align="center">
12
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/64b63f8ad57e02621dc93c8b/_SkPhhsg40juscfv9dU4v.jpeg" alt="An anime image of a pink and blue jellyfish surrounded by bubbles" width=500 style="border: 5px solid #3d3c3c"/>
13
+ </p>
14
+
15
+ Kurage is a multipurpose RAG model from [Lightblue](https://huggingface.co/lightblue) based on the Qwen 2 model ([Qwen/Qwen2-7B-Instruct](https://huggingface.co/Qwen/Qwen2-7B-Instruct)).
16
+
17
+ This version of the model has been trained to perform RAG in Arabic.
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](https://huggingface.co/collections/lightblue/kurage-66e40cbcc3b3a128bdf031f2). A multilingual model is coming soon!
30
+
31
+ This model was trained using a ml.gu7ef.8xlarge-gu100 instance on [Platform For AI](https://www.alibabacloud.com/en/product/machine-learning) from [Alibaba Cloud](https://www.alibabacloud.com/).
32
+
33
+ # Basic usage
34
+
35
+ To use the model for basic multi-chunk RAG, you can use the following code:
36
+
37
+ NOTE - Change the model name to that of this repository to use this model with Arabic questions (e.g. "lightblue/kurage-en" → "lightblue/kurage-ar").
38
+
39
+ ```python
40
+ from vllm import LLM, SamplingParams
41
+
42
+ llm = LLM(model="lightblue/kurage-en")
43
+ sampling_params = SamplingParams(temperature=0.2, top_p=0.95, max_tokens=128)
44
+
45
+ def create_rag_prompt(contexts, question):
46
+
47
+ context_str = "\n\n".join([f"<<Chunk {i+1}>>\n{x}" for i, x in enumerate(contexts)])
48
+
49
+ str_inputs = f"""{context_str}
50
+
51
+ <<Question>>
52
+ {question}"""
53
+
54
+ chat = [
55
+ {"role": "user", "content": str_inputs},
56
+ ]
57
+
58
+ return llm.llm_engine.tokenizer.tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
59
+
60
+ contexts = [
61
+ "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.",
62
+ "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.",
63
+ "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.",
64
+ "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."
65
+ ]
66
+
67
+ question = "What is Japan's primary income balance currently?"
68
+
69
+ inputs = create_rag_prompt(contexts, question)
70
+
71
+ outputs = llm.generate([inputs], sampling_params)
72
+
73
+ print(outputs[0].outputs[0].text)
74
+ # <<References>>
75
+ # 2
76
+ #
77
+ # <<Answer>>
78
+ # 4.4 trillion yen.
79
+ ```
80
+
81
+ # Feature: Multi-chunk RAG
82
+
83
+ 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.
84
+
85
+ <details>
86
+ <summary>Prompt style</summary>
87
+
88
+ ### Input:
89
+ ```markdown
90
+ <<Chunk 1>>
91
+ 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.
92
+ 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.
93
+
94
+ <<Chunk 2>>
95
+ Japan's current account surplus in July was 3.2 trillion yen, the highest monthly surplus on record for the month of July.
96
+ 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.
97
+
98
+ <<Chunk 3>>
99
+ 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.
100
+
101
+ <<Chunk 4>>
102
+ 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.
103
+
104
+ <<Question>>
105
+ What is Japan's primary income balance currently?
106
+ ```
107
+
108
+ ### Output:
109
+
110
+ ```markdown
111
+ <<References>>
112
+ 2
113
+
114
+ <<Answer>>
115
+ 4.4 trillion yen
116
+ ```
117
+
118
+ </details>
119
+
120
+ <details>
121
+ <summary>Python code</summary>
122
+
123
+ ```python
124
+ from vllm import LLM, SamplingParams
125
+
126
+ llm = LLM(model="lightblue/kurage-en")
127
+ sampling_params = SamplingParams(temperature=0.2, top_p=0.95, max_tokens=128)
128
+
129
+ def create_rag_prompt(contexts, question):
130
+
131
+ context_str = "\n\n".join([f"<<Chunk {i+1}>>\n{x}" for i, x in enumerate(contexts)])
132
+
133
+ str_inputs = f"""{context_str}
134
+
135
+ <<Question>>
136
+ {question}"""
137
+
138
+ chat = [
139
+ {"role": "user", "content": str_inputs},
140
+ ]
141
+
142
+ return llm.llm_engine.tokenizer.tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
143
+
144
+ contexts = [
145
+ "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.",
146
+ "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.",
147
+ "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.",
148
+ "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."
149
+ ]
150
+
151
+ question = "What is Japan's primary income balance currently?"
152
+
153
+ inputs = create_rag_prompt(contexts, question)
154
+
155
+ outputs = llm.generate([inputs], sampling_params)
156
+
157
+ print(outputs[0].outputs[0].text)
158
+ # <<References>>
159
+ # 2
160
+ #
161
+ # <<Answer>>
162
+ # 4.4 trillion yen.
163
+
164
+ ```
165
+
166
+ </details>
167
+
168
+ <br/>
169
+
170
+ # Feature: Single-chunk RAG
171
+
172
+ 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.
173
+
174
+ <details>
175
+ <summary>Prompt style</summary>
176
+
177
+
178
+
179
+ ### Irrelevant context input:
180
+ ```markdown
181
+ <<Chunk 1>>
182
+ 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.
183
+ 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.
184
+
185
+ <<Question>>
186
+ What is Japan's primary income balance currently?
187
+ ```
188
+
189
+ ### Irrelevant context output:
190
+
191
+ ```markdown
192
+ <<References>>
193
+ None
194
+ ```
195
+
196
+
197
+ ### Relevant context input:
198
+ ```markdown
199
+ <<Chunk 1>>
200
+ Japan's current account surplus in July was 3.2 trillion yen, the highest monthly surplus on record for the month of July.
201
+ 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.
202
+
203
+ <<Question>>
204
+ What is Japan's primary income balance currently?
205
+ ```
206
+
207
+ ### Relevant context output:
208
+
209
+ ```markdown
210
+ <<References>>
211
+ 1
212
+
213
+ <<Answer>>
214
+ 4.4 trillion yen
215
+ ```
216
+
217
+ </details>
218
+
219
+ <details>
220
+ <summary>Python code</summary>
221
+
222
+ ```python
223
+ from vllm import LLM, SamplingParams
224
+
225
+ llm = LLM(model="lightblue/kurage-en")
226
+ sampling_params = SamplingParams(temperature=0.2, top_p=0.95, max_tokens=128)
227
+
228
+ def create_rag_prompt(contexts, question):
229
+
230
+ context_str = "\n\n".join([f"<<Chunk {i+1}>>\n{x}" for i, x in enumerate(contexts)])
231
+
232
+ str_inputs = f"""{context_str}
233
+
234
+ <<Question>>
235
+ {question}"""
236
+
237
+ chat = [
238
+ {"role": "user", "content": str_inputs},
239
+ ]
240
+
241
+ return llm.llm_engine.tokenizer.tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
242
+
243
+ contexts = [
244
+ "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.",
245
+ "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.",
246
+ "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.",
247
+ "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."
248
+ ]
249
+
250
+ question = "What is Japan's primary income balance currently?"
251
+
252
+ outputs = llm.generate([create_rag_prompt([x], question) for x in contexts], sampling_params)
253
+
254
+ print("\n\n".join([f"{i+1}.\n{o.outputs[0].text}" for i, o in enumerate(outputs)]))
255
+ # 1.
256
+ # <<References>>
257
+ # None
258
+
259
+ # 2.
260
+ # <<References>>
261
+ # 1
262
+ #
263
+ # <<Answer>>
264
+ # 4.4 trillion yen.
265
+
266
+ # 3.
267
+ # <<References>>
268
+ # None
269
+
270
+ # 4.
271
+ # <<References>>
272
+ # None
273
+
274
+ ```
275
+
276
+ </details>
277
+ <br/>
278
+
279
+ # Feature: Answer extension
280
+
281
+ 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.
282
+
283
+ <details>
284
+ <summary>Prompt style</summary>
285
+
286
+ ### Input:
287
+ ```markdown
288
+ <<Chunk 1>>
289
+ Japan's current account surplus in July was 3.2 trillion yen, the highest monthly surplus on record for the month of July.
290
+ 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.
291
+
292
+ <<Question>>
293
+ What is Japan's primary income balance currently? <<Long>>
294
+ ```
295
+
296
+ ### Relevant context output:
297
+
298
+ ```markdown
299
+ <<References>>
300
+ 1
301
+
302
+ <<Answer>>
303
+ 4.4 trillion yen
304
+ ```
305
+
306
+ </details>
307
+
308
+ <details>
309
+ <summary>Python code</summary>
310
+
311
+ ```python
312
+ from vllm import LLM, SamplingParams
313
+
314
+ llm = LLM(model="lightblue/kurage-en")
315
+ sampling_params = SamplingParams(temperature=0.2, top_p=0.95, max_tokens=128)
316
+
317
+ def create_rag_prompt(contexts, question):
318
+
319
+ context_str = "\n\n".join([f"<<Chunk {i+1}>>\n{x}" for i, x in enumerate(contexts)])
320
+
321
+ str_inputs = f"""{context_str}
322
+
323
+ <<Question>>
324
+ {question}"""
325
+
326
+ chat = [
327
+ {"role": "user", "content": str_inputs},
328
+ ]
329
+
330
+ return llm.llm_engine.tokenizer.tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
331
+
332
+ contexts = [
333
+ "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.",
334
+ "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.",
335
+ "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.",
336
+ "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."
337
+ ]
338
+
339
+ question = "What is Japan's primary income balance currently? <<Long>>"
340
+
341
+ inputs = create_rag_prompt(contexts, question)
342
+
343
+ outputs = llm.generate([inputs], sampling_params)
344
+
345
+ print(outputs[0].outputs[0].text)
346
+
347
+ # <<References>>
348
+ # 2
349
+ #
350
+ # <<Answer>>
351
+ # Japan's primary income balance recorded a surplus of 4.4 trillion yen in July.
352
+ ```
353
+
354
+ </details>
355
+ <br/>
356
+
357
+ # Feature: Multilinguality
358
+
359
+ We have trained our model to be able to answer questions in Arabic based on texts in other languages too!
360
+
361
+ (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.)
362
+
363
+ <details>
364
+ <summary>Prompt style</summary>
365
+
366
+ ### Input:
367
+ ```markdown
368
+ <<Chunk 1>>
369
+ 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.
370
+ 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.
371
+
372
+ <<Chunk 2>>
373
+ 7月の日本の経常収支は3.2兆円の黒字となり、7月としては過去最高の黒字額を記録した。しかし、黒字に貢献しているのは相変わらず第一次所得収支の黒字で、7月は4.4兆円の黒字を記録し、1カ���の黒字額としては過去最高を記録した。
374
+
375
+ <<Chunk 3>>
376
+ รัฐมนตรีว่าการกระทรวงการคลัง ชุนอิจิ สุซูกิ ได้แต่งตั้ง เค็นจิ สุวาโซโนะ อดีตอธิบดีกรมศุลกากรและภาษีสิ่งนำเข้าแห่งกระทรวงการคลัง เป็นกรรมการบริหารธนาคารแห่งประเทศญี่ปุ่นคนใหม่ มีผลตั้งแต่วันที่ 10 สุวาโซโนะจะมาแทน มาซาอะกิ ไคซูกะ ที่พ้นวาระไปในวันที่ 9 โดยมีวาระ 4 ปี
377
+
378
+ <<Chunk 4>>
379
+ 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.
380
+
381
+ <<Question>>
382
+ What is Japan's primary income balance currently?
383
+ ```
384
+
385
+ ### Output:
386
+
387
+ ```markdown
388
+ <<References>>
389
+ 2
390
+
391
+ <<Answer>>
392
+ 4.4 trillion yen
393
+ ```
394
+
395
+ </details>
396
+
397
+ <details>
398
+ <summary>Python code</summary>
399
+
400
+ ```python
401
+
402
+ from vllm import LLM, SamplingParams
403
+
404
+ llm = LLM(model="lightblue/kurage-en")
405
+ sampling_params = SamplingParams(temperature=0.2, top_p=0.95, max_tokens=128)
406
+
407
+ def create_rag_prompt(contexts, question):
408
+
409
+ context_str = "\n\n".join([f"<<Chunk {i+1}>>\n{x}" for i, x in enumerate(contexts)])
410
+
411
+ str_inputs = f"""{context_str}
412
+
413
+ <<Question>>
414
+ {question}"""
415
+
416
+ chat = [
417
+ {"role": "user", "content": str_inputs},
418
+ ]
419
+
420
+ return llm.llm_engine.tokenizer.tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
421
+
422
+ contexts = [
423
+ "นากากาวะ จุนโกะ สมาชิกคณะกรรมการนโยบายการเงิน ธนาคารแห่งประเทศญี่ปุ่น กล่าวในวันที่ 11 ว่า อัตราดอกเบี้ยที่แท้จริงอยู่ในระดับต่ำมากในปัจจุบัน และกล่าวว่า หากแนวโน้มเศรษฐกิจและราคาของธนาคารกลางญี่ปุ่นเป็นจริงในอนาคต การผ่อนคลายนโยบายการเงินจะถูกปรับโดยพิจารณาจากการบรรลุเป้าหมายด้านราคา",
424
+ "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.",
425
+ "鈴木俊一財務相は10日付で元財務省関税局長の諏訪園健司氏を新しい日銀理事に任命した。9日に任期満了で退任した貝塚正彰前理事の後任で、任期は4年。",
426
+ "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é."
427
+ ]
428
+
429
+ question = "What is Japan's primary income balance currently?"
430
+
431
+ inputs = create_rag_prompt(contexts, question)
432
+
433
+ outputs = llm.generate([inputs], sampling_params)
434
+
435
+ print(outputs[0].outputs[0].text)
436
+ # <<References>>
437
+ # 2
438
+ #
439
+ # <<Answer>>
440
+ # The primary income balance of Japan is currently 4.4 billion yen.
441
+
442
+ ```
443
+
444
+ </details>
445
+ <br/>
446
+
447
+ # Feature: Q&A generation
448
+
449
+ 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.
450
+
451
+ <details>
452
+ <summary>Prompt style</summary>
453
+
454
+ ### Input:
455
+ ```markdown
456
+ <<Q&A Generation Context>>
457
+ Japan's current account surplus in July was 3.2 trillion yen, the highest monthly surplus on record for the month of July.
458
+ 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.
459
+ ```
460
+
461
+ ### Output:
462
+
463
+ ```markdown
464
+ <<Question>>
465
+ What is Japan's current account surplus in July?
466
+
467
+ <<Answer>>
468
+ 3.2 trillion yen
469
+ ```
470
+
471
+ </details>
472
+
473
+ <details>
474
+ <summary>Python code</summary>
475
+
476
+ ```python
477
+ from vllm import LLM, SamplingParams
478
+
479
+ llm = LLM(model="lightblue/kurage-en")
480
+ sampling_params = SamplingParams(temperature=0.2, top_p=0.95, max_tokens=128)
481
+
482
+ 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.",
483
+
484
+ def create_qagen_prompt(context):
485
+
486
+ str_inputs = f"""<<Q&A Generation Context>>
487
+ {context}"""
488
+
489
+ chat = [
490
+ {"role": "user", "content": str_inputs},
491
+ ]
492
+
493
+ return llm.llm_engine.tokenizer.tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
494
+
495
+ outputs = llm.generate([create_qagen_prompt(context)], sampling_params)
496
+
497
+ print("\n\n".join([o.outputs[0].text for o in outputs]))
498
+ # <<Question>>
499
+ # Who was appointed as the new Executive Director of the Bank of Japan by Finance Minister Shunichi Suzuki?
500
+ #
501
+ # <<Answer>>
502
+ # Kenji Suwazono
503
+ ```
504
+
505
+ </details>
506
+
507
+ <br/>
508
+
509
+ # Training data
510
+
511
+ We trained on chunks sourced from the documents in [MADLAD-400](https://huggingface.co/datasets/allenai/MADLAD-400) dataset that
512
+ had been evaluated to contain a higher amount of educational information according to a state-of-the-art LLM.
513
+
514
+ We took chunks of size 250 tokens, 500 tokens, and 1000 tokens randomly for each document.
515
+
516
+ We then used these chunks to generate questions and answers based on this text using a state-of-the-art LLM.
517
+
518
+ Finally, we selected negatives for each chunk using the similarity from the dense embeddings of the [BAAI/bge-m3](https://huggingface.co/BAAI/bge-m3) model.
519
+
520
+ The training data for this model can be found at [lightblue/kurage_training_data](https://huggingface.co/datasets/lightblue/kurage_training_data).