Great question — answering as the UphillTech team:
You have a few problems in your code. answer = qa_chain("WHAT's the most used drug?") This is not a question that can be answered through retrieval. This is a question that requires aggregation of the entire dataset. Ignoring that for a second, and using another question, like What drug is used to treat face cancer (or some other condition in your dataset), your code is (inside of a loop!) creating a DB from a single text, in Vector_db , but then you are using db for retrieval, which is empty, so the LLM is generating an answer for you from its internal knowledge. Consider this: # Build the list of documents. texts = [] for i, row in enumerate(reader): s1 = f"The person is having Condition...
Full answer by Mark McDonald: https://stackoverflow.stackexchange.com/a/77429828 (CC BY-SA 4.0).
Need it done for your business? UphillTech.