Rust 原生即用型自然语言处理流水线及基于 Transformer 的模型(BERT、DistilBERT、GPT2 等)
Rust原生最先进自然语言处理模型与流水线。 将 Hugging Face 的 Transformers 库移植而来,使用 tch-rs 或 onnxruntime 绑定,并采用 Rust-tokenizers 进行预处理。支持多线程分词和 GPU 推理。本仓库公开了模型基础架构、任务特定头(见下文)以及即用型流水线。基准测试见本文档末尾。
通过几行代码即可开始使用任务,包括问答、命名实体识别、翻译、摘要、文本生成、对话代理等:
let qa_model = QuestionAnsweringModel::new(Default::default ()) ?;
let question = String::from("Where does Amy live ?");
let context = String::from("Amy lives in Amsterdam");
let answers = qa_model.predict( & [QaInput { question, context }], 1, 32);输出:
目前支持的任务包括:
| 序列分类 | 词元分类 | 问答 | 文本生成 | 摘要 | 翻译 | 掩码语言模型 | 句子嵌入 | |
|---|---|---|---|---|---|---|---|---|
| DistilBERT | ✅ | ✅ | ✅ | ✅ | ✅ | |||
| Mob |
[Answer { score: 0.9976, start: 13, end: 21, answer: "Amsterdam" }]
暂无开放 Issues,或尚未同步最近议题。