File size: 1,105 Bytes
5f47952
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gradio as gr
from transformers import pipeline

unmasker = pipeline("fill-mask", model="anferico/bert-for-patents")


def unmask(text):
    res = unmasker(text)
    out = {item["token_str"]: item["score"] for item in res}
    return out


textbox = gr.Textbox(label="Type patent abstract here", lines=5)

demo = gr.Interface(
    fn=unmask,
    inputs=textbox,
    outputs="label",
    examples=[
        [
            "The present [MASK] provides a torque sensor that is small and highly rigid and for which high production efficiency is possible."
        ],
        [
            "The present invention relates to [MASK] accessories and pertains particularly to a brake light unit for bicycles."
        ],
        [
            "The present invention discloses a space-bound-free [MASK] and its coordinate determining circuit for determining a coordinate of a stylus pen."
        ],
        [
            "The illuminated [MASK] includes a substantially translucent canopy supported by a plurality of ribs pivotally swingable towards and away from a shaft."
        ],
    ],
)

demo.launch()