Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from sentence_transformers import SentenceTransformer | |
| # Load the pre-trained paraphrase-mpnet-base-v2 model | |
| model = SentenceTransformer('sentence-transformers/paraphrase-mpnet-base-v2') | |
| def get_embeddings(sentences): | |
| # Get embeddings for the input sentences | |
| embeddings = model.encode(sentences, convert_to_tensor=True) | |
| return embeddings.tolist() | |
| # Define the Gradio interface | |
| interface = gr.Interface( | |
| fn=get_embeddings, # Function to call | |
| inputs=gr.Textbox(lines=2, placeholder="Enter sentences here, one per line"), # Input component | |
| outputs=gr.JSON(), # Output component | |
| title="Sentence Embeddings with MPNet", # Interface title | |
| description="Enter sentences to get their embeddings with paraphrase-mpnet-base-v2." # Description | |
| ) | |
| # Launch the interface | |
| interface.launch() | |