liveBook · Manning

Embedding

As explained in Data Pipelines with Apache Airflow, Second Edition

A vector is an ordered numerical quantity representing a point, direction, or set of measurable attributes in a multidimensional space.

Suppose a recipe collection contains thousands of entries and someone asks, “How can I make lasagna?” Searching only for matching words may miss a relevant recipe phrased differently. An embedding is a numerical vector representation of text: it gives the question and recipes a form that can be compared for similarity. section 14.10.1 section 14.3

A small vector space

Imagine placing recipes on two scales: mild to spicy and savory to sweet. Each recipe becomes a point described by two numbers. A poke-bowl recipe could then be compared with stored recipes, with sushi emerging as a nearby match. Real recipe embeddings are generated from text rather than assigned flavor scores; the two-dimensional example makes the comparison visible. section 14.3

In a recipe retrieval workflow:

  • Convert stored recipe text into embeddings and keep them in a vector database. An embedding model determines the numerical representation; text-embedding-3-large is one model used for this job. section 14.6.1
  • Embed the user’s question with the same model used for the stored recipes, then run a vector similarity search to retrieve relevant documents. section 14.10.1
  • For retrieval-augmented generation (RAG), combine the question with retrieved recipes and pass that context to a language model to generate an answer. Airflow can automate ingestion, chunking, embedding generation, and vector-database updates. section 14.3 section 14.11
Figure 14.17 In the retrieval workflow, we can embed a user’s question and perform a similarity search in the database using cosine similarity. The vector database returns the documents that are most relevant to the question.

The retrieval diagram shows why both the stored documents and the incoming question need vector representations: similarity search compares them before returning relevant documents. section 14.10.1

Similarity depends on how vectors are compared. The flavor-space example first uses proximity to explain related recipes. For text, cosine similarity emphasizes vector direction rather than exact numerical values, helping compare recipes whose wording differs but whose meaning is similar. Vectors pointing in the same direction have cosine similarity of 1. section 14.10.1

Configure the embedding model

A Weaviate collection can receive its embedding setup through `vectorizer_config=[get_vectorizer_config(embedding_model)]`. The configuration function selects an OpenAI API or Azure OpenAI vectorizer according to `OPENAI_CONN_TYPE`; the collection-creation command supplies the model name. This keeps provider-specific settings out of the collection definition while making the model choice explicit. section 14.6.1

How Data Pipelines with Apache Airflow, Second Edition covers it

How deep it goes
Explains vectors through a two-dimensional analogy and cosine similarity, but sets embedding-model training details aside.
Examples
Uses flavor coordinates, a poke-bowl-to-sushi comparison, a lasagna question, and Weaviate vectorizer configuration.
What it assumes
Introduces vectors with a two-dimensional recipe example and does not require embedding-model training details.
What you can do after
Operate/configure it by choosing a recipe embedding model, configuring a Weaviate collection, and embedding questions for retrieval.
How it connects
Connects embedding models with vector databases, cosine similarity, retrieval-augmented generation, and Airflow data pipelines.

Also explained in

Compare how 47 books explain embedding →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Pipelines with Apache Airflow, Second Edition. The section links point to the parts of the book it draws on.