Spaces:
Build error
Build error
Add a first summarization model for testing
Browse filesFiles changed (2)
- app.py+16-3
- requirements.txtAdded+26
12345import streamlit as stst.text_input('Enter the text to summarize')st.button('Summarize')123456789101112131415161718from transformers import AutoTokenizer, AutoModelForSeq2SeqLMtokenizer = AutoTokenizer.from_pretrained("sshleifer/distilbart-cnn-12-6")model = AutoModelForSeq2SeqLM.from_pretrained("sshleifer/distilbart-cnn-12-6")ARTICLE_TO_SUMMARIZE = ("PG&E stated it scheduled the blackouts in response to forecasts for high winds ""amid dry conditions. The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were ""scheduled to be affected by the shutoffs which were expected to last through at least midday tomorrow.")inputs = tokenizer([ARTICLE_TO_SUMMARIZE], max_length=1024, return_tensors="pt")summary_ids = model.generate(inputs["input_ids"], num_beams=2, min_length=0, max_length=20)result = tokenizer.batch_decode(summary_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]print(result)
1234567891011121314151617181920212223242526certifi==2023.7.22charset-normalizer==3.2.0filelock==3.12.3fsspec==2023.6.0huggingface-hub==0.16.4idna==3.4Jinja2==3.1.2MarkupSafe==2.1.3mpmath==1.3.0networkx==3.1numpy==1.25.2packaging==23.1Pillow==10.0.0PyYAML==6.0.1regex==2023.8.8requests==2.31.0safetensors==0.3.3sentencepiece==0.1.99sympy==1.12tokenizers==0.13.3torch==2.0.1torchvision==0.15.2tqdm==4.66.1transformers==4.32.1typing_extensions==4.7.1urllib3==2.0.4app.py+16-3
requirements.txtAdded+26