File size: 663 Bytes
6ac5d1e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from InstructorEmbedding import INSTRUCTOR

def represent_science_title(instruction, sentence):
    model = INSTRUCTOR('hkunlp/instructor-xl')
    embeddings = model.encode([[instruction, sentence]])
    print("Embeddings:", embeddings)
    return embeddings

title_representor = gr.Interface(
    fn=represent_science_title,
    inputs=[
        gr.inputs.Textbox(label="Instruction"),
        gr.inputs.Textbox(label="Sentence")
    ],
    outputs="text",
    title="Science Title Representation",
    description="Enter an instruction and a sentence to represent the science title using the Instructor model."
)

title_representor.launch()