File size: 1,227 Bytes
bf4ee0a
 
8c9ddae
 
 
bbba75b
 
bf4ee0a
 
bbba75b
bf4ee0a
bbba75b
bf4ee0a
bbba75b
 
 
 
bf4ee0a
bbba75b
 
 
 
 
 
 
bf4ee0a
bbba75b
 
bf4ee0a
bbba75b
 
bf4ee0a
bbba75b
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
library_name: transformers
license: other
license_name: deepseek-license
license_link: LICENSE
base_model:
- deepseek-ai/DeepSeek-Coder-V2-Lite-Base
---

Bitsandbytes quantization of https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Lite-Base.

See https://huggingface.co/blog/4bit-transformers-bitsandbytes for instructions.

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers import BitsAndBytesConfig
import torch

# Define the 4-bit configuration
nf4_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_use_double_quant=True,
    bnb_4bit_compute_dtype=torch.bfloat16
)

# Load the pre-trained model with the 4-bit quantization configuration
model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base", quantization_config=nf4_config)

# Load the tokenizer associated with the model
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Coder-V2-Lite-Base")

# Push the model and tokenizer to the Hugging Face hub
model.push_to_hub("onekq-ai/DeepSeek-Coder-V2-Lite-Base-bnb-4bit", use_auth_token=True)
tokenizer.push_to_hub("onekq-ai/DeepSeek-Coder-V2-Lite-Base-bnb-4bit", use_auth_token=True)
```