aliabd commited on
Commit
24acc34
1 Parent(s): f4ca157

added cache

Browse files
app.py CHANGED
@@ -5,15 +5,30 @@ import gradio as gr
5
 
6
  model = st_model.summarizer()
7
 
8
- def inference(text):
9
- documents = [text]
10
- model.summarize(documents)
11
- return model.summarize(documents)[0]
12
-
13
  title = "SummerTime: Text Summarization for Non-Experts"
14
  description = "This is a demo of SummerTime: An open-source text summarization toolkit for non-experts. You can read more about the project at the links below. Input your text below (or click one of the examples to load them), and the model will generate a summary for it. Results should take 10-15s"
15
  article = "<p style='text-align: center'><a target='_blank' href='https://arxiv.org/abs/2108.12738'>SummerTime: Text Summarization Toolkit for Non-experts</a> | <a target='_blank' href='https://github.com/Yale-LILY/SummerTime'>Github Repo</a> | <a target='_blank' href='https://colab.research.google.com/drive/19tPdBgaJ4_QjSiFyoxtpnFGW4OG1gTec?usp=sharing'>Colab Notebook</a></p>"
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  gr.Interface(
18
  inference,
19
  [gr.inputs.Textbox(label="Input", lines=20)],
@@ -21,8 +36,4 @@ gr.Interface(
21
  title=title,
22
  description=description,
23
  article=article,
24
- examples=[["""PG&E stated it scheduled the blackouts in response to forecasts for high winds amid dry conditions.
25
- The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were scheduled to be affected
26
- by the shutoffs which were expected to last through at least midday tomorrow."""],
27
- ["""Representative Kevin McCarthy, the House Republican leader, has threatened to retaliate against any company that complies with the congressional committee investigating the Jan. 6 riot, after the panel asked dozens of firms to preserve the phone and social media records of 11 far-right members of Congress who pushed to overturn the results of the 2020 election. Mr. McCarthy’s warning was an escalation of his efforts to thwart a full accounting of the deadly attack at the Capitol carried out by a pro-Trump mob, and his latest attempt to insulate the former president and Republican lawmakers from scrutiny of any ties to the violence. It came after he led the G.O.P. opposition to the creation of an independent bipartisan commission to investigate the riot, and then pulled five Republican congressmen from the select committee that Democrats created on their own, boycotting the proceedings."""],
28
- ["""Asked about the report, Google responded in an email that its "advertising technologies help websites and apps fund their content, enable small businesses to grow, and protect users from exploitative privacy practices and bad ad experiences." A lawsuit by 38 U.S. states and territories accuses Google of abusing its market power in an effort to make its search engine as dominant inside cars, TVs and speakers as it is in phones. This was consolidated with the federal lawsuit for purposes of discovery. Texas, backed by other states, filed a separate lawsuit against Google, accusing it of breaking antitrust law in how it runs its online advertising business."""]]).launch(debug=True)
5
 
6
  model = st_model.summarizer()
7
 
 
 
 
 
 
8
  title = "SummerTime: Text Summarization for Non-Experts"
9
  description = "This is a demo of SummerTime: An open-source text summarization toolkit for non-experts. You can read more about the project at the links below. Input your text below (or click one of the examples to load them), and the model will generate a summary for it. Results should take 10-15s"
10
  article = "<p style='text-align: center'><a target='_blank' href='https://arxiv.org/abs/2108.12738'>SummerTime: Text Summarization Toolkit for Non-experts</a> | <a target='_blank' href='https://github.com/Yale-LILY/SummerTime'>Github Repo</a> | <a target='_blank' href='https://colab.research.google.com/drive/19tPdBgaJ4_QjSiFyoxtpnFGW4OG1gTec?usp=sharing'>Colab Notebook</a></p>"
11
 
12
+
13
+ examples=[["""PG&E stated it scheduled the blackouts in response to forecasts for high winds amid dry conditions.
14
+ The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were scheduled to be affected
15
+ by the shutoffs which were expected to last through at least midday tomorrow."""],
16
+ ["""Representative Kevin McCarthy, the House Republican leader, has threatened to retaliate against any company that complies with the congressional committee investigating the Jan. 6 riot, after the panel asked dozens of firms to preserve the phone and social media records of 11 far-right members of Congress who pushed to overturn the results of the 2020 election. Mr. McCarthy’s warning was an escalation of his efforts to thwart a full accounting of the deadly attack at the Capitol carried out by a pro-Trump mob, and his latest attempt to insulate the former president and Republican lawmakers from scrutiny of any ties to the violence. It came after he led the G.O.P. opposition to the creation of an independent bipartisan commission to investigate the riot, and then pulled five Republican congressmen from the select committee that Democrats created on their own, boycotting the proceedings."""],
17
+ ["""Asked about the report, Google responded in an email that its "advertising technologies help websites and apps fund their content, enable small businesses to grow, and protect users from exploitative privacy practices and bad ad experiences." A lawsuit by 38 U.S. states and territories accuses Google of abusing its market power in an effort to make its search engine as dominant inside cars, TVs and speakers as it is in phones. This was consolidated with the federal lawsuit for purposes of discovery. Texas, backed by other states, filed a separate lawsuit against Google, accusing it of breaking antitrust law in how it runs its online advertising business."""]]
18
+
19
+
20
+ cache = {}
21
+ for example in examples:
22
+ cache[example[0]] = model.summarize(example)[0]
23
+
24
+
25
+ def inference(text):
26
+ if text in cache:
27
+ return cache[text]
28
+ documents = [text]
29
+ return model.summarize(documents)[0]
30
+
31
+
32
  gr.Interface(
33
  inference,
34
  [gr.inputs.Textbox(label="Input", lines=20)],
36
  title=title,
37
  description=description,
38
  article=article,
39
+ examples=examples).launch(debug=True)
 
 
 
 
model/__pycache__/__init__.cpython-38.pyc ADDED
Binary file (843 Bytes). View file
model/__pycache__/base_model.cpython-38.pyc ADDED
Binary file (2.81 kB). View file
model/single_doc/__pycache__/__init__.cpython-38.pyc ADDED
Binary file (414 Bytes). View file
model/single_doc/__pycache__/bart_model.cpython-38.pyc ADDED
Binary file (1.5 kB). View file
model/single_doc/__pycache__/base_single_doc_model.cpython-38.pyc ADDED
Binary file (1.49 kB). View file
model/single_doc/__pycache__/lexrank_model.cpython-38.pyc ADDED
Binary file (2.44 kB). View file
model/single_doc/__pycache__/longformer_model.cpython-38.pyc ADDED
Binary file (2.35 kB). View file
model/single_doc/__pycache__/pegasus_model.cpython-38.pyc ADDED
Binary file (2.14 kB). View file
model/single_doc/__pycache__/textrank_model.cpython-38.pyc ADDED
Binary file (3.2 kB). View file