From 960980247f4737be2a952b8a6055b95e7f1dd46f Mon Sep 17 00:00:00 2001 From: cal066 <60696996+cal066@users.noreply.github.com> Date: Fri, 25 Aug 2023 14:33:04 +0000 Subject: [PATCH] ctransformers: gguf support (#3685) --- modules/models.py | 11 ++++++++++- requirements.txt | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/models.py b/modules/models.py index 48a384cf..ea9cc528 100644 --- a/modules/models.py +++ b/modules/models.py @@ -280,7 +280,16 @@ def ctransformers_loader(model_name): if path.is_file(): model_file = path else: - model_file = list(Path(f'{shared.args.model_dir}/{model_name}').glob('*.bin'))[0] + entries = Path(f'{shared.args.model_dir}/{model_name}') + gguf = list(entries.glob('*.gguf')) + bin = list(entries.glob('*.bin')) + if len(gguf) > 0: + model_file = gguf[0] + elif len(bin) > 0: + model_file = bin[0] + else: + logger.error("Could not find a model for ctransformers.") + return None, None logger.info(f'ctransformers weights detected: {model_file}') model, tokenizer = ctrans.from_pretrained(model_file) diff --git a/requirements.txt b/requirements.txt index daccd5dd..90c7969f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -41,4 +41,4 @@ https://github.com/jllllll/GPTQ-for-LLaMa-CUDA/releases/download/0.1.0/gptq_for_ https://github.com/jllllll/GPTQ-for-LLaMa-CUDA/releases/download/0.1.0/gptq_for_llama-0.1.0+cu117-cp310-cp310-linux_x86_64.whl; platform_system == "Linux" and platform_machine == "x86_64" # ctransformers -https://github.com/jllllll/ctransformers-cuBLAS-wheels/releases/download/AVX2/ctransformers-0.2.23+cu117-py3-none-any.whl +https://github.com/jllllll/ctransformers-cuBLAS-wheels/releases/download/AVX2/ctransformers-0.2.24+cu117-py3-none-any.whl