dfskGT commited on
Commit
5f47952
1 Parent(s): 1eb5179

add app.py

Browse files
Files changed (3) hide show
  1. .gitignore +3 -0
  2. app.py +35 -0
  3. requirements.txt +3 -0
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ .venv
2
+ .vscode
3
+ flagged
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ unmasker = pipeline("fill-mask", model="anferico/bert-for-patents")
5
+
6
+
7
+ def unmask(text):
8
+ res = unmasker(text)
9
+ out = {item["token_str"]: item["score"] for item in res}
10
+ return out
11
+
12
+
13
+ textbox = gr.Textbox(label="Type patent abstract here", lines=5)
14
+
15
+ demo = gr.Interface(
16
+ fn=unmask,
17
+ inputs=textbox,
18
+ outputs="label",
19
+ examples=[
20
+ [
21
+ "The present [MASK] provides a torque sensor that is small and highly rigid and for which high production efficiency is possible."
22
+ ],
23
+ [
24
+ "The present invention relates to [MASK] accessories and pertains particularly to a brake light unit for bicycles."
25
+ ],
26
+ [
27
+ "The present invention discloses a space-bound-free [MASK] and its coordinate determining circuit for determining a coordinate of a stylus pen."
28
+ ],
29
+ [
30
+ "The illuminated [MASK] includes a substantially translucent canopy supported by a plurality of ribs pivotally swingable towards and away from a shaft."
31
+ ],
32
+ ],
33
+ )
34
+
35
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ torch
3
+ transformers