ghh001 commited on
Commit
642c50f
1 Parent(s): 18076c6
Files changed (2) hide show
  1. README.md +23 -17
  2. README_CN.md +18 -17
README.md CHANGED
@@ -7,23 +7,8 @@ Compared to zjunlp/knowlm-13b-zhixi, zjunlp/knowlm-13b-ie exhibits slightly stro
7
  zjunlp/knowlm-13b-ie samples around 10% of the data from Chinese-English information extraction datasets, which then undergo negative sampling. For instance, if dataset A contains labels [a, b, c, d, e, f], we first sample 10% of the data from A. For a given sample 's', it might only contain labels a and b. We randomly add relationships that it doesn't originally have, such as c and d, from the specified list of relation candidates. When encountering these additional relationships, the model might output text similar to 'NAN'.This method equips the model with the ability to generate 'NAN' outputs to a certain extent, enhancing its information extraction capability while weakening its generalization ability.
8
 
9
 
10
- # 2.Usage
11
- We provide a script, [inference.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/src/inference.py), for direct inference using the `zjunlp/knowlm-13b-ie model``. Please refer to the README.md at https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/ for environment configuration and other details.
12
 
13
- ```bash
14
- CUDA_VISIBLE_DEVICES="0" python src/inference.py \
15
- --model_name_or_path 'models/knowlm-13b-ie' \
16
- --model_name 'llama' \
17
- --input_file 'data/NER/processed.json' \
18
- --output_file 'results/ner_test.json' \
19
- --fp16
20
- ```
21
-
22
- If GPU memory is not enough, you can use `--bits 8` or `--bits 4`.
23
-
24
-
25
-
26
- # 3.IE template
27
  NER supports the following templates:
28
  ```python
