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

Fix(tokenizer): Set rstrip,lstrip,norm to False #678

Merged

Conversation

NanoCode012
Copy link
Collaborator

Attempt to fix the tokenizer saving new special tokens properties (rstrip,lstrip) as True.

This issue can be seen in Mistral Tokenizer saved after finetuning.

@NanoCode012 NanoCode012 marked this pull request as draft October 5, 2023 17:48
@NanoCode012
Copy link
Collaborator Author

NanoCode012 commented Oct 5, 2023

Before:

"added_tokens_decoder": {
    "0": {
      "content": "<unk>",
      "lstrip": true,
      "normalized": false,
      "rstrip": true,
      "single_word": false,
      "special": true
    },
    "1": {
      "content": "<s>",
      "lstrip": true,
      "normalized": false,
      "rstrip": true,
      "single_word": false,
      "special": true
    },
    "2": {
      "content": "</s>",
      "lstrip": true,
      "normalized": false,
      "rstrip": true,
      "single_word": false,
      "special": true
    }
  },
  "additional_special_tokens": [
    "<unk>",
    "<s>",
    "</s>"
  ],

After

{
  "add_bos_token": true,
  "add_eos_token": false,
  "added_tokens_decoder": {
    "0": {
      "content": "<unk>",
      "lstrip": false,
      "normalized": false,
      "rstrip": false,
      "single_word": false,
      "special": true
    },
    "1": {
      "content": "<s>",
      "lstrip": false,
      "normalized": false,
      "rstrip": false,
      "single_word": false,
      "special": true
    },
    "2": {
      "content": "</s>",
      "lstrip": false,
      "normalized": false,
      "rstrip": false,
      "single_word": false,
      "special": true
    }
  },
  "additional_special_tokens": [
    "<unk>",
    "<s>",
    "</s>"
  ],
  "bos_token": "<s>",
  "clean_up_tokenization_spaces": false,
  "eos_token": "</s>",
  "legacy": true,
  "model_max_length": 1000000000000000019884624838656,
  "pad_token": "</s>",
  "sp_model_kwargs": {},
  "spaces_between_special_tokens": false,
  "tokenizer_class": "LlamaTokenizer",
  "tokenizer_file": "/root/.cache/huggingface/hub/models--mistralai--Mistral-7B-v0.1/snapshots/ae9d75c6b4eb39515def78c685fb4d71d49fc2cf/tokenizer.json",
  "trust_remote_code": false,
  "unk_token": "<unk>",
  "use_default_system_prompt": true,
  "use_fast": true
}

Confirmed that it's false now.

@NanoCode012 NanoCode012 marked this pull request as ready for review October 5, 2023 18:34
@NanoCode012
Copy link
Collaborator Author

One extra config seem to be use_fast=True. This is the default, and although Mistral's tokenizer config does not have it, Mistral's tokenizer has fast tokenizer support.

https://huggingface.co/docs/transformers/v4.34.0/en/index#supported-frameworks

Copy link
Collaborator

@winglian winglian left a comment

Choose a reason for hiding this comment

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

I wonder if maybe we should only specify actual new tokens in the YML file. so remove the default tokens the tokenizer model already includes. that's probably the root of the issue.

@NanoCode012
Copy link
Collaborator Author

I wonder if maybe we should only specify actual new tokens in the YML file. so remove the default tokens the tokenizer model already includes. that's probably the root of the issue.

Yes, makes sense. We can address that in a followup PR.

@NanoCode012 NanoCode012 merged commit e0b7eea into axolotl-ai-cloud:main Oct 5, 2023
4 checks passed
@NanoCode012 NanoCode012 deleted the fix/tokenizer-rlstrip branch October 5, 2023 18:50
mkeoliya pushed a commit to mkeoliya/axolotl that referenced this pull request Dec 15, 2023
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.

None yet

2 participants