Spaces:
Running
Running
added search URL to the README
Browse files- README.md +3 -0
- src/encode.py +0 -14
README.md
CHANGED
|
@@ -8,3 +8,6 @@ pinned: false
|
|
| 8 |
---
|
| 9 |
|
| 10 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 11 |
+
|
| 12 |
+
query the model with:
|
| 13 |
+
https://wbrooks-coul-document-search.hf.space:7860/search?query=books
|
src/encode.py
DELETED
|
@@ -1,14 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
|
| 3 |
-
#
|
| 4 |
-
def encode(sentences, tokenizer, model, device="mps"):
|
| 5 |
-
inputs = tokenizer(sentences, padding=True, truncation=True, return_tensors="pt").to(device = device)
|
| 6 |
-
|
| 7 |
-
with torch.no_grad():
|
| 8 |
-
outputs = model(**inputs)
|
| 9 |
-
|
| 10 |
-
# outputs.last_hidden_state = [batch, tokens, hidden_dim]
|
| 11 |
-
# mean pooling
|
| 12 |
-
embeddings = outputs.last_hidden_state.mean(dim=1)
|
| 13 |
-
|
| 14 |
-
return(embeddings)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|