You Probably Don't Need a Vector Database

  • Comments posted to this topic are about the item You Probably Don't Need a Vector Database

  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • This is a very nice, concise, demo of RAG. I learned a lot of it. Thanks for posting!

    The example required a few small changes in the function retrieve: the lines with sorted() and the last line of the function have a missing indexer .

    Corrected version:

        def retrieve(self, query: str, top_k: int = TOP_K) -> list[str]:
            scores = self.bm25.get_scores(query.lower().split())
            top_idx = sorted(range(len(scores)), key=lambda i: scores[ i ], reverse=True)[:top_k]
            print(f"  Top chunks retrieved:")
            for rank, idx in enumerate(top_idx):
                print(f"    [{rank+1}] score={scores[idx]:.4f} ? {self.chunks[idx][:80]}...")
            print()
            return [self.chunks[ i ] for i in top_idx]

     

    • This reply was modified 1 weeks, 5 days ago by sqlservercentral 57377. Reason: The BBcode formatting caused the same error in the code as in the published version
    • This reply was modified 1 weeks, 5 days ago by sqlservercentral 57377. Reason: another try to avoid BBcode removing the [ i ]

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply