summaryrefslogtreecommitdiff
path: root/llm/stat.go
diff options
context:
space:
mode:
authorJonas Knobloch <jonas.knobloch@t-online.de>2026-04-07 00:01:23 +0200
committerJonas Knobloch <jonas.knobloch@t-online.de>2026-04-07 00:01:23 +0200
commitb81fa93e098ca689cb6f73627968fe0b4d49decb (patch)
treebb852b92c2761a0924a5cefcc3bce6d10b480822 /llm/stat.go
parentb9faf92148c7e6432ff0411783f444b7779fa36a (diff)
Run evaluator with score
Diffstat (limited to 'llm/stat.go')
-rw-r--r--llm/stat.go34
1 files changed, 0 insertions, 34 deletions
diff --git a/llm/stat.go b/llm/stat.go
deleted file mode 100644
index 228e9f2..0000000
--- a/llm/stat.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package llm
-
-import (
- "math"
- "slices"
-)
-
-func NegLogLikelihood(logits [][]float32, targets []int) (float64, int) {
- if len(logits) != len(targets) {
- panic("mismatched input lengths")
- }
-
- total := float64(0)
-
- for i, target := range targets {
- maxLogit := float64(slices.Max(logits[i]))
-
- sumExp := float64(0)
-
- for _, v := range logits[i] {
- sumExp += math.Exp(float64(v) - maxLogit)
- }
-
- logSumExp := maxLogit + math.Log(sumExp)
-
- targetLogit := float64(logits[i][target])
-
- logProb := targetLogit - logSumExp
-
- total -= logProb
- }
-
- return total, len(targets)
-}