Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,21 @@
|
|
| 1 |
|
| 2 |
import gradio as gr
|
| 3 |
-
from
|
| 4 |
-
import torch
|
| 5 |
|
| 6 |
-
# Load the model
|
| 7 |
-
|
| 8 |
-
model = AutoModelForCausalLM.from_pretrained("braindeck/text2text", trust_remote_code=True, torch_dtype=torch.bfloat16, device_map="auto", subfolder="checkpoints/model")
|
| 9 |
|
| 10 |
def generate_response(prompt):
|
| 11 |
"""
|
| 12 |
Generates a response from the model.
|
| 13 |
"""
|
| 14 |
-
|
| 15 |
-
outputs =
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
generated_text =
|
|
|
|
|
|
|
| 19 |
|
| 20 |
return generated_text
|
| 21 |
|
|
|
|
| 1 |
|
| 2 |
import gradio as gr
|
| 3 |
+
from vllm import LLM, SamplingParams
|
|
|
|
| 4 |
|
| 5 |
+
# Load the model
|
| 6 |
+
llm = LLM(model="deepseek-ai/DeepSeek-R1-Distill-Qwen-7B", trust_remote_code=True)
|
|
|
|
| 7 |
|
| 8 |
def generate_response(prompt):
|
| 9 |
"""
|
| 10 |
Generates a response from the model.
|
| 11 |
"""
|
| 12 |
+
sampling_params = SamplingParams(temperature=0.0, top_p=1.0, max_tokens=512)
|
| 13 |
+
outputs = llm.generate(prompt, sampling_params)
|
| 14 |
|
| 15 |
+
# Extract the generated text
|
| 16 |
+
generated_text = ""
|
| 17 |
+
for output in outputs:
|
| 18 |
+
generated_text += output.outputs[0].text
|
| 19 |
|
| 20 |
return generated_text
|
| 21 |
|