codeteach commited on
Commit
65fb371
·
verified ·
1 Parent(s): 128d6a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -18,11 +18,11 @@ translation_models = {
18
  # Initialize summarization pipelines with specified models
19
  summarization_models = {
20
  'Scientific': "facebook/bart-large-cnn",
21
- 'Literature': "t5-small"
22
  }
23
 
24
  # Initialize tokenizer
25
- tokenizer = AutoTokenizer.from_pretrained("facebook/bart-large-cnn") # Using BART tokenizer for the 'Scientific' model
26
 
27
  # Initialize summarization pipelines
28
  summarizers = {model: pipeline("summarization", model=model) for model in summarization_models.values()}
@@ -60,7 +60,7 @@ def summarize_text(text, model):
60
  summaries = []
61
  for chunk in chunks:
62
  try:
63
- summary = summarizers[model](chunk, max_length=150, min_length=40, do_sample=False)[0]['summary_text']
64
  summaries.append(summary)
65
  except Exception as e:
66
  print(f"Error summarizing chunk: {chunk}\nError: {e}")
@@ -142,3 +142,4 @@ iface.launch()
142
 
143
 
144
 
 
 
18
  # Initialize summarization pipelines with specified models
19
  summarization_models = {
20
  'Scientific': "facebook/bart-large-cnn",
21
+ 'Literature': "allenai/scibert_scivocab_cased"
22
  }
23
 
24
  # Initialize tokenizer
25
+ tokenizer = AutoTokenizer.from_pretrained("facebook/bart-large-cnn")
26
 
27
  # Initialize summarization pipelines
28
  summarizers = {model: pipeline("summarization", model=model) for model in summarization_models.values()}
 
60
  summaries = []
61
  for chunk in chunks:
62
  try:
63
+ summary = summarizers[model](chunk, max_length=150, min_length=20, do_sample=False)[0]['summary_text']
64
  summaries.append(summary)
65
  except Exception as e:
66
  print(f"Error summarizing chunk: {chunk}\nError: {e}")
 
142
 
143
 
144
 
145
+