File size: 2,023 Bytes
09aea6b
d709c2e
 
 
 
 
09aea6b
 
d709c2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c58784
d709c2e
 
 
 
3c58784
d709c2e
 
 
3c58784
d709c2e
 
 
3c58784
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d709c2e
d0c8651
53436fe
 
d0c8651
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
language:
- zh
tags:
- infomation extraction
- uie
license: apache-2.0
---

# UIE信息抽取模型(Pytorch)

## 模型介绍

+ [UIE(Universal Information Extraction)](https://arxiv.org/pdf/2203.12277.pdf):Yaojie Lu等人在ACL-2022中提出了通用信息抽取统一框架 `UIE`+ 该框架实现了实体抽取、关系抽取、事件抽取、情感分析等任务的统一建模,并使得不同任务间具备良好的迁移和泛化能力。

+ 为了方便大家使用 `UIE` 的强大能力,[PaddleNLP](https://github.com/PaddlePaddle/PaddleNLP)借鉴该论文的方法,基于 `ERNIE 3.0` 知识增强预训练模型,训练并开源了首个中文通用信息抽取模型 `UIE`+ 该模型可以支持不限定行业领域和抽取目标的关键信息抽取,实现零样本快速冷启动,并具备优秀的小样本微调能力,快速适配特定的抽取目标。

## 使用方法

```commandline
pip install litie
```

```python
from pprint import pprint
from litie.pipelines import UIEPipeline

# 实体识别
schema = ['时间', '选手', '赛事名称'] 
uie = UIEPipeline("xusenlin/uie-base", schema=schema)
pprint(uie("2月8日上午北京冬奥会自由式滑雪女子大跳台决赛中中国选手谷爱凌以188.25分获得金牌!")) # Better print results using pprint

# 输出
[
  {
    "时间": [
      {
        "end": 6,
        "probability": 0.98573786,
        "start": 0,
        "text": "2月8日上午"
      }
    ],
    "赛事名称": [
      {
        "end": 23,
        "probability": 0.8503085,
        "start": 6,
        "text": "北京冬奥会自由式滑雪女子大跳台决赛"
      }
    ],
    "选手": [
      {
        "end": 31,
        "probability": 0.8981544,
        "start": 28,
        "text": "谷爱凌"
      }
    ]
  }
]
```

更多实体抽取和关系抽取模型的使用详见 [litie](https://github.com/xusenlinzy/lit-ie)

## 参考链接

[PaddleNLP](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/model_zoo/uie)