随着 Aspose.Words for .NET 25.7 的发布,您现在可以选择集成 self-hosted Large Language Models (LLMs) 来实现 AI 增强的文档处理,从而提供更高的隐私性、灵活性和控制力,同时避免第三方托管的 APIs。

为何选择 Go Self-Hosted?LLM
- Data Sovereignty:将敏感文档完全保留在您自己的基础架构内
- Cost Control:在您自己的硬件上托管模型,避免提供商的额外费用
- Customization:无缝集成自定义端点或本地模型部署
如何利用自托管LLM和Aspose.Words
Aspose.Words 支持各种 AI 功能,例如文档翻译、摘要和语法检查,这些功能均由Aspose.Words.AI命名空间。虽然您可以使用托管模型(例如 OpenAI、Google),但该库还支持自定义自托管模型。
要切换到自托管 LLM,请使用以下命令:
public void SelfHostedModel()
{
Document doc = new Document(MyDir + "Big document.docx");
string apiKey = Environment.GetEnvironmentVariable("API_KEY");
// Use OpenAI generative language models.
AiModel model = new CustomAiModel().WithApiKey(apiKey);
Document translatedDoc = model.Translate(doc, Language.Russian);
translatedDoc.Save(ArtifactsDir + "AI.SelfHostedModel.docx");
}
// Custom self-hosted AI model.
internal class CustomAiModel : OpenAiModel
{
protected override string Url
{
get { return "https://localhost/"; }
}
protected override string Name
{
get { return "my-model-24b"; }
}
}
真实用例
- Enterprise Documents:翻译机密法律或财务文件,无需将数据暴露给外部APIs
- Offline Deployment:在高安全性环境或隔离网络中使用大量自定义 LLMs(例如,经过微调的开源模型)
- Cost-Sensitive Scenarios:在本地 GPUs 上运行推理以节省云服务成本
此功能使您能够维护 Aspose.Words 的强大 AI 功能,同时保持对 AI 基础架构的完全所有权和控制权。