Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4073532

Browse filesBrowse files
committed
switch to llama_get_embeddings_seq
1 parent 93dc56a commit 4073532
Copy full SHA for 4073532

File tree

Expand file treeCollapse file tree

2 files changed

+17
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-1
lines changed

‎llama_cpp/llama.py

Copy file name to clipboardExpand all lines: llama_cpp/llama.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ def decode_batch(n_seq: int):
814814

815815
# store embeddings
816816
for i in range(n_seq):
817-
embedding: List[float] = llama_cpp.llama_get_embeddings_ith(
817+
embedding: List[float] = llama_cpp.llama_get_embeddings_seq(
818818
self._ctx.ctx, i
819819
)[:n_embd]
820820
if normalize:

‎llama_cpp/llama_cpp.py

Copy file name to clipboardExpand all lines: llama_cpp/llama_cpp.py
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,22 @@ def llama_get_embeddings_ith(
18031803
...
18041804

18051805

1806+
# // Get the embeddings for sequence seq_id
1807+
# // shape: [n_embd] (1-dimensional)
1808+
# LLAMA_API float * llama_get_embeddings_seq(struct llama_context * ctx, llama_seq_id seq_id);
1809+
@ctypes_function(
1810+
"llama_get_embeddings_seq",
1811+
[llama_context_p_ctypes, ctypes.c_int32],
1812+
ctypes.POINTER(ctypes.c_float),
1813+
)
1814+
def llama_get_embeddings_seq(
1815+
ctx: llama_context_p, i: Union[ctypes.c_int32, int], /
1816+
) -> CtypesArray[ctypes.c_float]:
1817+
"""Get the embeddings for sequence seq_id
1818+
shape: [n_embd] (1-dimensional)"""
1819+
...
1820+
1821+
18061822
# // Get the embeddings for a sequence id
18071823
# // Returns NULL if pooling_type is LLAMA_POOLING_TYPE_NONE
18081824
# // shape: [n_embd] (1-dimensional)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.