liveBook · Manning

Schema

As explained in Generative AI in Action

A schema is a formal specification of the structure and permitted content of a data representation.

A schema formally specifies the structure and permitted content of a data representation. In retrieval systems, it turns source records into searchable fields; in prompt engineering, it constrains generated JSON to an intended shape. section 8.3 section 6.4.1

A schema can assign different roles to fields:

  • Tag fields store categorical labels that support Boolean filtering. section 8.3
  • Text fields store titles, descriptions, dates, and content for full-text search. section 8.3
  • Vector fields store embeddings with an indexing algorithm, numeric type, dimension, and distance metric. section 8.3
  • A JSON schema prompt lists allowed output fields and discourages additional fields. section 6.4.1

Blog retrieval index

A Redis index named posts defines url as a tag, title and content as text, and embedding as an HNSW vector with FLOAT32 values, 1536 dimensions, and cosine distance. The schema is then supplied when creating the index.

Constrained entity extraction

A system instruction asks an AI assistant to extract entities as JSON using only the_name, the_company, and a_phone_number. Tightening the schema prevents an unwanted the_email field from being added.

How Generative AI in Action covers it

How deep it goes
Defines concrete fields, types, vector parameters, and permitted JSON keys through implementation examples.
Examples
Uses a blog-post Redis index and a pet-salon entity-extraction prompt with controlled JSON fields.
What it assumes
Assumes familiarity with data fields and basic Python or prompt construction while demonstrating field roles from concrete examples.
What you can do after
Apply it via Redis index creation or prompt instructions to organize searchable records and shape extracted JSON.
How it connects
Connects data schemas with Redis, full-text search, vector similarity search, embeddings, JSON, and entity extraction.

Also explained in

Compare how 44 books explain schema →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Generative AI in Action. The section links point to the parts of the book it draws on.