Skip to content

Commit

Permalink
Add assert for old behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
minimaxir committed Apr 19, 2021
1 parent e1740ef commit 4a1c6dc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion aitextgen/aitextgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from transformers import (
AutoConfig,
AutoModelForCausalLM,
AutoTokenizer,
GPT2Config,
GPT2LMHeadModel,
GPT2TokenizerFast,
Expand Down Expand Up @@ -97,6 +98,12 @@ def __init__(
**kwargs,
) -> None:

if model:
assert not os.path.isfile(model), (
"As of aitextgen 0.5.0, you must "
+ "use `model_folder` to load an existing model."
)

if not verbose:
for module in [
"transformers.file_utils",
Expand Down Expand Up @@ -189,7 +196,7 @@ def __init__(
)
if model and "gpt2" not in model:
logger.info(f"Using the tokenizer for {model}.")
self.tokenizer = GPT2TokenizerFast.from_pretrained(
self.tokenizer = AutoTokenizer.from_pretrained(
model,
cache_dir=cache_dir,
)
Expand Down

0 comments on commit 4a1c6dc

Please sign in to comment.