With the release of Aspose.Words for .NET 25.7, you now have the powerful option to integrate self-hosted Large Language Models (LLMs) for AI-enhanced document processing, offering greater privacy, flexibility, and control, while avoiding third-party hosted APIs.

Image

Why Go Self-Hosted LLM?

  • Data Sovereignty: Keep sensitive documents entirely within your own infrastructure
  • Cost Control: Host models on your own hardware, avoiding additional fees from providers
  • Customization: Seamlessly integrate custom endpoints or on-premise model deployments

How to Leverage Self-Hosted LLM with Aspose.Words

Aspose.Words supports various AI-powered features like document translation, summarization, and grammar checking, powered by the Aspose.Words.AI namespace. While you can use hosted models (e.g., OpenAI, Google), the library also supports custom self-hosted models.

To switch to a self-hosted LLM, use the following:

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"; }
    }
}

Real-World Use Cases

  • Enterprise Documents: Translate confidential legal or financial documents without exposing data to external APIs
  • Offline Deployment: Use heavy custom LLMs (e.g., fine-tuned open-source models) in high-security environments or air-gapped networks
  • Cost-Sensitive Scenarios: Run inference on local GPUs to save on cloud service costs

This capability empowers you to maintain the robust AI features of Aspose.Words while keeping full ownership and control over your AI infrastructure.

See Also