MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / make_codec

Function make_codec

nodedb-vector/src/quantize/pq_codec.rs:155–169  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

153 use super::*;
154
155 fn make_codec() -> PqCodec {
156 let vecs: Vec<Vec<f32>> = (0..80)
157 .map(|i| {
158 let c = (i / 20) as f32 * 5.0;
159 vec![
160 c + (i as f32) * 0.1,
161 c - (i as f32) * 0.05,
162 c + 1.0,
163 c - 1.0,
164 ]
165 })
166 .collect();
167 let refs: Vec<&[f32]> = vecs.iter().map(|v| v.as_slice()).collect();
168 PqCodec::train(&refs, 4, 2, 8, 10)
169 }
170
171 /// `encode` round-trip: packed_bits in the UQV must match the raw
172 /// `PqCodec::encode` output.

Calls 3

collectMethod · 0.80
iterMethod · 0.45
as_sliceMethod · 0.45