From 10bf114474d5b79193159e5c865734362cf7abfb Mon Sep 17 00:00:00 2001 From: Onur Gündüz Date: Sat, 30 May 2026 10:36:10 +0200 Subject: api: add opt-in l2 normalization helper --- pplx_embed.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pplx_embed.h') diff --git a/pplx_embed.h b/pplx_embed.h index 276c67f..0816e20 100644 --- a/pplx_embed.h +++ b/pplx_embed.h @@ -164,8 +164,17 @@ int pplx_model_embed_spans(const pplx_model_t *model, pplx_workspace_t *ws, const pplx_span_t *spans, int n_spans, float *out_embeddings); +/* + * L2-normalize vec[dim] in place. + * + * Returns 0 on success. Returns -1 for invalid arguments or a zero-length + * vector, which cannot be normalized. + */ +int pplx_l2_normalize(float *vec, int dim); + /* * Cosine similarity between two vectors. + * Returns 0 for invalid arguments or if either vector has zero length. */ float pplx_cosine_similarity(const float *a, const float *b, int dim); -- cgit v1.3.1