Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,9 +27,27 @@ system_message = (
|
|
| 27 |
# Function to load the model and tokenizer
|
| 28 |
@spaces.GPU()
|
| 29 |
def load_model_and_tokenizer():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
# Load the model and tokenizer
|
| 31 |
model = AutoModelForCausalLM.from_pretrained(
|
| 32 |
model_name,
|
|
|
|
| 33 |
token=hf_token
|
| 34 |
)
|
| 35 |
|
|
|
|
| 27 |
# Function to load the model and tokenizer
|
| 28 |
@spaces.GPU()
|
| 29 |
def load_model_and_tokenizer():
|
| 30 |
+
# Configuration for bitsandbytes
|
| 31 |
+
use_4bit = True
|
| 32 |
+
bnb_4bit_compute_dtype = "float16"
|
| 33 |
+
bnb_4bit_quant_type = "nf4"
|
| 34 |
+
use_nested_quant = False
|
| 35 |
+
|
| 36 |
+
# Setup device and bitsandbytes configuration
|
| 37 |
+
device_map = {"": 0}
|
| 38 |
+
compute_dtype = getattr(torch, bnb_4bit_compute_dtype)
|
| 39 |
+
|
| 40 |
+
bnb_config = BitsAndBytesConfig(
|
| 41 |
+
load_in_4bit=use_4bit,
|
| 42 |
+
bnb_4bit_quant_type=bnb_4bit_quant_type,
|
| 43 |
+
bnb_4bit_compute_dtype=compute_dtype,
|
| 44 |
+
bnb_4bit_use_double_quant=use_nested_quant,
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
# Load the model and tokenizer
|
| 48 |
model = AutoModelForCausalLM.from_pretrained(
|
| 49 |
model_name,
|
| 50 |
+
quantization_config=bnb_config,
|
| 51 |
token=hf_token
|
| 52 |
)
|
| 53 |
|