Skip to content

Conversation

@Ashish-Patnaik
Copy link

@Ashish-Patnaik Ashish-Patnaik commented Jan 9, 2026

This PR improves the robustness of "examples/classification.py" by removing hardcoded
token IDs for the classification labels.

Fixes Issue #496

Changes

  1. Dynamically computes the token IDs for "Yes" and "No" using the tokenizer instead
    of relying on fixed numeric IDs.
  2. Adds a small validation check to ensure each label maps to exactly one token,
    preventing silent errors if tokenization changes.
  3. Fixes minor typos in the prompt template and comments:
    • "grammaticaly" = "grammatically"
    • "respectivelly" = "respectively"

Why?
Hardcoding token IDs makes the example fragile if the tokenizer vocabulary changes
or if the script is reused with a different model variant. This change keeps the
example functionally identical while making it safer and easier to maintain.

@google-cla
Copy link

google-cla bot commented Jan 9, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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