Urgent.News

What's breaking now, across thousands of outlets.

AI

How AI Stores Millions of Vectors Without Using Tons of Memory

Hello, I'm Rijul, and I'm building LiveReview — a blast-radius aware AI code review built for your business-critical systems. Star us to help devs discover the project, give it a try, and share your feedback to help improve the product. In any sort of AI application, we have the concept of vectors . Vectors come in different shapes and sizes. Especially when they are large, we need a good way to…

Rijul, the creator of LiveReview, a code review tool for critical business systems, explains how to store millions of vector embeddings efficiently without consuming large amounts of memory. This is crucial for applications like Retrieval-Augmented Generation (RAG) that rely on thousands of embeddings derived from product documentation, FAQs, and support articles.

To understand the problem, consider a customer support RAG app with 10 million embeddings, each consisting of 768 dimensions. Each dimension is represented by a 32-bit floating-point number, which is equivalent to 4 bytes. Thus, storing all 10 million embeddings would require approximately 30 GB of memory, equivalent to the storage capacity of a large game or several high-quality movies.

Product Quantization (PQ) is a technique that can significantly reduce the storage requirements for these large vectors. PQ works by splitting each vector into smaller pieces called subvectors and then learning representative patterns for each piece. These patterns are stored as "codewords," allowing the entire subvector to be represented by the ID of its closest codeword.

For example, consider an 8-dimensional vector: [0.21, 0.73, -0.15, 0.91, 0.34, -0.52, 0.18, 0.66]. This vector can be split into four subvectors. For each subvector, a separate codebook is learned, and the subvector is replaced by the ID of the codeword that best matches it. The original vector is then represented by a list of these IDs, which can be stored using fewer bits than the original floating-point numbers.

In the example, the 8-dimensional vector is split into four subvectors, and each subvector is represented by an ID. The entire vector is now represented as [1, 2, 3, 0], where each number is the ID of the codeword for the corresponding subvector. This representation requires only 4 bytes, whereas the original vector required 32 bytes.

When applied to larger embeddings, such as a 768-dimensional vector, PQ can reduce the storage requirement by a factor of 32. This dramatic reduction in storage significantly benefits applications that deal with millions or billions of vectors, making it feasible to perform large-scale vector search without consuming excessive memory.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

What skills are needed of CEOs in the AI era? A headhunter on the bittersweet future The rapid development of AI (artificial intelligence) is drastically changing the business environment. In order to survive in this new era, companies need to drastically change their organisations and management styles. A headhunter who has introduced numerous top executives to major companies had a talk with a journalist about what CEOs need in order to be successful in the AI era. The headhunter emphasized that in order to survive in the AI era, top executives need to change their attitude towards data. In the past, making decisions based on experience and intuition was often enough, but in the AI era, making decisions based on data is becoming increasingly important. The headhunter also said that top executives need to have a deep understanding of new technologies such as AI and digital transformation. They also need to have the ability to promote digital transformation within their organisations. In addition, the headhunter emphasized that top executives need to have a strong leadership and the ability to make tough decisions. In the AI era, companies need to be able to adapt quickly to changes in the business environment, and top executives need to be able to lead their organisations in this process. The headhunter also noted that the AI era will bring many challenges for top executives, but it will also bring many opportunities. Top executives who are able to adapt to the new era and lead their organisations to success will be highly rewarded. However, those who are unable to adapt will struggle to survive. The headhunter concluded that the AI era will be a bittersweet future for top executives, but with the right skills and mindset, they can succeed and lead their organisations to success. The AI era is coming, and top executives need to be prepared. They need to develop the skills and mindset needed to succeed in this new era. The headhunter's advice is clear: top executives need to change their attitude towards data, develop a deep understanding of new technologies, and have strong leadership and decision-making skills. Only then can they succeed in the AI era and lead their organisations to success.

More from Saturday 29 August →