fix: gracefully handle hallucinated dataset IDs in populate_stage to prevent KeyError #152#155
Conversation
…Error Skip unknown dataset IDs with a warning log in format_multidataset_queries and V2 populate_stage dataset references, instead of crashing. This prevents a KeyError when the LLM hallucinates a dataset UUID before _remove_hallucinations gets a chance to filter it out.
|
the issue is not only with formatting. if llm selected incorrect |
|
also, it's better not to pass uuid to llm. instead, we can pass:
we also need to make sure there are no duplicates. for example if there are duplicated urns (for some reason. though they should not) we can add index prefix: "1-imf:weo" |
I think it gets deleted in the latter stage at _remove_hallucinations() |
Sound like a bigger change. Should we merge this PR as a hotfix, and create a follow-up feature request to make these changes? |
|
I don't like the current proposed change. it states that, when populating stage or formatting query, the query can contain dataset queries to unavailable datasets. this seems incorrect - we should remove any hallucinations from LLM response and call formatting only afterwards |
…allucinated-dataset-id-in-populate-stage
…in-populate-stage
…cator Selection Chain" This reverts commit d3ec0bd.
Created a separate feature request: #172, and pushed changes in PR #173. It's done to un-block this hotfix merge, and to have review and discussion for the in-depth fix in the separate place. |
I disagree that proposed change is wrong, populate stage should not make implicit assumptions, and must not fail if the code that calls it will change in the future. On the other hand, swapping remove_hallucinations and populate_stage makes sense. But because of the code structure, such change seem to require refactoring. And so should be prioritized separately |
Add warning log for unknown dataset IDs when populating stage content.
Skip unknown dataset IDs with a warning log in format_multidataset_queries and V2 populate_stage dataset references, instead of crashing. This prevents a KeyError when the LLM hallucinates a dataset UUID before _remove_hallucinations gets a chance to filter it out.
Applicable issues
Description of changes
Checklist
Reviewenvironment.By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.