Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig, BitsAndBytesConfig
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
|
@@ -16,14 +16,8 @@ print("********************")
|
|
16 |
print(device)
|
17 |
print("********************")
|
18 |
|
19 |
-
bnb_config = BitsAndBytesConfig(
|
20 |
-
load_in_4bit=True,
|
21 |
-
bnb_4bit_quant_type='nf4',
|
22 |
-
bnb_4bit_use_double_quant=True,
|
23 |
-
bnb_4bit_compute_dtype=torch.bfloat16
|
24 |
-
)
|
25 |
|
26 |
-
model = AutoModelForCausalLM.from_pretrained(model_id,
|
27 |
model = model.to(device)
|
28 |
|
29 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
|
1 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig, BitsAndBytesConfig, GenerationConfig
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
|
|
|
16 |
print(device)
|
17 |
print("********************")
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
|
21 |
model = model.to(device)
|
22 |
|
23 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|