Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SentencePieceProcessor: piece_to_id throws when piece token is unknown #42

Closed
wants to merge 1 commit into from

Conversation

shadeMe
Copy link
Collaborator

@shadeMe shadeMe commented Jun 26, 2023

Description

Previously, we had the inconsistent behavior where piece_to_id would return the ID of the unk metatoken when the piece token was out-of-vocab, but id_to_piece would throw when an invalid piece ID was passed to it. This PR fixes that by making piece_to_id throw as well.

Types of change

Refactor/enhancement

Checklist

  • I confirm that I have the right to submit this contribution under the project's MIT license.
  • I ran the tests, and all new and existing tests passed.
  • My changes don't require a change to the documentation, or if they do, I've added all required information.

@shadeMe shadeMe added the enhancement New feature or request label Jun 26, 2023
@shadeMe
Copy link
Collaborator Author

shadeMe commented Jun 26, 2023

Closed after internal discussion - id_to_piece and piece_to_id will return Optionals across the board instead of throwing.

@shadeMe shadeMe closed this Jun 26, 2023
@shadeMe shadeMe deleted the refactor/spp-piece-id-throw branch June 26, 2023 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant