TiGa-RCE commited on
Commit
97e5e64
·
verified ·
1 Parent(s): 2fad4af

Disable unused KV cache for embedding controls

Browse files
Files changed (1) hide show
  1. app.py +1 -1
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