Skip to content

Commit

Permalink
Fixed template imports
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Eyceoz <[email protected]>
  • Loading branch information
Maxusmusti committed Jun 21, 2024
1 parent 07b6662 commit 0db67f6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/instructlab/training/chat_templates/ibm_generic_tmpl.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Third Party
from tokenizer_utils import SpecialTokens
# First Party
from instructlab.training.tokenizer_utils import SpecialTokens

SPECIAL_TOKENS = SpecialTokens(
system="<|system|>",
Expand Down
4 changes: 2 additions & 2 deletions src/instructlab/training/chat_templates/mistral_tmpl.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Third Party
from tokenizer_utils import SpecialTokens
# First Party
from instructlab.training.tokenizer_utils import SpecialTokens

SPECIAL_TOKENS = SpecialTokens(
bos="<s>",
Expand Down
15 changes: 9 additions & 6 deletions src/instructlab/training/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ def retrieve_chat_template(chat_tmpl_path):
import importlib.util
import sys

Check warning on line 30 in src/instructlab/training/utils.py

View workflow job for this annotation

GitHub Actions / lint

W0404: Reimport 'sys' (imported line 11) (reimported)

spec = importlib.util.spec_from_file_location("spcl_chat_tmpl", chat_tmpl_path)
module = importlib.util.module_from_spec(spec)
sys.modules["spcl_chat_tmpl"] = module
spec.loader.exec_module(module)
SPECIAL_TOKENS = module.SPECIAL_TOKENS
CHAT_TEMPLATE = module.CHAT_TEMPLATE
try:
spec = importlib.util.spec_from_file_location("spcl_chat_tmpl", chat_tmpl_path)
module = importlib.util.module_from_spec(spec)
sys.modules["spcl_chat_tmpl"] = module
spec.loader.exec_module(module)
SPECIAL_TOKENS = module.SPECIAL_TOKENS
CHAT_TEMPLATE = module.CHAT_TEMPLATE
except:

Check warning on line 39 in src/instructlab/training/utils.py

View workflow job for this annotation

GitHub Actions / lint

W0702: No exception type(s) specified (bare-except)
sys.exit(f"Invalid chat template path: {chat_tmpl_path}")
return CHAT_TEMPLATE, SPECIAL_TOKENS


Expand Down

0 comments on commit 0db67f6

Please sign in to comment.