Implement Phase 18: Hybrid Search (BM25 + Vector)
- FastEmbedSparse(Qdrant/bm25) 기반 sparse 임베딩 추가 (fastembed 패키지) - IngestionService: HYBRID_SEARCH_ENABLED 시 dense + sparse 동시 저장 (RetrievalMode.HYBRID) - _ensure_collection_schema(): sparse vector 미설정 컬렉션 자동 삭제·재생성 - RetrieverService: hybrid 스토어 + dense 폴백 구조, Qdrant 내장 RRF로 결과 통합 - container.py: sparse_embeddings Singleton 프로바이더, ingestion/retriever 양쪽 주입 - .env.example: HYBRID_SEARCH_ENABLED, SPARSE_MODEL_ID 항목 추가 활성화: .env에 HYBRID_SEARCH_ENABLED=true 설정 후 기존 문서 재수집 필요 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-9
@@ -184,15 +184,21 @@ turns = conversation_repository.load_turns_after(self._conv_id, None, limit=10)
|
||||
|
||||
---
|
||||
|
||||
## Phase 18 — Hybrid Search (BM25 + Vector) ★★☆
|
||||
## ✅ Phase 18 — Hybrid Search (BM25 + Vector) ★★☆
|
||||
|
||||
**배경**: 한국어 질문에서 고유명사·전문용어가 포함된 경우 의미 검색(Dense)만으로는 recall이 떨어진다. BM25 키워드 검색과 결합(Hybrid)하면 보완이 가능하다.
|
||||
|
||||
**구현 방식**:
|
||||
- Qdrant의 Sparse Vector 지원 활용 (`FastEmbedSparseEmbeddings` 또는 BM42)
|
||||
- 인덱싱 시 dense + sparse 두 벡터 동시 저장
|
||||
- 검색 시 `RRF(Reciprocal Rank Fusion)`로 결과 통합
|
||||
- `IngestionService`, `RetrieverService` 양쪽 수정 필요
|
||||
**구현 내용**:
|
||||
- `FastEmbedSparse(model_name="Qdrant/bm25")` — 언어 무관 BM25 sparse 임베딩 (`fastembed` 패키지)
|
||||
- `IngestionService`: `HYBRID_SEARCH_ENABLED=true` 시 dense + sparse 동시 저장 (`RetrievalMode.HYBRID`)
|
||||
- `RetrieverService`: hybrid 스토어로 검색 → Qdrant 내장 RRF로 결과 통합; sparse vector 미설정 컬렉션은 dense로 자동 폴백
|
||||
- `_ensure_collection_schema()`: hybrid 전환 시 스키마 불일치 컬렉션 자동 재생성 (기존 문서 재수집 필요)
|
||||
- `.env` `HYBRID_SEARCH_ENABLED=true`로 활성화, 활성화 후 기존 문서 재수집 필요
|
||||
|
||||
| 설정 | 기본값 | 설명 |
|
||||
|------|--------|------|
|
||||
| `HYBRID_SEARCH_ENABLED` | `false` | `true`로 설정 시 활성화 |
|
||||
| `SPARSE_MODEL_ID` | `Qdrant/bm25` | fastembed sparse 모델 (첫 실행 시 자동 다운로드) |
|
||||
|
||||
**난이도**: 중간 | **임팩트**: 높음 (키워드 포함 질문 recall 대폭 향상)
|
||||
|
||||
@@ -271,8 +277,8 @@ docker-compose.yml
|
||||
```
|
||||
단기 (1~2주) 중기 (1개월) 장기
|
||||
──────────────────────── ────────────────────── ──────────────────
|
||||
Phase 18 Hybrid Search → Phase 15 (모델선택) → Phase 16 (Docker)
|
||||
Phase 19 Query Rewriting → Phase 20 (RAGAS 평가) → Phase 17 (멀티모달)
|
||||
Phase 19 Query Rewriting → Phase 15 (모델선택) → Phase 16 (Docker)
|
||||
→ Phase 20 (RAGAS 평가) → Phase 17 (멀티모달)
|
||||
```
|
||||
|
||||
### 우선순위 매트릭스
|
||||
@@ -295,7 +301,7 @@ Phase 19 Query Rewriting → Phase 20 (RAGAS 평가) → Phase 17 (멀티모
|
||||
| Phase 13 Semantic Chunker | ✅ 완료 | — | — | — |
|
||||
| Phase 14 음성 인터페이스 | ✅ 완료 | — | — | — |
|
||||
| Phase 13-B Reranker | ✅ 완료 | — | — | — |
|
||||
| Phase 18 Hybrid Search | 🔲 신규 | 중간 | 높음 | ⭐ 1순위 |
|
||||
| Phase 18 Hybrid Search | ✅ 완료 | — | — | — |
|
||||
| Phase 19 Query Rewriting | 🔲 신규 | 하 | 중간 | 3순위 |
|
||||
| Phase 15 모델 선택 | 🔲 미완 | 중간 | 중간 | 4순위 |
|
||||
| Phase 20 RAGAS 평가 | 🔲 신규 | 중간 | 중간 | 5순위 |
|
||||
|
||||
Reference in New Issue
Block a user