Text Generation
Transformers
PyTorch
Safetensors
code
llama
llama-2
conversational
text-generation-inference
Instructions to use codellama/CodeLlama-13b-Instruct-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use codellama/CodeLlama-13b-Instruct-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="codellama/CodeLlama-13b-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-13b-Instruct-hf") model = AutoModelForCausalLM.from_pretrained("codellama/CodeLlama-13b-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-13b-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-13b-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-13b-Instruct-hf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/codellama/CodeLlama-13b-Instruct-hf
- SGLang
How to use codellama/CodeLlama-13b-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-13b-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-13b-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-13b-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-13b-Instruct-hf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use codellama/CodeLlama-13b-Instruct-hf with Docker Model Runner:
docker model run hf.co/codellama/CodeLlama-13b-Instruct-hf
Commit History
-
Update README.md
Verified signature7457954
-
Fix le chat (#15)
Verified signature- Fix le chat (1742b2732c862305cc4be8920e941f8fc6e2779a) Co-authored-by: Lewis Tunstall <lewtun@users.noreply.huggingface.co>f054708 -
Add chat template (#14)
Verified signature- Add chat template (9eddae898a773c78b9434fbcc76790b1cdf72903) - Use LLama2 template (191135142b7f98903dfb320bef695df135ef9541) Co-authored-by: Lewis Tunstall <lewtun@users.noreply.huggingface.co>4a56f2b
-
Update README.md
Verified signaturee9066d1 -
Update README.md
Verified signature0c9f9b2
-
Fix link to responsible use guide
daacef3
-
Update README.md
ff0983b -
CodeLlamaTokenizer (#5)
- CodeLlamaTokenizer (0ca2fdc89898a85f3cd2566c7d35ffbe092d4990) Co-authored-by: Pedro Cuenca <pcuenq@users.noreply.huggingface.co>4cb1403
-
Fix version description
bceb28a -
Use and capabilities
bb7f8f6 -
Adding `safetensors` variant of this model (#4)
- Adding `safetensors` variant of this model (360192dfa3ed7abc6d738e74643c60d403391dbe)5a34c4a -
upload re-converted correct weights
173c00e -
Adding `safetensors` variant of this model (#3)
- Adding `safetensors` variant of this model (63d16f628892914ab801fcac87375fda6fd5cc74)b9f91b7 -
Update README.md
8a5fed9 -
Update README.md
972d2f5 -
Fix 13b and 34b instruct links (#1)
- Fix 13b and 34b instruct links (54e579ac2fc33d89c14a68615a4f59f6e3c764c7)36bf97e
-
Upload 2 files
709f6d1 -
add model weights
5e0ae10 -
Create README.md
d8be2ce -
initial commit
f3b1d47