Although it seems like you’re having a chat conversation with AI and it’s understanding all of your questions and comments from your prompt; it’s actually not. AI doesn’t “understand” our words the same humans do. It has to turn the words into something that it can work with, numbers.
AI doesn’t provide words with random numbers. Instead, it gives it a location on a map of meaning. This is called an embedding.
An interesting way of thinking about embeddings is Sherlock Holmes. Sherlock has encyclopedic knowledge about many topics that pertain to his detective work. The way he has been able to store and retrieve all of this information is through the usage of his “brain attic” (or “mind palace” if you’re a bigger fan of the BBC Sherlock). The “brain attic” is an interlocking mind map where he has been able to categorize and relate information together so that the retrieval can happen quickly.
For AI, a vector database works the same way. It assigns words coordinates and stores it in a high-dimensional space where it can store and group information together. So instead looping through information to find the most relevant data for you. It can jump to a specific area. (Think: the table of contents in a book.) A vector is simply an array of numbers but they represent complex objects, like words, sentences, images, and even audio files. From there, these embeddings can be used for recommendation engines, search engines, and obviously, AI chat like ChatGPT.

Prompt text ("Explain relativity to a 7-year-old")
↓ (1. Tokenization)
Tokens: ["Explain", " relat", "ivity", " to", " a", " 7", "-", "year", "-", "old"]
↓ (2. ID Lookup)
Token IDs: [345, 1290, 4721, 201, 17, 503, 12, 890, 12, 764]
↓ (3. Embedding Lookup)
Vectors: [ [0.12, 0.97, ...], [0.45, 0.22, ...], ... ]This is why the prompt that you write is important and needs to be descriptive and you need to provide as much as context as you can. For instance, the prompt "Explain relativity simply" lands the AI in one neighborhood of vectors. However, the prompt "Explain relativity to a 7-year-old with short sentences" lands the AI in a different, but more specific neighborhood with that makes short and simple ideas in the response more likely.
