Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
model = AutoModelForCausalLM.from_pretrained("checkpoint_500",trust_remote_code=True)
|
| 6 |
tokenizer = AutoTokenizer.from_pretrained("checkpoint_500", trust_remote_code=True)
|
| 7 |
tokenizer.pad_token = tokenizer.eos_token
|
| 8 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline,BitsAndBytesConfig
|
| 4 |
+
|
| 5 |
+
#model = AutoModelForCausalLM.from_pretrained("checkpoint_500",trust_remote_code=True)
|
| 6 |
+
|
| 7 |
+
model_name = "microsoft/phi-2"
|
| 8 |
+
|
| 9 |
+
bnb_config = BitsAndBytesConfig(
|
| 10 |
+
load_in_4bit=True,
|
| 11 |
+
bnb_4bit_quant_type="nf4",
|
| 12 |
+
bnb_4bit_compute_dtype=torch.float16,
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 16 |
+
model_name,
|
| 17 |
+
quantization_config=bnb_config,
|
| 18 |
+
trust_remote_code=True
|
| 19 |
+
)
|
| 20 |
+
model.config.use_cache = False
|
| 21 |
+
model.load_adapter("checkpoint")
|
| 22 |
|
|
|
|
| 23 |
tokenizer = AutoTokenizer.from_pretrained("checkpoint_500", trust_remote_code=True)
|
| 24 |
tokenizer.pad_token = tokenizer.eos_token
|
| 25 |
|