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
-
Delete pytorch_model-00004-of-00006.bin
4721f2b -
Delete pytorch_model-00003-of-00006.bin
04bfe1f -
Delete pytorch_model-00002-of-00006.bin
bc79b58 -
Delete pytorch_model-00001-of-00006.bin
2d832a0 -
Delete unused checkpoints
models were consisting of 6 shards in float32, this [commit](https://huggingface.co/codellama/CodeLlama-7b-Instruct-hf/commit/ac8223d6d6d61691272151fd4e58eea52f8d6cf1) changed them to 3 shards of bfloat16. see this issue https://huggingface.co/codellama/CodeLlama-7b-Python-hf/discussions/4089c016 -
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