Change the embedding dimensions
The stock crate hardcodes 2 dimensions as a demo default. Here is why, where the constant lives, and how to fork it for real embeddings.
memista is experimental (v0.1.x), and the stock crate hardcodes the embedding dimension to 2 as a demo default. Real embedding models produce 384, 768, 1536, or larger vectors, so this is the first thing you change.
Where the constant lives
The dimension is set in IndexOptions::dimensions inside src/lib.rs, in the
load_or_create_index helper. Change 2 to your model’s output size:
let options = IndexOptions {
dimensions: 768, // was 2 — set to your embedding model's size
metric: MetricKind::IP,
quantization: ScalarKind::F32,
..Default::default()
};
This is a rebuild, not a migration
The on-disk USearch format is fixed at index creation. Changing the dimension means the existing
<database_id>.usearchfile is incompatible — you rebuild the index by re-inserting from your source vectors.
Because memista is a crate first, the clean path is to fork it: vendor the
crate, set the dimension, and pull in your fork. If you’re tuning recall vs.
latency at the same time, this is also where you’d override USearch’s default
connectivity and expansion_* parameters.
Related: persistence and the .usearch file, how it works.
Frequently Asked Questions
Why is the dimension hardcoded to 2?
It is a demo default in the current experimental crate. Real embeddings are 384, 768, 1536, etc. — you set IndexOptions::dimensions before shipping.
Can I change dimensions on an existing index?
No. The on-disk USearch format is fixed at index creation. Changing dimensions forces a rebuild from the source vectors.