Spaces:
Running
on
Zero
Running
on
Zero
update model class
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ from threading import Thread
|
|
| 2 |
|
| 3 |
import torch
|
| 4 |
import gradio as gr
|
| 5 |
-
from transformers import AutoTokenizer,
|
| 6 |
|
| 7 |
model_id = "EleutherAI/pythia-6.9b-deduped"
|
| 8 |
assistant_id = "EleutherAI/pythia-70m-deduped"
|
|
@@ -12,11 +12,11 @@ print("CPU threads:", torch.get_num_threads())
|
|
| 12 |
|
| 13 |
|
| 14 |
if torch_device == "cuda":
|
| 15 |
-
model =
|
| 16 |
else:
|
| 17 |
-
model =
|
| 18 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 19 |
-
assistant_model =
|
| 20 |
|
| 21 |
|
| 22 |
def run_generation(user_text, top_p, temperature, top_k, max_new_tokens):
|
|
|
|
| 2 |
|
| 3 |
import torch
|
| 4 |
import gradio as gr
|
| 5 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, TextIteratorStreamer
|
| 6 |
|
| 7 |
model_id = "EleutherAI/pythia-6.9b-deduped"
|
| 8 |
assistant_id = "EleutherAI/pythia-70m-deduped"
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
if torch_device == "cuda":
|
| 15 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, load_in_8bit=True, device_map="auto")
|
| 16 |
else:
|
| 17 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 18 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 19 |
+
assistant_model = AutoModelForCausalLM.from_pretrained(assistant_id).to(torch_device)
|
| 20 |
|
| 21 |
|
| 22 |
def run_generation(user_text, top_p, temperature, top_k, max_new_tokens):
|