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)# 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") 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- 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
Delete unused checkpoints
#9
by loubnabnl HF Staff - opened
- pytorch_model-00001-of-00002.bin +0 -3
- pytorch_model-00001-of-00006.bin +0 -3
- pytorch_model-00002-of-00002.bin +0 -3
- pytorch_model-00002-of-00006.bin +0 -3
- pytorch_model-00003-of-00006.bin +0 -3
- pytorch_model-00004-of-00006.bin +0 -3
- pytorch_model-00005-of-00006.bin +0 -3
- pytorch_model-00006-of-00006.bin +0 -3
pytorch_model-00001-of-00002.bin
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:3262d0b99a18b989027f4b4e9ef73c2de434b89825b77c6ea1550cf61f4b84db
|
| 3 |
-
size 9976751194
|
|
|
|
|
|
|
|
|
|
|
|
pytorch_model-00001-of-00006.bin
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:e4e715bd18d72fbb7c6ecfc2bfbe20e94f15b485728b2b5203a4592781d703bb
|
| 3 |
-
size 4840669603
|
|
|
|
|
|
|
|
|
|
|
|
pytorch_model-00002-of-00002.bin
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:326fb3739eb055eca7b20aaef0f5061ea809ad91af715869e1c97cfb6899b947
|
| 3 |
-
size 3500441859
|
|
|
|
|
|
|
|
|
|
|
|
pytorch_model-00002-of-00006.bin
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:06915b957e6b6485d01bf50982d204827901bb0021de96c0acdcedcdeb0c7e3d
|
| 3 |
-
size 4857218807
|
|
|
|
|
|
|
|
|
|
|
|
pytorch_model-00003-of-00006.bin
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:976d878e931d5f109f5445fc48c3522abee8b83fcede561ae9e6e1ce01c1d955
|
| 3 |
-
size 4857218807
|
|
|
|
|
|
|
|
|
|
|
|
pytorch_model-00004-of-00006.bin
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:0df4a45658f3c2c8024fa469df8d050c0605e38a3b6f46720606309f9f800587
|
| 3 |
-
size 4857218807
|
|
|
|
|
|
|
|
|
|
|
|
pytorch_model-00005-of-00006.bin
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:06eb91468aa4aa60ee1466d56823517f3b1e92ecd9a6351a06af5d0b5aee30a4
|
| 3 |
-
size 4857218807
|
|
|
|
|
|
|
|
|
|
|
|
pytorch_model-00006-of-00006.bin
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:d56f21a4e0dc163f956e30f27a0bdf85cdf08c7a79cc0516ec50554af07932ee
|
| 3 |
-
size 2684739793
|
|
|
|
|
|
|
|
|
|
|
|