Instructions to use codellama/CodeLlama-34b-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use codellama/CodeLlama-34b-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="codellama/CodeLlama-34b-hf")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("codellama/CodeLlama-34b-hf") model = AutoModelForCausalLM.from_pretrained("codellama/CodeLlama-34b-hf") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use codellama/CodeLlama-34b-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-hf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "codellama/CodeLlama-34b-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/codellama/CodeLlama-34b-hf
- SGLang
How to use codellama/CodeLlama-34b-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-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": "codellama/CodeLlama-34b-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 "codellama/CodeLlama-34b-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": "codellama/CodeLlama-34b-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use codellama/CodeLlama-34b-hf with Docker Model Runner:
docker model run hf.co/codellama/CodeLlama-34b-hf
Commit ·
5799998
1
Parent(s): 678fb46
Update README.md
Browse files
README.md
CHANGED
|
@@ -15,6 +15,43 @@ Code Llama is a collection of pretrained and fine-tuned generative text models r
|
|
| 15 |
| 13B | [codellama/CodeLlama-13b-hf](https://huggingface.co/codellama/CodeLlama-13b-hf) | [codellama/CodeLlama-13b-Python-hf](https://huggingface.co/codellama/CodeLlama-13b-Python-hf) | [codellama/CodeLlama-13b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-7b-Instruct-hf) |
|
| 16 |
| 34B | [codellama/CodeLlama-34b-hf](https://huggingface.co/codellama/CodeLlama-34b-hf) | [codellama/CodeLlama-34b-Python-hf](https://huggingface.co/codellama/CodeLlama-34b-Python-hf) | [codellama/CodeLlama-34b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-7b-Instruct-hf) |
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
## Model Details
|
| 19 |
*Note: Use of this model is governed by the Meta license. Meta developed and publicly released the Code Llama family of large language models (LLMs).
|
| 20 |
|
|
|
|
| 15 |
| 13B | [codellama/CodeLlama-13b-hf](https://huggingface.co/codellama/CodeLlama-13b-hf) | [codellama/CodeLlama-13b-Python-hf](https://huggingface.co/codellama/CodeLlama-13b-Python-hf) | [codellama/CodeLlama-13b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-7b-Instruct-hf) |
|
| 16 |
| 34B | [codellama/CodeLlama-34b-hf](https://huggingface.co/codellama/CodeLlama-34b-hf) | [codellama/CodeLlama-34b-Python-hf](https://huggingface.co/codellama/CodeLlama-34b-Python-hf) | [codellama/CodeLlama-34b-Instruct-hf](https://huggingface.co/codellama/CodeLlama-7b-Instruct-hf) |
|
| 17 |
|
| 18 |
+
Make sure to be using this temporary branch of transformers unit support is fully merged and released.
|
| 19 |
+
|
| 20 |
+
```bash
|
| 21 |
+
pip install git+https://github.com/huggingface/transformers.git@refs/pull/25740/head accelerate
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
```python
|
| 26 |
+
from transformers import AutoTokenizer
|
| 27 |
+
import transformers
|
| 28 |
+
import torch
|
| 29 |
+
|
| 30 |
+
model = "codellama/CodeLlama-34b-hf"
|
| 31 |
+
|
| 32 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
| 33 |
+
pipeline = transformers.pipeline(
|
| 34 |
+
"text-generation",
|
| 35 |
+
model=model,
|
| 36 |
+
torch_dtype=torch.float16,
|
| 37 |
+
device_map="auto",
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
sequences = pipeline(
|
| 41 |
+
'import socket\n\ndef ping_exponential_backoff(host: str):',
|
| 42 |
+
do_sample=True,
|
| 43 |
+
top_k=10,
|
| 44 |
+
temperature=0.1,
|
| 45 |
+
top_p=0.95
|
| 46 |
+
num_return_sequences=1,
|
| 47 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 48 |
+
max_length=200,
|
| 49 |
+
)
|
| 50 |
+
for seq in sequences:
|
| 51 |
+
print(f"Result: {seq['generated_text']}")
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
|
| 55 |
## Model Details
|
| 56 |
*Note: Use of this model is governed by the Meta license. Meta developed and publicly released the Code Llama family of large language models (LLMs).
|
| 57 |
|