Text Generation
Transformers
Safetensors
PyTorch
English
llama
facebook
meta
llama-2
text-generation-inference
4-bit precision
awq
Instructions to use TheBloke/Llama-2-13B-AWQ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TheBloke/Llama-2-13B-AWQ with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TheBloke/Llama-2-13B-AWQ")# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("TheBloke/Llama-2-13B-AWQ") model = AutoModelForMultimodalLM.from_pretrained("TheBloke/Llama-2-13B-AWQ") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use TheBloke/Llama-2-13B-AWQ with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TheBloke/Llama-2-13B-AWQ" # 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-13B-AWQ", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/TheBloke/Llama-2-13B-AWQ
- SGLang
How to use TheBloke/Llama-2-13B-AWQ 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-13B-AWQ" \ --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-13B-AWQ", "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-13B-AWQ" \ --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-13B-AWQ", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use TheBloke/Llama-2-13B-AWQ with Docker Model Runner:
docker model run hf.co/TheBloke/Llama-2-13B-AWQ
AttributeError 'LlamaLikeModel' object has no attribute 'layers'
#1
by jeffrey-sh - opened
@TheBloke Hello.
I ran the code and the set quant_path to TheBloke/Llama-2-13B-AWQ. However, I encountered the following error. How I resolve this error?
~/autoawq$ CUDA_VISIBLE_DEVICES=0 python3 test.py
Fetching 13 files: 100%|βββββββββββββββββββββ| 13/13 [00:00<00:00, 86963.24it/s]
Replacing layers...: 100%|ββββββββββββββββββββββ| 40/40 [00:04<00:00, 9.63it/s]
Fusing layers...: 100%|βββββββββββββββββββββββββ| 40/40 [00:02<00:00, 18.21it/s]
Traceback (most recent call last):
File "/home/jeffrey/autoawq/test.py", line 94, in <module>
generated_output = model.generate(
File "/home/jeffrey/.cache/pypoetry/virtualenvs/autoawq-MwlF3Uxe-py3.10/lib/python3.10/site-packages/awq/models/base.py", line 104, in generate
return self.model.generate(*args, **kwargs)
File "/home/jeffrey/.cache/pypoetry/virtualenvs/autoawq-MwlF3Uxe-py3.10/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/home/jeffrey/.cache/pypoetry/virtualenvs/autoawq-MwlF3Uxe-py3.10/lib/python3.10/site-packages/transformers/generation/utils.py", line 1544, in generate
return self.greedy_search(
File "/home/jeffrey/.cache/pypoetry/virtualenvs/autoawq-MwlF3Uxe-py3.10/lib/python3.10/site-packages/transformers/generation/utils.py", line 2401, in greedy_search
model_inputs = self.prepare_inputs_for_generation(input_ids, **model_kwargs)
File "/home/jeffrey/.cache/pypoetry/virtualenvs/autoawq-MwlF3Uxe-py3.10/lib/python3.10/site-packages/transformers/models/llama/modeling_llama.py", line 1256, in prepare_inputs_for_generation
if past_key_value := getattr(self.model.layers[0].self_attn, "past_key_value", None):
File "/home/jeffrey/.cache/pypoetry/virtualenvs/autoawq-MwlF3Uxe-py3.10/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1688, in __getattr__
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'LlamaLikeModel' object has no attribute 'layers'