Skip to main content

Shape

Struct Shape 

Source
pub struct Shape {
    pub ksim: usize,
    pub dproj: usize,
    pub reps: usize,
}
Expand description

How big an encoding is and how much accuracy it buys.

The three numbers trade the same way in every experiment in the paper: more buckets and more repetitions track Chamfer more closely and cost a longer encoding, and the encoding’s length is the product of all three.

Fields§

§ksim: usize

How many random hyperplanes cut the space, so there are 2^ksim buckets.

This is the one to think about against the number of tokens a document has. Buckets well past the token count means most of them are empty and filled from a neighbour, which is not wrong but is not buying anything either.

§dproj: usize

How many numbers each bucket’s block is squeezed down to.

Without this a block would be the token dimension long and the encoding would be buckets times that, which at 128 dimensional tokens and sixteen buckets is two thousand numbers for one repetition.

§reps: usize

How many times the whole thing is done again with fresh hyperplanes.

Whether a query token and its true best match land in the same bucket is a coin toss that this averages out, and it is the knob that buys accuracy rather than just length.

Trait Implementations§

Source§

impl Clone for Shape

Source§

fn clone(&self) -> Shape

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Shape

Source§

impl Debug for Shape

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Shape

Source§

fn default() -> Shape

Sixteen buckets, sixteen numbers a block, eight repetitions, which is two thousand numbers whatever the token dimension is.

That is the middle of the range the paper measures, and it is a reasonable place to start for the hundred or so tokens a passage has. At one bit a dimension it is a 256 byte code, against the 100 token by 128 dimension set it stands in for, which would be 12 kilobytes of floats.

Auto Trait Implementations§

§

impl Freeze for Shape

§

impl RefUnwindSafe for Shape

§

impl Send for Shape

§

impl Sync for Shape

§

impl Unpin for Shape

§

impl UnsafeUnpin for Shape

§

impl UnwindSafe for Shape

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.