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

Add regex loading from tokenizer.json and code refinement #863

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wenbingl
Copy link
Member

@wenbingl wenbingl commented Dec 19, 2024

  1. using regex pattern if it exist in tokenizer.json
  2. add tokenizer test case like AMD/OLMa through pp_api

}

if (iter_type->get<std::string>() != "Sequence") {
return {kOrtxErrorNotImplemented, "Unsupported pretokenizer type!"};
Copy link
Contributor

@sayanshaw24 sayanshaw24 Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something in the test seems off, or maybe my understanding is wrong - i saw in test_pp_api.py you use the "amd/AMD-OLMo-1B-SFT-DPO" model, and if you look in the tokenizer.json for it, pre_tokenizer type is "ByteLevel", not "Sequence" (Note: you have support for "ByteLevel" for "pretokenizers" below, (which I guess you are expecting within the "pre_tokenizer") but not for "pre_tokenizer" itself); so it would fail here right? (but in the CI it is passing)

So - maybe we should add "ByteLevel" to the supported types for "pre_tokenizer" as well here, but also first identify why it is not failing the test currently, perhaps the type is not being extracted right or it is conflating "pretokenizers" and "pre_tokenizer".

continue;
}

auto regex_str = iter_pattern->find("Regex");
Copy link
Contributor

@sayanshaw24 sayanshaw24 Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am seeing some examples of lowercase "regex" in tokenizer.json as well - perhaps we make the case insensitive here?

@sayanshaw24
Copy link
Contributor

Can we add an example to test the regex string option as well? HF "amd/AMD-OLMo-1B-SFT-DPO" has a "pre_tokenizer" value with type ""ByteLevel" and "use_regex": true, but maybe we can find one with a "regex" string that we can then use to demonstrate the custom regex functionality.

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.

2 participants