Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,9 +6,8 @@ model_name = 'facebook/bart-large-cnn'
|
|
6 |
tokenizer = BartTokenizer.from_pretrained(model_name)
|
7 |
model = BartForConditionalGeneration.from_pretrained(model_name)
|
8 |
|
9 |
-
def summarize(
|
10 |
-
inp =
|
11 |
-
inp = tokenizer.encode(inp, return_tensors='pt', max_length=1024)
|
12 |
summary_ids = model.generate(inp, num_beams=4, max_length=150, early_stopping=True)
|
13 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
14 |
return summary
|
|
|
6 |
tokenizer = BartTokenizer.from_pretrained(model_name)
|
7 |
model = BartForConditionalGeneration.from_pretrained(model_name)
|
8 |
|
9 |
+
def summarize(input_text):
|
10 |
+
inp = tokenizer.encode("summarize: " + input_text.replace('\n',''), return_tensors="pt", max_length=1024, truncation=True)
|
|
|
11 |
summary_ids = model.generate(inp, num_beams=4, max_length=150, early_stopping=True)
|
12 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
13 |
return summary
|