interface
Browse files
app.py
CHANGED
@@ -12,15 +12,13 @@ def mean_pooling(model_output, attention_mask):
|
|
12 |
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
|
13 |
|
14 |
|
15 |
-
|
16 |
tokenizer = AutoTokenizer.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
|
17 |
model = AutoModel.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
|
18 |
|
19 |
|
20 |
-
|
21 |
-
def Bemenet(bemenet):
|
22 |
# Tokenize sentences
|
23 |
-
encoded_input = tokenizer([
|
24 |
|
25 |
# Compute token embeddings
|
26 |
with torch.no_grad():
|
@@ -34,8 +32,8 @@ def Bemenet(bemenet):
|
|
34 |
|
35 |
|
36 |
interface = gr.Interface(fn=Bemenet,
|
37 |
-
title="
|
38 |
-
description="
|
39 |
inputs="text",
|
40 |
outputs="text")
|
41 |
|
|
|
12 |
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
|
13 |
|
14 |
|
|
|
15 |
tokenizer = AutoTokenizer.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
|
16 |
model = AutoModel.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
|
17 |
|
18 |
|
19 |
+
def Bemenet(input_string):
|
|
|
20 |
# Tokenize sentences
|
21 |
+
encoded_input = tokenizer([input_string], padding=True, truncation=True, return_tensors='pt')
|
22 |
|
23 |
# Compute token embeddings
|
24 |
with torch.no_grad():
|
|
|
32 |
|
33 |
|
34 |
interface = gr.Interface(fn=Bemenet,
|
35 |
+
title="Beágyazások",
|
36 |
+
description="Az itt megosztott példa mondatokhoz készít beágyazásokat (embedding). A bal oldali input mezőbe beírt mondat beágyazása a jobb oldali szöveges mezőben jelenik meg.",
|
37 |
inputs="text",
|
38 |
outputs="text")
|
39 |
|