LocalAI.Translation
1.2.1
dotnet add package LocalAI.Translation --version 1.2.1
NuGet\Install-Package LocalAI.Translation -Version 1.2.1
<PackageReference Include="LocalAI.Translation" Version="1.2.1" />
<PackageVersion Include="LocalAI.Translation" Version="1.2.1" />
<PackageReference Include="LocalAI.Translation" />
paket add LocalAI.Translation --version 1.2.1
#r "nuget: LocalAI.Translation, 1.2.1"
#:package LocalAI.Translation@1.2.1
#addin nuget:?package=LocalAI.Translation&version=1.2.1
#tool nuget:?package=LocalAI.Translation&version=1.2.1
LocalAI Translate — .NET 本地 AI 离线翻译 SDK
一个安装入口,包含 DirectML 推理库及自动还原的中英越 INT8 模型。模型在本机运行, 无需网络服务。
模型源自
facebook/nllb-200-distilled-600M,模型资产受 CC BY-NC 4.0 约束,仅限非商业用途。SDK 源代码采用 MIT 许可证。
安装
dotnet add package LocalAI.Translation
虽然 NuGet 因单包大小限制在内部还原四个模型组件,但应用只需要引用上面的主包。
模型会自动进入输出和发布目录的 models 文件夹,不需要配置模型路径。
最小示例
using Nllb.Onnx;
await using var engine = new TranslationEngine();
var initialization = await engine.InitializeAsync();
var result = await engine.TranslateAsync(new TranslationRequest(
"今天天气很好。",
"zho_Hans",
"vie_Latn"));
if (!result.IsSuccess)
{
throw new InvalidOperationException($"{result.Status}: {result.ErrorMessage}");
}
Console.WriteLine(result.Text);
默认配置会自动选择 DirectML/CPU 并让模型常驻。InitializeAsync() 可在应用启动时完成
预热;engine.Metrics 提供请求、耗时、缓存命中率、实际后端和模型加载状态。
语言代码为:简体中文 zho_Hans、英文 eng_Latn、越南文 vie_Latn。
高级部署才需要通过 new TranslationEngineOptions(path) 或环境变量
NLLB_ONNX_MODEL_DIR 覆盖默认目录。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- LocalAI.Translation.Models.Decoder (= 1.0.0)
- LocalAI.Translation.Models.Embedding (= 1.0.0)
- LocalAI.Translation.Models.Encoder (= 1.0.0)
- LocalAI.Translation.Models.OutputProjection (= 1.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- Microsoft.ML.OnnxRuntime.DirectML (>= 1.24.4)
- Tokenizers.HuggingFace (>= 3.23.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
SDK 1.2.1 fixes transitive model asset propagation so installing only the main package automatically restores and copies the 1.0.0 model bundle.