From 5f68fcab127b157b2886c22e02585b600adfe7b4 Mon Sep 17 00:00:00 2001
From: Jesse Gross <jesse@ollama.com>
Date: Tue, 19 Nov 2024 16:41:42 -0800
Subject: [PATCH] runner.go: Use correct index when retrieving embedding
 results

This doesn't have any impact currently because NUM_PARALLEL is forced
to 1 for embeddings, so both indicies will always be 0.
---
 llama/runner/runner.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llama/runner/runner.go b/llama/runner/runner.go
index a2da546f..b8fc7cc6 100644
--- a/llama/runner/runner.go
+++ b/llama/runner/runner.go
@@ -454,7 +454,7 @@ func (s *Server) processBatch(tokenBatch *llama.Batch, embedBatch *llama.Batch)
 
 		// if done processing the prompt, generate an embedding and return
 		if seq.embeddingOnly {
-			embed := s.lc.GetEmbeddingsSeq(i)
+			embed := s.lc.GetEmbeddingsSeq(seq.cache.Id)
 			if embed == nil {
 				embed = s.lc.GetEmbeddingsIth(seq.iBatch)
 			}