Text Generation
Transformers
Safetensors
English
llama
unsloth
codellama
codellama-34b
text-generation-inference
4-bit precision
bitsandbytes
Instructions to use unsloth/codellama-34b-bnb-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/codellama-34b-bnb-4bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="unsloth/codellama-34b-bnb-4bit")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("unsloth/codellama-34b-bnb-4bit") model = AutoModelForCausalLM.from_pretrained("unsloth/codellama-34b-bnb-4bit") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use unsloth/codellama-34b-bnb-4bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/codellama-34b-bnb-4bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsloth/codellama-34b-bnb-4bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/unsloth/codellama-34b-bnb-4bit
- SGLang
How to use unsloth/codellama-34b-bnb-4bit 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 "unsloth/codellama-34b-bnb-4bit" \ --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": "unsloth/codellama-34b-bnb-4bit", "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 "unsloth/codellama-34b-bnb-4bit" \ --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": "unsloth/codellama-34b-bnb-4bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Unsloth Studio
How to use unsloth/codellama-34b-bnb-4bit with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for unsloth/codellama-34b-bnb-4bit to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for unsloth/codellama-34b-bnb-4bit to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for unsloth/codellama-34b-bnb-4bit to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="unsloth/codellama-34b-bnb-4bit", max_seq_length=2048, ) - Docker Model Runner
How to use unsloth/codellama-34b-bnb-4bit with Docker Model Runner:
docker model run hf.co/unsloth/codellama-34b-bnb-4bit
Upload config
Browse files- README.md +1 -2
- config.json +8 -3
README.md
CHANGED
|
@@ -1,14 +1,13 @@
|
|
| 1 |
---
|
| 2 |
language:
|
| 3 |
- en
|
| 4 |
-
license: apache-2.0
|
| 5 |
library_name: transformers
|
|
|
|
| 6 |
tags:
|
| 7 |
- unsloth
|
| 8 |
- transformers
|
| 9 |
- codellama
|
| 10 |
- codellama-34b
|
| 11 |
-
|
| 12 |
---
|
| 13 |
|
| 14 |
# Finetune Mistral, Gemma, Llama 2-5x faster with 70% less memory via Unsloth!
|
|
|
|
| 1 |
---
|
| 2 |
language:
|
| 3 |
- en
|
|
|
|
| 4 |
library_name: transformers
|
| 5 |
+
license: apache-2.0
|
| 6 |
tags:
|
| 7 |
- unsloth
|
| 8 |
- transformers
|
| 9 |
- codellama
|
| 10 |
- codellama-34b
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
# Finetune Mistral, Gemma, Llama 2-5x faster with 70% less memory via Unsloth!
|
config.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"_name_or_path": "
|
| 3 |
"architectures": [
|
| 4 |
"LlamaForCausalLM"
|
| 5 |
],
|
|
@@ -12,14 +12,18 @@
|
|
| 12 |
"initializer_range": 0.02,
|
| 13 |
"intermediate_size": 22016,
|
| 14 |
"max_position_embeddings": 16384,
|
|
|
|
| 15 |
"model_type": "llama",
|
| 16 |
"num_attention_heads": 64,
|
| 17 |
"num_hidden_layers": 48,
|
| 18 |
"num_key_value_heads": 8,
|
| 19 |
-
"pad_token_id":
|
| 20 |
"pretraining_tp": 1,
|
| 21 |
"quantization_config": {
|
|
|
|
|
|
|
| 22 |
"bnb_4bit_compute_dtype": "bfloat16",
|
|
|
|
| 23 |
"bnb_4bit_quant_type": "nf4",
|
| 24 |
"bnb_4bit_use_double_quant": true,
|
| 25 |
"llm_int8_enable_fp32_cpu_offload": false,
|
|
@@ -35,7 +39,8 @@
|
|
| 35 |
"rope_theta": 1000000,
|
| 36 |
"tie_word_embeddings": false,
|
| 37 |
"torch_dtype": "bfloat16",
|
| 38 |
-
"transformers_version": "4.
|
|
|
|
| 39 |
"use_cache": true,
|
| 40 |
"vocab_size": 32000
|
| 41 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"_name_or_path": "unsloth/codellama-34b",
|
| 3 |
"architectures": [
|
| 4 |
"LlamaForCausalLM"
|
| 5 |
],
|
|
|
|
| 12 |
"initializer_range": 0.02,
|
| 13 |
"intermediate_size": 22016,
|
| 14 |
"max_position_embeddings": 16384,
|
| 15 |
+
"mlp_bias": false,
|
| 16 |
"model_type": "llama",
|
| 17 |
"num_attention_heads": 64,
|
| 18 |
"num_hidden_layers": 48,
|
| 19 |
"num_key_value_heads": 8,
|
| 20 |
+
"pad_token_id": 0,
|
| 21 |
"pretraining_tp": 1,
|
| 22 |
"quantization_config": {
|
| 23 |
+
"_load_in_4bit": true,
|
| 24 |
+
"_load_in_8bit": false,
|
| 25 |
"bnb_4bit_compute_dtype": "bfloat16",
|
| 26 |
+
"bnb_4bit_quant_storage": "uint8",
|
| 27 |
"bnb_4bit_quant_type": "nf4",
|
| 28 |
"bnb_4bit_use_double_quant": true,
|
| 29 |
"llm_int8_enable_fp32_cpu_offload": false,
|
|
|
|
| 39 |
"rope_theta": 1000000,
|
| 40 |
"tie_word_embeddings": false,
|
| 41 |
"torch_dtype": "bfloat16",
|
| 42 |
+
"transformers_version": "4.44.0",
|
| 43 |
+
"unsloth_version": "2024.8",
|
| 44 |
"use_cache": true,
|
| 45 |
"vocab_size": 32000
|
| 46 |
}
|