Spaces:
Build error
Build error
LawalAfeez
commited on
Commit
•
619a263
1
Parent(s):
8c1f2d6
Upload embed.py
Browse files
embed.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
def cls_pool(model):
|
3 |
+
|
4 |
+
return model.last_hidden_state[:,0,:]
|
5 |
+
|
6 |
+
def sample_embedding(example):
|
7 |
+
|
8 |
+
token_output=tokenizer(example,padding=True,truncation=True,return_tensors="tf")
|
9 |
+
|
10 |
+
token_output={k:v for k,v in token_output.items()}
|
11 |
+
|
12 |
+
|
13 |
+
model_output=model(**token_output)
|
14 |
+
|
15 |
+
return {"embedding":cls_pool(model_output).numpy()[0]}
|