Retrieval-Augmented Generation

Retrieval-Augmented Generation (RAG)

검색 증강 생성(RAG)은 생성형 AI(Gen AI) 모델이 새로운 정보를 검색하고 활용할 수 있게 해 주는 기법입니다. LLM과의 상호작용을 수정해, 모델이 지정된 문서 집합을 참고해 사용자 질의에 응답하고 이 정보로 사전 학습 데이터의 정보를 보강하게 합니다. 덕분에 LLM은 도메인 특화 정보나 최신 정보를 활용할 수 있게 됩니다. 활용 사례로는 내부 회사 데이터에 챗봇 접근을 제공하거나 권위 있는 출처에 기반해 응답을 생성하는 것 등이 있습니다.

다음은 vLLM과 연동되는 RAG 통합입니다:

출처: 문서

본문

vLLM + langchain

사전 준비 (Prerequisites)

vLLM과 langchain 환경을 설정합니다:

pip install -U vllm \
            langchain_milvus langchain_openai \
            langchain_community beautifulsoup4 \
            langchain-text-splitters

배포 (Deploy)

  • 지원되는 임베딩 모델로 vLLM 서버를 시작합니다. 예:
# Start embedding service (port 8000)
vllm serve ssmits/Qwen2-7B-Instruct-embed-base
  • 지원되는 채팅 완성 모델로 vLLM 서버를 시작합니다. 예:
# Start chat service (port 8001)
vllm serve qwen/Qwen1.5-0.5B-Chat --port 8001
python retrieval_augmented_generation_with_langchain.py

vLLM + llamaindex

사전 준비 (Prerequisites)

vLLM과 llamaindex 환경을 설정합니다:

pip install vllm \
            llama-index llama-index-readers-web \
            llama-index-llms-openai-like    \
            llama-index-embeddings-openai-like \
            llama-index-vector-stores-milvus \

배포 (Deploy)

  • 지원되는 임베딩 모델로 vLLM 서버를 시작합니다. 예:
# Start embedding service (port 8000)
vllm serve ssmits/Qwen2-7B-Instruct-embed-base
  • 지원되는 채팅 완성 모델로 vLLM 서버를 시작합니다. 예:
# Start chat service (port 8001)
vllm serve qwen/Qwen1.5-0.5B-Chat --port 8001
python retrieval_augmented_generation_with_llamaindex.py

더 알아보기 (Learn more)