Text Generation
Transformers
PyTorch
Safetensors
code
llama
llama-2
conversational
text-generation-inference
Instructions to use codellama/CodeLlama-7b-Instruct-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use codellama/CodeLlama-7b-Instruct-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="codellama/CodeLlama-7b-Instruct-hf") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("codellama/CodeLlama-7b-Instruct-hf") model = AutoModelForCausalLM.from_pretrained("codellama/CodeLlama-7b-Instruct-hf", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use codellama/CodeLlama-7b-Instruct-hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "codellama/CodeLlama-7b-Instruct-hf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "codellama/CodeLlama-7b-Instruct-hf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/codellama/CodeLlama-7b-Instruct-hf
- SGLang
How to use codellama/CodeLlama-7b-Instruct-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 "codellama/CodeLlama-7b-Instruct-hf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "codellama/CodeLlama-7b-Instruct-hf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "codellama/CodeLlama-7b-Instruct-hf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "codellama/CodeLlama-7b-Instruct-hf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use codellama/CodeLlama-7b-Instruct-hf with Docker Model Runner:
docker model run hf.co/codellama/CodeLlama-7b-Instruct-hf
Commit History
-
Update README.md
Verified signature22cb240
-
Fix chat template (again!) (#28)
Verified signature- Fix chat template (again!) (1ab65d2aa72316ad75724c7f11e7c9f11cdcb077) - FML (96e0a617ff120d86bb34579e33bebfd84f154719) Co-authored-by: Lewis Tunstall <lewtun@users.noreply.huggingface.co>4ead8e6 -
Add chat template (#27)
Verified signature- Add chat template (c1b0ef9258e4fd6a2c1d6329f08f5f1dc78bfe4e) - Use Llama2 template (a7eb558c905566e48cb1466e794a3b7c389ac9fc) Co-authored-by: Lewis Tunstall <lewtun@users.noreply.huggingface.co>c7c9b8e
-
Update README.md
Verified signaturef02cb64 -
Update README.md
Verified signature6948519
-
Fix link to responsible use guide
65515fc
-
Update README.md
6114dd1 -
Delete unused checkpoints (#9)
- Delete unused checkpoints (089c016a7ce3550caa93534b9a61603c21c77e4c) - Delete pytorch_model-00001-of-00006.bin (2d832a0a0e313851cb4a5b74547cb5ede488fcea) - Delete pytorch_model-00002-of-00006.bin (bc79b5883d1f73f1298624886c8e3d3fe931b367) - Delete pytorch_model-00003-of-00006.bin (04bfe1fdf5846b4c63d8c33517110ef0a31f6c38) - Delete pytorch_model-00004-of-00006.bin (4721f2b91cb213e355f9fbea2cf9b482e514ea74) - Delete pytorch_model-00005-of-00006.bin (02c595211ee7292cdd1694e088125f665653bda8) - Delete pytorch_model-00006-of-00006.bin (2692b615b21ca10e9d07fcad8a8445f1be40fb03) - Delete pytorch_model-00002-of-00002.bin (cb6229c66b04310c31b0b58cf443f3e517cef4c7)0a5c03f -
Upload LlamaForCausalLM
ac8223d -
CodeLlamaTokenizer (#8)
- CodeLlamaTokenizer (0b06b9aa2e15831dee931046da1c47674b72bd90) Co-authored-by: Pedro Cuenca <pcuenq@users.noreply.huggingface.co>91415ec
-
Fix version description
70a7b0e -
Use and capabilities (#6)
- Use and capabilities (09623edd24257fad12877a47bd358c3ab62d1b37)6f7c241 -
use 6 shards instead of 2
7affc44 -
Adding `safetensors` variant of this model (#4)
- Adding `safetensors` variant of this model (0c8fca17a9d9c34ae9bb736ca86c7967ad56cb24)2f6d97b -
Update README.md
90346e7 -
Fix 13b and 34b instruct links (#2)
- Fix 13b and 34b instruct links (6825f91e95dfdc9fa32105361e1e8fe122b298b5)0a82d75
-
Upload 2 files
4070c4f -
add model weights
65db8fc -
Create README.md
d06abb7 -
initial commit
3a2d775