Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 5.4 — Collections, Ids and Payloads
RAG and Vector Search · Example 1 of 1

A collection: fixed shape, your ids, a payload, text elsewhere

The 4-number embedder is a toy: one number per word group. A real model gives hundreds of numbers, but the collection behaves the same way.

A collection fixes the vector length and the distance when it is created. You choose the ids, and each point can carry a small payload. The full text usually stays in your own table, found by id.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write chunk_id(doc_id, n) that returns ids like D3#2, and parse_id(point_id) that returns (doc_id, n). Print both for D3, 2.

02

Write check_point(dim, vector, payload, model) that returns a list of problems: a wrong vector length and a payload whose model differs. Print the list for dim=4, a three-number vector and payload {"model": "old"} with model="new".

Explain it without notes

01

What is fixed when a collection is created, and why?

02

Why choose your own ids?

03

Where should the chunk text live, in the payload or in your own table?

04

How would you move to a new embedding model?

A collection: fixed shape, your ids, a payload, text elsewhere
Sign in to run this example in your browser.

Expected output

collection lumen: dim=4 metric=cosine points=3
after upserting D3 again: points=3
rejected: expected 4 numbers, got 3
D3 0.928 title=Password reset model=toy-4
   text: To reset your password, open the app, ta...
D1 0.000 title=Refunds model=toy-4
   text: A ride cancelled at least 2 hours before...