tahirsher commited on
Commit
dcbb3a1
1 Parent(s): 15a9e3b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -70,7 +70,14 @@ def load_or_create_vector_store(text_chunks):
70
 
71
  # Generate summary based on the retrieved text
72
  def generate_summary_with_huggingface(query, retrieved_text):
 
73
  summarization_input = f"{query}\n\nRelated information:\n{retrieved_text}"
 
 
 
 
 
 
74
  summary = summarizer(summarization_input, max_length=200, min_length=50, do_sample=False)
75
  return summary[0]["summary_text"]
76
 
 
70
 
71
  # Generate summary based on the retrieved text
72
  def generate_summary_with_huggingface(query, retrieved_text):
73
+ # Concatenate query and retrieved text for summarization
74
  summarization_input = f"{query}\n\nRelated information:\n{retrieved_text}"
75
+
76
+ # Truncate input to fit within the model’s token length limit (approximately 1024 tokens)
77
+ max_input_length = 1024
78
+ summarization_input = summarization_input[:max_input_length]
79
+
80
+ # Generate the summary
81
  summary = summarizer(summarization_input, max_length=200, min_length=50, do_sample=False)
82
  return summary[0]["summary_text"]
83