ragas
ragas copied to clipboard
Improve JSON format prompt for large chunks & Handle ZeroDivisionError
Description
In this PR there are three different changes
Changes
- Fixed a Typo in the filter_question_prompt Instruction from
AssestoAssess - Added a try-except block for handling ZeroDivisionError for the filter method in the NodeFilter class
- Improved the JSON_FORMAT_INSTRUCTIONS for better output generation
It seems like the LLM sometimes loses track of the imposed instruction for the output, especially for long prompts. So although the output generated for a chunk_size of 512 is perfect, the output for a chunk_size of 1024 has an extra newline. Here parsing fails when using PydanticOutputParser even though the llm has generated an output and there is only an extra
'\n'as shown in the instances below.But by tuning the prompt and adding
Please output your response in the demanded json format.at the end of the instruction we get output without'\n'. This output can then be parsed and the context can be considered.
@shahules786 could you check if we can merge this in?
hey @Manav916 we did make some improvements with the v0.2 release - do check it out
closing this for now but I'm really sorry we couldn't merge it 🙁 but at the same time thanks a million for taking the time to raise this, really grateful too and do checkout this form https://docs.google.com/forms/d/e/1FAIpQLSdM9FrrZrnpByG4XxuTbcAB-zn-Z7i_a7CsMkgBVOWQjRJckg/viewform - our way of saying thank you 🙂