mudler / LocalAI

:robot: The free, Open Source alternative to OpenAI, Claude and others. Self-hosted and local-first. Drop-in replacement for OpenAI, running on consumer-grade hardware. No GPU required. Runs gguf, transformers, diffusers and many more models architectures. Features: Generate Text, Audio, Video, Images, Voice Cloning, Distributed inference
https://localai.io
MIT License
23.65k stars 1.81k forks source link

`/models/available` broken for Huggingface gallery #2045

Open ape-nq opened 5 months ago

ape-nq commented 5 months ago

LocalAI version:

OK:

Broken:

Environment, CPU architecture, OS, and Version:

$ uname -a
Linux 2d083df80d05 6.5.0-1018-oem #19-Ubuntu SMP PREEMPT_DYNAMIC Thu Mar 14 21:40:46 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Describe the bug

Cannot get Huggingface gallery in recent versions:

"Index" model gallery works:

To Reproduce

  1. Set Huggingface gallery:
    • export GALLERIES='[{"url": "github:go-skynet/model-gallery/huggingface.yaml","name":"huggingface"}]'
  2. Start LocalAI binary
    • e.g. ./local-ai-avx2-Linux-x86_64-2.12.4
  3. Try to view Gallery in Browser: http://localhost:8080/models/available
    • up to v2.9.0:
      • Log: 200 - GET /models/available
      • Browser: JSON result is shown
    • from v2.10.1 to v2.12.4:
      • Log: 500 - GET /models/available
      • Browser: {"error":{"code":500,"message":"json: unsupported type: map[interface {}]interface {}","type":""}}

Expected behavior

JSON for Huggingface gallery should be returned as in versions v2.9.0 and prior. Or as it is returned for standard 'model-gallery'.

Logs

Debug-Log is 15MB, so not attaching it here.

There is a really long line with what looks like a hex array:

Excerpt with Model found messages:

