Views
No views yet
1!pip install ragatouille
2
3# Additional package to enable GPU for indexing. Ignore for CPU indexing (slow).
4!pip uninstall faiss-cpu -y
5!pip install faiss-gpu1from ragatouille import RAGPretrainedModel
2
3RAG = RAGPretrainedModel.from_pretrained("turjo4nis/colbertv2.0-bn")
4
5# define your desired documents as a list of strings.
6my_documents = [
7 "উইকিপিডিয়া হলো সম্মিলিতভাবে সম্পাদিত, বহুভাষিক, মুক্ত প্রবেশাধিকার, মুক্ত.....",
8 "বিষয়বস্তু সংযুক্ত অনলাইন বিশ্বকোষ যা উইকিপিডিয়ান বলে.....",
9 "পরিচিত স্বেচ্ছাসেবক সম্প্রদায় কর্তৃক লিখিত এবং রক্ষণাবেক্ষণকৃত। স্বেচ্ছাসেবকেরা.....",
10 "মিডিয়াউইকি নামে একটি উইকি -ভিত্তিক সম্পাদনা ব্যবস্থা ব্যবহার করে সম্পাদনা করেন।.....",
11]
12
13# OPTIONAL - define document ids as a list of strings
14docid_list = ['1', '2', '3', '4', ]
15
16RAG.index(
17 index_name="my_index", # local save location -> '.ragatouille/colbert/indexes/my_index'
18 collection=my_documents,
19 document_ids=docid_list, # OPTIONAL
20 split_documents=False, # if set True, then documents will be chunked to the token amount set in max_document_length
21 # max_document_length=512, # un-comment if split_documents is set True
22 use_faiss=True,
23)
24
25query = "উইকিপিডিয়া কি?"
26RAG.search(query)1from ragatouille import RAGPretrainedModel
2
3path_to_index = ".ragatouille/colbert/indexes/my_index"
4RAG = RAGPretrainedModel.from_index(path_to_index)
5
6query = "উইকিপিডিয়া কি?"
7results = RAG.search(query, k=2) # k = number of top-ranked documents to be retrieved
8
9results