Skip to main content

Module hubness_rust

Module hubness_rust 

Source
Expand description

ARCHIVED: Pure-Rust cosine_similarity and compute_hubness_scores.

This file preserves the original Rust implementations that were replaced by the C SIMD kernel in c-kernels/similarity.c (via FFI in hubness.rs).

Archived on: 2026-07-12 Reason: Performance — C kernel with compiler auto-vectorization; AVX2/FMA is enabled only for targets that advertise those features. replaces the pure-Rust dot product / norm computation.

The cosine_similarity function below is the original pure-Rust version. compute_hubness_scores remains in Rust (in hubness.rs) and calls the C-backed cosine_similarity — only the inner math was moved to C.

To restore the pure-Rust version, copy these functions back into hubness.rs and remove the FFI extern "C" block.

Structs§

HubnessScore
Per-item hubness score (archived copy — the live one is in hubness.rs).

Functions§

compute_hubness_scores
Compute hubness scores for a collection of embeddings.
cosine_similarity
Cosine similarity between two equal-length vectors.