Entendendo o BM25
Antes de começar a integrar um retriever esparso BM25 na sua arquitetura de RAG, é melhor testá-lo em algumas strings curtas para ganhar intuição sobre como o retriever seleciona os documentos.
Foram fornecidas três strings que você usará como base para o seu retriever BM25. A funcionalidade necessária para este exercício já está carregada para você.
Este exercício faz parte do curso
Retrieval Augmented Generation (RAG) com LangChain
Instruções do exercício
- Inicialize o retriever BM25 a partir dos documentos, configurando-o para recuperar três documentos por vez.
- Invoque o retriever na consulta fornecida.
- Imprima o conteúdo da página do primeiro resultado.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
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(____)