Spaces:
Runtime error
Runtime error
| # Load model directly | |
| from transformers import AutoTokenizer, AutoModelForSeq2SeqLM | |
| tokenizer = AutoTokenizer.from_pretrained("facebook/bart-large-cnn") | |
| model = AutoModelForSeq2SeqLM.from_pretrained("facebook/bart-large-cnn") | |
| from transformers import pipeline | |
| summarizer = pipeline("summarization", model="facebook/bart-large-cnn") | |
| ARTICLE = """ Climate change is one of the most pressing issues facing our planet today.It is caused by the increase in greenhouse gases, primarily carbon dioxide and methane,in the Earth's atmosphere. These gases trap heat from the sun, leading to a rise in global temperatures. The consequences of climate change are far-reaching and severe. They include more frequent and intense heatwaves,rising sea levels, melting glaciers, and changes in precipitation patterns.These changes have significant impacts on ecosystems, biodiversity, agriculture, water resources, and human health. | |
| To combat climate change, urgent and coordinated action is needed at the global level.This includes reducing greenhouse gas emissions by transitioning to renewable energy sources, increasing energy efficiency, protecting and restoring forests, and implementing policies to promote sustainable development. Additionally, adaptation measures are necessary to cope with the changes that are already occurringand will continue to worsen in the coming decades. | |
| """ | |
| #print(summarizer(ARTICLE, max_length=130, min_length=30, do_sample=False)) | |
| #>>> [{'Climate change, driven by increased greenhouse gases like carbon dioxide and methane, poses severe threats to the planet. Its consequences include intense heatwaves, rising sea levels, melting glaciers, and altered precipitation patterns, impacting ecosystems, biodiversity, agriculture, water resources, and human health. Urgent global action is imperative, requiring a shift to renewable energy, enhanced energy efficiency, forest preservation, and sustainable development policies. Adaptation measures are also crucial to address existing and escalating changes'}] | |
| summarizer(ARTICLE, max_length=130, min_length=30, do_sample=False)=='Climate change, driven by increased greenhouse gases like carbon dioxide and methane, poses severe threats to the planet. Its consequences include intense heatwaves, rising sea levels, melting glaciers, and altered precipitation patterns, impacting ecosystems, biodiversity, agriculture, water resources, and human health. Urgent global action is imperative, requiring a shift to renewable energy, enhanced energy efficiency, forest preservation, and sustainable development policies. Adaptation measures are also crucial to address existing and escalating changes' | |
| print(summarizer) |