---
title: "Truncate safely, keep one model"
lesson_id: "03"
---

# Truncate safely, keep one model

- **Lesson ID:** 03
- **Goal:** Save storage with shorter vectors without breaking ranking, and never mix setups.
- **Human lesson:** [03-truncate-and-keep-one-model.html](03-truncate-and-keep-one-model.html)

## Prerequisites

- Lessons 01 and 02.

## Inputs, outputs, and artifacts

- **Inputs:** 768d unit vectors and a target dimension.
- **Outputs:** Normalized vectors at the target dimension and an index with stored setup.
- **Artifacts:** `vectors.npy`, `index.json`.

## Agent build steps

1. Pick 512 or 256 dimensions. Test 128 before using it.
2. Slice and normalize with `truncate`.
3. Save with `save_index`, which checks unit length.
4. Load with `load_index`, which refuses a different setup.
5. Rebuild the index on any model, prefix, or dimension change.

## Constraints

Keep the language simple, friendly, and literal. No quizzes, no em dashes. Brand Edge FDE only. Use small local models. Do not invent flags, endpoints, or issue numbers. 

## Key concepts

- Matryoshka vectors can be cut to 512, 256, or 128 dimensions.
- A cut vector is shorter than length 1 and must be normalized again.
- Query and document vectors must use the same model, prefixes, and dimension.
- Mixing setups gives bad ranking, not errors.

## Takeaways

- Slice, then normalize, every time.
- Store model, prefixes, dimension, and normalization next to the vectors.
- Rebuild the whole index when any of them changes.

## Acceptance checks

- Norms after slicing are shown and are below 1.
- The guard refuses an index built with a different SETUP.
- [ ] Proceed to [lesson 04 brief](04-recall-test-and-speed.llms.md).
