from transformers import pipeline # Load the model and tokenizer from Hugging Face summarizer = pipeline("summarization", model="ibrahimgiki/facebook_bart_base") # Define a function to summarize text def summarize_text(text, max_length=130, min_length=30, do_sample=False): summary = summarizer(text, max_length=max_length, min_length=min_length, do_sample=do_sample) return summary[0]['summary_text'] # Example usage text = """ Your text here. This text should be a long paragraph that you want to summarize. The pipeline will take this text and generate a shorter version of it. """ summary = summarize_text(text) print("Original Text:", text) print("Summary:", summary)