# Private AI-Assisted DOCX Editing with RAG in ASP.NET Core

> This article walks through a hands-on test of private AI-assisted DOCX editing with the TX Text Control AI preview in an ASP.NET Core sample. The document agent uses a local language model to review a mutual NDA against an approved clause policy retrieved from a private RAG collection. It identifies the deviations, and the TX Text Control engine applies the approved wording to the Word document.

- **Author:** Deepika Kathiravan
- **Published:** 2026-12-02
- **Modified:** 2026-12-02
- **Description:** This article walks through a hands-on test of private AI-assisted DOCX editing with the TX Text Control AI preview in an ASP.NET Core sample. The document agent uses a local language model to review a mutual NDA against an approved clause policy retrieved from a private RAG collection. It identifies the deviations, and the TX Text Control engine applies the approved wording to the Word document.
- **11 min read** (2029 words)
- **Tags:**
  - ASP.NET Core
  - Private AI
  - RAG
  - DOCX Editor
- **Web URL:** https://www.textcontrol.com/blog/2026/12/02/private-ai-assisted-docx-editing-with-rag-in-aspnet-core/
- **LLMs URL:** https://www.textcontrol.com/blog/2026/12/02/private-ai-assisted-docx-editing-with-rag-in-aspnet-core/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2026/12/02/private-ai-assisted-docx-editing-with-rag-in-aspnet-core/llms-full.txt

---

General-purpose language models are familiar with common legal and business practices. However, they lack knowledge of an organization's internal rules, such as the approved confidentiality period for its NDAs or the precise wording its policies require. As explained in [Building Legal Document AI with TX Text Control](https://www.textcontrol.com/blog/2026/09/23/building-legal-document-ai-with-tx-text-control/llms-full.txt), private retrieval-augmented generation (RAG) can address this limitation by providing the model with relevant passages from approved internal documents, which stay on infrastructure you control.

In document workflows, private RAG can help the AI review documents, answer questions about the content, and propose edits that follow internal standards. Typical use cases include:

- **Legal**: compare contracts with clause libraries and negotiation playbooks.
- **Healthcare**: check documentation against internal procedures and approved templates.
- **Insurance and finance**: draft responses based on the applicable policy wording.
- **HR**: answer questions from current handbooks and expense policies.

These are often confidential documents that must not leave the organization's own systems. This article shows how private AI-assisted DOCX editing with RAG works in TX Text Control AI. The test uses the [WebDocumentAssistant sample](https://github.com/TextControl/txtextcontrol-ai-samples/tree/master/samples/WebDocumentAssistant) for ASP.NET Core, where the document agent checks an NDA against an approved clause policy and then, at the user's request, replaces a deviating clause with the approved wording.

What Is Private AI-Assisted DOCX Editing?
-----------------------------------------

Private AI-assisted DOCX editing means an AI assistant reviews Word documents and proposes edits directly in your application, while inference and document data stay within your own infrastructure. A local language model interprets the user's request, private RAG supplies approved content, and the document engine applies the change to the DOCX. Unlike end-user tools such as Microsoft Copilot in Word, this article covers AI DOCX editing that developers build into their own applications.

Running AI locally does not make an application secure or compliant on its own. Authentication, authorization, encrypted transport, and logging are still required. A fully isolated deployment also needs self-hosted web assets and controlled outbound network traffic.

How Private AI-Assisted DOCX Editing Works
------------------------------------------

The document agent handles each request in four steps:

1. The **user** types a request.
2. The **local model** interprets the request and proposes structured tool calls.
3. The **TX Text Control AI** integration sends those calls to the MCP document server.
4. The **TX Text Control engine** performs the edit, and the updated document loads back into the editor.

