solution removed
This gives error in executing with query text
TypeError Traceback (most recent call last)
Cell In[92], line 2
1 # Output is a list of indices
----> 2 bm25_retrieve(“What are the recent news about GDP?”)
Cell In[91], line 29, in bm25_retrieve(query, top_k)
25 BM25_RETRIEVER.index(TOKENIZED_DATA)
27 # Use the ‘BM25_RETRIEVER’ to retrieve documents and their scores based on the tokenized query
28 # Retrieve the top ‘k’ documents
—> 29 results, scores = BM25_RETRIEVER.retrieve(tokenized_query, top_k)
31 # Extract the first element from ‘results’ to get the list of retrieved documents
32 results = results[0]
File /opt/conda/lib/python3.12/site-packages/bm25s/init.py:866, in BM25.retrieve(self, query_tokens, corpus, k, sorted, return_as, show_progress, leave_progress, n_threads, chunksize, backend_selection, weight_mask)
864 else:
865 index_flat = indices.flatten().tolist()
→ 866 results = [corpus[i] for i in index_flat]
867 retrieved_docs = np.array(results).reshape(indices.shape)
869 if return_as == “tuple”:
TypeError: ‘int’ object is not subscriptable