Upload T5/generate-dict-embeddingsT5.py with huggingface_hub
Browse files
T5/generate-dict-embeddingsT5.py
CHANGED
@@ -33,6 +33,9 @@ def embed_from_text(text):
|
|
33 |
print("ERROR: expected single token per word")
|
34 |
print(text)
|
35 |
exit(1)
|
|
|
|
|
|
|
36 |
|
37 |
with torch.no_grad():
|
38 |
outputs = tmodel(tokens.input_ids)
|
|
|
33 |
print("ERROR: expected single token per word")
|
34 |
print(text)
|
35 |
exit(1)
|
36 |
+
# We can only accept single-token words, because we want our output
|
37 |
+
# to be a single embedding per word, and we dont have an official
|
38 |
+
# way to merge multiple T5 embeddings into one, like CLIP does
|
39 |
|
40 |
with torch.no_grad():
|
41 |
outputs = tmodel(tokens.input_ids)
|