Datasets:
Update README.md
Browse files
README.md
CHANGED
@@ -7,84 +7,6 @@ This dataset was created by automatically translating "OpenAssistant/oasst1" int
|
|
7 |
The "ng_translation" flag indicates that the translation was not successful, and "1" means that the translation failed.
|
8 |
Therefore, for data with "1", "text" and "text_en" contain the same text.
|
9 |
|
10 |
-
以下のコードを用いることで、 Instruction と Output (prompterの命令とassistantの回答)の形式に変換することができます。
|
11 |
-
ファインチューニングで使用する場合はこちらのコードで変換して下さい。
|
12 |
-
|
13 |
-
変換コード参考
|
14 |
-
https://github.com/h2oai/h2o-llmstudio/blob/5ebfd3879e226b4e1afd0a0b45eb632e60412129/app_utils/utils.py#L1888
|
15 |
-
|
16 |
-
```python
|
17 |
-
pip install huggingface-hub
|
18 |
-
pip install datasets
|
19 |
-
```
|
20 |
-
|
21 |
-
```python
|
22 |
-
from datasets import load_dataset
|
23 |
-
import pandas as pd
|
24 |
-
import os
|
25 |
-
import json
|
26 |
-
|
27 |
-
|
28 |
-
# oasst1のオリジナルデータのロード
|
29 |
-
ds = load_dataset("OpenAssistant/oasst1")
|
30 |
-
train = ds["train"].to_pandas()
|
31 |
-
val = ds["validation"].to_pandas()
|
32 |
-
|
33 |
-
df_origin = pd.concat([train, val], axis=0).reset_index(drop=True)
|
34 |
-
|
35 |
-
# oasst1日本語翻訳データの読み込み
|
36 |
-
df_ja = pd.read_json("oasst1_ja_89k.json")
|
37 |
-
|
38 |
-
# oasst1のオリジナルデータと日本語翻訳データのマージ
|
39 |
-
df = pd.merge(df_origin, df_ja[["message_id", "text_ja"]], on="message_id", how="left").copy()
|
40 |
-
df["text"] = df["text_ja"]
|
41 |
-
|
42 |
-
df_assistant = df[(df.role == "assistant")].copy()
|
43 |
-
df_prompter = df[(df.role == "prompter")].copy()
|
44 |
-
df_prompter = df_prompter.set_index("message_id")
|
45 |
-
df_assistant["output"] = df_assistant["text"].values
|
46 |
-
|
47 |
-
inputs = []
|
48 |
-
parent_ids = []
|
49 |
-
for _, row in df_assistant.iterrows():
|
50 |
-
input = df_prompter.loc[row.parent_id]
|
51 |
-
inputs.append(input.text)
|
52 |
-
parent_ids.append(input.parent_id)
|
53 |
-
|
54 |
-
df_assistant["instruction"] = inputs
|
55 |
-
df_assistant["parent_id"] = parent_ids
|
56 |
-
|
57 |
-
df_assistant = df_assistant[
|
58 |
-
["instruction", "output", "message_id", "parent_id", "lang", "rank"]
|
59 |
-
].rename(columns={"message_id": "id"})
|
60 |
-
|
61 |
-
|
62 |
-
# 翻訳タスクのみデータに異常があるので除外
|
63 |
-
df_assistant2 = df_assistant[~df_assistant["instruction"].str.contains("翻訳")]
|
64 |
-
|
65 |
-
|
66 |
-
# これ以下でjsonファイルへ書き出し---------------
|
67 |
-
|
68 |
-
learn_datas = []
|
69 |
-
input_list = []
|
70 |
-
|
71 |
-
for n in range(len(df_assistant2)):
|
72 |
-
learn_data = {
|
73 |
-
"instruction": str(df_assistant2.iloc[n, 0]),
|
74 |
-
"input": "",
|
75 |
-
"output": ""
|
76 |
-
}
|
77 |
-
|
78 |
-
input_list.append(df_assistant2.iloc[n, 0])
|
79 |
-
learn_data["input"] = ""
|
80 |
-
learn_data["output"] = str(df_assistant2.iloc[n, 1])
|
81 |
-
|
82 |
-
learn_datas.append(learn_data)
|
83 |
-
|
84 |
-
json_learn_data = json.dumps(learn_datas, indent=4, ensure_ascii=False)
|
85 |
-
with open('oasst1_ja_51k_converted.json', 'w', encoding="utf-8") as f:
|
86 |
-
f.write(json_learn_data)
|
87 |
-
```
|
88 |
|
89 |
oasst1-ja-89k Repository
|
90 |
https://github.com/kunishou/oasst1-89k-ja
|
|
|
7 |
The "ng_translation" flag indicates that the translation was not successful, and "1" means that the translation failed.
|
8 |
Therefore, for data with "1", "text" and "text_en" contain the same text.
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
oasst1-ja-89k Repository
|
12 |
https://github.com/kunishou/oasst1-89k-ja
|