Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM,
|
4 |
-
from threading import Thread
|
5 |
|
6 |
tokenizer = AutoTokenizer.from_pretrained("afrizalha/Bakpia-V1-1.5B-Javanese")
|
7 |
model = AutoModelForCausalLM.from_pretrained("afrizalha/Bakpia-V1-1.5B-Javanese")
|
|
|
8 |
|
9 |
desc = """Bakpia V1 is a fine-tuned version of Qwen 2 1.5B Instruct. It is fine-tuned using massive synthetic data for Krama Javanese, where the prompts are generated by GPT-4o and the responses are generated by Claude 3 Haiku."""
|
10 |
template = """<|im_start|>system
|
@@ -18,6 +18,7 @@ def generate(query, temp, top_p):
|
|
18 |
inputs = template.format(prompt=query)
|
19 |
inputs = tokenizer([inputs], return_tensors="pt").to(model.device)
|
20 |
outputs = model.generate(
|
|
|
21 |
inputs=inputs.input_ids,
|
22 |
max_new_tokens=1024,
|
23 |
do_sample=True,
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
|
|
|
4 |
|
5 |
tokenizer = AutoTokenizer.from_pretrained("afrizalha/Bakpia-V1-1.5B-Javanese")
|
6 |
model = AutoModelForCausalLM.from_pretrained("afrizalha/Bakpia-V1-1.5B-Javanese")
|
7 |
+
text_streamer = TextStreamer(tokenizer)
|
8 |
|
9 |
desc = """Bakpia V1 is a fine-tuned version of Qwen 2 1.5B Instruct. It is fine-tuned using massive synthetic data for Krama Javanese, where the prompts are generated by GPT-4o and the responses are generated by Claude 3 Haiku."""
|
10 |
template = """<|im_start|>system
|
|
|
18 |
inputs = template.format(prompt=query)
|
19 |
inputs = tokenizer([inputs], return_tensors="pt").to(model.device)
|
20 |
outputs = model.generate(
|
21 |
+
streamer = text_streamer,
|
22 |
inputs=inputs.input_ids,
|
23 |
max_new_tokens=1024,
|
24 |
do_sample=True,
|