check normalization

This commit is contained in:
Roy Han 2024-06-28 15:10:58 -07:00
parent 49e341147d
commit b9c74df37b

View File

@ -480,6 +480,15 @@ func (s *Server) EmbeddingsHandler(c *gin.Context) {
return
}
// assert that embedding is normalized
sum := 0.0
for _, v := range embedding {
sum += v * v
}
if math.Abs(sum-1) > 1e-6 {
slog.Info("embedding is not normalized", "sum", sum)
}
resp := api.EmbeddingResponse{
Embedding: embedding,
}