liveBook · Manning

Collection

As explained in AI Agents and Applications

A collection is a Chroma container for documents, embeddings, metadata, and identifiers.

A collection is a Chroma container for documents, embeddings, metadata, and identifiers. It gives a retrieval application a named place to ingest content and search its meaning rather than resending the full source with every question. section 6.2.5

A practical collection workflow is:

  • Create a collection from a Chroma client, choosing an in-memory client for temporary work or a persistent/client-server setup when data must survive the session. section 6.2.5
  • Split source content into documents or chunks, then add the text with metadata such as its source and an associated identifier. section 6.2.5 section 8.3.4
  • Let Chroma generate embeddings from supplied text by default, or provide an embedding function when using the LangChain integration. section 6.2.5 section 8.3.4
  • Query the collection with natural language and inspect returned documents, identifiers, metadata, and distances; increase the requested result count when broader context is needed. section 6.2.5

One collection, one semantic search

A tourism collection can store three Paestum chunks, each with a Britannica source URL and an identifier. Querying “How many Doric temples are in Paestum” returns the closest chunk containing the answer, together with its metadata and distance. section 6.2.5

Listing 6.1 Creating and populating a ChromaDB collection
tourism_collection.add(
    documents=[
        "Paestum, Greek Poseidonia, …[shortened] … Greek temples.", 
        "Poseidonia was probably …[shortened] … in the 18th century.",
        "The ancient Greek part of …[shortened] … from the site."
    ],
    metadatas=[
        {"source": "https://www.britannica.com/place/Paestum"}, 
        {"source": "https://www.britannica.com/place/Paestum"},
        {"source": "https://www.britannica.com/place/Paestum"}
    ],
    ids=["paestum-br-01", "paestum-br-02", "paestum-br-03"]
)

Inspect the complete add operation, including documents, source metadata, and stable identifiers. section 6.2.5

client = chromadb.PersistentClient(path="./chroma_db")
collection = client.create_collection("my_persistent_collection")

Compare an in-memory collection with a collection backed by a persistent Chroma path. section 6.2.5

How AI Agents and Applications covers it

How deep it goes
Explains creation, ingestion, embeddings, metadata, identifiers, querying, chunk granularity, and persistence, but not storage internals.
Examples
Demonstrates Paestum tourism chunks, Cornwall HTML chunks, granular and coarse collections, and multiple UK destination collections.
What it assumes
Assumes basic Python, virtual environments, notebooks, and package installation while introducing collection and embedding workflow.
What you can do after
Build it from scratch with Chroma or LangChain, populate it with chunked documents, and run similarity queries against the stored content.
How it connects
Connects collections with embeddings, vector databases, metadata, document chunking, semantic search, and persistence.

Also explained in

Compare how 16 books explain collection →

Related concepts

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