Update README.md
Browse files
README.md
CHANGED
@@ -21,51 +21,38 @@ license: apache-2.0
|
|
21 |
|
22 |
## 使用方法
|
23 |
|
24 |
-
```commandline
|
25 |
-
pip install litie
|
26 |
-
```
|
27 |
|
28 |
```python
|
29 |
-
from
|
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 |
-
"end": 31,
|
59 |
-
"probability": 0.8981544,
|
60 |
-
"start": 28,
|
61 |
-
"text": "谷爱凌"
|
62 |
-
}
|
63 |
-
]
|
64 |
-
}
|
65 |
-
]
|
66 |
```
|
67 |
|
68 |
-
更多实体抽取和关系抽取模型的使用详见 [litie](https://github.com/xusenlinzy/lit-ie)
|
69 |
|
70 |
## 参考链接
|
71 |
|
|
|
21 |
|
22 |
## 使用方法
|
23 |
|
|
|
|
|
|
|
24 |
|
25 |
```python
|
26 |
+
from transformers import AutoModel, AutoTokenizer
|
27 |
+
|
28 |
+
tokenizer = AutoTokenizer.from_pretrained("uie-base", trust_remote_code=True)
|
29 |
+
model = AutoModel.from_pretrained("uie-base", trust_remote_code=True)
|
30 |
+
|
31 |
+
schema = ["时间", "选手", "赛事名称"] # Define the schema for entity extraction
|
32 |
+
print(model.predict(tokenizer, "2月8日上午北京冬奥会自由式滑雪女子大跳台决赛中中国选手谷爱凌以188.25分获得金牌!", schema=schema))
|
33 |
+
|
34 |
+
schema = {'竞赛名称': ['主办方', '承办方', '已举办次数']} # Define the schema for relation extraction
|
35 |
+
model.set_schema(schema)
|
36 |
+
print(model.predict(tokenizer, "2022语言与智能技术竞赛由中国中文信息学会和中国计算机学会联合主办,百度公司、中国中文信息学会评测工作委员会和中国计算机学会自然语言处理专委会承办,已连续举办4届,成为全球最热门的中文NLP赛事之一。"))
|
37 |
+
|
38 |
+
schema = {'地震触发词': ['地震强度', '时间', '震中位置', '震源深度']} # Define the schema for event extraction
|
39 |
+
model.set_schema(schema)
|
40 |
+
print(model.predict(tokenizer, "中国地震台网正式测定:5月16日06时08分在云南临沧市凤庆县(北纬24.34度,东经99.98度)发生3.5级地震,震源深度10千米。"))
|
41 |
+
|
42 |
+
schema = {'评价维度': ['观点词', '情感倾向[正向,负向]']} # Define the schema for opinion extraction
|
43 |
+
model.set_schema(schema)
|
44 |
+
print(model.predict(tokenizer, "店面干净,很清静,服务员服务热情,性价比很高,发现收银台有排队"))
|
45 |
+
|
46 |
+
schema = "情感倾向[正向,负向]" # Define the schema for opinion extraction
|
47 |
+
model.set_schema(schema)
|
48 |
+
print(model.predict(tokenizer, "这个产品用起来真的很流畅,我非常喜欢"))
|
49 |
+
|
50 |
+
schema = ['法院', {'原告': '委托代理人'}, {'被告': '委托代理人'}] # Define the schema for opinion extraction
|
51 |
+
model.set_schema(schema)
|
52 |
+
print(model.predict(tokenizer, "北京市海淀区人民法院\n民事判决书\n(199x)建初字第xxx号\n原告:张三。\n委托代理人李四,北京市 A律师事务所律师。\n被告:B公司,法定代表人王五,开发公司总经理。\n委托代理人赵六,北京市 C律师事务所律师。"))
|
53 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
```
|
55 |
|
|
|
56 |
|
57 |
## 参考链接
|
58 |
|