Turning Text into Vectors
batch embedding a corpus
Part of: Semantic Search Engine
Lesson 1 handed you vectors. Now you produce them yourself, and the decision that matters is making one batch call instead of one call per document. Batching, not looping A first attempt often embeds documents one at a time in a loop, calling the API once per document. That's slow, one network round trip per doc, and on most providers it costs more than sending them together. Collect every text you need embedded, then send them as a single batch request. One request in, one vector per text out, in the same order you sent them. That is the shape of an index : a corpus where every document now also carries its vector. Documents vs. queries Notice the input type="document" argument. Voyage's models embed documents and search queries slightly differently. Documents expect to be searched; queries expect to search. When you later embed the user's search text, you pass input type="query" instead. Using the wrong one for a given side won't crash anything. It quietly makes your rankings worse, so get it right from the start. Why batching matters as the corpus grows A batch call to an embeddings API caps how many texts (and total tokens) it accepts per request, and there's usually a per-minu
Challenge: Batch-Embed the Corpus