-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
149 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,19 @@ LTP(Language Technology Platform) 提供了一系列中文自然语言处理 | |
### [Python](python/interface/README.md) | ||
|
||
```bash | ||
pip install -U ltp ltp-core ltp-extension -i https://pypi.org/simple # 安装 ltp | ||
# 方法 1: 使用清华源安装 LTP | ||
# 1. 安装 PyTorch 和 Transformers 依赖 | ||
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch transformers | ||
# 2. 安装 LTP | ||
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ltp ltp-core ltp-extension | ||
|
||
# 方法 2: 先全局换源,再安装 LTP | ||
# 1. 全局换 TUNA 源 | ||
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple | ||
# 2. 安装 PyTorch 和 Transformers 依赖 | ||
pip install torch transformers | ||
# 3. 安装 LTP | ||
pip install ltp ltp-core ltp-extension | ||
``` | ||
|
||
**注:** 如果遇到任何错误,请尝试使用上述命令重新安装 ltp,如果依然报错,请在 Github issues 中反馈。 | ||
|
@@ -73,6 +85,8 @@ import torch | |
from ltp import LTP | ||
|
||
ltp = LTP("LTP/small") # 默认加载 Small 模型 | ||
# 也可以传入模型的路径,ltp = LTP("/path/to/your/model") | ||
# /path/to/your/model 应当存在 config.json 和其他模型文件 | ||
|
||
# 将模型移动到 GPU 上 | ||
if torch.cuda.is_available(): | ||
|
@@ -124,20 +138,50 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { | |
|
||
## 模型性能以及下载地址 | ||
|
||
| 深度学习模型 | 分词 | 词性 | 命名实体 | 语义角色 | 依存句法 | 语义依存 | 速度(句/S) | | ||
| :---------------------------------------: | :---: | :---: | :---: | :---: | :---: | :---: | :-----: | | ||
| [Base](https://huggingface.co/LTP/base) | 98.7 | 98.5 | 95.4 | 80.6 | 89.5 | 75.2 | 39.12 | | ||
| [Base1](https://huggingface.co/LTP/base1) | 99.22 | 98.73 | 96.39 | 79.28 | 89.57 | 76.57 | --.-- | | ||
| [Base2](https://huggingface.co/LTP/base2) | 99.18 | 98.69 | 95.97 | 79.49 | 90.19 | 76.62 | --.-- | | ||
| [Small](https://huggingface.co/LTP/small) | 98.4 | 98.2 | 94.3 | 78.4 | 88.3 | 74.7 | 43.13 | | ||
| [Tiny](https://huggingface.co/LTP/tiny) | 96.8 | 97.1 | 91.6 | 70.9 | 83.8 | 70.1 | 53.22 | | ||
| 深度学习模型 | 直链下载 | 分词 | 词性 | 命名实体 | 语义角色 | 依存句法 | 语义依存 | 速度(句/S) | | ||
|:-----------------------------------------:|:-----------------------------------------------:| :---: | :---: | :---: | :---: | :---: | :-----: | | ||
| [🤗Base](https://huggingface.co/LTP/base) | [🗜Base](http://39.96.43.154/ltp/v4/base.tgz) | 98.7 | 98.5 | 95.4 | 80.6 | 89.5 | 75.2 | 39.12 | | ||
| [🤗Base1](https://huggingface.co/LTP/base1) | [🗜Base1](http://39.96.43.154/ltp/v4/base1.tgz) |99.22 | 98.73 | 96.39 | 79.28 | 89.57 | 76.57 | --.-- | | ||
| [🤗Base2](https://huggingface.co/LTP/base2) | [🗜Base2](http://39.96.43.154/ltp/v4/base2.tgz) |99.18 | 98.69 | 95.97 | 79.49 | 90.19 | 76.62 | --.-- | | ||
| [🤗Small](https://huggingface.co/LTP/small) | [🗜Small](http://39.96.43.154/ltp/v4/small.tgz) | 98.4 | 98.2 | 94.3 | 78.4 | 88.3 | 74.7 | 43.13 | | ||
| [🤗Tiny](https://huggingface.co/LTP/tiny) | [🗜Tiny](http://39.96.43.154/ltp/v4/tiny.tgz) | 96.8 | 97.1 | 91.6 | 70.9 | 83.8 | 70.1 | 53.22 | | ||
|
||
| 感知机算法 | 分词 | 词性 | 命名实体 | 速度(句/s) | 备注 | | ||
| :-----------------------------------------: | :---: | :---: | :---: | :------: | :------------------------: | | ||
| [Legacy](https://huggingface.co/LTP/legacy) | 97.93 | 98.41 | 94.28 | 21581.48 | [性能详情](rust/ltp/README.md) | | ||
| 感知机算法 | 直链下载 | 分词 | 词性 | 命名实体 | 速度(句/s) | 备注 | | ||
| :-----------------------------------------: |:-------------------------------------------------:|:----------:| :---: | :---: | :------: | :------------------------: | | ||
| [🤗Legacy](https://huggingface.co/LTP/legacy) | [🗜Legacy](http://39.96.43.154/ltp/v4/legacy.tgz) | 97.93 | 98.41 | 94.28 | 21581.48 | [性能详情](rust/ltp/README.md) | | ||
|
||
**注:感知机算法速度为开启16线程速度** | ||
|
||
### 如何下载对应的模型 | ||
|
||
```bash | ||
# 使用 HTTP 链接下载 | ||
# 确保已安装 git-lfs (https://git-lfs.com) | ||
git lfs install | ||
git clone https://huggingface.co/LTP/base | ||
|
||
# 使用 ssh 下载 | ||
# 确保已安装 git-lfs (https://git-lfs.com) | ||
git lfs install | ||
git clone [email protected]:LTP/base | ||
|
||
# 下载压缩包 | ||
wget http://39.96.43.154/ltp/v4/base.tgz | ||
tar -zxvf base.tgz -C base | ||
``` | ||
|
||
### 如何使用下载的模型 | ||
|
||
```python | ||
from ltp import LTP | ||
|
||
# 在路径中给出模型下载或解压后的路径 | ||
# 例如:base 模型的文件夹路径为 "path/to/base" | ||
# "path/to/base" 下应当存在 "config.json" | ||
ltp = LTP("path/to/base") | ||
``` | ||
|
||
|
||
## 构建 Wheel 包 | ||
|
||
```shell script | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "ltp-extension" | ||
version = "0.1.10" | ||
version = "0.1.11" | ||
edition = "2021" | ||
authors = ["ylfeng <[email protected]>"] | ||
description = "Rust Extension For Language Technology Platform(Python)." | ||
|
@@ -17,11 +17,11 @@ crate-type = ["cdylib"] | |
|
||
[dependencies] | ||
libc = { version = "0.2" } | ||
rayon = { version = "1.5" } | ||
rayon = { version = "1.7" } | ||
rayon-cond = { version = "0.2" } | ||
anyhow = { version = "1.0" } | ||
serde = { version = "1.0", features = ["derive"] } | ||
pyo3 = { version = "0.18", features = ["extension-module", "anyhow", "serde"] } | ||
pyo3 = { version = "0.19", features = ["extension-module", "anyhow", "serde"] } | ||
mimalloc = { version = "0.1", default-features = false, optional = true } | ||
|
||
[dependencies.ltp] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[build-system] | ||
requires = ["maturin>=0.13,<0.14"] | ||
requires = ["maturin>=1.0,<2.0"] | ||
build-backend = "maturin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.