Embedding

An embedding is a list of numbers that represents a piece of text, or an image, so software can measure how close in meaning two things are.

Checked 27/11/2026 against 3 sources. Next review 27/05/2027.

An embedding is a vector, which is a list of floating point numbers, that stands for a piece of content [1]. The distance between two vectors measures how related the two pieces are: small distances suggest high relatedness and large distances suggest low relatedness [1]. Google's machine learning course describes them as lower-dimensional representations of sparse data [3]. They are how a search can match meaning and not only exact words, and they sit underneath RAG systems and chatbot knowledge bases.

What is actually inside an embedding?

Numbers, and nothing you can read. OpenAI's embeddings API returns the vector along with some metadata, and you can save the vector in a vector database [1]. You send a text string and a model name, and the model does the rest [1].

Google's machine learning course shows why a plain one-hot encoding is a poor fit: each item gets a vector as long as the whole list of items, which means a huge number of weights, more data and more computation [3]. Embeddings are its answer, lower-dimensional representations of sparse data [3].

The vector has a length, and it depends on the model. OpenAI lets you pass a dimensions parameter to shorten it without losing its ability to represent concepts [1].

How does a search use embeddings to find the right paragraph?

  1. Embed your documents Each paragraph of your price list, policies and FAQs is sent to an embedding model, which returns one vector per paragraph [1].
  2. Store the vectors They can be saved in a vector database [1].
  3. Embed the question The customer's question goes through the same model and becomes a vector [1].
  4. Rank by closeness OpenAI's own example ranks documents by the cosine similarity between the query vector and each document vector, and returns the highest scored [1].

The best-scoring paragraphs are then handed to a large language model to write the answer. That pairing is RAG. Google lists building RAG systems as a common use of its embeddings and says embeddings improve factual accuracy, coherence and contextual richness in model outputs [2].

Why does a search for "money back" find the refund policy?

Google says embeddings support tasks such as semantic search, classification and clustering, and give more accurate, context-aware results than keyword-based approaches [2]. A keyword search needs the words to match. An embedding search compares meaning.

A worked example

Say a tuition centre's FAQ has one paragraph headed "Refund policy". A parent types "how long to get my money back". The words "refund" and "money back" share nothing, so a keyword search can miss the paragraph. The two texts still land close together as vectors, so the embedding search ranks that paragraph near the top.

ApproachMatches onSource
Keyword searchThe words you typedGoogle [2]
Embedding searchCloseness of meaning, measured as distance between vectorsOpenAI [1], Google [2]

What do embeddings cost?

OpenAI says embedding requests are billed on the number of tokens in the input, and that usage is priced per input token [1]. See token for how text is counted. You pay once to embed a document. After that, each customer question costs one small embedding request plus the search.

Google adds that picking the right task type, such as retrieval or similarity, helps tune the embeddings for the relationship you care about [2].

Questions people ask

What is an embedding in simple terms?

It is a list of numbers that stands for the meaning of a piece of text. Two texts with similar meanings get vectors that are close together, and unrelated texts get vectors that are far apart [1].

Is an embedding the same as a vector database?

No. An embedding is the list of numbers. A vector database is where you store many of them so you can search by closeness [1]. OpenAI's guide says you can save an embedding vector in a vector database.

Can embeddings handle images and not only text?

Some can. Google says its latest Gemini embedding model maps text, images, video, audio and documents into one shared space, so a search can work across them [2]. Support differs by model, so check the provider's documentation.

See also

  • RAG RAG is a method where an AI looks up your own documents first, then writes its answer from what it found, not only from what it learned in training.
  • Vector database A vector database stores numerical representations of text, images or audio, called embeddings, and finds the ones closest in meaning to a query.
  • Large language model A large language model (LLM) is an AI system trained on huge amounts of text to predict the next piece of text, which lets it write, summarise and answer questions.
  • Token A token is the small piece of text, such as a word, part of a word or a punctuation mark, that an AI language model reads and writes.
  • Chatbot A chatbot is a program you talk to by text or voice, which answers questions or helps you finish a task.
  • Hallucination A hallucination is when an AI model states something false as if it were true, such as an invented fact, quote or source.

References

  1. Vector embeddings, OpenAI. Read 27/11/2026.An embedding is a vector (list) of floating point numbers. The distance between two vectors measures their relatedness.
  2. Embeddings (Gemini API), Google AI for Developers. Read 27/11/2026.These resulting embeddings can then be used for tasks such as semantic search, classification, and clustering, providing more accurate, context-aware results than keyword-based approaches.
  3. Machine Learning Crash Course: Embeddings, Google for Developers. Read 27/11/2026.In this module, you'll learn how to create embeddings, lower-dimensional representations of sparse data, that address these issues.