10:32AM DBG Model found from galleries: &{URL:github:go-skynet/model-gallery/base.yaml Name:1tuanpham__instruct_en-vi_12000_1e_thebloke_mistralic-7b-1-gptq_lora_causal_lm__instruct_en-vi_12000_1e__adapter_model.bin Description: License: URLs:[https://huggingface.co/1TuanPham/Instruct_en-vi_12000_1e_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM] Icon: Tags:[peft region:us] ConfigFile:map[] Overrides:map[parameters:map[model:Instruct_en-vi_12000_1e/adapter_model.bin]] AdditionalFiles:[{Filename:Instruct_en-vi_12000_1e/adapter_model.bin SHA256: URI:https://huggingface.co/1TuanPham/Instruct_en-vi_12000_1e_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM/resolve/main/Instruct_en-vi_12000_1e/adapter_model.bin}] Gallery:{URL:github:go-skynet/model-gallery/huggingface.yaml Name:huggingface} Installed:false}
10:32AM DBG Model found from galleries: &{URL:github:go-skynet/model-gallery/base.yaml Name:1tuanpham__instruct_en-vi_14000_1e_b60_lr2e-4_thebloke_mistralic-7b-1-gptq_lora_causal_lm__adapter_model.bin Description: License: URLs:[https://huggingface.co/1TuanPham/Instruct_en-vi_14000_1e_b60_lr2e-4_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM] Icon: Tags:[peft region:us] ConfigFile:map[] Overrides:map[parameters:map[model:adapter_model.bin]] AdditionalFiles:[{Filename:adapter_model.bin SHA256: URI:https://huggingface.co/1TuanPham/Instruct_en-vi_14000_1e_b60_lr2e-4_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM/resolve/main/adapter_model.bin}] Gallery:{URL:github:go-skynet/model-gallery/huggingface.yaml Name:huggingface} Installed:false}
10:32AM DBG Model found from galleries: &{URL:github:go-skynet/model-gallery/base.yaml Name:1tuanpham__instruct_en-vi_14000_1e_b60_lr2e-4_thebloke_mistralic-7b-1-gptq_lora_causal_lm__instruct_en-vi_14000_1e_b60_lr2e-4__adapter_model.bin Description: License: URLs:[https://huggingface.co/1TuanPham/Instruct_en-vi_14000_1e_b60_lr2e-4_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM] Icon: Tags:[peft region:us] ConfigFile:map[] Overrides:map[parameters:map[model:Instruct_en-vi_14000_1e_b60_lr2e-4/adapter_model.bin]] AdditionalFiles:[{Filename:Instruct_en-vi_14000_1e_b60_lr2e-4/adapter_model.bin SHA256: URI:https://huggingface.co/1TuanPham/Instruct_en-vi_14000_1e_b60_lr2e-4_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM/resolve/main/Instruct_en-vi_14000_1e_b60_lr2e-4/adapter_model.bin}] Gallery:{URL:github:go-skynet/model-gallery/huggingface.yaml Name:huggingface} Installed:false}
10:32AM DBG Model found from galleries: &{URL:github:go-skynet/model-gallery/base.yaml Name:1tuanpham__instruct_en-vi_14500_1e_thebloke_mistralic-7b-1-gptq_lora_causal_lm__adapter_model.bin Description: License: URLs:[https://huggingface.co/1TuanPham/Instruct_en-vi_14500_1e_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM] Icon: Tags:[peft region:us] ConfigFile:map[] Overrides:map[parameters:map[model:adapter_model.bin]] AdditionalFiles:[{Filename:adapter_model.bin SHA256: URI:https://huggingface.co/1TuanPham/Instruct_en-vi_14500_1e_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM/resolve/main/adapter_model.bin}] Gallery:{URL:github:go-skynet/model-gallery/huggingface.yaml Name:huggingface} Installed:false}
10:32AM DBG Model found from galleries: &{URL:github:go-skynet/model-gallery/base.yaml Name:1tuanpham__instruct_en-vi_14500_1e_thebloke_mistralic-7b-1-gptq_lora_causal_lm__instruct_en-vi_14500_1e__adapter_model.bin Description: License: URLs:[https://huggingface.co/1TuanPham/Instruct_en-vi_14500_1e_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM] Icon: Tags:[peft region:us] ConfigFile:map[] Overrides:map[parameters:map[model:Instruct_en-vi_14500_1e/adapter_model.bin]] AdditionalFiles:[{Filename:Instruct_en-vi_14500_1e/adapter_model.bin SHA256: URI:https://huggingface.co/1TuanPham/Instruct_en-vi_14500_1e_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM/resolve/main/Instruct_en-vi_14500_1e/adapter_model.bin}] Gallery:{URL:github:go-skynet/model-gallery/huggingface.yaml Name:huggingface} Installed:false}
10:32AM DBG Model found from galleries: &{URL:github:go-skynet/model-gallery/base.yaml Name:1tuanpham__instruct_en-vi_7500_1epoch_thebloke_mistralic-7b-1-gptq_lora_causal_lm__adapter_model.bin Description: License: URLs:[https://huggingface.co/1TuanPham/Instruct_en-vi_7500_1epoch_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM] Icon: Tags:[peft region:us] ConfigFile:map[] Overrides:map[parameters:map[model:adapter_model.bin]] AdditionalFiles:[{Filename:adapter_model.bin SHA256: URI:https://huggingface.co/1TuanPham/Instruct_en-vi_7500_1epoch_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM/resolve/main/adapter_model.bin}] Gallery:{URL:github:go-skynet/model-gallery/huggingface.yaml Name:huggingface} Installed:false}
10:32AM DBG Model found from galleries: &{URL:github:go-skynet/model-gallery/base.yaml Name:1tuanpham__instruct_en-vi_7500_1epoch_thebloke_mistralic-7b-1-gptq_lora_causal_lm__instruct_en-vi_7500_1epoch__adapter_model.bin Description: License: URLs:[https://huggingface.co/1TuanPham/Instruct_en-vi_7500_1epoch_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM] Icon: Tags:[peft region:us] ConfigFile:map[] Overrides:map[parameters:map[model:Instruct_en-vi_7500_1epoch/adapter_model.bin]] AdditionalFiles:[{Filename:Instruct_en-vi_7500_1epoch/adapter_model.bin SHA256: URI:https://huggingface.co/1TuanPham/Instruct_en-vi_7500_1epoch_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM/resolve/main/Instruct_en-vi_7500_1epoch/adapter_model.bin}] Gallery:{URL:github:go-skynet/model-gallery/huggingface.yaml Name:huggingface} Installed:false}
10:32AM DBG Model found from galleries: &{URL:github:go-skynet/model-gallery/base.yaml Name:1tuanpham__instruct_en-vi_8000_1e_thebloke_mistralic-7b-1-gptq_lora_causal_lm__adapter_model.bin Description: License: URLs:[https://huggingface.co/1TuanPham/Instruct_en-vi_8000_1e_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM] Icon: Tags:[peft region:us] ConfigFile:map[] Overrides:map[parameters:map[model:adapter_model.bin]] AdditionalFiles:[{Filename:adapter_model.bin SHA256: URI:https://huggingface.co/1TuanPham/Instruct_en-vi_8000_1e_TheBloke_Mistralic-7B-1-GPTQ_LORA_CAUSAL_LM/resolve/main/adapter_model.bin}] Gallery:{URL:github:go-skynet/model-gallery/huggingface.yaml Name:huggingface} Installed:false}

Additional context

Running from release binaries on a rented VM. Binaries downloaded from GitHub and renamed to include version number.

localai-bot commented 5 months ago

It seems like the issue you're facing is related to a compatibility problem between the Hugging Face transformers library version and the models used. The error messages suggest that the models found in the galleries are not compatible with the version of transformers you are using.

The models mentioned are likely SF-T5 models, which require a specific version of the transformers library to work properly. You mentioned using transformers==4.6.0, but these models may require a different version. Specifically, the error suggests that you may need to use transformers==4.5.0.

To resolve this issue, you should update the transformers library in your environment to version 4.5.0. You can do this with pip by running the following command:

pip install transformers==4.5.0

After installing the correct version of the transformers library, try running your code again to see if the issue is resolved. If you continue to encounter problems, make sure that the models you are trying to load are compatible not only with the transformers library version but also with the Python version you are using.

ape-nq commented 5 months ago

This is not about running any model.

Just trying to list the gallery as described in https://localai.io/models/#list-models

Repro:

  1. Start LocalAI
  2. List gallery
  3. Error
$ curl http://localhost:8080/models/available
{"error":{"code":500,"message":"json: unsupported type: map[interface {}]interface {}","type":""}}
ape-nq commented 5 months ago

Maybe the full debug log will help:

The only request to LocalAI after startup is listing gallery models:

10:08AM INF core/startup process completed!
10:08AM DBG No configuration file found at /tmp/localai/upload/uploadedFiles.json
10:08AM DBG No configuration file found at /tmp/localai/config/assistants.json
10:08AM DBG No configuration file found at /tmp/localai/config/assistantsFile.json
10:08AM DBG Listing models from galleries: [{URL:github:go-skynet/model-gallery/huggingface.yaml Name:huggingface}]
lenaxia commented 5 months ago

I'm also able to replicate this, model-gallery works, hugging face does not.

lopezl commented 5 months ago

I'm also able to replicate this, model-gallery works, hugging face does not.

Another confirmation here. I can get a model list using only the main gallery but not using only huggingface gallery, using both at the same time also fails.

Currently running v2.12.4 (0004ec8be3ca150ce6d8b79f2991bfe3a9dc65ad) with the AIO docker image latest-aio-gpu-nvidia-cuda-11 a6ffa9444dd5

With DEBUG=true I can see that LocalAI reads and parses entire huggingface.yaml, last lines from the log matches with last lines from the YAML file), but finally fails to build the model list.

$ curl  $LOCAL_AI/models/available
{"error":{"code":500,"message":"json: unsupported type: map[interface {}]interface {}","type":""}}

Relevant log lines:

localai  | 8:00AM DBG Model found from galleries: &{URL:github:go-skynet/model-gallery/base.yaml Name:zhaijunxiao__pygmalion-13b-ggml__ggml-model-q4_0.bin Description: License: URLs:[https://huggingface.co/zhaijunxiao/Pygmalion-13B-ggml] Icon: Tags:[region:us] ConfigFile:map[] Overrides:map[parameters:map[model:ggml-model-q4_0.bin]] AdditionalFiles:[{Filename:ggml-model-q4_0.bin SHA256: URI:https://huggingface.co/zhaijunxiao/Pygmalion-13B-ggml/resolve/main/ggml-model-q4_0.bin}] Gallery:{URL:github:go-skynet/model-gallery/huggingface.yaml Name:model-gallery} Installed:false}
localai  | 8:00AM DBG Model found from galleries: &{URL:github:go-skynet/model-gallery/base.yaml Name:zinccat__santacoder-ggml-quantized__gpt_bigcode-santacoder-ggml-q4_1.bin Description: License:bigcode-openrail-m URLs:[https://huggingface.co/zinccat/santacoder-ggml-quantized] Icon: Tags:[license:bigcode-openrail-m region:us] ConfigFile:map[] Overrides:map[parameters:map[model:gpt_bigcode-santacoder-ggml-q4_1.bin]] AdditionalFiles:[{Filename:gpt_bigcode-santacoder-ggml-q4_1.bin SHA256: URI:https://huggingface.co/zinccat/santacoder-ggml-quantized/resolve/main/gpt_bigcode-santacoder-ggml-q4_1.bin}] Gallery:{URL:github:go-skynet/model-gallery/huggingface.yaml Name:model-gallery} Installed:false}
devexa commented 5 months ago

Same error on my side too with huggingface, using latest-aio-gpu-nvidia-cuda-12 docker image

mKenfenheuer commented 5 months ago

Same here

localai/localai:latest-aio-cpu sha256:a0924e805f9dc8cc5337e63442aca35463cdc10ab0f4b46fd2337a978974f8bf

ape-nq commented 5 months ago

Models in Huggingface gallery can be browsed using /browse/ endpoint in version 2.13.0.

The /models/available endpoint still throws errors in version 2.13.0:

$ curl http://localhost:8080/models/available
{"error":{"code":500,"message":"json: unsupported type: map[interface {}]interface {}","type":""}}
ape-nq commented 5 months ago

After checking out the new documentation, I noticed Huggingface gallery from go-skynet is not mentioned anymore.

Testing new recommended GALLERIES setting in version 2.13.0:

When not setting GALLERIES: