Fix hidden size detection for GPTJForCausalLM

This commit is contained in:
Gnome Ann 2021-11-15 11:56:02 -05:00
parent 3e38b462c6
commit ab1a65f13a
1 changed files with 5 additions and 2 deletions

View File

@ -600,17 +600,20 @@ if(not vars.model in ["InferKit", "Colab", "OAI", "ReadOnly"]):
try:
return int(model.transformer.hidden_size)
except:
try:
return int(model.transformer.embed_dim)
except:
return int(model.lm_head.in_features)
# If custom GPT Neo model was chosen
if(vars.model == "NeoCustom"):
model_config = open(vars.custmodpth + "/config.json", "r")
js = json.load(model_config)
vars.modeldim = int(js['hidden_size'])
if("model_type" in js):
model = AutoModelForCausalLM.from_pretrained(vars.custmodpth)
else:
model = GPTNeoForCausalLM.from_pretrained(vars.custmodpth)
vars.modeldim = get_hidden_size_from_model(model)
tokenizer = GPT2Tokenizer.from_pretrained(vars.custmodpth)
# Is CUDA available? If so, use GPU, otherwise fall back to CPU
if(vars.hascuda):