![Private AI-assisted DOCX editing workflow](https://s1-www.textcontrol.com/assets/dist/blog/2026/12/02/d/assets/workflow.webp "Private AI-assisted DOCX editing workflow")

The model never writes the DOCX file itself. It decides what should change, and the deterministic TX Text Control document engine performs the operation. The article [LLM Tool Calling vs. LLM-Generated Files in .NET](https://www.textcontrol.com/blog/2026/10/14/reliable-document-ai-in-dotnet-llm-tool-calling-vs-llm-generated-files/llms-full.txt) explains why this separation makes document AI more reliable.

Local Test Setup with TX Text Control AI
----------------------------------------

| Component | Configuration |
|---|---|
| Application | WebDocumentAssistant sample, TX Text Control AI 0.1.0-beta.3 |
| Chat model | Qwen\_Qwen3.5-4B-Q4\_K\_M (GGUF), 65536-token context |
| Hardware | Developer PC, CPU only |
| Document engine | TX Text Control MCP document server, running locally |
| Retrieval | Keyword search, no embedding model |
| Test documents | A fictional NDA and a fictional approved clause policy, both DOCX |

To repeat the test, [download the two test documents](https://s1-www.textcontrol.com/assets/dist/blog/2026/12/02/d/assets/test-documents.zip) and run the *WebDocumentAssistant* sample from the [TX Text Control AI samples repository on GitHub](https://github.com/TextControl/txtextcontrol-ai-samples).

#### Run the WebDocumentAssistant Sample in ASP.NET Core

For complete setup instructions, including licensing, NuGet feed access, and the MCP administration password, see the [Explore the Samples](https://www.textcontrol.com/blog/2026/09/09/introducing-tx-text-control-ai-private-ai-for-real-document-workflows-in-dot-net-c-sharp/#explore-the-samples) section of the TX Text Control AI article. The core steps start with cloning and building the sample repository:

```
git clone https://github.com/TextControl/txtextcontrol-ai-samples.git 
cd txtextcontrol-ai-samples 
dotnet restore TXTextControl.AI.Samples.sln 
dotnet build TXTextControl.AI.Samples.sln -c Release --no-restore
```

Place a compatible GGUF model in samples/WebDocumentAssistant/Models. Then start the MCP document server and, in a second terminal, the *WebDocumentAssistant* sample:

```
### Terminal 1: start the MCP document server
dotnet run --project samples/McpServer

### Terminal 2: start the WebDocumentAssistant sample
dotnet run --project samples/WebDocumentAssistant
```

The MCP document server listens on `http://127.0.0.1:5000`, and the sample runs at `http://localhost:5187`.

![WebDocumentAssistant sample with a DOCX loaded in Document Studio](https://s1-www.textcontrol.com/assets/dist/blog/2026/12/02/d/assets/textcontrolai1.webp "WebDocumentAssistant sample with a DOCX loaded in Document Studio")

Using RAG to Review and Edit DOCX Documents
-------------------------------------------

The test uses a fictional NDA that contains four deliberate deviations from a fictional clause policy, plus one clause that complies.

#### Step 1: Index the Approved Documents

First, add the approved clause policy to a private collection in the **Knowledge** tab.

##### Create the collection and add the NDA policy:

1. Enter "Approved NDA Policies" as the collection name and click **Create collection**.
2. Select the collection in the **Collection** dropdown.
3. Under **Reference documents**, choose `Approved-NDA-Clause-Policy.docx`. The file is queued for local indexing.
4. Click **Refresh jobs and sources** until the **Indexing activity** shows the file as Complete (100%).

##### Search the NDA policy to check the indexing (Preview evidence):

1. Under **Question**, enter: `What is the approved confidentiality period?`
2. Leave **Retrieval mode** on **Automatic**.
3. Click **Search references**.

**Result:** The search returned five passages in keyword mode. The top results were the confidentiality rule and the approved three-year wording.

![Indexed clause policy in the Knowledge tab](https://s1-www.textcontrol.com/assets/dist/blog/2026/12/02/d/assets/textcontrolai2.webp "Indexed clause policy in the Knowledge tab")

Keyword search worked immediately, with no embedding model required. For semantic search, a [separate embedding model can be configured](https://www.textcontrol.com/blog/2026/09/09/introducing-tx-text-control-ai-private-ai-for-real-document-workflows-in-dot-net-c-sharp/#use-a-separate-embedding-model-for-semantic-retrieval) in the global knowledge settings.

#### Step 2: Compare the NDA with the Clause Policy

Before running the comparison, configure the knowledge settings in the toolbar:

1. **Reference knowledge**: Select the collection created in Step 1, "Approved NDA Policies".
2. **Approved source**: Keep the default, "All active sources".
3. **Allow explicitly requested document changes**: Leave this option unchecked. This keeps the AI in read-only mode, so it can read the NDA but cannot modify it.

Next, the following prompt was sent to the document agent:

AI PromptCompare this NDA with our approved clause policy. List each deviation, the approved wording, and the source. Do not change the document.

The document agent returned a deviation analysis, listing the current wording, deviation, approved wording, and the policy source:

| Clause | Deviation in the NDA | Found by the AI |
|---|---|---|
| Confidentiality period | 7 years instead of 3 | Yes ✅ |
| Termination | 60 days' notice instead of 30 | Yes ✅ |
| Governing law | New York instead of Germany, courts of Bremen | Yes ✅ |
| Return of information | 90 days instead of 30, no mention of written confirmation | No ❌ |

Three of the four deviations were identified. The permitted disclosure clause, which matches the policy, was not flagged.

The full answer can also be downloaded as a PDF, which gives the reviewer a copy of the analysis to save or share.

![NDA deviation analysis](https://s1-www.textcontrol.com/assets/dist/blog/2026/12/02/d/assets/textcontrolai3.webp "NDA deviation analysis")

#### Step 3: Review Individual Clauses

To review the return of information clause, which was missed in Step 2, the following clause-specific prompt was sent to the document agent:

AI PromptCompare the Return or Destruction of Information clause with our approved policy.

This time, the document agent found all three differences in the clause:

| Clause element | Deviation in the NDA | Found by the AI |
|---|---|---|
| Return period | 90 days instead of 30 | Yes ✅ |
| Trigger | No "upon written request" provision | Yes ✅ |
| Written confirmation | No mention of written confirmation | Yes ✅ |

It quoted the approved wording from the policy and recommended updating the clause to match it.

![Clause-level deviation analysis](https://s1-www.textcontrol.com/assets/dist/blog/2026/12/02/d/assets/textcontrolai4.webp "Clause-level deviation analysis")

In this test, the full-document comparison provided a useful overview but missed one deviation, while the clause-level question identified every difference in that clause, producing more accurate results. Even with AI assistance, a human review is still recommended before a contract is finalized.

#### Step 4: Update Clauses with Approved Policy Wording

To apply the approved wording, enable **Allow explicitly requested document changes** in the toolbar and send the request to the document agent:

AI PromptReplace the body text of the Return or Destruction of Information clause with the approved clause policy. Keep the heading and formatting unchanged.

The document agent replaced the clause with all three approved elements: the 30-day period, the "upon written request" trigger, and the written confirmation. The heading and formatting stayed unchanged. The remaining deviations can be updated the same way, one clause at a time, for more reliable results.

![Clause updated by the TX Text Control engine](https://s1-www.textcontrol.com/assets/dist/blog/2026/12/02/d/assets/textcontrolai5.webp "Clause updated by the TX Text Control engine")

#### Performance and Preview Considerations

- **Expect latency on CPU**. A 4B model on a CPU-only developer PC handled the review and the edits, but each request took about 40 to 150 seconds. A GPU or a central GPU server inside the company network reduces this.
- **Preview status**. TX Text Control AI is a preview on NuGet, and APIs and behavior may change. A compatible GGUF model must be provided separately. An appropriate TX Text Control license is also required.

#### Learn More

- [Building Legal Document AI with TX Text Control](https://www.textcontrol.com/blog/2026/09/23/building-legal-document-ai-with-tx-text-control/llms-full.txt)
- [Introducing TX Text Control AI: Private AI for Real Document Workflows in .NET C#](https://www.textcontrol.com/blog/2026/09/09/introducing-tx-text-control-ai-private-ai-for-real-document-workflows-in-dot-net-c-sharp/llms-full.txt)
- [Running a Local LLM in .NET C# with TX Text Control AI](https://www.textcontrol.com/blog/2026/09/10/running-a-local-llm-in-dot-net-c-sharp-with-tx-text-control-ai/llms-full.txt)
- [LLM Tool Calling vs. LLM-Generated Files in .NET](https://www.textcontrol.com/blog/2026/10/14/reliable-document-ai-in-dotnet-llm-tool-calling-vs-llm-generated-files/llms-full.txt)
- [DOCX Editor SDK: A Complete Evaluation Guide and Checklist](https://www.textcontrol.com/blog/2026/10/28/docx-editor-sdk-complete-evaluation-guide-and-checklist/llms-full.txt)

#### Frequently Asked Questions

What is AI-assisted DOCX editing? 
----------------------------------

AI-assisted DOCX editing adds an AI document agent to the document editor in an application, so users can review and edit Word documents with natural-language instructions. The agent interprets each instruction and proposes changes, and a document engine applies them to the DOCX. The updated document then appears in the editor for the user to review.

What is private RAG for confidential documents? 
------------------------------------------------

Retrieval-augmented generation (RAG) lets an AI answer from your own documents rather than relying solely on its training data. With private RAG, documents such as an approved clause policy are indexed in a knowledge collection. The AI retrieves the relevant passages and uses them to answer or compare, while the reference documents remain on the organization's own systems.

Can AI edit DOCX documents with a local LLM instead of a cloud service? 
------------------------------------------------------------------------

Yes. TX Text Control AI runs with a local GGUF language model on a workstation, a private server, or a GPU server inside the company network. In a hands-on test, the model, the knowledge collection, the MCP document server, and the web app all ran on one CPU-only developer machine. No document, prompt, or retrieved passage was sent to a cloud AI service.

How do I add AI-assisted DOCX editing to an ASP.NET Core application? 
----------------------------------------------------------------------

Add the TX Text Control AI NuGet packages to the application, provide a local GGUF model, and connect the TX Text Control MCP document server. The *TXTextControl.AI.AspNetCore* package provides the AI endpoints and browser libraries. The *WebDocumentAssistant* sample on GitHub shows the complete setup.

Can AI review an NDA or contract against an approved clause policy? 
--------------------------------------------------------------------

Yes, with private RAG. In a hands-on test, the document agent compared a mutual NDA with an approved clause policy and listed the deviations it found, with the approved wording and its source paragraph. Approval of the document remains with a human reviewer.

How accurately does a local AI model find deviations in a contract? 
--------------------------------------------------------------------

In a test with a mutual NDA and an approved clause policy, a 4B model on CPU found three of the four deviations in a full-document comparison. A clause-level question then found all three differences in the clause it had missed. Clause-level questions provided more accurate answers.

---

## About Deepika Kathiravan

Deepika Kathiravan is a developer marketing professional, currently Developer Experience Marketing Lead at Text Control. Before moving into marketing, she had almost eight years of experience in various software industry roles. Following her passion for digital media, Deepika relocated to Germany and earned a Master's in Digital Media from the University of Bremen. She now enjoys blending her technical and marketing expertise by creating developer-centered content and driving strategic growth for the brand.

- [LinkedIn](https://www.linkedin.com/in/deepikakathiravan/)

---

## Related Posts

- [Introducing TX Text Control AI: Private AI for Real Document Workflows in .NET C#](https://www.textcontrol.com/blog/2026/09/09/introducing-tx-text-control-ai-private-ai-for-real-document-workflows-in-dot-net-c-sharp/llms.txt)
- [React DOCX Editor: Add Word-Like Editing to Your Web App](https://www.textcontrol.com/blog/2026/11/04/how-to-add-react-docx-editor/llms.txt)
- [How to Embed a DOCX Editor in a Web Application (ASP.NET Core)](https://www.textcontrol.com/blog/2026/10/30/how-to-embed-docx-editor-aspnet-core/llms.txt)
- [DOCX Editor SDK: A Complete Evaluation Guide and Checklist](https://www.textcontrol.com/blog/2026/10/28/docx-editor-sdk-complete-evaluation-guide-and-checklist/llms.txt)
- [Reliable Document AI in .NET: LLM Tool Calling vs. LLM-Generated Files](https://www.textcontrol.com/blog/2026/10/14/reliable-document-ai-in-dotnet-llm-tool-calling-vs-llm-generated-files/llms.txt)
