add convert_test.py
Browse files- README.md +12 -1
- README_CN.md +17 -5
README.md
CHANGED
@@ -67,7 +67,7 @@ Here [schema](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC
|
|
67 |
|
68 |
# 4.Convert script
|
69 |
|
70 |
-
A script named [convert.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/convert.py) is provided to facilitate the uniform conversion of data into KnowLM instructions. The [data](https://github.com/zjunlp/DeepKE/tree/main/example/llm/InstructKGC/data) directory contains the expected data format for each task before executing convert.py.
|
71 |
|
72 |
|
73 |
```bash
|
@@ -81,6 +81,17 @@ python kg2instruction/convert.py \
|
|
81 |
--all
|
82 |
```
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
|
86 |
# 5.Usage
|
|
|
67 |
|
68 |
# 4.Convert script
|
69 |
|
70 |
+
A script named [convert.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/convert.py)、[convert_test.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/convert_test.py) is provided to facilitate the uniform conversion of data into KnowLM instructions. The [data](https://github.com/zjunlp/DeepKE/tree/main/example/llm/InstructKGC/data) directory contains the expected data format for each task before executing convert.py.
|
71 |
|
72 |
|
73 |
```bash
|
|
|
81 |
--all
|
82 |
```
|
83 |
|
84 |
+
[convert_test.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/convert_test.py) does not require data to have label (`entity`, `relation`, `event`) fields, only needs to have an `input` field and provide a `schema_path` is suitable for processing test data.
|
85 |
+
|
86 |
+
```bash
|
87 |
+
python kg2instruction/convert_test.py \
|
88 |
+
--src_path data/NER/sample.json \
|
89 |
+
--tgt_path data/NER/processed.json \
|
90 |
+
--schema_path data/NER/schema.json \
|
91 |
+
--language zh \
|
92 |
+
--task NER \
|
93 |
+
--sample 0
|
94 |
+
```
|
95 |
|
96 |
|
97 |
# 5.Usage
|
README_CN.md
CHANGED
@@ -65,17 +65,29 @@ relation_int_out_format_en = {
|
|
65 |
|
66 |
# 4. 转换脚本
|
67 |
|
68 |
-
提供一个名为 [convert.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/convert.py) 的脚本,用于将数据统一转换为可以直接输入 KnowLM 的指令。在执行 convert.py 之前,请参考 [data](https://github.com/zjunlp/DeepKE/tree/main/example/llm/InstructKGC/data) 目录中包含了每个任务的预期数据格式。
|
69 |
|
70 |
```bash
|
71 |
python kg2instruction/convert.py \
|
72 |
--src_path data/NER/sample.json \
|
73 |
--tgt_path data/NER/processed.json \
|
74 |
--schema_path data/NER/schema.json \
|
75 |
-
--language zh \
|
76 |
-
--task NER \
|
77 |
-
--sample 0 \
|
78 |
-
--all
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
```
|
80 |
|
81 |
|
|
|
65 |
|
66 |
# 4. 转换脚本
|
67 |
|
68 |
+
提供一个名为 [convert.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/convert.py)、[convert_test.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/convert_test.py) 的脚本,用于将数据统一转换为可以直接输入 KnowLM 的指令。在执行 convert.py 之前,请参考 [data](https://github.com/zjunlp/DeepKE/tree/main/example/llm/InstructKGC/data) 目录中包含了每个任务的预期数据格式。
|
69 |
|
70 |
```bash
|
71 |
python kg2instruction/convert.py \
|
72 |
--src_path data/NER/sample.json \
|
73 |
--tgt_path data/NER/processed.json \
|
74 |
--schema_path data/NER/schema.json \
|
75 |
+
--language zh \ # 不同语言使用的template及转换脚本不同
|
76 |
+
--task NER \ # ['RE', 'NER', 'EE']三种任务
|
77 |
+
--sample 0 \ # 若为-1, 则从4种指令和4种输出格式中随机采样其中一种, 否则即为指定的指令格式, -1<=sample<=3
|
78 |
+
--all # 是否将指令中指定的抽取类型列表设置为全部schema
|
79 |
+
```
|
80 |
+
|
81 |
+
[convert_test.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/convert_test.py) 不要求数据具有标签(`entity`、`relation`、`event`)字段, 只需要具有 `input` 字段, 以及提供 `schema_path`, 适合用来处理测试数据。
|
82 |
+
|
83 |
+
```bash
|
84 |
+
python kg2instruction/convert_test.py \
|
85 |
+
--src_path data/NER/sample.json \
|
86 |
+
--tgt_path data/NER/processed.json \
|
87 |
+
--schema_path data/NER/schema.json \
|
88 |
+
--language zh \
|
89 |
+
--task NER \
|
90 |
+
--sample 0
|
91 |
```
|
92 |
|
93 |
|