Files changed (1) hide show
  1. README.md +3 -160
README.md CHANGED
@@ -1,160 +1,3 @@
1
- ![CODE SIZE](https://img.shields.io/github/languages/code-size/HIT-SCIR/ltp)
2
- ![CONTRIBUTORS](https://img.shields.io/github/contributors/HIT-SCIR/ltp)
3
- ![LAST COMMIT](https://img.shields.io/github/last-commit/HIT-SCIR/ltp)
4
-
5
- | Language | version |
6
- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
- | [Python](python/interface/README.md) | [![LTP](https://img.shields.io/pypi/v/ltp?label=LTP)](https://pypi.org/project/ltp) [![LTP-Core](https://img.shields.io/pypi/v/ltp-core?label=LTP-Core)](https://pypi.org/project/ltp-core) [![LTP-Extension](https://img.shields.io/pypi/v/ltp-extension?label=LTP-Extension)](https://pypi.org/project/ltp-extension) |
8
- | [Rust](rust/ltp/README.md) | [![LTP](https://img.shields.io/crates/v/ltp?label=LTP)](https://crates.io/crates/ltp) |
9
-
10
- # LTP 4
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)
29
- 》(作者:车万翔、郭江、崔一鸣;主审:刘挺)一书现已正式出版,该书重点介绍了新的基于预训练模型的自然语言处理技术,包括基础知识、预训练词向量和预训练模型三大部分,可供广大LTP用户学习参考。
30
-
31
- ### 更新说明
32
-
33
- - 4.2.0
34
- - \[结构性变化\] 将 LTP 拆分成 2 个部分,维护和训练更方便,结构更清晰
35
- - \[Legacy 模型\] 针对广大用户对于**推理速度**的需求,使用 Rust 重写了基于感知机的算法,准确率与 LTP3 版本相当,速度则是 LTP v3 的 **3.55** 倍,开启多线程更可获得 **17.17** 倍的速度提升,但目前仅支持分词、词性、命名实体三大任务
36
- - \[深度学习模型\] 即基于 PyTorch 实现的深度学习模型,支持全部的6大任务(分词/词性/命名实体/语义角色/依存句法/语义依存)
37
- - \[其他改进\] 改进了模型训练方法
38
- - \[共同\] 提供了训练脚本和训练样例,使得用户能够更方便地使用私有的数据,自行训练个性化的模型
39
- - \[深度学习模型\] 采用 hydra 对训练过程进行配置,方便广大用户修改模型训练参数以及对 LTP 进行扩展(比如使用其他包中的 Module)
40
- - \[其他变化\] 分词、依存句法分析 (Eisner) 和 语义依存分析 (Eisner) 任务的解码算法使用 Rust 实现,速度更快
41
- - \[新特性\] 模型上传至 [Huggingface Hub](https://huggingface.co/LTP),支持自动下载,下载速度更快,并且支持用户自行上传自己训练的模型供LTP进行推理使用
42
- - \[破坏性变更\] 改用 Pipeline API 进行推理,方便后续进行更深入的性能优化(如SDP和SDPG很大一部分是重叠的,重用可以加快推理速度),使用说明参见[Github快速使用部分](https://github.com/hit-scir/ltp)
43
- - 4.1.0
44
- - 提供了自定义分词等功能
45
- - 修复了一些bug
46
- - 4.0.0
47
- - 基于Pytorch 开发,原生 Python 接口
48
- - 可根据需要自由选择不同速度和指标的模型
49
- - 分词、词性、命名实体、依存句法、语义角色、语义依存6大任务
50
-
51
- ## 快速使用
52
-
53
- ### [Python](python/interface/README.md)
54
-
55
- ```bash
56
- pip install -U ltp ltp-core ltp-extension -i https://pypi.org/simple # 安装 ltp
57
- ```
58
-
59
- **注:** 如果遇到任何错误,请尝试使用上述命令重新安装 ltp,如果依然报错,请在 Github issues 中反馈。
60
-
61
- ```python
62
- import torch
63
- from ltp import LTP
64
-
65
- ltp = LTP("LTP/small") # 默认加载 Small 模型
66
-
67
- # 将模型移动到 GPU 上
68
- if torch.cuda.is_available():
69
- # ltp.cuda()
70
- ltp.to("cuda")
71
-
72
- output = ltp.pipeline(["他叫汤姆去拿外衣。"], tasks=["cws", "pos", "ner", "srl", "dep", "sdp"])
73
- # 使用字典格式作为返回结果
74
- print(output.cws) # print(output[0]) / print(output['cws']) # 也可以使用下标访问
75
- print(output.pos)
76
- print(output.sdp)
77
-
78
- # 使用感知机算法实现的分词、词性和命名实体识别,速度比较快,但是精度略低
79
- ltp = LTP("LTP/legacy")
80
- # cws, pos, ner = ltp.pipeline(["他叫汤姆去拿外衣。"], tasks=["cws", "ner"]).to_tuple() # error: NER 需要 词性标注任务的结果
81
- cws, pos, ner = ltp.pipeline(["他叫汤姆去拿外衣。"], tasks=["cws", "pos", "ner"]).to_tuple() # to tuple 可以自动转换为元组格式
82
- # 使用元组格式作为返回结果
83
- print(cws, pos, ner)
84
- ```
85
-
86
- **[详细说明](python/interface/docs/quickstart.rst)**
87
-
88
- ### [Rust](rust/ltp/README.md)
89
-
90
- ```rust
91
- use std::fs::File;
92
- use itertools::multizip;
93
- use ltp::{CWSModel, POSModel, NERModel, ModelSerde, Format, Codec};
94
-
95
- fn main() -> Result<(), Box<dyn std::error::Error>> {
96
- let file = File::open("data/legacy-models/cws_model.bin")?;
97
- let cws: CWSModel = ModelSerde::load(file, Format::AVRO(Codec::Deflate))?;
98
- let file = File::open("data/legacy-models/pos_model.bin")?;
99
- let pos: POSModel = ModelSerde::load(file, Format::AVRO(Codec::Deflate))?;
100
- let file = File::open("data/legacy-models/ner_model.bin")?;
101
- let ner: NERModel = ModelSerde::load(file, Format::AVRO(Codec::Deflate))?;
102
-
103
- let words = cws.predict("他叫汤姆去拿外衣。")?;
104
- let pos = pos.predict(&words)?;
105
- let ner = ner.predict((&words, &pos))?;
106
-
107
- for (w, p, n) in multizip((words, pos, ner)) {
108
- println!("{}/{}/{}", w, p, n);
109
- }
110
-
111
- Ok(())
112
- }
113
- ```
114
-
115
- ## 模型性能以及下载地址
116
-
117
- | 深度学习模型 | 分词 | 词性 | 命名实体 | 语义角色 | 依存句法 | 语义依存 | 速度(句/S) |
118
- | :---------------------------------------: | :---: | :---: | :---: | :---: | :---: | :---: | :-----: |
119
- | [Base](https://huggingface.co/LTP/base) | 98.7 | 98.5 | 95.4 | 80.6 | 89.5 | 75.2 | 39.12 |
120
- | [Base1](https://huggingface.co/LTP/base1) | 99.22 | 98.73 | 96.39 | 79.28 | 89.57 | 76.57 | --.-- |
121
- | [Base2](https://huggingface.co/LTP/base2) | 99.18 | 98.69 | 95.97 | 79.49 | 90.19 | 76.62 | --.-- |
122
- | [Small](https://huggingface.co/LTP/small) | 98.4 | 98.2 | 94.3 | 78.4 | 88.3 | 74.7 | 43.13 |
123
- | [Tiny](https://huggingface.co/LTP/tiny) | 96.8 | 97.1 | 91.6 | 70.9 | 83.8 | 70.1 | 53.22 |
124
-
125
- | 感知机算法 | 分词 | 词性 | 命名实体 | 速度(句/s) | 备注 |
126
- | :-----------------------------------------: | :---: | :---: | :---: | :------: | :------------------------: |
127
- | [Legacy](https://huggingface.co/LTP/legacy) | 97.93 | 98.41 | 94.28 | 21581.48 | [性能详情](rust/ltp/README.md) |
128
-
129
- **注:感知机算法速度为开启16线程速度**
130
-
131
- ## 构建 Wheel 包
132
-
133
- ```shell script
134
- make bdist
135
- ```
136
-
137
- ## 其他语言绑定
138
-
139
- **感知机算法**
140
-
141
- - [Rust](rust/ltp)
142
- - [C/C++](rust/ltp-cffi)
143
-
144
- **深度学习算法**
145
-
146
- - [Rust](https://github.com/HIT-SCIR/libltp/tree/master/ltp-rs)
147
- - [C++](https://github.com/HIT-SCIR/libltp/tree/master/ltp-cpp)
148
- - [Java](https://github.com/HIT-SCIR/libltp/tree/master/ltp-java)
149
-
150
- ## 作者信息
151
-
152
- - 冯云龙 \<\<[ylfeng@ir.hit.edu.cn](mailto:ylfeng@ir.hit.edu.cn)>>
153
-
154
- ## 开源协议
155
-
156
- 1. 语言技术平台面向国内外大学、中科院各研究所以及个人研究者免费开放源代码,但如上述机构和个人将该平台用于商业目的(如企业合作项目等)则需要付费。
157
- 2. 除上述机构以外的企事业单位,如申请使用该平台,需付费。
158
- 3. 凡涉及付费问题,请发邮件到 car@ir.hit.edu.cn 洽商。
159
- 4. 如果您在 LTP 基础上发表论文或取得科研成果,请您在发表论文和申报成果时声明“使用了哈工大社会计算与信息检索研究中心研制的语言技术平台(LTP)”.
160
- 同时,发信给car@ir.hit.edu.cn,说明发表论文或申报成果的题目、出处等。
 
1
+ ---
2
+ license: other
3
+ ---