29
  entity_template_zh = {
@@ -55,7 +40,10 @@ Both the schema and format placeholders ({s_schema} and {s_format}) are embedded
55
 
56
  For a more comprehensive understanding of the templates, please refer to the files [ner_template.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/ner_template.py)、[re_template.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/re_template.py)、[ee_template.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/ee_template.py) .
57
 
58
- # 4.Convert script
 
 
 
59
 
60
  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.
61
 
@@ -71,6 +59,24 @@ python kg2instruction/convert.py \
71
  --all
72
  ```
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  # 5.Evaluate
75
 
76
  We provide a script at [evaluate.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/evaluate.py) to convert the string output of the model into a list and calculate F1
 
7
  zjunlp/knowlm-13b-ie samples around 10% of the data from Chinese-English information extraction datasets, which then undergo negative sampling. For instance, if dataset A contains labels [a, b, c, d, e, f], we first sample 10% of the data from A. For a given sample 's', it might only contain labels a and b. We randomly add relationships that it doesn't originally have, such as c and d, from the specified list of relation candidates. When encountering these additional relationships, the model might output text similar to 'NAN'.This method equips the model with the ability to generate 'NAN' outputs to a certain extent, enhancing its information extraction capability while weakening its generalization ability.
8
 
9
 
 
 
10
 
11
+ # 2.IE template
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  NER supports the following templates:
13
  ```python
14
  entity_template_zh = {
 
40
 
41
  For a more comprehensive understanding of the templates, please refer to the files [ner_template.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/ner_template.py)、[re_template.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/re_template.py)、[ee_template.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/ee_template.py) .
42
 
43
+
44
+
45
+
46
+ # 3.Convert script
47
 
48
  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.
49
 
 
59
  --all
60
  ```
61
 
62
+
63
+
64
+ # 4.Usage
65
+ We provide a script, [inference.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/src/inference.py), for direct inference using the `zjunlp/knowlm-13b-ie model`. Please refer to the [README.md](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/README.md) for environment configuration and other details.
66
+
67
+ ```bash
68
+ CUDA_VISIBLE_DEVICES="0" python src/inference.py \
69
+ --model_name_or_path 'models/knowlm-13b-ie' \
70
+ --model_name 'llama' \
71
+ --input_file 'data/NER/processed.json' \
72
+ --output_file 'results/ner_test.json' \
73
+ --fp16
74
+ ```
75
+
76
+ If GPU memory is not enough, you can use `--bits 8` or `--bits 4`.
77
+
78
+
79
+
80
  # 5.Evaluate
81
 
82
  We provide a script at [evaluate.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/evaluate.py) to convert the string output of the model into a list and calculate F1
README_CN.md CHANGED
@@ -5,23 +5,8 @@
5
  zjunlp/knowlm-13b-ie 从中英文信息抽取数据集中采样约 10% 的数据,然后进行负采样。例如,如果数据集 A 包含标签 [a,b,c,d,e,f],我们首先从 A 中采样出 10% 的数据。对于给定的样本 s,它可能只包含标签 a 和 b。我们随机地添加原本没有的关系,比如来自指定关系候选列表的 c 和 d。当遇到这些额外的关系时,模型可能会输出类似 'NAN' 的文本。这种方法使模型在一定程度上具备生成 'NAN' 输出的能力,增强了其信息抽取能力,但削弱了其泛化能力。
6
 
7
 
8
- # 2. 使用
9
- 我们提供了可直接使用 `zjunlp/knowlm-13b-ie` 模型进行推理的脚本[inference.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/src/inference.py), 请参考 https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/README.md 配置环境等。
10
 
11
- ```bash
12
- CUDA_VISIBLE_DEVICES="0" python src/inference.py \
13
- --model_name_or_path 'models/knowlm-13b-ie' \
14
- --model_name 'llama' \
15
- --input_file 'data/NER/processed.json' \
16
- --output_file 'results/ner_test.json' \
17
- --fp16
18
- ```
19
-
20
- 如果GPU显存不足够, 可以采用 `--bits 8` 或 `--bits 4`
21
-
22
-
23
-
24
- # 3. 信息抽取模板
25
  命名实体识别(NER)支持以下模板:
26
 
27
  ```python
@@ -56,7 +41,7 @@ entity_int_out_format_en = {
56
 
57
 
58
 
59
- # 4. 转换脚本
60
 
61
  提供一个名为 [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) 目录中包含了每个任务的预期数据格式。
62
 
@@ -71,6 +56,22 @@ python kg2instruction/convert.py \
71
  --all
72
  ```
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  # 5. 评估
75
  我们提供一个位于 [evaluate.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/evaluate.py) 的脚本,用于将模型的字符串输出转换为列表并计算 F1 分数。
76
 
 
5
  zjunlp/knowlm-13b-ie 从中英文信息抽取数据集中采样约 10% 的数据,然后进行负采样。例如,如果数据集 A 包含标签 [a,b,c,d,e,f],我们首先从 A 中采样出 10% 的数据。对于给定的样本 s,它可能只包含标签 a 和 b。我们随机地添加原本没有的关系,比如来自指定关系候选列表的 c 和 d。当遇到这些额外的关系时,模型可能会输出类似 'NAN' 的文本。这种方法使模型在一定程度上具备生成 'NAN' 输出的能力,增强了其信息抽取能力,但削弱了其泛化能力。
6
 
7
 
 
 
8
 
9
+ # 2. 信息抽取模板
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  命名实体识别(NER)支持以下模板:
11
 
12
  ```python
 
41
 
42
 
43
 
44
+ # 3. 转换脚本
45
 
46
  提供一个名为 [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) 目录中包含了每个任务的预期数据格式。
47
 
 
56
  --all
57
  ```
58
 
59
+
60
+ # 4. 使用
61
+ 我们提供了可直接使用 `zjunlp/knowlm-13b-ie` 模型进行推理的脚本[inference.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/src/inference.py), 请参考 [README.md](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/README.md) 配置环境等。
62
+
63
+ ```bash
64
+ CUDA_VISIBLE_DEVICES="0" python src/inference.py \
65
+ --model_name_or_path 'models/knowlm-13b-ie' \
66
+ --model_name 'llama' \
67
+ --input_file 'data/NER/processed.json' \
68
+ --output_file 'results/ner_test.json' \
69
+ --fp16
70
+ ```
71
+
72
+ 如果GPU显存不足够, 可以采用 `--bits 8` 或 `--bits 4`
73
+
74
+
75
  # 5. 评估
76
  我们提供一个位于 [evaluate.py](https://github.com/zjunlp/DeepKE/blob/main/example/llm/InstructKGC/kg2instruction/evaluate.py) 的脚本,用于将模型的字符串输出转换为列表并计算 F1 分数。
77