隨著 Aspose.Words for .NET 25.7 的發布,您現在可以選擇整合 self-hosted Large Language Models (LLMs) 來實現 AI 增強的文件處理,從而提供更高的隱私性、靈活性和控制力,同時避免第三方託管的 APIs。

Image

為何選擇 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 基礎架構的完全所有權和控制權。

參見