Adding confidence scores to Chat-GPT's predictions to detect hallucinations
We are attempting to build upon the ideas of Wang et. al. & Lakshminarayanan et. al. in this project.
To improve the accuracy of the LLM, we use Wang et. al.'s idea of 'self-consistency', which involves sampling the answer to the same question multiple times and using the answer with the maximum frequency as the answer returned t othe user. The whole process can be though of as a majority vote, which amplifies the chances to arrive at the correct answer and discards unfrequent 'hallucinations'.
Next, we extend this by using Lakshminarayanan et. al.'s ideas on uncertainity in prediction to quantify how sure the LLM is about the final answer. This metric can be used to set a threshold that prevents hallucinatory answers from being displayed to the user.
- sampler.py -> makes a single query to Open AI's ChatGPT
- prompts/ -> folder containing exemplar prompts for different tasks
- ensembler.py -> uses sampler's results to cast a majority vote among answers
- parser/ -> folder contains parsers corresponding to different input prompts
- example_usage.py -> demonstration on how to use the provided codes