15 个不稳定版本 (3 个破坏性更改)
0.4.1 | 2024年4月26日 |
---|---|
0.4.0 | 2024年4月26日 |
0.3.0 | 2024年4月22日 |
0.2.2 | 2024年4月22日 |
0.1.9 | 2024年4月16日 |
#725 in 机器学习
每月下载量 931
34KB
658 代码行
glowrs
glowrs
库提供了一个简单易用的接口,用于使用预训练的模型进行嵌入和句子相似度。
示例
use glowrs::{SentenceTransformer, Device, PoolingStrategy, Error};
fn main() -> Result<(), Error> {
let encoder = SentenceTransformer::from_repo_string("sentence-transformers/all-MiniLM-L6-v2", &Device::Cpu)?;
let sentences = vec![
"Hello, how are you?",
"Hey, how are you doing?"
];
let embeddings = encoder.encode_batch(sentences, true, PoolingStrategy::Mean)?;
println!("{:?}", embeddings);
Ok(())
}
功能
- 从 Hugging Face Hub 加载模型
- 使用硬件加速(Metal、CUDA)
- 更多功能即将推出!
构建功能
metal
:使用 Metal 加速编译cuda
:使用 CUDA 加速编译accelerate
:使用 Accelerate 框架加速(CPU)
免责声明
这仍是一个正在进行中的项目。嵌入性能相当不错,但可能需要一些基准测试。
请勿在生产环境中使用此软件。
依赖项
~28–49MB
~851K SLoC