aboutsummaryrefslogtreecommitdiff
path: root/pplx_embed.h
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-05-30 05:26:44 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-06-14 08:18:59 +0200
commit385bed06e606f9cbacb719c9569cc77e4000f12c (patch)
tree89da34bae34d89f467e4a6e3cae01354d710dd69 /pplx_embed.h
parentaba76ae05435492b8ac3fc477ce13356fda6ffde (diff)
downloadffwd-385bed06e606f9cbacb719c9569cc77e4000f12c.tar.gz
ffwd-385bed06e606f9cbacb719c9569cc77e4000f12c.zip
server: align embedding quantization with perplexity
Diffstat (limited to 'pplx_embed.h')
-rw-r--r--pplx_embed.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/pplx_embed.h b/pplx_embed.h
index ba46639..276c67f 100644
--- a/pplx_embed.h
+++ b/pplx_embed.h
@@ -94,7 +94,10 @@ size_t pplx_workspace_nbytes(const pplx_workspace_t *ws);
* 2. N transformer layers (bidirectional GQA + RoPE + SwiGLU)
* 3. Final RMSNorm
* 4. Mean pooling over all positions
- * 5. L2 normalization
+ *
+ * Perplexity embeddings are intentionally not L2-normalized. Use cosine
+ * similarity for comparisons, or normalize explicitly before storing in vector
+ * databases that only support inner product.
*
* Returns malloc'd float[hidden_size] (caller frees). NULL on error.
*/
@@ -142,11 +145,11 @@ int pplx_model_forward_into(const pplx_model_t *model, pplx_workspace_t *ws,
float *out_states);
/*
- * Pool normalized embeddings from final hidden states.
+ * Pool embeddings from final hidden states.
*
* states is [n_tokens, hidden_size], normally produced by
- * pplx_model_forward_into(). Each span is mean pooled and L2 normalized into
- * out_embeddings[n_spans, hidden_size].
+ * pplx_model_forward_into(). Each span is mean pooled into
+ * out_embeddings[n_spans, hidden_size] without L2 normalization.
*/
int pplx_pool_spans(const pplx_config_t *cfg, const float *states, int n_tokens,
const pplx_span_t *spans, int n_spans,
@@ -162,7 +165,7 @@ int pplx_model_embed_spans(const pplx_model_t *model, pplx_workspace_t *ws,
float *out_embeddings);
/*
- * Cosine similarity between two L2-normalized vectors.
+ * Cosine similarity between two vectors.
*/
float pplx_cosine_similarity(const float *a, const float *b, int dim);