From 15b8875cfc5568e53dd5d2310ad1ca6dfe75427d Mon Sep 17 00:00:00 2001 From: jmorganca Date: Tue, 11 Mar 2025 23:41:18 +0100 Subject: [PATCH] runner/ollamarunner: set temperature to 0 when images are provided --- runner/ollamarunner/runner.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/runner/ollamarunner/runner.go b/runner/ollamarunner/runner.go index c1475cbb2..d29f910d1 100644 --- a/runner/ollamarunner/runner.go +++ b/runner/ollamarunner/runner.go @@ -590,8 +590,17 @@ func (s *Server) completion(w http.ResponseWriter, r *http.Request) { } } + // temperature > 0 can tend to cause the model to + // hallucinate, so when images are provided, so + // we use a temperature of 0 for requests that + // include them + temperature := req.Temperature + if len(req.Images) > 0 { + temperature = 0 + } + sampler := sample.NewSampler( - req.Temperature, + temperature, req.TopK, req.TopP, req.MinP,