TLH01 commited on
Commit
cc3cb31
·
verified ·
1 Parent(s): ec70cef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
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 = "t5-small"
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
- # T5-specific prompt
28
- prompt = f"summarize: {review}"
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 T5-Small 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.")
 
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.")