emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/elisa a4f34972bb 1/7: Improve embeddings calculation in


From: ELPA Syncer
Subject: [elpa] externals/elisa a4f34972bb 1/7: Improve embeddings calculation in Elisa
Date: Sat, 23 Nov 2024 12:57:56 -0500 (EST)

branch: externals/elisa
commit a4f34972bb0af16b0fb5e62fa8f00f11b0b3f0b1
Author: Sergey Kostyaev <kostyaev.sergey2@wb.ru>
Commit: Sergey Kostyaev <kostyaev.sergey2@wb.ru>

    Improve embeddings calculation in Elisa
    
    Added `elisa-embeddings` function for calculating embeddings for
    chunks. If the LLM provider supports batch embeddings, use them;
    otherwise, calculate embeddings individually using `llm-embedding`.
---
 elisa.el | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/elisa.el b/elisa.el
index 5a1c4ab725..65ded645bf 100644
--- a/elisa.el
+++ b/elisa.el
@@ -455,6 +455,14 @@ FOREIGN KEY(collection_id) REFERENCES collections(rowid)
   "Calculate breakpoint threshold for DISTANCES based on K standard 
deviations."
   (+ (elisa-avg distances) (* k (elisa-std-dev distances))))
 
+(defun elisa-embeddings (chunks)
+  "Calculate embeddings for CHUNKS.
+Return list of vectors."
+  (let ((provider elisa-embeddings-provider))
+    (if (member 'embeddings-batch (llm-capabilities provider))
+       (llm-batch-embeddings provider chunks)
+      (mapcar (lambda (chunk) (llm-embedding provider chunk)) chunks))))
+
 (defun elisa-parse-info-manual (name collection-name)
   "Parse info manual with NAME and save index to COLLECTION-NAME."
   (with-temp-buffer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]