Text Generation
Transformers
Safetensors
English
gemma
unsloth
gemma-2b
bnb
text-generation-inference
4-bit precision
bitsandbytes
Instructions to use unsloth/gemma-2b-bnb-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/gemma-2b-bnb-4bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="unsloth/gemma-2b-bnb-4bit")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("unsloth/gemma-2b-bnb-4bit") model = AutoModelForCausalLM.from_pretrained("unsloth/gemma-2b-bnb-4bit", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use unsloth/gemma-2b-bnb-4bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/gemma-2b-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/gemma-2b-bnb-4bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/unsloth/gemma-2b-bnb-4bit
- SGLang
How to use unsloth/gemma-2b-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/gemma-2b-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/gemma-2b-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/gemma-2b-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/gemma-2b-bnb-4bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Unsloth Desktop
- Docker Model Runner
How to use unsloth/gemma-2b-bnb-4bit with Docker Model Runner:
docker model run hf.co/unsloth/gemma-2b-bnb-4bit
Upload tokenizer
Browse files- special_tokens_map.json +7 -1
- tokenizer.model +2 -2
- tokenizer_config.json +2 -3
special_tokens_map.json
CHANGED
|
@@ -13,7 +13,13 @@
|
|
| 13 |
"rstrip": false,
|
| 14 |
"single_word": false
|
| 15 |
},
|
| 16 |
-
"pad_token":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
"unk_token": {
|
| 18 |
"content": "<unk>",
|
| 19 |
"lstrip": false,
|
|
|
|
| 13 |
"rstrip": false,
|
| 14 |
"single_word": false
|
| 15 |
},
|
| 16 |
+
"pad_token": {
|
| 17 |
+
"content": "<pad>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
},
|
| 23 |
"unk_token": {
|
| 24 |
"content": "<unk>",
|
| 25 |
"lstrip": false,
|
tokenizer.model
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:61a7b147390c64585d6c3543dd6fc636906c9af3865a5548f27f31aee1d4c8e2
|
| 3 |
+
size 4241003
|
tokenizer_config.json
CHANGED
|
@@ -39,9 +39,8 @@
|
|
| 39 |
"clean_up_tokenization_spaces": false,
|
| 40 |
"eos_token": "<eos>",
|
| 41 |
"legacy": null,
|
| 42 |
-
"model_max_length":
|
| 43 |
-
"pad_token": "<
|
| 44 |
-
"padding_side": "right",
|
| 45 |
"sp_model_kwargs": {},
|
| 46 |
"spaces_between_special_tokens": false,
|
| 47 |
"tokenizer_class": "GemmaTokenizer",
|
|
|
|
| 39 |
"clean_up_tokenization_spaces": false,
|
| 40 |
"eos_token": "<eos>",
|
| 41 |
"legacy": null,
|
| 42 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 43 |
+
"pad_token": "<pad>",
|
|
|
|
| 44 |
"sp_model_kwargs": {},
|
| 45 |
"spaces_between_special_tokens": false,
|
| 46 |
"tokenizer_class": "GemmaTokenizer",
|