Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from InstructorEmbedding import INSTRUCTOR
|
| 3 |
+
|
| 4 |
+
def represent_science_title(instruction, sentence):
|
| 5 |
+
model = INSTRUCTOR('hkunlp/instructor-xl')
|
| 6 |
+
embeddings = model.encode([[instruction, sentence]])
|
| 7 |
+
print("Embeddings:", embeddings)
|
| 8 |
+
return embeddings
|
| 9 |
+
|
| 10 |
+
title_representor = gr.Interface(
|
| 11 |
+
fn=represent_science_title,
|
| 12 |
+
inputs=[
|
| 13 |
+
gr.inputs.Textbox(label="Instruction"),
|
| 14 |
+
gr.inputs.Textbox(label="Sentence")
|
| 15 |
+
],
|
| 16 |
+
outputs="text",
|
| 17 |
+
title="Science Title Representation",
|
| 18 |
+
description="Enter an instruction and a sentence to represent the science title using the Instructor model."
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
title_representor.launch()
|