Skip to content

Commit 0c7242f

Browse files
feat(sphere): integrate generalized primitives from core/samplers
- compute.rs: Re-export text primitives from thrml_core::text (RollingHash, ngram_hashes, jaccard_similarity, TextSimilarityConfig) - evaluation.rs: Document availability of thrml_core::metrics for general-purpose retrieval metrics - lib.rs: Re-export generalized APIs for sphere users: - thrml_core::metrics: evaluate_retrieval, RetrievalMetrics - thrml_core::text: ngram_hashes, RollingHash, TextSimilarityConfig - thrml_samplers::maxcut: maxcut_gibbs, maxcut_multistart, cut_value Sphere retains its domain-specific implementations (NavigationMetrics, cpu_ising, substring) while exposing lower-level primitives for users who need them. Also fixes: duplicate GpuInfo re-export in thrml-core/src/lib.rs
1 parent bc1c7c4 commit 0c7242f

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

crates/thrml-core/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ pub use text::*;
9595
#[cfg(feature = "gpu")]
9696
pub use backend::GpuInfo;
9797

98-
// Re-export GpuInfo only when gpu feature is enabled
99-
#[cfg(feature = "gpu")]
100-
pub use backend::GpuInfo;
101-
10298
#[cfg(feature = "gpu")]
10399
pub use distance::*;
104100
#[cfg(feature = "gpu")]

crates/thrml-sphere/src/compute.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
//! - [`substring`]: Substring similarity for Ising max-cut coupling
77
//! - [`cpu_ising`]: CPU-based f64 Ising max-cut partitioning
88
//!
9+
//! ## Core Primitives
10+
//!
11+
//! For lower-level text similarity, see [`thrml_core::text`]:
12+
//! - `RollingHash`: Efficient n-gram hashing
13+
//! - `ngram_hashes`, `jaccard_similarity`: Text similarity primitives
14+
//!
15+
//! For simpler max-cut on dense matrices, see [`thrml_samplers::maxcut`]:
16+
//! - `maxcut_gibbs`, `maxcut_multistart`: Graph partitioning
17+
//! - `cut_value`: Compute cut quality
18+
//!
919
//! ## Usage
1020
//!
1121
//! ```rust,ignore
@@ -23,6 +33,11 @@
2333
// Re-export core compute types from thrml-core
2434
pub use thrml_core::compute::{ComputeBackend, HybridConfig, OpType, PrecisionMode};
2535

36+
// Re-export text similarity primitives from thrml-core
37+
pub use thrml_core::text::{
38+
jaccard_similarity as text_jaccard, ngram_hashes, RollingHash, TextSimilarityConfig,
39+
};
40+
2641
// =============================================================================
2742
// Substring Similarity (for Ising max-cut enhancement)
2843
// =============================================================================

crates/thrml-sphere/src/evaluation.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
//! - **MRR**: Mean Reciprocal Rank - average of 1/rank for correct answers
88
//! - **nDCG@k**: Normalized Discounted Cumulative Gain
99
//!
10+
//! ## Core Primitives
11+
//!
12+
//! For general-purpose retrieval metrics without navigation dependencies,
13+
//! see [`thrml_core::metrics`]:
14+
//! - `recall_at_k`, `mrr`, `ndcg`: Single-query metrics
15+
//! - `evaluate_retrieval`: Batch evaluation over multiple queries
16+
//! - `RetrievalMetrics`: Aggregated metrics struct
17+
//!
1018
//! ## Quick Start
1119
//!
1220
//! ```rust,ignore

crates/thrml-sphere/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,9 @@ pub use compute::substring::SubstringConfig;
321321

322322
// Re-export hardware tier types from thrml-core for RuntimeConfig users
323323
pub use thrml_core::compute::{HardwareTier, PrecisionProfile, RuntimePolicy};
324+
325+
// Re-export generalized primitives from thrml-core and thrml-samplers
326+
// These can be used directly or as building blocks for sphere-specific APIs
327+
pub use thrml_core::metrics::{evaluate_retrieval, RetrievalMetrics};
328+
pub use thrml_core::text::{ngram_hashes, RollingHash, TextSimilarityConfig};
329+
pub use thrml_samplers::maxcut::{cut_value, maxcut_gibbs, maxcut_multistart};

0 commit comments

Comments
 (0)