Skip to content

Conversation

@Ashutosh0x
Copy link

Summary

This PR adds input validation to the make_seq2seq_fields function to handle empty prompt/response arrays gracefully.

Problem

When an empty prompt or response array is passed to make_seq2seq_fields, the function crashes with confusing numpy errors (negative array dimensions) instead of providing a clear error message.

Fixes #483

Solution

Added validation at the start of the function that:

  • Checks if prompt is empty and raises ValueError with clear message
  • Checks if
    esponse is empty and raises ValueError with clear message

Changes

File: gemma/gm/data/_functional.py

  • Added input validation for empty arrays
  • Updated docstring to document the new Raises section

Testing

  • Syntax validation passed
  • The fix provides clear error messages instead of cryptic numpy errors

…2seq_fields

When empty prompt or response arrays are passed to make_seq2seq_fields,
the function now raises a clear ValueError instead of cryptic numpy errors.

This prevents confusing errors like negative array dimensions and makes
debugging easier for users.

Fixes google-deepmind#483
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.

make_seq2seq_fields crashes with confusing error when empty prompt array is passed

1 participant