Instructions to use TheBloke/Llama-2-7B-Chat-GGML with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TheBloke/Llama-2-7B-Chat-GGML with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TheBloke/Llama-2-7B-Chat-GGML")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("TheBloke/Llama-2-7B-Chat-GGML", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use TheBloke/Llama-2-7B-Chat-GGML with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TheBloke/Llama-2-7B-Chat-GGML" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TheBloke/Llama-2-7B-Chat-GGML", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/TheBloke/Llama-2-7B-Chat-GGML
- SGLang
How to use TheBloke/Llama-2-7B-Chat-GGML with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "TheBloke/Llama-2-7B-Chat-GGML" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TheBloke/Llama-2-7B-Chat-GGML", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "TheBloke/Llama-2-7B-Chat-GGML" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TheBloke/Llama-2-7B-Chat-GGML", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use TheBloke/Llama-2-7B-Chat-GGML with Docker Model Runner:
docker model run hf.co/TheBloke/Llama-2-7B-Chat-GGML
Newbie question on local model loading
I have downloaded the file llama-2-7b-chat.ggmlv3.q4_K_S.bin and placed it in the folder ../models/llama-2-7b-chat.ggmlv3.q4_K_S.
Calling AutoModel.from_pretrained('../models/llama-2-7b-chat.ggmlv3.q4_K_S') gives the error about not finding the file named pytorch_model.bin`.
Upon renaming the .bin file to such name I get this error:
OSError: Unable to load weights from pytorch checkpoint file for '../models/llama-2-7b-chat.ggmlv3.q4_K_S/pytorch_model.bin' at '../models/llama-2-7b-chat.ggmlv3.q4_K_S/pytorch_model.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
what is the correct way to load the model from binaries?
thanks very much!
You can load up the model by just referencing the directory on GGML models using c transformers.
from ctransformers import AutoModelForCausalLM
llm = AutoModelForCausalLM.from_pretrained('models/', model_type='gpt2')
print(llm('AI is going to'))
Loading directly from huggingface doesn't seem to work either. The mysterious error keeps suggesting using from_tf=True even when I have already used it there:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id="TheBloke/Llama-2-7B-Chat-GGML".lower()
model =AutoModelForCausalLM.from_pretrained(model_id, from_tf=True)
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Traceback (most recent call last) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ in <module>:5 โ
โ โ
โ 2 โ
โ 3 model_id="TheBloke/Llama-2-7B-Chat-GGML".lower() โ
โ 4 โ
โ โฑ 5 model =AutoModelForCausalLM.from_pretrained(model_id, from_tf=True) โ
โ 6 โ
โ โ
โ /home/ec2-user/SageMaker/envs/py310/lib/python3.10/site-packages/transformers/models/auto/auto_f โ
โ actory.py:493 in from_pretrained โ
โ โ
โ 490 โ โ โ ) โ
โ 491 โ โ elif type(config) in cls._model_mapping.keys(): โ
โ 492 โ โ โ model_class = _get_model_class(config, cls._model_mapping) โ
โ โฑ 493 โ โ โ return model_class.from_pretrained( โ
โ 494 โ โ โ โ pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, โ
โ 495 โ โ โ ) โ
โ 496 โ โ raise ValueError( โ
โ โ
โ /home/ec2-user/SageMaker/envs/py310/lib/python3.10/site-packages/transformers/modeling_utils.py: โ
โ 2560 in from_pretrained โ
โ โ
โ 2557 โ โ โ โ โ โ โ "use_auth_token": token, โ
โ 2558 โ โ โ โ โ โ } โ
โ 2559 โ โ โ โ โ โ if has_file(pretrained_model_name_or_path, TF2_WEIGHTS_NAME, **h โ
โ โฑ 2560 โ โ โ โ โ โ โ raise EnvironmentError( โ
โ 2561 โ โ โ โ โ โ โ โ f"{pretrained_model_name_or_path} does not appear to hav โ
โ 2562 โ โ โ โ โ โ โ โ f" {_add_variant(WEIGHTS_NAME, variant)} but there is a โ
โ 2563 โ โ โ โ โ โ โ โ " Use `from_tf=True` to load this model from those weigh โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
OSError: thebloke/llama-2-7b-chat-ggml does not appear to have a file named pytorch_model.bin but there is a file
for TensorFlow weights. Use `from_tf=True` to load this model from those weights.
Thanks!