This commit is contained in:
xxupiano 2021-09-12 20:22:08 +08:00
parent 80f657949f
commit 67c872c161
3 changed files with 71 additions and 47 deletions

View File

@ -40,48 +40,60 @@ DeepKE 提供了多种知识抽取模型。
## 在线演示
演示的demo地址
1.NER
1. RE
```
REGULAR
```
```
1.REGULAR
2.FEW-SHOT
3.DOCUMENT
```
2.RE
2. NER
1.REGULAR
2.FEW-SHOT
3.DOCUMENT
```
REGULAR
```
3.AE
3. AE
## 快速上手
1.RE
1. RE
数据为csv文件样式范例为
数据为csv文件样式范例为
sentence|relation|head|head_offset|tail|tail_offset
:---:|:---:|:---:|:---:|:---:|:---:
《岳父也是爹》是王军执导的电视剧,由马恩然、范明主演。|导演|岳父也是爹|1|王军|8
《九玄珠》是在纵横中文网连载的一部小说,作者是龙马。|连载网站|九玄珠|1|纵横中文网|7
提起杭州的美景,西湖总是第一个映入脑海的词语。|所在城市|西湖|8|杭州|2
| Sentence | Relation | Head | Head_offset | Tail | Tail_offset |
| :----------------------------------------------------: | :------: | :--------: | :---------: | :--------: | :---------: |
| 《岳父也是爹》是王军执导的电视剧,由马恩然、范明主演。 | 导演 | 岳父也是爹 | 1 | 王军 | 8 |
| 《九玄珠》是在纵横中文网连载的一部小说,作者是龙马。 | 连载网站 | 九玄珠 | 1 | 纵横中文网 | 7 |
| 提起杭州的美景,西湖总是第一个映入脑海的词语。 | 所在城市 | 西湖 | 8 | 杭州 | 2 |
具体流程请进入具体的README中RE包括了以下三个子功能
具体流程请进入详细的README中RE包括了以下三个子功能
**[REGULAR](https://github.com/zjunlp/deepke/blob/test_new_deepke/example/re/regular/README.md)**
**[REGULAR](https://github.com/zjunlp/deepke/blob/test_new_deepke/example/re/regular/README.md)**
FEW-SHOT
FEW-SHOT
DOCUMENT
DOCUMENT
2.NER
2. NER
**[REGULAR](https://github.com/zjunlp/deepke/blob/test_new_deepke/example/ner/regular/README.md)**
数据为txt文件样式范例为
3.AE
| sentence | Person | Location | Organization | Miscellaneous |
| :----------------------------------------------------------: | :----------------------------------: | :---------------: | :-------------------------: | :-------------------: |
| Australian Tom Moody took six for 82 but Chris Adams, 123, and Tim O'Gorman, 109, took Derbyshire to 471 and a first innings lead of 233. | Tom Moody, Chris Adams, Tim O'Gorman | / | Derbysire | Australian |
| Irene, a master student in Zhejiang University, Hangzhou, is traveling in Warsaw for Chopin Music Festival. | Irene | Hangzhou, Warsaw | Zhejiang University | Chopin Music Festival |
| It was one o'clock when we left Lauriston Gardens and Sherlock Holmes led me to Metropolitan Police Service. | Sherlock Holmes | Lauriston Gardens | Metropolitan Police Service | / |
具体流程请进入详细的README中
**[REGULAR](https://github.com/zjunlp/deepke/blob/test_new_deepke/example/ner/regular/README.md)**
3. AE
## 模型架构
Deepke的架构图如下所示

View File

@ -1,5 +1,17 @@
# 快速上手
## 环境依赖
> python >= 3.7
- pytorch-transformers==1.2.0
- torch==1.2.0
- seqeval==0.0.5
- tqdm==4.31.1
- nltk==3.4.5
## 克隆代码
```
@ -8,34 +20,34 @@ git clone git@github.com:zjunlp/DeepKE.git
## 配置环境
## 使用pip安装
创建python虚拟环境python>=3.7
首先创建python虚拟环境再进入虚拟环境
安装依赖库
```
pip install -r requirements.txt
```
- 安装依赖:`pip install -r requirements.txt`
## 使用工具
## 使用数据进行训练预测
先进行训练训练后的模型参数保存在out_ner文件夹中
- 存放数据:在`data`文件夹下存放数据集。主要有三个文件:
- `train.txt`:存放训练数据集
- `valid.txt`:存放验证数据集
- `test.txt`:存放测试数据集
```
python run.py --data_dir=data/ --bert_model=bert-base-cased --task_name=ner --output_dir=out_ner --max_seq_length=128 --do_train --num_train_epochs 5 --do_eval --warmup_proportion=0.1
```
- 先进行训练训练后的模型参数保存在out_ner文件夹中
再进行预测<br>
```
python run.py --data_dir=data/ --bert_model=bert-base-cased --task_name=ner --output_dir=out_ner --max_seq_length=128 --do_train --num_train_epochs 5 --do_eval --warmup_proportion=0.1
```
执行以下命令运行示例
- 再进行预测
- 执行以下命令运行示例`python predict.py`
- 如果需要指定NER的文本可以利用--text参数指定
````
python predict.py --text="It was one o'clock when we left Lauriston Gardens and Sherlock Holmes led me to Metropolitan Police Service.."
````
```
python predict.py
```
如果需要指定NER的文本可以利用--text参数指定
```
python predict.py --text="Irene, a master student in Zhejiang University, Hangzhou, is traveling in Warsaw for Chopin Music Festival."
```

View File

@ -19,7 +19,7 @@ git clone git@github.com:zjunlp/DeepKE.git
```
### 使用pip安装
首先创建python虚拟环境再进入虚拟环境,然
首先创建python虚拟环境再进入虚拟环境
- 安装依赖: ```pip install -r requirements.txt```