Skip to content

Conversation

CostantinoEsposito89
Copy link

Improve robustness of score parsing

The format_output method in QualityScorer previously parsed scores by splitting the LLM output by newlines and iterating. This approach was brittle and could fail if the LLM included reasoning, explanations, or extra newlines before the score list, causing valid scores to be missed.

This commit refactors the parsing logic to use re.findall. This robustly extracts all lines matching the score format from the entire output, regardless of their position.

Key improvements:

  • Resilience: Correctly parses scores even when they are preceded by reasoning or other text from the LLM.
  • Reliability: Ensures the scores list is correctly padded with None if fewer scores are found than expected, maintaining a consistent output shape.

CostantinoEsposito89 and others added 2 commits October 1, 2025 14:38
The `format_output` method in `QualityScorer` previously parsed scores by splitting the LLM output by newlines and iterating. This approach was brittle and could fail if the LLM included reasoning, explanations, or extra newlines before the score list, causing valid scores to be missed.

This commit refactors the parsing logic to use `re.findall`. This robustly extracts all lines matching the score format from the entire output, regardless of their position.

Key improvements:
- Resilience: Correctly parses scores even when they are preceded by reasoning or other text from the LLM.
- Reliability: Ensures the `scores` list is correctly padded with `None` if fewer scores are found than expected, maintaining a consistent output shape.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant