Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9d1b8d

Browse files
committed
fallback to get_embeddings_ith
1 parent 1a9b8af commit e9d1b8d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llama_cpp/llama.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,11 @@ def decode_batch(n_seq: int):
821821
self._ctx.ctx, i
822822
)
823823
if not ptr:
824-
raise RuntimeError("Failed to get embeddings from sequence pooling type is not set")
824+
ptr = llama_cpp.llama_get_embeddings_ith(
825+
self._ctx.ctx, i
826+
)
827+
if not ptr:
828+
raise RuntimeError(f"Failed to get embeddings for sequence {i}")
825829
embedding: List[float] = ptr[:n_embd]
826830
if normalize:
827831
norm = float(np.linalg.norm(embedding))

0 commit comments

Comments
 (0)