Deploying a Retrieval-Augmented Generation System with Huixiangdou

The Huixiangdou platform provides a browser-based interface for rapidly initializing a domain-specific knowledge base. Access the hosted application endpoint and input a unique repository identifier alongside an authentication credential. Upon submission, the system provisions the backend infrastructure. The dashboard exposes core operational modules: document ingestion pipelines, query filtering via positive and negative exemplars, messaging platform integrations (WeChat/Lark), and web search toggles.

Document processing begins by uploading target files. The extraction engine parses and indexes content, typically achieving high accuracy across standard formats. Following successful ingestion, interactive validation commences. Submitted queries generate synthesized responses accompanied by explicit source citations. The architecture demonstrates robust cross-document context retrieval, accurately linking related concepts across distinct files. Query filtering is evaluated by injecting both domain-relevant and out-of-scope prompts to verify threshold-based rejection logic.

Transitioning to a local deployment environment requires establishing a dedicated workspace, mapping pre-trained checkpoints, and configuring application parameters.

Environment Provisioning & Dependency Resolution

Initialize the runtime environment using the designated template:

CONDA_ENV="InternLM2_Huixiangdou"
BASE_TEMPLATE="internlm-base"
studio-conda -o "$BASE_TEMPLATE" -t "$CONDA_ENV"

Map the required embedding, reranking, and generative model checkpoints to a centralized directory using symbolic links:

MODEL_BASE="/workspace/models"
mkdir -p "$MODEL_BASE"

ln -sf /root/share/new_models/maidalun1020/bce-embedding-base_v1 "${MODEL_BASE}/vec-embedder"
ln -sf /root/share/new_models/maidalun1020/bce-reranker-base_v1 "${MODEL_BASE}/vec-reranker"
ln -sf /root/share/new_models/Shanghai_AI_Laboratory/internlm2-chat-7b "${MODEL_BASE}/llm-core"

Generate a requirements manifest and install the necessary Python packages:

cat << 'REQS' > /tmp/rag_dependencies.txt
protobuf==4.25.3
accelerate==0.28.0
aiohttp==3.9.3
auto-gptq==0.7.1
bcembedding==0.1.3
beautifulsoup4==4.8.2
einops==0.7.0
faiss-gpu==1.7.2
langchain==0.1.14
loguru==0.7.2
lxml_html_clean==0.1.0
openai==1.16.1
openpyxl==3.1.2
pandas==2.2.1
pydantic==2.6.4
pymupdf==1.24.1
python-docx==1.1.0
pytoml==0.1.21
readability-lxml==0.8.1
redis==5.0.3
requests==2.31.0
scikit-learn==1.4.1.post1
sentence_transformers==2.2.2
textract==1.6.5
tiktoken==0.6.0
transformers==4.39.3
transformers_stream_generator==0.0.5
unstructured==0.11.2
REQS

pip install -r /tmp/rag_dependencies.txt

Retrieve the application source code and lock to a stable commit:

APP_ROOT="/workspace/huixiangdou"
git clone https://github.com/internlm/huixiangdou "$APP_ROOT"
cd "$APP_ROOT"
git checkout 447c6f7e68a1657fce1c4f7c740ea1700bde0440

Configuration & Dataset Initialization

Update the configuration file to point to the locally mapped model paths:

CONF_FILE="config.ini"
sed -i -e "6s/.*/embedding_model_path = \"${MODEL_BASE}\/vec-embedder\"/" \
       -e "7s/.*/reranker_model_path = \"${MODEL_BASE}\/vec-reranker\"/" \
       -e "29s/.*/local_llm_path = \"${MODEL_BASE}\/llm-core\"/" \
       "$CONF_FILE"

Fetch the supplementary knowledge corpus:

CORPUS_DIR="${APP_ROOT}/repodir"
mkdir -p "$CORPUS_DIR"
git clone --depth 1 https://github.com/internlm/huixiangdou "${CORPUS_DIR}/huixiangdou"

Construct the query filtering dataset using a Python utility to ensure valid JSON serialization:

import json
filter_path = "resource/good_questions.json"
with open(filter_path, "w", encoding="utf-8") as f:
    json.dump([
        "Integration methods between YOLO and mmpose",
        "Behavior recognition workflows post-estimation",
        "Checkpoint substitution procedures in topdown demos",
        "Multi-dataloader configuration in mmdetection",
        "RetinaNet single-scale adaptation guides",
        "Differentiation between MMPose tutorial notebooks and demo scripts",
        "Diagnostics for zero MAP metrics during evaluation",
        "Human keypoint extraction pipelines",
        "Dataset formatting standards for Labelme vs native formats",
        "C++ inference export routines for OpenMMPose",
        "Alternative model storage locations beyond the default demo directory",
        "Capabilities for activity recognition within mmpose",
        "Migration paths to YOLOX-Pose configurations",
        "Cross-architecture compilation notes for macOS Silicon",
        "Real-time 3D pose streaming via peripheral cameras",
        "Core functional overview of the Huixiangdou system",
        "Operational safety protocols for scientific instruments",
        "WeChat ecosystem deployment guidelines",
        "Lark workspace integration procedures",
        "Configuration syntax for config.ini parameters",
        "Compatible identifiers for the remote_llm_model setting"
    ], f, indent=2)

Prepare a test payload to validate the filtering pipeline:

["Define the primary architecture of huixiangdou.", "Generate a self-introduction."]

Save the payload to ./test_queries.json.

Pipeline Validation

Execute the filtering routine to verify rejection thresholds. The system correctly identifies and discards out-of-scope inputs such as conversational greetings or self-introduction prompts, demonstrating effective similarity-based gating. When processing valid technical queries, the console output logs the complete retrieval workflow: vector search, context window assembly, prompt construction, and LLM inference generation. The integrated pipeline successfully isolates irrelevant inputs while executing precise document-grounded responses for authorized queries.

Tags: RAG Knowledge Base Huixiangdou InternLM python

Posted on Mon, 10 Aug 2026 16:55:11 +0000 by surreal5335