Last active
February 1, 2024 00:18
-
-
Save fsndzomga/31c0d012ba7d06e6fea2788eaac26d31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ragatouille import RAGPretrainedModel | |
from ragatouille.utils import get_wikipedia_page | |
topics = ["Barack_Obama", "Nelson_Mandela", "king"] | |
RAG = RAGPretrainedModel.from_pretrained("colbert-ir/colbertv2.0") | |
my_documents = [] | |
# get documents for each topic | |
for topic in topics: | |
my_documents.append(get_wikipedia_page(topic)) | |
# create index | |
index_path = RAG.index( | |
index_name="leaders", | |
collection=my_documents, | |
document_ids=topics, | |
max_document_length=180, | |
split_documents=True | |
) | |
query = "Who was president of the united states of america in 2010 ?" | |
#retrieve relevant chunks from index | |
results = RAG.search(query, k=3) | |
print(results) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment