mirror of
https://github.com/lukaszraczylo/llm-testbench.git
synced 2026-10-12 00:45:19 +00:00
feat: LLM accuracy testing framework with 17-test catalog
Framework runs a category/subcategory test catalog against multiple LLMs through an OpenAI-compatible endpoint. Deterministic evaluators score each response. Reports render as table, markdown, or JSON.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package tests
|
||||
|
||||
import "math"
|
||||
|
||||
// cosineSimilarity computes the cosine similarity of two equal-length
|
||||
// vectors: dot(a,b) / (|a| * |b|). Used to derive ground-truth expected
|
||||
// values for numeric tests at catalog-registration time rather than
|
||||
// hardcoding a pre-computed constant.
|
||||
func cosineSimilarity(a, b []float64) float64 {
|
||||
var dot, normA, normB float64
|
||||
for i := range a {
|
||||
dot += a[i] * b[i]
|
||||
normA += a[i] * a[i]
|
||||
normB += b[i] * b[i]
|
||||
}
|
||||
return dot / (math.Sqrt(normA) * math.Sqrt(normB))
|
||||
}
|
||||
|
||||
// round4dp rounds v to 4 decimal places, matching the precision the
|
||||
// py-cosine prompt asks the model to answer to.
|
||||
func round4dp(v float64) float64 {
|
||||
return math.Round(v*10000) / 10000
|
||||
}
|
||||
Reference in New Issue
Block a user