Spaces:
Runtime error
Runtime error
MOSHNA
Browse files
app.py
CHANGED
|
@@ -9,11 +9,21 @@ bnb_config = BitsAndBytesConfig(
|
|
| 9 |
bnb_4bit_quant_type="nf4",
|
| 10 |
bnb_4bit_compute_dtype=torch.bfloat16,
|
| 11 |
bnb_4bit_use_double_quant=True,
|
| 12 |
-
llm_int8_enable_fp32_cpu_offload=True
|
|
|
|
| 13 |
)
|
| 14 |
|
| 15 |
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
model.generation_config = GenerationConfig.from_pretrained(model_name)
|
| 18 |
|
| 19 |
messages = [
|
|
|
|
| 9 |
bnb_4bit_quant_type="nf4",
|
| 10 |
bnb_4bit_compute_dtype=torch.bfloat16,
|
| 11 |
bnb_4bit_use_double_quant=True,
|
| 12 |
+
llm_int8_enable_fp32_cpu_offload=True,
|
| 13 |
+
|
| 14 |
)
|
| 15 |
|
| 16 |
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
| 17 |
+
|
| 18 |
+
device_map = {
|
| 19 |
+
"transformer.wte": "cpu",
|
| 20 |
+
"transformer.wpe": "cpu",
|
| 21 |
+
"transformer.h": "cpu",
|
| 22 |
+
"transformer.ln_f": "cpu",
|
| 23 |
+
"lm_head": "cpu",
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, quantization_config=bnb_config, device_map=device_map)
|
| 27 |
model.generation_config = GenerationConfig.from_pretrained(model_name)
|
| 28 |
|
| 29 |
messages = [
|