Spaces:
Running
Running
Upload 2 files
Browse files- app.py +27 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List
|
2 |
+
import torch
|
3 |
+
|
4 |
+
import gradio as gr
|
5 |
+
import spaces
|
6 |
+
from sentence_transformers import SentenceTransformer
|
7 |
+
|
8 |
+
device = torch.device("cpu")
|
9 |
+
model = SentenceTransformer("Snowflake/snowflake-arctic-embed-l", device=device, trust_remote_code=True)
|
10 |
+
|
11 |
+
@spaces.GPU
|
12 |
+
def embed(document: str):
|
13 |
+
return model.encode(document)
|
14 |
+
|
15 |
+
|
16 |
+
with gr.Blocks() as app:
|
17 |
+
# Create an input text box
|
18 |
+
text_input = gr.Textbox(label="Enter text to embed")
|
19 |
+
|
20 |
+
# Create an output component to display the embedding
|
21 |
+
output = gr.JSON(label="Text Embedding")
|
22 |
+
|
23 |
+
# When the input text is submitted, call the embedding function and display the output
|
24 |
+
text_input.submit(embed, inputs=text_input, outputs=output)
|
25 |
+
|
26 |
+
if __name__ == '__main__':
|
27 |
+
app.queue().launch(server_name="0.0.0.0", show_error=True, server_port=7860)
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
sentence_transformers==3.0.1
|
2 |
+
einops==0.7.0
|
3 |
+
torch
|
4 |
+
llama-cpp-python
|