Spaces:
Sleeping
Sleeping
Commit
·
498d36d
1
Parent(s):
77be9aa
modified app.py
Browse files
app.py
CHANGED
|
@@ -32,14 +32,14 @@ model = PeftModel.from_pretrained(model, "McGill-NLP/LLM2Vec-Sheared-LLaMA-mntp-
|
|
| 32 |
# Wrapper for encoding and pooling operations
|
| 33 |
l2v = LLM2Vec(model, tokenizer, pooling_mode="mean", max_length=512)
|
| 34 |
|
| 35 |
-
def
|
| 36 |
-
|
| 37 |
-
return
|
| 38 |
|
| 39 |
# Define Gradio interface
|
| 40 |
iface = gr.Interface(
|
| 41 |
-
fn=
|
| 42 |
-
inputs=gr.Textbox(lines=
|
| 43 |
outputs=gr.JSON()
|
| 44 |
)
|
| 45 |
|
|
|
|
| 32 |
# Wrapper for encoding and pooling operations
|
| 33 |
l2v = LLM2Vec(model, tokenizer, pooling_mode="mean", max_length=512)
|
| 34 |
|
| 35 |
+
def encode_texts(input_texts):
|
| 36 |
+
encodings = [l2v.encode(text) for text in input_texts]
|
| 37 |
+
return encodings
|
| 38 |
|
| 39 |
# Define Gradio interface
|
| 40 |
iface = gr.Interface(
|
| 41 |
+
fn=encode_texts,
|
| 42 |
+
inputs=gr.Textbox(lines=5, placeholder="Enter texts separated by newlines..."),
|
| 43 |
outputs=gr.JSON()
|
| 44 |
)
|
| 45 |
|