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

Post-processing steps of tokenizer (string replacements) are not included in the GGUF model #1093

Open
Jeronymous opened this issue Feb 2, 2025 · 2 comments

Comments

@Jeronymous
Copy link

It seems that the string replacements in the post-processing of the tokenizer are not included in the GGUF model.
Hence some LLM with fancy tokenizers can have the output text a bit weird with tools like ollama that use GGUF models.

I noticed it with Lucie Instruct: https://huggingface.co/OpenLLM-France/Lucie-7B-Instruct#test-with-ollama

The tokenizer include several post-processing steps that are discarded:
https://huggingface.co/OpenLLM-France/Lucie-7B/raw/main/tokenizer.json

"decoder": {
    "type": "Sequence",
    "decoders": [
      {
        "type": "ByteFallback"
      },
      {
        "type": "Metaspace",
        "replacement": "▁",
        "add_prefix_space": true,
        "prepend_scheme": "always"
      },
      {
        "type": "Fuse"
      },
      {
        "type": "Replace",
        "pattern": {
          "String": "\n "
        },
        "content": "\n"
      },
      {
        "type": "Replace",
        "pattern": {
          "String": "\t "
        },
        "content": "\t"
      },
...

Those are supposed to remove extra space (introduced in the pre-processing to have "uniform" subword tokens, i.e. sam e token represente for a word whether it comes after a space or after something starting a new sentence (start of string, apostrophe, quotation mark, ...).

Image

@ggerganov I would be happy to contribute to this repo to solve this bug :)

@ggerganov
Copy link
Owner

Patches are welcome - better to open in the llama.cpp repository for these kind of changes.

@Jeronymous
Copy link
Author

Thank you for your answer @ggerganov
Do you have any hint on where I should look at ?
Is there already a class for text post-processing bricks, or would it be a new thing ?

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

No branches or pull requests

2 participants