diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-05-30 10:36:10 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-06-14 08:26:42 +0200 |
| commit | 10bf114474d5b79193159e5c865734362cf7abfb (patch) | |
| tree | a5bcd2a7ea22e4008988f9daf6d5b479bfdd918e /pplx_embed.h | |
| parent | 385bed06e606f9cbacb719c9569cc77e4000f12c (diff) | |
| download | ffwd-10bf114474d5b79193159e5c865734362cf7abfb.tar.gz ffwd-10bf114474d5b79193159e5c865734362cf7abfb.zip | |
api: add opt-in l2 normalization helper
Diffstat (limited to 'pplx_embed.h')
| -rw-r--r-- | pplx_embed.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pplx_embed.h b/pplx_embed.h index 276c67f..0816e20 100644 --- a/pplx_embed.h +++ b/pplx_embed.h @@ -165,7 +165,16 @@ int pplx_model_embed_spans(const pplx_model_t *model, pplx_workspace_t *ws, 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); |
