mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-10 10:33:11 +03:00
Handle emb correctly
This commit is contained in:
parent
ac63be9ea7
commit
334399a260
@ -70,7 +70,11 @@ class GenAIEmbedding:
|
||||
|
||||
result = []
|
||||
for emb in embeddings:
|
||||
arr = np.asarray(emb, dtype=np.float32).flatten()
|
||||
arr = np.asarray(emb, dtype=np.float32)
|
||||
if arr.ndim > 1:
|
||||
# Some providers return token-level embeddings; pool to one vector.
|
||||
arr = arr.mean(axis=0)
|
||||
arr = arr.flatten()
|
||||
if arr.size != EMBEDDING_DIM:
|
||||
if arr.size > EMBEDDING_DIM:
|
||||
arr = arr[:EMBEDDING_DIM]
|
||||
|
||||
@ -254,6 +254,10 @@ class LlamaCppClient(GenAIClient):
|
||||
logger.warning("llama.cpp embeddings item missing embedding field")
|
||||
continue
|
||||
arr = np.array(emb, dtype=np.float32)
|
||||
if arr.ndim > 1:
|
||||
# llama.cpp can return token-level embeddings; pool per item
|
||||
arr = arr.mean(axis=0)
|
||||
arr = arr.flatten()
|
||||
orig_dim = arr.size
|
||||
if orig_dim != EMBEDDING_DIM:
|
||||
if orig_dim > EMBEDDING_DIM:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user