File size: 664 Bytes
3c0e5e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f4f0e98
3c0e5e4
 
 
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
import gradio as gr
from transformers import pipeline

import galai as gal

model = gal.load_model("base", num_gpus = 0, dtype='float16')

def predict(text):
    text = text.strip()
    out_text = model.generate(text)
    out_text = "<p>" + out_text + "</p>"
    out_text = out_text.replace(text, text + "<b><span style='background-color: #ffffcc;'>")
    out_text = out_text +  "</span></b>"
    out_text = out_text.replace("\n", "<br>")
    return out_text

iface = gr.Interface(
    fn=predict, 
    inputs=gr.Textbox(lines=10),
    outputs=gr.HTML(),
    description="Galactica",
    examples=[["The attention mechanism in LLM is"]]
)

iface.launch(share=True)