Skip to content

Support for LLaMA models #147

Closed
Closed

Description

@ye7iaserag

Meta just released there LLaMA model family
https://github.com/facebookresearch/llama
Can we got support for that?
They calim that the 13B model is better than GPT 3 175B model


This is how to use the model in the web UI:

LLaMA TUTORIAL

-- oobabooga, March 9th, 2023

Activity

  1. oobabooga commented on Feb 27, 2023

    @oobabooga
    Owner

    The models are not public yet, unfortunately. You have to request access.

  2. MetaIX commented on Mar 2, 2023

    @MetaIX
    Contributor
  3. Sumanai commented on Mar 2, 2023

    @Sumanai

    Of course, the weights themselves are closed. But the code from the repository should be enough to add support. And where the end users will download the weights from is their problem.

  4. catboxanon commented on Mar 3, 2023

    @catboxanon
  5. oobabooga commented on Mar 3, 2023

    @oobabooga
    Owner

    Done ea5c5eb

    1. Install LLaMa as in their README:
    conda activate textgen
    git clone https://github.com/facebookresearch/llama
    cd llama
    pip install -r requirements.txt
    pip install -e .
    
    1. Put the model that you downloaded using your academic credentials on models/LLaMA-7B (the folder name must start with llama)

    2. Put a copy of the files inside that folder too: tokenizer.model and tokenizer_checklist.chk

    3. Start the web ui. I have tested with

    python server.py --no-stream --model LLaMA-7B
    

    llamas

  6. moorehousew commented on Mar 3, 2023

    @moorehousew

    Getting a CUDA out-of-memory error- I assume lowmem support isn't included yet?

  7. oobabooga commented on Mar 3, 2023

    @oobabooga
    Owner

    This isn't part of Hugging Face yet, so it doesn't have access to 8bit and CPU offloading.

    The 7B model uses 14963MiB VRAM on my machine. Reducing the max_seq_len parameter from 2048 to 512 makes this go down to 13843MiB.

  8. musicurgy commented on Mar 4, 2023

    @musicurgy

    I get a bunch of dependency errors when launching despite setting up LLaMa beforehand (definitely my own fault and probably because of a messed up conda environment)

    ModuleNotFoundError: No module named 'fire'
    ModuleNotFoundError: No module named 'fairscale'
    

    etc. Any chance you could include these in the default webui requirements assuming they aren't too heavy?

  9. oobabooga commented on Mar 4, 2023

    @oobabooga
    Owner

    @musicurgy did you try pip install -r requirements.txt as in #147 (comment)?

  10. pinned this issue on Mar 4, 2023
  11. musicurgy commented on Mar 4, 2023

    @musicurgy

    Yeah, after a bit of a struggle I ended up getting it working by just copying all the dependencies into the webui folder. So far the model is really interesting. Thanks for supporting it.

  12. generic-username0718 commented on Mar 4, 2023

    @generic-username0718

    Awesome stuff. I'm able to load LLaMA-7b but trying to load LLaMA-13b crashes with the error:

    Traceback (most recent call last):
      File "/home/user/Documents/oobabooga/text-generation-webui/server.py", line 189, in <module>
        shared.model, shared.tokenizer = load_model(shared.model_name)
      File "/home/user/Documents/oobabooga/text-generation-webui/modules/models.py", line 94, in load_model
        model = LLaMAModel.from_pretrained(Path(f'models/{model_name}'))
      File "/home/user/Documents/oobabooga/text-generation-webui/modules/LLaMA.py", line 82, in from_pretrained
        generator = load(
      File "/home/user/Documents/oobabooga/text-generation-webui/modules/LLaMA.py", line 44, in load
        assert world_size == len(
    AssertionError: Loading a checkpoint for MP=2 but world size is 1
    
  13. generic-username0718 commented on Mar 4, 2023

    @generic-username0718

    Anyone reading this you can get past the issue above by changing the world_size variable found in modules/LLaMA.py like this:

    def setup_model_parallel() -> Tuple[int, int]:
    local_rank = int(os.environ.get("LOCAL_RANK", -1))
    world_size = 2

    My issue now is I'm running out of VRAM. I'm running dual 3090s and should be able to load the model if it's split among the cards...

  14. generic-username0718 commented on Mar 4, 2023

    @generic-username0718

    Is there a parameter I need to pass to oobabooga to tell it to split the model among my two 3090 gpus?

  15. Morb0 commented on Mar 4, 2023

    @Morb0

    Is there a parameter I need to pass to oobabooga to tell it to split the model among my two 3090 gpus?

    Try --gpu-memory 10 5, at least that's what the README says.

  16. 275 remaining items

  17. f8upd8 commented on Mar 17, 2023

    @f8upd8

    #147 (comment)

    This helped, thank you

  18. echo-lalia commented on Mar 20, 2023

    @echo-lalia

    Does anyone have a guess as to what may be causing this error?
    I'm in a Ubuntu subsystem in Windows 10. I've tried reinstalling the requirements and restarting the PC. Searching on google returns no relevant results.

    Loading llama-7b-hf...
    Traceback (most recent call last):
      File "/home/[user]/text-generation-webui/server.py", line 241, in <module>
        shared.model, shared.tokenizer = load_model(shared.model_name)
      File "/home/[user]/text-generation-webui/modules/models.py", line 101, in load_model
        model = load_quantized(model_name)
      File "/home/[user]/text-generation-webui/modules/GPTQ_loader.py", line 55, in load_quantized
        model = load_quant(str(path_to_model), str(pt_path), shared.args.gptq_bits)
    TypeError: load_quant() missing 1 required positional argument: 'groupsize'
    
  19. oobabooga commented on Mar 20, 2023

    @oobabooga
    Owner
  20. dipaloka commented on Mar 22, 2023

    @dipaloka

    does anybody know where i should start to go about fixing the below errors? running on a m1 max 64gb.

    Attempted with HFv2 Model Weights LLaMA-7B

    
    python server.py --model LLaMA-7B --load-in-8bit --no-stream
    Loading LLaMA-7B...
    
    ===================================BUG REPORT===================================
    Welcome to bitsandbytes. For bug reports, please submit your error trace to: https://github.com/TimDettmers/bitsandbytes/issues
    ================================================================================
    CUDA SETUP: Required library version not found: libsbitsandbytes_cpu.so. Maybe you need to compile it from source?
    CUDA SETUP: Defaulting to libbitsandbytes_cpu.so...
    dlopen(/opt/homebrew/Caskroom/miniconda/base/envs/textgen/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so, 0x0006): tried: '/opt/homebrew/Caskroom/miniconda/base/envs/textgen/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so' (not a mach-o file)
    CUDA SETUP: Required library version not found: libsbitsandbytes_cpu.so. Maybe you need to compile it from source?
    CUDA SETUP: Defaulting to libbitsandbytes_cpu.so...
    dlopen(/opt/homebrew/Caskroom/miniconda/base/envs/textgen/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so, 0x0006): tried: '/opt/homebrew/Caskroom/miniconda/base/envs/textgen/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so' (not a mach-o file)
    /opt/homebrew/Caskroom/miniconda/base/envs/textgen/lib/python3.10/site-packages/bitsandbytes/cextension.py:31: UserWarning: The installed version of bitsandbytes was compiled without GPU support. 8-bit optimizers and GPU quantization are unavailable.
      warn("The installed version of bitsandbytes was compiled without GPU support. "
    Traceback (most recent call last):
      File "/Users/username/text-generation-webui/server.py", line 241, in <module>
        shared.model, shared.tokenizer = load_model(shared.model_name)
      File "/Users/username/text-generation-webui/modules/models.py", line 159, in load_model
        model = AutoModelForCausalLM.from_pretrained(checkpoint, **params)
      File "/opt/homebrew/Caskroom/miniconda/base/envs/textgen/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 471, in from_pretrained
        return model_class.from_pretrained(
      File "/opt/homebrew/Caskroom/miniconda/base/envs/textgen/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2588, in from_pretrained
        raise ValueError(
    ValueError: 
                            Some modules are dispatched on the CPU or the disk. Make sure you have enough GPU RAM to fit
                            the quantized model. If you want to dispatch the model on the CPU or the disk while keeping
                            these modules in 32-bit, you need to set `load_in_8bit_fp32_cpu_offload=True` and pass a custom
                            `device_map` to `from_pretrained`. Check
                            https://huggingface.co/docs/transformers/main/en/main_classes/quantization#offload-between-cpu-and-gpu
                            for more details.
    
  21. oobabooga commented on Mar 22, 2023

    @oobabooga
    Owner

    It looks like you don't have enough memory to load the model. Try adding

    python server.py --model LLaMA-7B --load-in-8bit --no-stream --gpu-memory 4000MiB
    

    (adjust the value based on your GPU size)

  22. ye7iaserag commented on Mar 25, 2023

    @ye7iaserag
    ContributorAuthor

    @oobabooga there is a wrapper for llama.cpp now
    Check this out https://github.com/PotatoSpudowski/fastLLaMa

  23. JoshuaMBlaz commented on Mar 30, 2023

    @JoshuaMBlaz

    I've been following this tutorial trying to set up llama 7b and eventually 13b, and I'm running into an issue I can't find referenced anywhere online regarding the process, pasted below.

    I'm running Windows 10, and I've already attempted the fix detailed HERE. I've tried running the command in Anaconda Prompt (miniconda3) both normally and as an administrator, and I get the same error. I even tried running it in normal CMD which didn't lead anywhere.

    Let me know if I'm posting this in the wrong place, formatting incorrectly, or committing some other faux pas - I can't figure out how to do this clean looking 'snippet clipboard content' formatting that people are using here.

    (base) D:\AI Image Things\text-generation-webui>python server.py --cai-chat --wbits 4 --model llama-7b-hf --no-stream
    Traceback (most recent call last):
    File "D:\AI Image Things\text-generation-webui\server.py", line 13, in
    from modules import chat, shared, training, ui
    File "D:\AI Image Things\text-generation-webui\modules\training.py", line 11, in
    from peft import (LoraConfig, get_peft_model, get_peft_model_state_dict,
    File "C:\Users\J\miniconda3\lib\site-packages\peft_init_.py", line 22, in
    from .mapping import MODEL_TYPE_TO_PEFT_MODEL_MAPPING, PEFT_TYPE_TO_CONFIG_MAPPING, get_peft_config, get_peft_model
    File "C:\Users\J\miniconda3\lib\site-packages\peft\mapping.py", line 16, in
    from .peft_model import (
    File "C:\Users\J\miniconda3\lib\site-packages\peft\peft_model.py", line 31, in
    from .tuners import LoraModel, PrefixEncoder, PromptEmbedding, PromptEncoder
    File "C:\Users\J\miniconda3\lib\site-packages\peft\tuners_init_.py", line 20, in
    from .lora import LoraConfig, LoraModel
    File "C:\Users\J\miniconda3\lib\site-packages\peft\tuners\lora.py", line 36, in
    import bitsandbytes as bnb
    File "C:\Users\J\miniconda3\lib\site-packages\bitsandbytes_init_.py", line 7, in
    from .autograd.functions import (
    File "C:\Users\J\miniconda3\lib\site-packages\bitsandbytes\autograd_init
    .py", line 1, in
    from ._functions import undo_layout, get_inverse_transform_indices
    File "C:\Users\J\miniconda3\lib\site-packages\bitsandbytes\autograd_functions.py", line 9, in
    import bitsandbytes.functional as F
    File "C:\Users\J\miniconda3\lib\site-packages\bitsandbytes\functional.py", line 17, in
    from .cextension import COMPILED_WITH_CUDA, lib
    File "C:\Users\J\miniconda3\lib\site-packages\bitsandbytes\cextension.py", line 8, in
    from bitsandbytes.cuda_setup.main import CUDASetup
    File "C:\Users\J\miniconda3\lib\site-packages\bitsandbytes\cuda_setup\main.py", line 368
    if torch.cuda.is_available(): return 'libbitsandbytes_cuda116.dll', None, None, None, None
    ^
    IndentationError: unindent does not match any outer indentation level

    (base) D:\AI Image Things\text-generation-webui>

  24. oobabooga commented on Mar 30, 2023

    @oobabooga
    Owner

    I recommend using the new one-click installer for native Windows installation

    https://github.com/oobabooga/text-generation-webui#one-click-installers

  25. JoshuaMBlaz commented on Mar 30, 2023

    @JoshuaMBlaz

    I recommend using the new one-click installer for native Windows installation

    https://github.com/oobabooga/text-generation-webui#one-click-installers

    I'll give that a shot! Thanks for the work you put in on all this - the accessibility of this wave of AI tech is seriously appreciated.

  26. tillhanke commented on Mar 31, 2023

    @tillhanke

    I just succeeded in install 13B

    @guruace HOW? I don't understand, what I am doing wrong. I get the following error.

    ===================================BUG REPORT===================================
    Welcome to bitsandbytes. For bug reports, please submit your error trace to: https://github.com/TimDettmers/bitsandbytes/issues
    ================================================================================
    CUDA SETUP: Required library version not found: libsbitsandbytes_cpu.so. Maybe you need to compile it from source?
    CUDA SETUP: Defaulting to libbitsandbytes_cpu.so...
    dlopen(/Users/hanke/src/text-generation-webui/.venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so, 0x0006): tried: '/Users/hanke/src/text-generation-webui/.venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so' (not a mach-o file), '/System/Volumes/Preboot/Cryptexes/OS/Users/hanke/src/text-generation-webui/.venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so' (no such file), '/Users/hanke/src/text-generation-webui/.venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so' (not a mach-o file)
    CUDA SETUP: Required library version not found: libsbitsandbytes_cpu.so. Maybe you need to compile it from source?
    CUDA SETUP: Defaulting to libbitsandbytes_cpu.so...
    dlopen(/Users/hanke/src/text-generation-webui/.venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so, 0x0006): tried: '/Users/hanke/src/text-generation-webui/.venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so' (not a mach-o file), '/System/Volumes/Preboot/Cryptexes/OS/Users/hanke/src/text-generation-webui/.venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so' (no such file), '/Users/hanke/src/text-generation-webui/.venv/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so' (not a mach-o file)
    /Users/hanke/src/text-generation-webui/.venv/lib/python3.10/site-packages/bitsandbytes/cextension.py:31: UserWarning: The installed version of bitsandbytes was compiled without GPU support. 8-bit optimizers and GPU quantization are unavailable.
      warn("The installed version of bitsandbytes was compiled without GPU support. "
    Loading 13B-conv...
    Traceback (most recent call last):
      File "/Users/hanke/src/text-generation-webui/server.py", line 273, in <module>
        shared.model, shared.tokenizer = load_model(shared.model_name)
      File "/Users/hanke/src/text-generation-webui/modules/models.py", line 49, in load_model
        model = AutoModelForCausalLM.from_pretrained(Path(f"{shared.args.model_dir}/{shared.model_name}"), device_map='auto', load_in_8bit=True)
      File "/Users/hanke/src/text-generation-webui/.venv/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 471, in from_pretrained
        return model_class.from_pretrained(
      File "/Users/hanke/src/text-generation-webui/.venv/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2601, in from_pretrained
        raise ValueError(
    ValueError:
                            Some modules are dispatched on the CPU or the disk. Make sure you have enough GPU RAM to fit
                            the quantized model. If you want to dispatch the model on the CPU or the disk while keeping
                            these modules in 32-bit, you need to set `load_in_8bit_fp32_cpu_offload=True` and pass a custom
                            `device_map` to `from_pretrained`. Check
                            https://huggingface.co/docs/transformers/main/en/main_classes/quantization#offload-between-cpu-and-gpu
                            for more details.
    
    

    When running python server.py --auto-launch --model 13B
    I dont know, why it is trying to use cuda, when MPS should automatically be chosen? But I also just dont get the workflow of the program yet... Maybe you can give me some pointers, on how I might fix that?
    Thanks!

  27. oobabooga commented on Mar 31, 2023

    @oobabooga
    Owner

    @tillhanke this is an out of memory error. It means that not enough RAM and/or VRAM was found in the system to load the model.

  28. neuhaus commented on Apr 11, 2023

    @neuhaus

    so, Llama works, i guess this issue can be closed 👏🏼

  29. Modplay commented on Apr 14, 2023

    @Modplay

    File "/home/yinan/text-generation-webui/modules/text_generation.py", line 31, in encode
    input_ids = shared.tokenizer.encode(str(prompt), return_tensors='pt', add_special_tokens=add_special_tokens)
    AttributeError: 'NoneType' object has no attribute 'encode'

  30. xNul commented on Apr 14, 2023

    @xNul
    Contributor

    @Modplay you haven't downloaded or set the model yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions