Skip to content

Instantly share code, notes, and snippets.

View wrigleyDan's full-sized avatar

Daniel Wrigley wrigleyDan

View GitHub Profile
from transformers import pipeline
summarizer = pipeline("summarization") #, model="facebook/bart-large-cnn")
def summarize_content(text: str, max_len: int, shorten=True) -> str:
summary = summarizer("summarize: " + text, max_length=max_len, min_length=3, do_sample=False)
return summary[0]["summary_text"]
except IndexError as ex:
print("Sequence length too large")