Repository navigation
fix: Raise a clear error when HFSystemFormat's tokenizer has no chat template - #1983
Conversation
…template
HFSystemFormat failed on every instance with the generic transformers
ValueError when the model's tokenizer does not define a chat template.
Check this once in prepare() and raise a UnitxtError naming the model and
how to proceed: use a model with a chat template, pass one explicitly via
chat_kwargs_dict={'chat_template': ...}, or use SystemFormat.
Signed-off-by: Waleed Khalid <wak327@gmail.com>
|
@elronbandel @yoavkatz could you take a look when you have a moment? Small change: |
… is missing ReflectionToolCallingMetric and ReflectionToolCallingMetricSyntactic require llmevalkit, an internal package that CI installs only when the repository secrets are available. Since IBM#1989, pull requests from forks and Dependabot skip that install, so the 15 tests constructing these metrics errored with MissingRequirementsError and failed the unittests and eager jobs. Skip them when llmevalkit is not installed; they still run wherever it is. Signed-off-by: Waleed Khalid <wak327@gmail.com>
|
@yoavkatz thanks for the approval and for merging Fix (54c1f19, test-only): since #1989, fork runs skip installing Still red, but not fixable from this branch:
|
|
Hi @wak327 . Thank you for your contributions. Once the test that can pass complete, I'll merge. As you can see there is less active development over the last few months, and the library is more in a maintainance mode (security issues or fixes requested by existing user). Are you actively using it now? |
Summary
HFSystemFormatrenders prompts withtokenizer.apply_chat_template. When the model's tokenizer has nochat_template(e.g.ibm-granite/granite-20b-code-basefrom #1144, orgpt2), every instance fails while the dataset is being generated with transformers' generic error:That message doesn't name the model, and it doesn't mention the options unitxt already supports.
Changes
HFSystemFormat.prepare()checks the tokenizer right after loading it. If there is no chat template and none was passed throughchat_kwargs_dict, it raises aUnitxtErroronce, when the format is created:The
HFSystemFormatdocstring now mentions passing a template throughchat_kwargs_dict={"chat_template": ...}. That already works today, sincechat_kwargs_dictis forwarded toapply_chat_template.UnitxtErrorisn't in the retry list ofretry_connection_with_exponential_backoff, so the new check is not retried.Fixes #1144
Test plan
test_hf_system_format_without_chat_template: creating the format withopenai-community/gpt2raises theUnitxtError, and passing an explicitchat_templateinchat_kwargs_dictformats correctly. Fails onmain(UnitxtError not raised), passes here.test_hf_system_format(zephyr) still passes.pre-commit runon the changed files.