Restore Chat Models Menu + Safetensors Workaround

This commit restores the chat models menu now we finally have good chat models available again.

Unfortunately huggingface reports back pytorch_model.bin even if the model's name is model.safetensors. I don't have a good way to combat this at the moment, so instead we now do a hack where if the model copy fails it manually tries model.safetensors instead hoping that it will work.

This fixes Pygmalion for now, if new issues arise from this in the future from other models we have to implement a cleaner method.
This commit is contained in:
Henk
2023-01-11 22:24:12 +01:00
parent 271e4ed06b
commit d6a941de61

View File

@@ -168,6 +168,7 @@ model_menu = {
["Load custom model from Hugging Face", "customhuggingface", "", True],
["Adventure Models", "adventurelist", "", True],
["Novel Models", "novellist", "", True],
["Chat Models", "chatlist", "", True],
["NSFW Models", "nsfwlist", "", True],
["Untuned OPT", "optlist", "", True],
["Untuned GPT-Neo/J", "gptneolist", "", True],
@@ -225,9 +226,10 @@ model_menu = {
["Return to Main Menu", "mainmenu", "", True],
],
'chatlist': [
["Convo 6B (Chatbot)", "hitomi-team/convo-6B", "16GB", False],
["C1 6B (Chatbot)", "hakurei/c1-6B", "16GB", False],
["C1 1.3B (Chatbot)", "iokru/c1-1.3B", "6GB", False],
["Pygmalion 6B", "PygmalionAI/pygmalion-6b", "16GB", False],
["Pygmalion 2.7B", "PygmalionAI/pygmalion-2.7b", "8GB", False],
["Pygmalion 1.3B", "PygmalionAI/pygmalion-1.3b", "6GB", False],
["Pygmalion 350M", "PygmalionAI/pygmalion-350m", "2GB", False],
["Return to Main Menu", "mainmenu", "", True],
],
'gptneolist': [
@@ -3207,7 +3209,10 @@ def load_model(use_gpu=True, gpu_layers=None, disk_layers=None, initial_load=Fal
shutil.move(os.path.realpath(huggingface_hub.hf_hub_download(koboldai_vars.model, transformers.configuration_utils.CONFIG_NAME, revision=koboldai_vars.revision, cache_dir="cache", local_files_only=True, legacy_cache_layout=legacy)), os.path.join("models/{}".format(koboldai_vars.model.replace('/', '_')), transformers.configuration_utils.CONFIG_NAME))
if(utils.num_shards is None):
# Save the pytorch_model.bin of an unsharded model
shutil.move(os.path.realpath(huggingface_hub.hf_hub_download(koboldai_vars.model, transformers.modeling_utils.WEIGHTS_NAME, revision=koboldai_vars.revision, cache_dir="cache", local_files_only=True, legacy_cache_layout=legacy)), os.path.join("models/{}".format(koboldai_vars.model.replace('/', '_')), transformers.modeling_utils.WEIGHTS_NAME))
try:
shutil.move(os.path.realpath(huggingface_hub.hf_hub_download(koboldai_vars.model, transformers.modeling_utils.WEIGHTS_NAME, revision=koboldai_vars.revision, cache_dir="cache", local_files_only=True, legacy_cache_layout=legacy)), os.path.join("models/{}".format(koboldai_vars.model.replace('/', '_')), transformers.modeling_utils.WEIGHTS_NAME))
except:
shutil.move(os.path.realpath(huggingface_hub.hf_hub_download(koboldai_vars.model, "model.safetensors", revision=koboldai_vars.revision, cache_dir="cache", local_files_only=True, legacy_cache_layout=legacy)), os.path.join("models/{}".format(koboldai_vars.model.replace('/', '_')), "model.safetensors"))
else:
with open(utils.from_pretrained_index_filename) as f:
map_data = json.load(f)