I am developing a side project recently and there is a part in my project are required to extract the information from user's upload. These uploads could be pdf or image. The content of the upload will be extracted as key-value pair in json. My approach is using LLM to extract the data but there is a problem obviously that LLM may missing some data or have hallucination. I would like to design a validation test to detect whether there is any problem in LLM's output, and hint the user where can he find the problem probably. Now, I am struggling in how to design this validation test. For PDF, I develop a simple test to detect hallucination that save all text of the PDF to a string pdf_text, and search whether all LLM's output in pdf_text. ... search_items = re.findall(r'[\w-]+', content_from_pdf) all_item_found = all(item in pdf_text for item in search_items) ... The biggest challenge is for img, I don't have any idea how to detect the hallucination, not to mention the problem of missing data. Continue reading...