RAG and Vector Search · Exercise 1 of 5Next
Intermediate
Estimate memory and cost for a design
Write vector_mb(chunks, dimensions) that returns the raw size in megabytes (1 MB = 1,000,000 bytes) of 32-bit float vectors.
Write cost_per_1000(sources, chunk_tokens, extra_tokens, out_tokens, price_in, price_out) returning dollars for 1000 questions. Input tokens are sources * chunk_tokens + extra_tokens. Prices are dollars per million tokens.
What Check tests
- Raw size of 200,000 vectors of 384 dimensions
- Doubling the dimensions doubles the size
- Cost per 1000 questions with 5 sources
- Fewer sources cost less
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.