Update app.py
Browse files
app.py
CHANGED
@@ -18,17 +18,20 @@ def text_to_vector(texts_json):
|
|
18 |
|
19 |
inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True)
|
20 |
outputs = model(**inputs)
|
21 |
-
vectors = outputs.pooler_output.detach().numpy() #
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
25 |
|
26 |
demo = gr.Interface(
|
27 |
fn=text_to_vector,
|
28 |
inputs=gr.Textbox(label="Enter JSON array", placeholder="Enter an array of sentences as a JSON string"),
|
29 |
-
outputs=gr.Textbox(label="Text Vectors (
|
30 |
title="Batch Text to Vector",
|
31 |
-
description="This demo converts an array of sentences to vectors and returns them as a
|
32 |
)
|
33 |
|
34 |
-
demo.launch()
|
|
|
18 |
|
19 |
inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True)
|
20 |
outputs = model(**inputs)
|
21 |
+
vectors = outputs.pooler_output.detach().numpy().tolist() # Convert to list
|
22 |
+
return json.dumps(vectors) # Return as JSON string
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
|
29 |
demo = gr.Interface(
|
30 |
fn=text_to_vector,
|
31 |
inputs=gr.Textbox(label="Enter JSON array", placeholder="Enter an array of sentences as a JSON string"),
|
32 |
+
outputs=gr.Textbox(label="Text Vectors (JSON)", lines=10),
|
33 |
title="Batch Text to Vector",
|
34 |
+
description="This demo converts an array of sentences to vectors and returns them as a JSON array."
|
35 |
)
|
36 |
|
37 |
+
demo.launch()
|