Skip to content

Commit

Permalink
Fix(tokenizer): Set rstrip,lstrip,norm to False (#678)
Browse files Browse the repository at this point in the history
  • Loading branch information
NanoCode012 authored Oct 5, 2023
1 parent 43856c0 commit e0b7eea
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/axolotl/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from peft import PeftConfig, prepare_model_for_kbit_training
from peft.tuners.lora import QuantLinear
from transformers import ( # noqa: F401
AddedToken,
AutoConfig,
AutoModelForCausalLM,
AutoTokenizer,
Expand Down Expand Up @@ -82,9 +83,16 @@ def load_tokenizer(cfg):

if cfg.special_tokens:
for k, val in cfg.special_tokens.items():
tokenizer.add_special_tokens({k: val})
tokenizer.add_special_tokens(
{k: AddedToken(val, rstrip=False, lstrip=False, normalized=False)}
)
if cfg.tokens:
tokenizer.add_tokens(list(cfg.tokens))
tokenizer.add_tokens(
[
AddedToken(token, rstrip=False, lstrip=False, normalized=False)
for token in cfg.tokens
]
)

return tokenizer

Expand Down

0 comments on commit e0b7eea

Please sign in to comment.