File size: 746 Bytes
a5cc7a0
 
 
 
 
 
 
 
ef16b6d
0b76df3
 
a5cc7a0
 
0551a11
a5cc7a0
0551a11
 
a5cc7a0
 
 
 
 
0551a11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from sentence_transformers import SentenceTransformer
import gradio as gr

# Load the pre-trained model
embedding_model = SentenceTransformer('all-MiniLM-L6-v2')

# Define the function to process requests
def generate_embeddings(chunks):
    embeddings = embedding_model.encode(chunks, convert_to_tensor=False)
    shape= embeddings.shape
            return embeddings, shape  # Convert tensor to list for Gradio

# Define the Gradio interface
interface = gr.Interface(
    fn=generate_embeddings,
    inputs=gr.Textbox(lines=5, placeholder="Enter text chunks here..."),
    outputs=gr.JSON(),
    title="Sentence Transformer Embeddings",
    description="Generate embeddings for input text chunks."
)

# Launch the Gradio app
interface.launch()