영어 | 简体中文
HuixiangDou는 LLM을 기반으로 한 전문 지식 보조원 입니다.
장점:
chat_in_group
그룹 채팅 시나리오에 대처하고 메시지 홍수 없이 사용자 질문에 답변합니다. 2401.08772, 2405.02817, 하이브리드 검색 및 정밀 보고서를 참조하세요.chat_with_repo
HuixiangDou가 달리는 장면을 확인하고 WeChat 그룹에 가입하여 내부 AI 도우미를 사용해 보세요.
도움이 되셨다면 별점 부탁드립니다
우리의 웹 버전은 OpenXLab에 출시되었습니다. 여기서 지식 베이스를 생성하고, 긍정적인 예와 부정적인 예를 업데이트하고, 웹 검색을 활성화하고, 채팅을 테스트하고, Feishu/WeChat 그룹에 통합할 수 있습니다. BiliBili와 YouTube를 확인하세요!
Android용 웹 버전의 API는 다른 장치도 지원합니다. Python 샘플 코드를 참조하세요.
langchain
제거 ?? | LoRA-Qwen1.5-14B | LoRA-Qwen1.5-32B | 알파카 데이터 | arXiv |
법학대학원 | 파일 형식 | 검색 방법 | 완성 | 전처리 |
|
|
|
|
|
다음은 다양한 기능에 대한 GPU 메모리 요구 사항입니다. 차이점은 옵션이 켜져 있는지 여부에만 있습니다.
구성 예 | GPU 메모리 요구 사항 | 설명 | Linux에서 확인됨 |
---|---|---|---|
구성-cpu.ini | - | Siliconcloud API 사용 텍스트 전용 | |
구성-2G.ini | 2GB | openai API(예: kimi, deepseek, stepfun 등을 사용하여 텍스트만 검색) | |
config-multimodal.ini | 10GB | LLM, 이미지 및 텍스트 검색에 openai API 사용 | |
[스탠다드 에디션] config.ini | 19GB | LLM의 로컬 배포, 단일 양식 | |
구성-고급.ini | 80GB | 현지 LLM, 아나포라 해결, 단일 양식, WeChat 그룹에 실용적 |
우리는 표준판(로컬 실행 LLM, 텍스트 검색)을 소개 예로 들었습니다. 다른 버전은 구성 옵션이 다릅니다.
BCE 모델 계약에 동의하려면 클릭하고 로그인하세요.huggingface
huggingface-cli login
종속성 설치
# parsing `word` format requirements
apt update
apt install python-dev libxml2-dev libxslt1-dev antiword unrtf poppler-utils pstotext tesseract-ocr flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig libpulse-dev
# python requirements
pip install -r requirements.txt
# For python3.8, install faiss-gpu instead of faiss
mmpose 문서를 사용하여 mmpose 지식 기반과 필터링 질문을 구축하세요. 자신만의 문서가 있다면 repodir
아래에 넣으세요.
다음 명령('#' 기호 포함)을 모두 복사하고 실행합니다.
# Download the knowledge base, we only take the documents of mmpose as an example. You can put any of your own documents under `repodir`
cd HuixiangDou
mkdir repodir
git clone https://github.com/open-mmlab/mmpose --depth=1 repodir/mmpose
# Save the features of repodir to workdir, and update the positive and negative example thresholds into `config.ini`
mkdir workdir
python3 -m huixiangdou.service.feature_store
실행 후 python3 -m huixiangdou.main --standalone
으로 테스트합니다. 이때, mmpose 관련 질문(지식베이스 관련)에는 답변하고, 날씨 관련 질문에는 답변하지 않습니다.
python3 -m huixiangdou.main --standalone
+---------------------------+---------+----------------------------+-----------------+
| Query | State | Reply | References |
+===========================+=========+============================+=================+
| How to install mmpose ? | success | To install mmpose, plea.. | installation.md |
--------------------------------------------------------------------------------------
| How is the weather today ? | unrelated.. | .. | |
+-----------------------+---------+--------------------------------+-----------------+
? Input your question here, type ` bye ` for exit:
..
메모
또한 gradio
사용하여 간단한 웹 UI를 실행합니다.
python3 -m huixiangdou.gradio_ui
또는 서버를 실행하여 23333을 수신합니다. 기본 파이프라인은 chat_with_repo
입니다.
python3 -m huixiangdou.server
# test async API
curl -X POST http://127.0.0.1:23333/huixiangdou_stream -H " Content-Type: application/json " -d ' {"text": "how to install mmpose","image": ""} '
# cURL sync API
curl -X POST http://127.0.0.1:23333/huixiangdou_inference -H " Content-Type: application/json " -d ' {"text": "how to install mmpose","image": ""} '
repodir
문서, good_questions 및 bad_questions를 업데이트하고 자신의 도메인 지식(의료, 금융, 권력 등)을 시도해 보십시오.
우리는 typescript
프런트엔드 및 python
백엔드 소스 코드를 제공합니다.
OpenXlab APP과 동일합니다. 웹 배포 문서를 읽어보세요.
사용 가능한 GPU가 없는 경우 Siliconcloud API를 사용하여 모델 추론을 완료할 수 있습니다.
docker miniconda+Python3.11을 예로 들어 CPU 종속성을 설치하고 다음을 실행합니다.
# Start container
docker run -v /path/to/huixiangdou:/huixiangdou -p 7860:7860 -p 23333:23333 -it continuumio/miniconda3 /bin/bash
# Install dependencies
apt update
apt install python-dev libxml2-dev libxslt1-dev antiword unrtf poppler-utils pstotext tesseract-ocr flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig libpulse-dev
python3 -m pip install -r requirements-cpu.txt
# Establish knowledge base
python3 -m huixiangdou.service.feature_store --config_path config-cpu.ini
# Q&A test
python3 -m huixiangdou.main --standalone --config_path config-cpu.ini
# gradio UI
python3 -m huixiangdou.gradio_ui --config_path config-cpu.ini
설치가 너무 느리다면 Docker Hub에 사전 설치된 이미지가 제공됩니다. docker를 시작할 때 간단히 교체하세요.
GPU 메모리가 1.8G를 초과하거나 비용 효율성을 추구하는 경우. 이 구성은 로컬 LLM을 폐기하고 대신 Standard Edition과 동일한 원격 LLM을 사용합니다.
siliconcloud
예로 들어 공식 홈페이지에서 적용한 API TOKEN을 config-2G.ini
에 입력합니다.
# config-2G.ini
[ llm ]
enable_local = 0 # Turn off local LLM
enable_remote = 1 # Only use remote
..
remote_type = " siliconcloud " # Choose siliconcloud
remote_api_key = " YOUR-API-KEY-HERE " # Your API key
remote_llm_model = " alibaba/Qwen1.5-110B-Chat "
메모
Q&A 결과를 얻으려면 다음을 실행하세요.
python3 -m huixiangdou.main --standalone --config-path config-2G.ini # Start all services at once
10G GPU 메모리가 있는 경우 이미지 및 텍스트 검색을 추가로 지원할 수 있습니다. config.ini에 사용된 모델을 수정하면 됩니다.
# config-multimodal.ini
# !!! Download `https://huggingface.co/BAAI/bge-visualized/blob/main/Visualized_m3.pth` to `bge-m3` folder !!!
embedding_model_path = " BAAI/bge-m3 "
reranker_model_path = " BAAI/bge-reranker-v2-minicpm-layerwise "
메모:
bpe_simple_vocab_16e6.txt.gz
다운로드할 수 있습니다.테스트를 위해 Gradio를 실행하고 여기에서 이미지 및 텍스트 검색 결과를 확인하세요.
python3 tests/test_query_gradio.py
WeChat 체험 그룹의 "HuiXiangDou"는 모든 기능을 활성화했습니다.
다음 주제를 읽어보십시오.
기여자들은 WeChat과 상호작용할 수 있는 Android 도구를 제공했습니다. 이 솔루션은 시스템 레벨 API를 기반으로 하며 원칙적으로 모든 UI(통신 소프트웨어에 국한되지 않음)를 제어할 수 있습니다.
로봇이 너무 차갑거나 너무 수다스럽다면 어떻게 될까요?
resource/good_questions.json
에 입력하고, 거부해야 할 질문은 resource/bad_questions.json
에 입력합니다.repodir
의 테마 콘텐츠를 조정하세요. 임계값과 기능 라이브러리를 업데이트하려면 feature_store
다시 실행하세요.
reject_throttle
직접 수정할 수 있습니다. 일반적으로 0.5는 높은 값입니다. 0.2는 너무 낮습니다.
실행은 정상이지만 런타임 중에 메모리가 부족합니까?
변환기 구조를 기반으로 하는 LLM 긴 텍스트에는 더 많은 메모리가 필요합니다. 이때 lmdeploy 양자화 설명과 같은 모델에서 kv 캐시 양자화가 수행되어야 합니다. 그런 다음 docker를 사용하여 하이브리드 LLM 서비스를 독립적으로 배포합니다.
다른 지역 LLM에 접속하는 방법 / 접속 후 효과가 좋지 않습니까?
응답이 너무 느리거나 요청이 항상 실패하면 어떻게 되나요?
GPU 메모리가 너무 낮으면 어떻게 되나요?
이때 로컬 LLM 실행은 불가능하며, 원격 LLM만 text2vec와 연동하여 파이프라인 실행이 가능하다. config.ini
원격 LLM만 사용하는지 확인하고 로컬 LLM을 끄십시오.
@misc{kong2024huixiangdou,
title={HuiXiangDou: Overcoming Group Chat Scenarios with LLM-based Technical Assistance},
author={Huanjun Kong and Songyang Zhang and Jiaying Li and Min Xiao and Jun Xu and Kai Chen},
year={2024},
eprint={2401.08772},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
@misc{kong2024labelingsupervisedfinetuningdata,
title={Labeling supervised fine-tuning data with the scaling law},
author={Huanjun Kong},
year={2024},
eprint={2405.02817},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2405.02817},
}