File size: 744 Bytes
e292284
8bf71a3
 
949e724
 
 
 
 
 
8bf71a3
 
 
 
d5b0375
e292284
 
949e724
 
 
 
d5b0375
 
e292284
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
import sentencepiece as spm

examples = [
    "Hello, world!",
    "This is a test.",
    "The Page title option has a text input box for changing the title of the image gallery page.",
    "Algoritmos de diseño de árboles"]


def greet(sentence):
    sp = spm.SentencePieceProcessor()
    sp.load('bpe.model')
    return " • ".join(sp.encode_as_pieces(sentence))


demo = gr.Interface(fn=greet, inputs="text", outputs="text",
                    examples=examples, title="SentencePiece BPE",
                    description="This is a demo for SentencePiece BPE.",
                    cache_examples="lazy",
                    concurrency_limit=30,
                    css="textarea {font-size: 150%;}")
demo.launch()