Skip to content
This repository has been archived by the owner on Jul 13, 2024. It is now read-only.

Commit

Permalink
fix tokenizer (mikecovlee#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecovlee authored Apr 25, 2024
1 parent 0b2c539 commit 01b2704
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions mlora/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ def __init__(self, model_path: str):
self.pad_id_ = self.tokenizer.pad_token_id
self.unk_id_ = self.tokenizer.unk_token_id
# maybe pad id is unk
if self.pad_id_ is None and self.unk_id_ is not None:
if self.pad_id_ is not None:
return
if self.unk_id_ is None and self.eos_id_ is None:
logging.warn(
"Detecting <eos> and <unk> are None, setting <pad> to 0 by default.")
self.pad_id_ = 0
elif self.unk_id_ is not None:
logging.warn(
"Detecting <pad> is None, setting to <unk> by default.")
self.pad_id_ = self.unk_id_
if self.pad_id_ is None and self.eos_id_ is not None:
elif self.eos_id_ is not None:
logging.warn(
"Detecting <pad> is None, setting to <eos> by default.")
self.pad_id_ = self.eos_id_
logging.warn("Padding token ID is None, setting to <eos>.")
else:
raise ValueError(
"Can not set padding token id. <eos> and <unk> are None.")

def encode(self, data: Union[str, List[str]], add_special_tokens: bool = True) -> Tokens:
if isinstance(data, str):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "mlora"
version = "0.3.0.post1"
version = "0.3.0.post2"
description = "A tool for fine-tuning large language models (LLMs) using the LoRA or QLoRA methods more efficiently."
readme = "README.md"
requires-python = ">=3.10"
Expand Down

0 comments on commit 01b2704

Please sign in to comment.