Spaces:
Sleeping
Sleeping
Upload 2 files (#1)
Browse files- Upload 2 files (28e2a5b4a9264c95fc7091bf8d2fd5d120a40f28)
- app.py +19 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from InstructorEmbedding import INSTRUCTOR
|
3 |
+
|
4 |
+
model = INSTRUCTOR('hkunlp/instructor-xl')
|
5 |
+
|
6 |
+
def create_embedding(instruction, sentence):
|
7 |
+
embeddings = model.encode([[instruction, sentence]])
|
8 |
+
print("Embeddings:", embeddings)
|
9 |
+
return embeddings
|
10 |
+
|
11 |
+
instructor_model_embeddings = gr.Interface(
|
12 |
+
fn=create_embedding,
|
13 |
+
inputs=[
|
14 |
+
gr.inputs.Textbox(label="Query_Instruction"),
|
15 |
+
gr.inputs.Textbox(label="Query")
|
16 |
+
],
|
17 |
+
outputs="text",
|
18 |
+
title="API-Instructor-XL-1",
|
19 |
+
).launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
InstructorEmbedding
|
2 |
+
sentence_transformers
|