ragas icon indicating copy to clipboard operation
ragas copied to clipboard

Improve JSON format prompt for large chunks & Handle ZeroDivisionError

Open Manav916 opened this issue 1 year ago • 1 comments

Description

In this PR there are three different changes

Changes

  1. Fixed a Typo in the filter_question_prompt Instruction from Asses to Assess
  2. Added a try-except block for handling ZeroDivisionError for the filter method in the NodeFilter class
  3. 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. Screenshot 2024-05-22 093242 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. Screenshot 2024-05-22 093757

Manav916 avatar May 21 '24 14:05 Manav916

@shahules786 could you check if we can merge this in?

jjmachan avatar May 22 '24 12:05 jjmachan

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 🙂

jjmachan avatar Nov 03 '24 04:11 jjmachan