Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ model = AutoModel.from_pretrained(model_name)
|
|
8 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
9 |
|
10 |
def text_to_vector(texts):
|
11 |
-
#
|
12 |
inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True)
|
13 |
outputs = model(**inputs)
|
14 |
vectors = outputs.pooler_output.detach().numpy()
|
@@ -19,11 +19,12 @@ def text_to_vector(texts):
|
|
19 |
|
20 |
demo = gr.Interface(
|
21 |
fn=text_to_vector,
|
22 |
-
inputs=gr.Textbox(label="Enter
|
23 |
outputs=gr.Textbox(label="Text Vectors", lines=10),
|
24 |
title="Batch Text to Vector",
|
25 |
-
description="This demo converts
|
26 |
)
|
27 |
|
28 |
demo.launch()
|
29 |
|
|
|
|
8 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
9 |
|
10 |
def text_to_vector(texts):
|
11 |
+
# Expect texts to be an array of sentences
|
12 |
inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True)
|
13 |
outputs = model(**inputs)
|
14 |
vectors = outputs.pooler_output.detach().numpy()
|
|
|
19 |
|
20 |
demo = gr.Interface(
|
21 |
fn=text_to_vector,
|
22 |
+
inputs=gr.Textbox(label="Enter JSON array", placeholder="Enter an array of sentences as a JSON string"),
|
23 |
outputs=gr.Textbox(label="Text Vectors", lines=10),
|
24 |
title="Batch Text to Vector",
|
25 |
+
description="This demo converts an array of sentences to vectors."
|
26 |
)
|
27 |
|
28 |
demo.launch()
|
29 |
|
30 |
+
|