Right. So internally llama index tells the model to only use information from your documents (and not from itself) to answer queries, but the model doesn't always follow instructions. (They aren't as smart as us yet haha).
So there are three options in this case.
- Check response.source_nodes to ensure that the text use to generate the response has sufficient similarity
- Set something like
similarity_cutoff=0.6
to filter out documents that don't relate to the query
- Do some prompt engineering and customize the internal prompts:
https://gpt-index.readthedocs.io/en/latest/how_to/customization/custom_prompts.html