amielle commited on
Commit
8ecadd9
β€’
1 Parent(s): 82331bb

feat: Update layout

Browse files
Files changed (1) hide show
  1. app.py +39 -75
app.py CHANGED
@@ -1,93 +1,51 @@
1
  import gradio as gr
2
  import pandas as pd
3
- from util import summarizer, parser
4
-
5
- def patent_summarizer(patent_information, summaries_generated, min_char_abs, min_char_bg, min_char_claims):
6
-
7
- # TODO: add checker if valid patent info, return None if invalid
8
- # TODO: add scraper to get document
9
-
10
- # TODO: add parser to get the following info from the base document:
11
- abstract, background, claims = None, None, None
12
-
13
- summaries = list()
14
- if "Abstract" in summaries_generated:
15
- abstract_summary = summarizer.generate_abs_summary(abstract, min_char_abs)
16
- summaries.append(abstract_summary)
17
- else:
18
- summaries.append(None)
19
-
20
- if "Background" in summaries_generated:
21
- background_summary = summarizer.generate_bg_summary(background, min_char_bg)
22
- summaries.append(background_summary)
23
- else:
24
- summaries.append(None)
25
-
26
- if "Claims" in summaries_generated:
27
- claims_summary = summarizer.generate_claims_summary(claims, min_char_claims)
28
- summaries.append(claims_summary)
29
- else:
30
- summaries.append(None)
31
-
32
- return summaries
33
 
34
  summary_options = ["Abstract", "Background", "Claims"]
 
 
 
 
 
 
 
35
  iface = gr.Interface(
36
- patent_summarizer,
37
  theme="huggingface",
38
- examples=[
39
- [
40
- "US9820315B2",
41
- summary_options,
42
- 50,
43
- 250,
44
- 100
45
- ],
46
- [
47
- "https://patents.google.com/patent/US9820315B2",
48
- summary_options,
49
- 50,
50
- 250,
51
- 100
52
- ],
53
- [
54
- "https://patents.google.com/patent/US10263802B2/en?q=smart+user+interface&oq=smart+user+interface",
55
- summary_options[:-1],
56
- 75,
57
- 200,
58
- 125
59
-
60
- ]
61
- ],
62
  inputs=[
63
  gr.inputs.Textbox(label="Patent Information",
64
  placeholder="US9820315B2 or https://patents.google.com/patent/US9820315B2 ...",
65
- lines=1),
 
66
  # gr.inputs.Radio(["Link", "Patent Code"]), # Can be figured out automatically via parsing
67
- # gr.inputs.Dropdown(["model type 1", "model type 2", "model type 3"]), # Change model type
68
- gr.inputs.CheckboxGroup(summary_options,
69
- default=summary_options,
70
  label="Summaries to Generate"),
71
- gr.inputs.Slider(minimum=50,
72
- maximum=500,
73
- step=1,
74
- default=75,
75
- label="Minimum Characters (Abstract Summary)"),
76
- gr.inputs.Slider(minimum=50,
77
- maximum=500,
78
- step=1,
79
- default=200,
80
- label="Minimum Characters (Background Summary)"),
81
- gr.inputs.Slider(minimum=50,
82
- maximum=500,
83
- step=1,
84
- default=100,
85
- label="Minimum Characters (Per Claims Summary)")
 
 
86
  ],
87
  outputs=[
88
  gr.outputs.Textbox(label="Abstract Summary"),
89
  gr.outputs.Textbox(label="Background Summary"),
90
- gr.outputs.Textbox(label="Claims Summary")
91
  ],
92
  title="Patent Summarizer πŸ“–",
93
  description="""
@@ -105,6 +63,12 @@ iface = gr.Interface(
105
  ✏️ Provides an interface for user input
106
  πŸ“‚ Retrieves and parses the document based on the given patent information
107
  πŸ“‘ Returns summaries for the abstract, background, and/or claims.
 
 
 
 
 
 
108
  """
109
  )
110
 
 
1
  import gradio as gr
2
  import pandas as pd
3
+ from util import summarizer, textproc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  summary_options = ["Abstract", "Background", "Claims"]
6
+ model_names = ["google/bigbird-pegasus-large-bigpatent",
7
+ "huggingface/sshleifer/distilbart-cnn-12-6",
8
+ "huggingface/facebook/bart-large-cnn",
9
+ "huggingface/google/pegasus-xsum"]
10
+
11
+
12
+ patent_summarizer = summarizer.PatentSummarizer(model_collection)
13
  iface = gr.Interface(
14
+ patent_summarizer.pipeline,
15
  theme="huggingface",
16
+ examples=entries,
17
+ examples_per_page=4,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  inputs=[
19
  gr.inputs.Textbox(label="Patent Information",
20
  placeholder="US9820315B2 or https://patents.google.com/patent/US9820315B2 ...",
21
+ lines=1,
22
+ default="US9820315B2"),
23
  # gr.inputs.Radio(["Link", "Patent Code"]), # Can be figured out automatically via parsing
24
+ gr.inputs.CheckboxGroup(summarizer.summary_options,
25
+ default=summarizer.summary_options,
 
26
  label="Summaries to Generate"),
27
+ gr.inputs.Dropdown(summarizer.model_names,
28
+ default=summarizer.model_names[3],
29
+ label="Abstract Model"),
30
+ gr.inputs.Dropdown(summarizer.model_names,
31
+ default=summarizer.model_names[0],
32
+ label="Background Model"),
33
+ gr.inputs.Dropdown(summarizer.model_names,
34
+ default=summarizer.model_names[2],
35
+ label="Claims Model"),
36
+ gr.inputs.Checkbox(default=True,
37
+ label="Collate Claims",
38
+ optional=False),
39
+ gr.inputs.Slider(minimum=250,
40
+ maximum=1000,
41
+ step=5,
42
+ default=250,
43
+ label="Input Document Word Limit"),
44
  ],
45
  outputs=[
46
  gr.outputs.Textbox(label="Abstract Summary"),
47
  gr.outputs.Textbox(label="Background Summary"),
48
+ gr.outputs.Textbox(label="Sample Claims Summary")
49
  ],
50
  title="Patent Summarizer πŸ“–",
51
  description="""
 
63
  ✏️ Provides an interface for user input
64
  πŸ“‚ Retrieves and parses the document based on the given patent information
65
  πŸ“‘ Returns summaries for the abstract, background, and/or claims.
66
+
67
+ Models explored:
68
+ - https://huggingface.co/google/bigbird-pegasus-large-bigpatent
69
+ - https://huggingface.co/cnicu/t5-small-booksum
70
+ - https://huggingface.co/sshleifer/distilbart-cnn-6-6
71
+ - https://huggingface.co/google/pegasus-xsum
72
  """
73
  )
74