BM25 이해하기
RAG 아키텍처에 BM25 희소 리트리버를 통합하기 전에, 짧은 문자열로 먼저 시험해 보면서 리트리버가 문서를 어떻게 선택하는지 감을 잡아보는 것이 좋습니다.
BM25 리트리버의 기반으로 사용할 세 개의 문자열이 제공되었습니다. 이 연습에 필요한 기능은 이미 로드되어 있습니다.
이 연습은 강의의 일부입니다
LangChain을 활용한 RAG(검색 증강 생성)
연습 안내
- 문서에서 BM25 리트리버를 초기화하고, 한 번에 문서 세 개 를 검색하도록 설정하세요.
- 제공된 쿼리로 리트리버를 호출하세요.
- 첫 번째 결과의 페이지 콘텐츠를 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
chunks = [
"RAG stands for Retrieval Augmented Generation.",
"Graph Retrieval Augmented Generation uses graphs to store and utilize relationships between documents in the retrieval process.",
"There are different types of RAG architectures; for example, Graph RAG."
]
# Initialize the BM25 retriever
bm25_retriever = ____.from_texts(____)
# Invoke the retriever
results = bm25_retriever.____("Graph RAG")
# Extract the page content from the first result
print("Most Relevant Document:")
print(____)