Uploaded model
Browse files
README.md
CHANGED
|
@@ -1,3 +1,93 @@
|
|
| 1 |
---
|
| 2 |
license: other
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: other
|
| 3 |
---
|
| 4 |
+
|
| 5 |
+
| Language | version |
|
| 6 |
+
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 7 |
+
| [Python](python/interface/README.md) | [](https://pypi.org/project/ltp) [](https://pypi.org/project/ltp-core) [](https://pypi.org/project/ltp-extension) |
|
| 8 |
+
| [Rust](rust/ltp/README.md) | [](https://crates.io/crates/ltp) |
|
| 9 |
+
|
| 10 |
+
# [LTP 4](https://github.com/HIT-SCIR/ltp)
|
| 11 |
+
|
| 12 |
+
LTP(Language Technology Platform) 提供了一系列中文自然语言处理工具,用户可以使用这些工具对于中文文本进行分词、词性标注、句法分析等等工作。
|
| 13 |
+
|
| 14 |
+
## 引用
|
| 15 |
+
|
| 16 |
+
如果您在工作中使用了 LTP,您可以引用这篇论文
|
| 17 |
+
|
| 18 |
+
```bibtex
|
| 19 |
+
@article{che2020n,
|
| 20 |
+
title={N-LTP: A Open-source Neural Chinese Language Technology Platform with Pretrained Models},
|
| 21 |
+
author={Che, Wanxiang and Feng, Yunlong and Qin, Libo and Liu, Ting},
|
| 22 |
+
journal={arXiv preprint arXiv:2009.11616},
|
| 23 |
+
year={2020}
|
| 24 |
+
}
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
**参考书:**
|
| 28 |
+
由哈工大社会计算与信息检索研究中心(HIT-SCIR)的多位学者共同编著的《[自然语言处理:基于预训练模型的方法](https://item.jd.com/13344628.html)》(作者:车万翔、郭江、崔一鸣;主审:刘挺)一书现已正式出版,该书重点介绍了新的基于预训练模型的自然语言处理技术,包括基础知识、预训练词向量和预训练模型三大部分,可供广大LTP用户学习参考。
|
| 29 |
+
|
| 30 |
+
## 快速使用
|
| 31 |
+
|
| 32 |
+
### 安装 LTP
|
| 33 |
+
|
| 34 |
+
```bash
|
| 35 |
+
pip install -U ltp ltp-core ltp-extension -i https://pypi.org/simple
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
**注:** 如果遇到任何错误,请尝试使用上述命令重新安装 ltp,如果依然报错,请在 [Github issues](https://github.com/HIT-SCIR/ltp/issues) 中反馈。
|
| 39 |
+
|
| 40 |
+
### 使用 LTP
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
import torch
|
| 44 |
+
from ltp import LTP
|
| 45 |
+
|
| 46 |
+
ltp = LTP("LTP/small") # 默认加载 Small 模型
|
| 47 |
+
|
| 48 |
+
# 将模型移动到 GPU 上
|
| 49 |
+
if torch.cuda.is_available():
|
| 50 |
+
# ltp.cuda()
|
| 51 |
+
ltp.to("cuda")
|
| 52 |
+
|
| 53 |
+
output = ltp.pipeline(["他叫汤姆去拿外衣。"], tasks=["cws", "pos", "ner", "srl", "dep", "sdp"])
|
| 54 |
+
# 使用字典格式作为返回结果
|
| 55 |
+
print(output.cws) # print(output[0]) / print(output['cws']) # 也可以使用下标访问
|
| 56 |
+
print(output.pos)
|
| 57 |
+
print(output.sdp)
|
| 58 |
+
|
| 59 |
+
# 使用感知机算法实现的分词、词性和命名实体识别,速度比较快,但是精度略低
|
| 60 |
+
ltp = LTP("LTP/legacy")
|
| 61 |
+
# cws, pos, ner = ltp.pipeline(["他叫汤姆去拿外衣。"], tasks=["cws", "ner"]).to_tuple() # error: NER 需要 词性标注任务的结果
|
| 62 |
+
cws, pos, ner = ltp.pipeline(["他叫汤姆去拿外衣。"], tasks=["cws", "pos", "ner"]).to_tuple() # to tuple 可以自动转换为元组格式
|
| 63 |
+
# 使用元组格式作为返回结果
|
| 64 |
+
print(cws, pos, ner)
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
## 模型性能以及下载地址
|
| 68 |
+
|
| 69 |
+
| 深度学习模型 | 分词 | 词性 | 命名实体 | 语义角色 | 依存句法 | 语义依存 | 速度(句/S) |
|
| 70 |
+
| :---------------------------------------: | :---: | :---: | :---: | :---: | :---: | :---: | :-----: |
|
| 71 |
+
| [Base](https://huggingface.co/LTP/base) | 98.7 | 98.5 | 95.4 | 80.6 | 89.5 | 75.2 | 39.12 |
|
| 72 |
+
| [Base1](https://huggingface.co/LTP/base1) | 99.22 | 98.73 | 96.39 | 79.28 | 89.57 | 76.57 | --.-- |
|
| 73 |
+
| [Base2](https://huggingface.co/LTP/base2) | 99.18 | 98.69 | 95.97 | 79.49 | 90.19 | 76.62 | --.-- |
|
| 74 |
+
| [Small](https://huggingface.co/LTP/small) | 98.4 | 98.2 | 94.3 | 78.4 | 88.3 | 74.7 | 43.13 |
|
| 75 |
+
| [Tiny](https://huggingface.co/LTP/tiny) | 96.8 | 97.1 | 91.6 | 70.9 | 83.8 | 70.1 | 53.22 |
|
| 76 |
+
|
| 77 |
+
| 感知机算法 | 分词 | 词性 | 命名实体 | 速度(句/s) | 备注 |
|
| 78 |
+
| :-----------------------------------------: | :---: | :---: | :---: | :------: | :------------------------: |
|
| 79 |
+
| [Legacy](https://huggingface.co/LTP/legacy) | 97.93 | 98.41 | 94.28 | 21581.48 | [性能详情](https://github.com/HIT-SCIR/ltp/blob/main/python/extension/README.md) |
|
| 80 |
+
|
| 81 |
+
**注:感知机算法速度为开启16线程速度**
|
| 82 |
+
|
| 83 |
+
## 作者信息
|
| 84 |
+
|
| 85 |
+
- 冯云龙 \<\<[[email protected]](mailto:[email protected])>>
|
| 86 |
+
|
| 87 |
+
## 开源协议
|
| 88 |
+
|
| 89 |
+
1. 语言技术平台面向国内外大学、中科院各研究所以及个人研究者免费开放源代码,但如上述机构和个人将该平台用于商业目的(如企业合作项目等)则需要付费。
|
| 90 |
+
2. 除上述机构以外的企事业单位,如申请使用该平台,需付费。
|
| 91 |
+
3. 凡涉及付费问题,请发邮件到 [email protected] 洽商。
|
| 92 |
+
4. 如果您在 LTP 基础上发表论文或取得科研成果,请您在发表论文和申报成果时声明“使用了哈工大社会计算与信息检索研究中心研制的语言技术平台(LTP)”.
|
| 93 |
+
同时,发信给[email protected],说明发表论文或申报成果的题目、出处等。
|