Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,10 +4,10 @@ import time
|
|
| 4 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 5 |
|
| 6 |
# Streamlit page configuration
|
| 7 |
-
st.set_page_config(page_title="Review Keypoint Extractor", page_icon="🔑")
|
| 8 |
|
| 9 |
# Define the model
|
| 10 |
-
model_name = "
|
| 11 |
|
| 12 |
# Cache the model and tokenizer to avoid reloading
|
| 13 |
@st.cache_resource
|
|
@@ -24,8 +24,8 @@ def generate_keypoint(review, max_new_tokens=64):
|
|
| 24 |
|
| 25 |
start_time = time.time()
|
| 26 |
|
| 27 |
-
#
|
| 28 |
-
prompt =
|
| 29 |
|
| 30 |
# Inference
|
| 31 |
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, padding=True).to(device)
|
|
@@ -41,8 +41,8 @@ def generate_keypoint(review, max_new_tokens=64):
|
|
| 41 |
return keypoint, elapsed
|
| 42 |
|
| 43 |
# Streamlit UI
|
| 44 |
-
st.title("🔑 Review Keypoint Extractor")
|
| 45 |
-
st.write("Enter a product review below to extract its key points using the
|
| 46 |
|
| 47 |
# Input field for review
|
| 48 |
review = st.text_area("Product Review", placeholder="e.g., The Jackery power station is lightweight and charges quickly, but the battery life could be longer.")
|
|
|
|
| 4 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 5 |
|
| 6 |
# Streamlit page configuration
|
| 7 |
+
st.set_page_config(page_title="Review Keypoint Extractor (BART-Large-CNN)", page_icon="🔑")
|
| 8 |
|
| 9 |
# Define the model
|
| 10 |
+
model_name = "facebook/bart-large-cnn"
|
| 11 |
|
| 12 |
# Cache the model and tokenizer to avoid reloading
|
| 13 |
@st.cache_resource
|
|
|
|
| 24 |
|
| 25 |
start_time = time.time()
|
| 26 |
|
| 27 |
+
# BART-specific prompt (no additional prompt engineering)
|
| 28 |
+
prompt = review
|
| 29 |
|
| 30 |
# Inference
|
| 31 |
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, padding=True).to(device)
|
|
|
|
| 41 |
return keypoint, elapsed
|
| 42 |
|
| 43 |
# Streamlit UI
|
| 44 |
+
st.title("🔑 Review Keypoint Extractor (BART-Large-CNN)")
|
| 45 |
+
st.write("Enter a product review below to extract its key points using the facebook/bart-large-cnn model.")
|
| 46 |
|
| 47 |
# Input field for review
|
| 48 |
review = st.text_area("Product Review", placeholder="e.g., The Jackery power station is lightweight and charges quickly, but the battery life could be longer.")
|