Ronak0 commited on
Commit
b9daaf8
·
verified ·
1 Parent(s): 5d89e72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -64,8 +64,13 @@ def simplify_document(pdf_file):
64
 
65
  takeaways = []
66
  for idx, chunk in enumerate(chunks, 1):
67
- # Standard FLAN-T5 prefix for concise layperson summaries
68
- prompt = f"summarize in simple terms: {chunk}"
 
 
 
 
 
69
  inputs = tokenizer(
70
  prompt, return_tensors="pt", max_length=512, truncation=True
71
  ).to(device)
@@ -83,9 +88,9 @@ def simplify_document(pdf_file):
83
  )
84
 
85
  summary = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
86
-
87
- # Ensure output finishes cleanly without abrupt cutoffs
88
  summary = summary.strip()
 
 
89
  if summary and not summary.endswith((".", "!", "?")):
90
  last_period = summary.rfind(".")
91
  if last_period > 20:
 
64
 
65
  takeaways = []
66
  for idx, chunk in enumerate(chunks, 1):
67
+ # Explicit structured prompt instruction
68
+ prompt = (
69
+ "Summarize the RTI/civic document in simple, clear bullet points for an"
70
+ " ordinary citizen. Separate the Subject, Timeframe, Fees Paid, and"
71
+ f" Delivery Mode clearly: {chunk}"
72
+ )
73
+
74
  inputs = tokenizer(
75
  prompt, return_tensors="pt", max_length=512, truncation=True
76
  ).to(device)
 
88
  )
89
 
90
  summary = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
 
 
91
  summary = summary.strip()
92
+
93
+ # Clean up any trailing broken sentences
94
  if summary and not summary.endswith((".", "!", "?")):
95
  last_period = summary.rfind(".")
96
  if last_period > 20: