다국어 RAG 아키텍처 개요
Elasticsearch와 Mixtral 8x22B 모델을 결합해 다국어 RAG(Retrieval-Augmented Generation) 애플리케이션을 구축합니다. Mixtral 8x22B는 영어, 스페인어, 프랑스어, 이탈리아어, 독일어 등 다국어 지원이 뛰어난 오픈 모델로, 글로벌 기업의 다양한 언어로 작성된 지원 티켓을 통합 관리하는 데 적합합니다.
핵심 구성 단계
- 임베딩 엔드포인트 설정
- 매핑 구성
- 데이터 인덱싱
- 질의 처리
다국어 임베딩 엔드포인트 설정
Mistral 임베딩 모델은 단일 언어만 지원하므로, 다국어 텍스트 처리에는 e5 모델을 사용합니다. Kibana 콘솔에서 다음 API 호출로 설정:
PUT _inference/text_embedding/multilingual-embedder
{
"service": "elasticsearch",
"service_settings": {
"model_id": ".multilingual-e5-small",
"num_allocations": 1,
"num_threads": 1
}
}
인덱스 매핑 구성
semantic_text 필드 타입을 사용해 자동 청킹과 임베딩 생성을 활성화합니다:
PUT multilingual-index
{
"mappings": {
"properties": {
"document_content": {
"type": "semantic_text",
"inference_id": "multilingual-embedder"
}
}
}
}
다국어 데이터 샘플 인덱싱
다양한 언어의 지원 티켓을 인덱스에 추가:
영어 티켓: 캘린더 동기화 오류
**Subject**: Google Calendar sync failure **Resolution**: 1. Settings > Integrations 이동 2. Google 연동 해제 3. 브라우저 캐시/쿠키 삭제 4. 연동 재설정
독일어 티켓: 파일 업로드 실패
**Betreff**: Datei-Upload Fehler **Lösung**: 1. 파일 크기 확인 (최대 100MB) 2. 방화벽 일시 비활성화 3. 시크릿 모드에서 시도
다국어 질의 처리
스페인어로 질의:
Hola, tengo problemas para sincronizar mi calendario y subir archivos
유사도 검색 쿼리
GET multilingual-index/_search
{
"size": 2,
"_source": {"excludes": ["*.embeddings"]},
"query": {
"semantic": {
"field": "document_content",
"query": "Hola, tengo problemas para sincronizar mi calendario y subir archivos"
}
}
}
Mistral API를 통한 응답 생성
from mistralai.client import MistralClient
mistral = MistralClient(api_key=os.environ["MISTRAL_KEY"])
system_prompt = "사용자 질문 언어로 답변하는 다국어 지원 에이전트"
response = mistral.chat(
model="open-mixtral-8x22b",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": f"질문: {user_query}\n관련 문서: {retrieved_docs}"}
]
)
print(response.choices[0].message.content)
스페인어 응답 결과
Para sincronizar el calendario: 1. Desconecta la integración en Configuración 2. Limpia caché del navegador 3. Vuelve a conectar Para errores de subida: 1. Verifica el tamaño del archivo 2. Prueba en modo incógnito
기술적 장점
Mixtral 8x22B의 다국어 이해 능력과 Elasticsearch의 semantic_text 필드 결합은 언어 장벽 없이 크로스-링구얼 지식 검색을 가능하게 합니다.