Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,8 +4,9 @@ os.environ["SPACES_ZERO_GPU"] = "false"
|
|
| 4 |
import gradio as gr
|
| 5 |
from transformers import pipeline, AutoTokenizer
|
| 6 |
import torch
|
|
|
|
| 7 |
|
| 8 |
-
# Load model and tokenizer
|
| 9 |
model_name = "DISLab/SummLlama3.2-3B"
|
| 10 |
print(f"Loading model: {model_name}")
|
| 11 |
|
|
@@ -29,6 +30,7 @@ def format_chat_template(document):
|
|
| 29 |
}]
|
| 30 |
return tokenizer.apply_chat_template(row_json, tokenize=False, add_generation_prompt=False)
|
| 31 |
|
|
|
|
| 32 |
def summarize(text):
|
| 33 |
"""Generate summary using the model"""
|
| 34 |
try:
|
|
@@ -40,7 +42,7 @@ def summarize(text):
|
|
| 40 |
formatted_input,
|
| 41 |
max_new_tokens=512,
|
| 42 |
do_sample=True,
|
| 43 |
-
temperature=0.
|
| 44 |
top_p=0.9,
|
| 45 |
return_full_text=False
|
| 46 |
)
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
from transformers import pipeline, AutoTokenizer
|
| 6 |
import torch
|
| 7 |
+
import spaces
|
| 8 |
|
| 9 |
+
# Load model and tokenizer globally
|
| 10 |
model_name = "DISLab/SummLlama3.2-3B"
|
| 11 |
print(f"Loading model: {model_name}")
|
| 12 |
|
|
|
|
| 30 |
}]
|
| 31 |
return tokenizer.apply_chat_template(row_json, tokenize=False, add_generation_prompt=False)
|
| 32 |
|
| 33 |
+
@spaces.GPU
|
| 34 |
def summarize(text):
|
| 35 |
"""Generate summary using the model"""
|
| 36 |
try:
|
|
|
|
| 42 |
formatted_input,
|
| 43 |
max_new_tokens=512,
|
| 44 |
do_sample=True,
|
| 45 |
+
temperature=0.7,
|
| 46 |
top_p=0.9,
|
| 47 |
return_full_text=False
|
| 48 |
)
|