Instructions to use codellama/CodeLlama-7b-Python-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use codellama/CodeLlama-7b-Python-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="codellama/CodeLlama-7b-Python-hf")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("codellama/CodeLlama-7b-Python-hf") model = AutoModelForCausalLM.from_pretrained("codellama/CodeLlama-7b-Python-hf") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use codellama/CodeLlama-7b-Python-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-Python-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-7b-Python-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/codellama/CodeLlama-7b-Python-hf
- SGLang
How to use codellama/CodeLlama-7b-Python-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-Python-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-7b-Python-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-7b-Python-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-7b-Python-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use codellama/CodeLlama-7b-Python-hf with Docker Model Runner:
docker model run hf.co/codellama/CodeLlama-7b-Python-hf
Commit ·
b46bda9
1
Parent(s): 7ee7b6b
Update tokenizer_config.json
Browse filesFollowing https://huggingface.co/codellama/CodeLlama-34b-hf/discussions/9 to support usage with ctranslate2
cc: @ctranslate2-4you
- tokenizer_config.json +7 -0
tokenizer_config.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
{
|
| 2 |
"add_bos_token": true,
|
| 3 |
"add_eos_token": false,
|
|
|
|
| 4 |
"bos_token": {
|
| 5 |
"__type": "AddedToken",
|
| 6 |
"content": "<s>",
|
|
@@ -9,6 +10,8 @@
|
|
| 9 |
"rstrip": false,
|
| 10 |
"single_word": false
|
| 11 |
},
|
|
|
|
|
|
|
| 12 |
"clean_up_tokenization_spaces": false,
|
| 13 |
"eos_token": {
|
| 14 |
"__type": "AddedToken",
|
|
@@ -19,9 +22,13 @@
|
|
| 19 |
"single_word": false
|
| 20 |
},
|
| 21 |
"legacy": null,
|
|
|
|
| 22 |
"model_max_length": 1000000000000000019884624838656,
|
| 23 |
"pad_token": null,
|
|
|
|
| 24 |
"sp_model_kwargs": {},
|
|
|
|
|
|
|
| 25 |
"tokenizer_class": "CodeLlamaTokenizer",
|
| 26 |
"unk_token": {
|
| 27 |
"__type": "AddedToken",
|
|
|
|
| 1 |
{
|
| 2 |
"add_bos_token": true,
|
| 3 |
"add_eos_token": false,
|
| 4 |
+
"additional_special_tokens": [],
|
| 5 |
"bos_token": {
|
| 6 |
"__type": "AddedToken",
|
| 7 |
"content": "<s>",
|
|
|
|
| 10 |
"rstrip": false,
|
| 11 |
"single_word": false
|
| 12 |
},
|
| 13 |
+
"eot_token": null,
|
| 14 |
+
"fill_token": "<FILL_ME>",
|
| 15 |
"clean_up_tokenization_spaces": false,
|
| 16 |
"eos_token": {
|
| 17 |
"__type": "AddedToken",
|
|
|
|
| 22 |
"single_word": false
|
| 23 |
},
|
| 24 |
"legacy": null,
|
| 25 |
+
"middle_token": null,
|
| 26 |
"model_max_length": 1000000000000000019884624838656,
|
| 27 |
"pad_token": null,
|
| 28 |
+
"prefix_token": null,
|
| 29 |
"sp_model_kwargs": {},
|
| 30 |
+
"suffix_first": false,
|
| 31 |
+
"suffix_token": null,
|
| 32 |
"tokenizer_class": "CodeLlamaTokenizer",
|
| 33 |
"unk_token": {
|
| 34 |
"__type": "AddedToken",
|