mlx-swift-examples icon indicating copy to clipboard operation
mlx-swift-examples copied to clipboard

Use chat template

Open DePasqualeOrg opened this issue 1 year ago • 6 comments

Since https://github.com/huggingface/swift-transformers/pull/104, it's now possible to use the chat template from tokenizer_config.json. ~~I've updated LLMEval to use the chat template, but I noticed that the output from the Mistral models ends with <|im_end|>, even when this string is included in extraEOSTokens. Perhaps @pcuenca has an idea why this might be happening?~~

DePasqualeOrg avatar Sep 29 '24 19:09 DePasqualeOrg

Using the chat templates with Llama 3.2 will result in an error until none ~~and tojson are~~ is implemented in the Jinja package: https://github.com/maiqingqiang/Jinja/pull/4

DePasqualeOrg avatar Sep 30 '24 11:09 DePasqualeOrg

Using the chat templates with Llama 3.2 will result in an error until none and tojson are implemented in the Jinja package: maiqingqiang/Jinja#4

OK, should we hold off on taking this until that is merged (and we can pick it up here)?

davidkoski avatar Sep 30 '24 21:09 davidkoski

OK, should we hold off on taking this until that is merged (and we can pick it up here)?

Yes, since LLMEval includes model configs for Llama 3.2. In the meantime, this branch can be used to test Llama 3.2 with the work in progress on Jinja.

DePasqualeOrg avatar Sep 30 '24 21:09 DePasqualeOrg

~~We had a similar issue with an EOS token at the end of the output of Gemma 2: https://github.com/ml-explore/mlx-swift-examples/issues/89~~

~~This shouldn't be appearing in the output if it's included in extraEOSTokens. It could be an issue with the tokenizer, because I can see when it's generating in my app that <|im_end|> is being produced as multiple tokens, and it sometimes even continues generating beyond this string.~~

DePasqualeOrg avatar Sep 30 '24 21:09 DePasqualeOrg

The problem with Mistral 7B is resolved here: https://github.com/huggingface/swift-transformers/pull/134

DePasqualeOrg avatar Oct 01 '24 14:10 DePasqualeOrg

Llama 3.2 1B and 3B and Mistral 7B now work with chat templates, thanks to the changes in swift-transformers and Jinja.

DePasqualeOrg avatar Oct 05 '24 11:10 DePasqualeOrg