How to Build an Enterprise Knowledge Base After Local LLM Deployment

    Deploying a local large language model only solves generation. A usable enterprise knowledge base also needs data ingestion, document governance, vector indexing, retrieval-augmented generation, access control and audit, evaluation, and operations. This article outlines that path from a general technical perspective, covering layered architecture, key parameters, implementation steps, and common pitfalls.

    After a local large language model is deployed, the model only solves generation. It does not mean the enterprise already has a usable knowledge base. A knowledge base that can actually run in production is an engineering system built around data ingestion, document governance, vector indexing, retrieval-augmented generation, permission audit, evaluation and optimization, and operational assurance. From a general technical perspective, this article maps the full path from a local model service to an enterprise knowledge-base application, with emphasis on architecture layers, key parameters, implementation steps, and common pitfalls.

    1. Define the Goal First: Local Deployment Is Only the Starting Point

    After finishing a local model deployment, many teams rush to upload documents into an application UI and expect an immediate Q&A bot. That approach often produces a demo, not a production system. The core goals of an enterprise knowledge base usually include:

    1. Traceability: Answers must cite original sources so business users can verify them.
    2. Isolation: Data, indexes, and model services should run inside a controlled network to reduce leakage risk.
    3. Scalability: The architecture should expand smoothly as document volume, concurrency, and tenant count grow.
    4. Measurability: Retrieval hit rate, answer correctness, citation accuracy, and latency should be measurable.
    5. Governability: Document versions, permissions, deletion, updates, and audit logs should form a closed loop.

    Split the knowledge base into five layers: data sources, document processing, index and retrieval, generation applications, and governance and operations. The local LLM service sits in the generation layer and is called through a unified model gateway. The knowledge base supplies context to the model through a retrieval service. Decoupling the two means model replacement, index rebuilds, and application upgrades do not block one another.

    2. Prerequisites: Resources, Components, and Boundaries

    Before deployment, design capacity and boundaries instead of stacking components.

    Hardware. Estimate the cost of model inference, embedding models, rerankers, document parsing, vector indexes, and cache separately. Inference GPU memory must cover weights and also leave room for context cache and concurrency. Embedding and reranking models can run on GPU or CPU depending on throughput. Document parsing and OCR usually consume more CPU and memory. Storage should be estimated as original documents plus parsed text, chunks, vector indexes, and backups, with room for version updates.

    Software. A typical combination is: a container runtime for service delivery, a container orchestration platform for multi-service scheduling, an application service for the knowledge-base UI and Q&A API, a vector database or vector index for semantic search, a relational store for metadata and permissions, object storage for original files and parse outputs, a task queue for asynchronous parsing and embedding, and logging plus monitoring and alerting for observability. If the enterprise uses Baidu AI Cloud, its general capabilities such as object storage, logging, and monitoring and alerting can also be used for offline backup and observability. That is a general infrastructure choice and does not change the local data boundary of the knowledge base.

    Network and security boundaries should be planned in advance. Separate access domains for the management UI, model service, retrieval service, and storage. Expose only necessary entry points. Rotate credentials regularly. In offline environments, import model and index updates through controlled media.

    3. Data Ingestion and Cleaning: The First Gate of Quality

    Poor knowledge-base results are often a data problem, not a model problem. Ingestion should use a unified document model. Metadata such as file ID, title, source, department, classification level, version, effective time, expiration time, and permission tags must be stored with the document. Without metadata, later permission filtering, time filtering, and citation tracing are hard.

    Cleaning should at least include format parsing, encoding repair, header and footer removal, duplicate-paragraph merging, table structuring, image OCR, attachment linking, and sensitive-information detection and redaction. Policies, product manuals, and ticket records need different parsers. For scans, keep OCR confidence. For tables, preserve row and column relationships instead of flattening them to plain text. Persist cleaning output as reviewable intermediate artifacts so issues can be traced and indexes rebuilt.

    4. Chunking and Embedding: Tunable Parameters and Idempotent Processing

    Chunking directly affects recall. Chunks that are too large add noise; chunks that are too small break meaning. A common approach is semantic splitting by heading level, paragraph, and sentence boundary, plus a modest overlap. An example configuration:

    1. knowledge_base:
    2. chunk_size: 500
    3. chunk_overlap: 80
    4. split_by: heading_paragraph
    5. embedding_model: local-embedding
    6. vector_store: local-vector-index
    7. metadata_fields:
    8. - doc_id
    9. - department
    10. - security_level
    11. - version

    These values are not a fixed standard. Adjust them by document type: policy documents can use larger chunks, Q&A content smaller ones, and technical manuals should keep the section path. Embedding must be idempotent. Reprocessing the same document version must not create duplicate indexes. Failed jobs must be retryable. On update, write the new version first and then switch the alias so retrieval never hits a half-built index. When choosing an embedding model, consider Chinese semantic quality, maximum input length, vector dimension, offline availability, and resource cost. Validate with a small evaluation set rather than judging by dimension alone.

    5. Indexing and Retrieval: Hybrid Search Beats Vectors Alone

    Vector search is strong at semantic similarity but can be unstable for IDs, proper nouns, and exact phrases. Production knowledge bases usually combine vector search with keyword search, then use a reranker to improve relevance. Retrieval should support metadata filters, such as department, classification level, document version, and effective time, so results are both relevant and compliant.

    Example retrieval configuration:

    1. retrieval:
    2. top_k: 8
    3. keyword_weight: 0.3
    4. vector_weight: 0.7
    5. rerank: true
    6. rerank_top_n: 4
    7. filters:
    8. - security_level <= user_level
    9. - status == active

    Do not concatenate retrieval results directly into the model prompt. Deduplicate, truncate, order the context, and assign citation numbers. For long documents, keep section titles as context clues. For table fragments, include header descriptions. Control rerank latency. When needed, use two stages: a coarse recall of more candidates, then a smaller model for reranking.

    6. Generation and Citations: Answers That Can Be Checked

    The generation stage must constrain the model to the retrieved context and require citations. The system prompt should state: answer only from the given materials; if the materials are insufficient, say so; do not invent sources; citation numbers must match retrieved passages. Keep temperature low to reduce divergence. Example request:

    1. {
    2. "question": "差旅报销标准是什么?",
    3. "top_k": 8,
    4. "with_citations": true,
    5. "answer_mode": "strict"
    6. }

    The response should include the answer, cited passages, document IDs, and version numbers. For high-risk cases, add an answer-confidence signal and a human-review flag. If retrieval is empty or rerank scores are too low, refuse or hand off to a person instead of letting the model answer freely.

    7. Permissions, Audit, and Security: Local Deployment Is Not Automatic Safety

    The knowledge base must enforce document-level or passage-level access control. When a user asks a question, the retrieval layer filters candidates by identity, department, and classification level before generation. Do not retrieve everything and then hide content in the answer. Audit logs should record the asker, time, question, retrieved documents, cited passages, model version, and an output summary for accountability and improvement. Redact sensitive information before ingestion, grant credentials with least privilege, and encrypt backups.

    8. Evaluation, Operations, and Rollout

    Before launch, build an evaluation set of real questions, reference answers, documents that should be cited, and documents that should not be retrieved. Metrics should at least include recall, citation accuracy, answer correctness, refusal accuracy, average latency, and failure rate. After launch, feed user feedback, low-scoring questions, and answers without citations back into the evaluation set so optimization stays closed-loop.

    Operations should monitor parse-queue backlog, embedding failure rate, retrieval latency, model-service error rate, storage capacity, and index size. Rebuild indexes by version after document updates. Run regression evaluation before model upgrades. Practice backup and restore regularly. A practical rollout is pilot, evaluate and tune, harden permissions, then expand in batches: start with one department, one document type, and a set of high-frequency questions until the loop works, then grow data sources and concurrency.

    Common pitfalls include treating embedding as the whole knowledge base, ignoring metadata and permissions, having no refusal path, lacking an evaluation set, and letting indexes drift after document updates. Avoiding these pitfalls is what turns a local large language model into an auditable, scalable, and continuously operable enterprise knowledge base.