Spaces:
Sleeping
Sleeping
File size: 866 Bytes
a7eec35 |
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 26 27 28 29 |
from typing import List
import gradio as gr
import spaces
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("nomic-ai/nomic-embed-text-v1", trust_remote_code=True, device='cuda')
@spaces.GPU
def embed(documents: List[str]):
embeddings = []
for document in documents:
embeddings.append(model.encode(document))
return embeddings
with gr.Blocks() as app:
# Create an input text box
text_input = gr.Textbox(label="Enter text to embed")
# Create an output component to display the embedding
output = gr.JSON(label="Text Embedding")
# When the input text is submitted, call the embedding function and display the output
text_input.submit(embed, inputs=text_input, outputs=output)
if __name__ == '__main__':
app.queue().launch(server_name="0.0.0.0", show_error=True, server_port=7860) |