Setting Up the Development Environment on InternLM Studio
Begin by launching a develompent instance and configuring the runtime environment. Once inside, replicate the base environment for running InternLM by creating a custom conda environment named InternLM2_Huixiangdou:
studio-conda -o internlm-base -t InternLM2_Huixiangdou
After cloning the environment, verify its presence locally. Then activate the newly created Python virtual environment using Conda:
conda activate InternLM2_Huixiangdou
Next, prepare the required model files for the assistant. Create a dedicated directory and link the necessary models:
# Create models directory
cd /root && mkdir models
# Link BCE embedding model
ln -s /root/share/new_models/maidalun1020/bce-embedding-base_v1 /root/models/bce-embedding-base_v1
# Link BCE reranker model
ln -s /root/share/new_models/maidalun1020/bce-reranker-base_v1 /root/models/bce-reranker-base_v1
# Select one large language model based on your task (example below)
ln -s /root/share/new_models/Shanghai_AI_Laboratory/internlm2-chat-7b /root/models/internlm2-chat-7b
Install all dependencies needed for the assistant to function properly:
pip install 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
Note: Since InternLM Studio does not allow permenent system modifications, it is recommended to skip installing
.doc/.docxparsing dependencies unless you plan to process Word documents in later stages. To enable document parsing, uncomment the following line:# apt update && apt -y install python-dev python libxml2-dev libxslt1-dev antiword unrtf poppler-utils pstotext tesseract-ocr flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig libpulse-dev
Now, fetch the official repository for the assistant:
cd /root
git clone https://github.com/internlm/huixiangdou && cd huixiengdou
git checkout 447c6f7e68a1657fce1c4f7c740ea1700bde0440
Update the configuration file to point to the local model paths. Modify three entries in /root/huixiangdou/config.ini:
Set the embedding model path:
sed -i '6s#.*#embedding_model_path = "/root/models/bce-embedding-base_v1"#' /root/huixiangdou/config.ini
Set the reranking model path:
sed -i '7s#.*#reranker_model_path = "/root/models/bce-reranker-base_v1"#' /root/huixiangdou/config.ini
Set the local LLM path:
sed -i '29s#.*#local_llm_path = "/root/models/internlm2-chat-7b"#' /root/huixiangdou/config.ini
Prepare the knowledge base by cloning relevant source material:
cd /root/huixiangdou && mkdir repodir
git clone https://github.com/internlm/huixiangdou --depth=1 repodir/huixiangdou
Perform a basic test run:
Modify the default query list in the main script to include sample questions:
sed -i '74s/.*/ queries = ["What is Huixiangdou?", "How to deploy Huixiangdou in WeChat", "What's the weather today?"]/' /root/huixiangdou/huixiangdou/main.py
Finally, launch the assistant:
cd /root/huixiangdou
python3 -m huixiangdou.main --standalone
This completes the setup for handling queries such as "How to deploy Huixiangdou in WeChat?".
Integrating with WeChat via Web Interface
Use the web-based version of Huixiangdou for deployment.
Download the precompiled APK from the GitHub Releases page following the provided instructions.
- Enter the webhook URL provided by the WeChat integration service and confirm.
- Tap the "Tap Me" button to toggle the "Huixiangdou LLM RAG Response" feature on or off.
- Keep the application running. Navigate to a WeChat group chat and send a message to experience real-time responses.