Text Generation
Transformers
PyTorch
Safetensors
code
llama
llama-2
conversational
text-generation-inference
Instructions to use codellama/CodeLlama-34b-Instruct-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use codellama/CodeLlama-34b-Instruct-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="codellama/CodeLlama-34b-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-34b-Instruct-hf") model = AutoModelForCausalLM.from_pretrained("codellama/CodeLlama-34b-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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use codellama/CodeLlama-34b-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-34b-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-34b-Instruct-hf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/codellama/CodeLlama-34b-Instruct-hf
- SGLang
How to use codellama/CodeLlama-34b-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-34b-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-34b-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-34b-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-34b-Instruct-hf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use codellama/CodeLlama-34b-Instruct-hf with Docker Model Runner:
docker model run hf.co/codellama/CodeLlama-34b-Instruct-hf
Commit History
-
Update README.md
Verified signatured4c1c47
-
Say no to chat templates 🙅♂️ (#26)
Verified signature- Say no to chat templates 🙅♂️ (2c36c94aea99a50bf2c1b551f8905ef299b5694f) Co-authored-by: Lewis Tunstall <lewtun@users.noreply.huggingface.co>adc6436 -
Add chat template (#25)
Verified signature- Add chat template (286f2a9b6e26c0506d539979fc8c5c740b88f398) - Use Llama2 template (2b975ac6dbb7d6212f9d8b913456271920d47ae4) Co-authored-by: Lewis Tunstall <lewtun@users.noreply.huggingface.co>ada9bf9
-
Update README.md
Verified signaturecebb11e -
Update README.md
Verified signatured58d65a
-
Fix link to responsible use guide
bf5e506
-
Update README.md
38a1e15 -
CodeLlamaTokenizer (#8)
- CodeLlamaTokenizer (469ae7fae986bc841e1fff566774e5d9eff9fb94) Co-authored-by: Pedro Cuenca <pcuenq@users.noreply.huggingface.co>b57af5d
-
Fix version
6728f3a -
Use and capabilities
47efc58 -
Fix instruct 13B and 34B pointing to instruct 7B model (#2)
- Fix instruct 13B and 34B pointing to instruct 7B model (e8d3e7b0610f05f1c1529eb43bd25947690a0b6f) Co-authored-by: theblackcat102 <ikala-ray@users.noreply.huggingface.co>c109b9d -
Adding `safetensors` variant of this model (#5)
- Adding `safetensors` variant of this model (2eb78ac136a157c20099a94fc41abcac574ce939)fd39817 -
Update README.md
d650b03 -
Fix 13b and 34b instruct links (#3)
- Fix 13b and 34b instruct links (2d4249007da830793992e2e23f2744a2d81371ee)2b209d2
-
add model weights
5396a0b -
Update README.md
6f3bef3 -
initial commit
6e7110f