Instructions to use NousResearch/Llama-2-7b-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NousResearch/Llama-2-7b-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NousResearch/Llama-2-7b-hf")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("NousResearch/Llama-2-7b-hf") model = AutoModelForCausalLM.from_pretrained("NousResearch/Llama-2-7b-hf") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use NousResearch/Llama-2-7b-hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NousResearch/Llama-2-7b-hf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NousResearch/Llama-2-7b-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/NousResearch/Llama-2-7b-hf
- SGLang
How to use NousResearch/Llama-2-7b-hf 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 "NousResearch/Llama-2-7b-hf" \ --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": "NousResearch/Llama-2-7b-hf", "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 "NousResearch/Llama-2-7b-hf" \ --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": "NousResearch/Llama-2-7b-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use NousResearch/Llama-2-7b-hf with Docker Model Runner:
docker model run hf.co/NousResearch/Llama-2-7b-hf
Re-upload with tokenizer/config changes?
The HF team has made several updates to the main repo for this model since this repo was published. One of which, significantly, fixes the tokenizer:
I've seen a few people getting tripped up by this issue on Discord and reddit: https://www.reddit.com/r/LocalLLaMA/comments/15hz7gl/my_finetuning_based_on_llama27bchathf_model/
I dont think you need to change the model files to take advantage of changes in HF Transformers implementation of the model
Oh sorry, to clarify - I'm referring to changes the HF team has made to the model repos, not transformers.
It seems like a lot of tutorials use these mirrors, which is causing difficult-to-debug problems like the improper tokenization of </s> above.
(Out of curiosity - I noticed the mirror for the 7b chat model is 404ing now. Did you guys delete it, or was it taken down?)
Oh sorry, to clarify - I'm referring to changes the HF team has made to the model repos, not
transformers.It seems like a lot of tutorials use these mirrors, which is causing difficult-to-debug problems like the improper tokenization of
</s>above.(Out of curiosity - I noticed the mirror for the 7b chat model is 404ing now. Did you guys delete it, or was it taken down?)
@LDJnr and me figured no one would want to train over that model so privated it to clean up, do you use it?
Nah, just curious. Others apparently use it (someone was asking questions about a Colab which uses it in TheBloke's Discord earlier today, and others are using it in the reddit thread I linked above) but I agree, finetuning an RLHF'd model is probably not ideal.
re: the original issue, though - lmk if it makes sense why I'm suggesting you re-mirror the updated version or if I should clarify anything
done
