aboutsummaryrefslogtreecommitdiff
path: root/libffwd/late.c
diff options
context:
space:
mode:
Diffstat (limited to 'libffwd/late.c')
-rw-r--r--libffwd/late.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/libffwd/late.c b/libffwd/late.c
index e086ad3..9418a20 100644
--- a/libffwd/late.c
+++ b/libffwd/late.c
@@ -1,3 +1,16 @@
+/*
+ * Late-interaction model.
+ *
+ * A late-interaction model is a pooled base model plus a 1_Dense linear
+ * projection from hidden states to token vectors.
+ *
+ * Instead of pooling to one vector, it keeps one projected vector per kept token
+ * and scores query/doc pairs with MaxSim.
+ *
+ * Reuses the base model's packed forward pass and workspace. This layer only
+ * owns the projection, token-vector buffer, and scoring.
+ */
+
#include "ffwd.h"
#include "model_internal.h"
#include "kernels.h"
@@ -8,17 +21,6 @@
#include <limits.h>
#include <float.h>
-/* ========================================================================
- * Late-interaction model
- *
- * A late-interaction model is a pooled base model plus a 1_Dense linear
- * projection from hidden states to token vectors. Instead of pooling to one
- * vector, it keeps one projected vector per kept token and scores query/doc
- * pairs with MaxSim. It reuses the base model's packed forward pass and
- * workspace; only the projection, the token-vector buffer, and the scoring
- * live here.
- * ======================================================================== */
-
struct ffwd_late_model {
ffwd_model_t *base;
safetensors_file_t *dense_sf;
@@ -107,8 +109,9 @@ const ffwd_config_t *ffwd_late_model_config(const ffwd_late_model_t *model) {
int ffwd_late_model_token_dim(const ffwd_late_model_t *model) { return model ? model->token_dim : 0; }
-/* Internal (internal.h): expose the base model and projection so GPU
- * backends can upload them to device without seeing struct ffwd_late_model. */
+/* Internal (internal.h):
+ * expose the base model and projection so GPU backends can upload them to the
+ * device without seeing struct ffwd_late_model. */
ffwd_model_t *ffwd_late_model_base(const ffwd_late_model_t *model) {
return model ? model->base : NULL;
}