Table of Contents

👉 Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/rag/help_desk_knowledge_base

Help Desk Knowledge Base for C# .NET Applications


🎯 Purpose of the Sample

The Help Desk Knowledge Base demo shows how to build a production-grade RAG system with LM-Kit.NET that persists its index to disk, supports incremental article management, and scopes queries to specific categories using DataFilter.

This is the demo to study when you need to build a knowledge base that survives restarts, grows over time, and serves different departments or topics.


👥 Industry Target Audience

This demo is particularly useful for developers and organizations working on:

  • Customer support: build a knowledge base of FAQs and support articles that agents (human or AI) query to resolve tickets
  • Internal documentation portals: maintain a searchable wiki of company policies, procedures, and technical documentation
  • Multi-department help desks: scope queries to specific departments (HR, IT, Finance) using category filters
  • SaaS product documentation: embed a searchable knowledge base in your product for self-service support
  • Compliance and legal: maintain a persistent, auditable knowledge base of regulations and policies

🚀 Problem Solved

Most RAG tutorials show a "build once, query, throw away" pattern. Real applications need to:

  • Persist the index so it survives restarts without re-embedding (which is slow and costly)
  • Add and remove content incrementally as documentation evolves
  • Scope queries so users searching billing issues do not get results from technical troubleshooting
  • Show sources so users can verify answers against the original articles

This demo solves all of these problems with a complete, working implementation.


💻 Sample Application Description

The Help Desk Knowledge Base demo is a console application that:

  • Loads a chat model and an embedding model
  • Creates or reloads a persistent, file-backed knowledge base
  • Seeds 20 fictional support articles across 5 categories on first run
  • Provides an interactive help desk assistant with article management commands

✨ Key Features

  • Persistent storage: file-backed DataSource that reloads instantly without re-embedding
  • Incremental management: add and remove articles at runtime; changes persist automatically
  • Category-scoped search: DataFilter restricts queries to specific categories
  • Markdown-aware chunking: MarkdownChunking respects heading boundaries for cleaner chunks
  • Answer generation: two-step pipeline using FindMatchingPartitions then QueryPartitions
  • Source attribution: shows which articles contributed to each answer, with relevance scores

🏗️ Architecture

    ┌─────────────────────────────────────────────────────────┐
    │                   help_desk_kb.dat                      │
    │              (persistent file storage)                  │
    │                                                         │
    │  Account Management/  Billing/  Technical Support/ ...  │
    │    Password Reset       Plans     Connectivity          │
    │    Account Recovery     Payments  Error Codes           │
    │    Profile Settings     Refunds   API Rate Limits       │
    │    ...                  ...       ...                   │
    └──────────────────────────┬──────────────────────────────┘
                               │
                    LoadFromFile / CreateFileDataSource
                               │
                    ┌──────────▼──────────┐
                    │     RagEngine       │
                    │  + DataFilter       │◄── /scope Billing
                    └──────────┬──────────┘
                               │
                    FindMatchingPartitions
                               │
                    ┌──────────▼──────────┐
                    │  Top-5 Passages     │
                    │  + source info      │──► Source Attribution
                    └──────────┬──────────┘
                               │
                      QueryPartitions
                               │
                    ┌──────────▼──────────┐
                    │  SingleTurnConv     │
                    │  (chat model)       │──► Grounded Answer
                    └─────────────────────┘

🛠️ Getting Started

📋 Prerequisites

  • .NET 8.0 or later
  • Minimum 6 GB VRAM (Qwen-3 8B) or 4 GB VRAM (Gemma 3 4B)

📥 Download the Project

▶️ Running the Application

  1. Clone the repository:

    git clone https://github.com/LM-Kit/lm-kit-net-samples
    
  2. Navigate to the project directory:

    cd lm-kit-net-samples/console_net/rag/help_desk_knowledge_base
    
  3. Build and run the application:

    dotnet build
    dotnet run
    
  4. First run: the knowledge base is created and seeded with 20 sample articles. Subsequent runs reload the persisted index instantly.


💡 Example Usage

  1. Ask a question: type a support question to get a grounded answer with source attribution
  2. Scope to a category: use /scope Billing to restrict queries, then /scope all to remove the filter
  3. Add an article: use /add Security "API Key Best Practices" and enter content interactively
  4. Remove outdated content: use /remove "Outdated Article" to remove articles
  5. Browse the knowledge base: use /categories for an overview or /list Technical Support for details
  6. Restart the demo: the knowledge base reloads from disk without re-embedding

🔧 Troubleshooting

Issue Solution
No relevant articles found Remove the scope filter with /scope all or lower the search threshold
First run is slow Embedding 20 articles takes a few seconds; subsequent runs are instant
Article not added Check that the section identifier (Category/Title) does not already exist

🚀 Extend the Demo

  • Load from files: use /addfile to import Markdown files, or modify the code to scan a directory
  • Add hybrid search: set ragEngine.RetrievalStrategy = new HybridRetrievalStrategy() for BM25 + vector fusion
  • Multi-turn conversation: replace SingleTurnConversation with RagChat for follow-up questions
  • Connect to Qdrant: replace the file-backed DataSource with a Qdrant-backed store for scalability

📚 Additional Resources

Share