Spaces:
Running on Zero
Running on Zero
Disable unused KV cache for embedding controls
Browse files
app.py
CHANGED
|
@@ -56,7 +56,7 @@ def encode_with(active_model, text: str, active_tokenizer=None) -> np.ndarray:
|
|
| 56 |
)
|
| 57 |
batch = {key: value.to("cuda") for key, value in batch.items()}
|
| 58 |
with torch.inference_mode():
|
| 59 |
-
output = active_model(**batch)
|
| 60 |
vector = F.normalize(output.last_hidden_state[:, -1, :].float(), p=2, dim=-1)
|
| 61 |
return vector[0].cpu().numpy()
|
| 62 |
|
|
|
|
| 56 |
)
|
| 57 |
batch = {key: value.to("cuda") for key, value in batch.items()}
|
| 58 |
with torch.inference_mode():
|
| 59 |
+
output = active_model(**batch, use_cache=False)
|
| 60 |
vector = F.normalize(output.last_hidden_state[:, -1, :].float(), p=2, dim=-1)
|
| 61 |
return vector[0].cpu().numpy()
|
| 62 |
|