Integrate Chroma and design semantic search API
System Design: Add Semantic Search to an Existing CRUD Service Using Chroma
Context
You own a document CRUD service (create/read/update/delete) that stores documents with an ID, text body, and optional metadata. Extend this service by integrating a Chroma vector store to support semantic search over documents. Assume you can add a background worker if needed, but aim for a minimal, production-ready design.
Tasks
- Define the vector collection schema and explain how text embeddings are produced (model choice, dimensionality, normalization, and how metadata is stored).
- Implement API endpoints to:
- Upsert documents into the vector store.
- Delete documents (by ID and/or by metadata filter).
- Query by vector similarity (semantic search) with optional metadata filters.
- Implement a
search_queryfunction that returns a response object with a requiredresultslist (may be empty; neverNone). Include per-result scores and metadata. - Describe how you would handle:
- Indexing strategy and parameters.
- Pagination for vector search results.
- Filtering by metadata.
- Eventual consistency between the CRUD store and the vector index.
- Discuss production concerns: latency targets, batching strategies, and error handling (including retries, timeouts, and idempotency).
AI interview prep
Core dilemma
Balancing the operational complexity, data consistency, and performance trade-offs of integrating a specialized vector store (Chroma) with an existing transactional CRUD service, while ensuring a scalable and resilient semantic search capability.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Integrate Chroma and design semantic search API
System Design: Add Semantic Search to an Existing CRUD Service Using Chroma
Context
You own a document CRUD service (create/read/update/delete) that stores documents with an ID, text body, and optional metadata. Extend this service by integrating a Chroma vector store to support semantic search over documents. Assume you can add a background worker if needed, but aim for a minimal, production-ready design.
Tasks
- Define the vector collection schema and explain how text embeddings are produced (model choice, dimensionality, normalization, and how metadata is stored).
- Implement API endpoints to:
- Upsert documents into the vector store.
- Delete documents (by ID and/or by metadata filter).
- Query by vector similarity (semantic search) with optional metadata filters.
- Implement a
search_queryfunction that returns a response object with a requiredresultslist (may be empty; neverNone). Include per-result scores and metadata. - Describe how you would handle:
- Indexing strategy and parameters.
- Pagination for vector search results.
- Filtering by metadata.
- Eventual consistency between the CRUD store and the vector index.
- Discuss production concerns: latency targets, batching strategies, and error handling (including retries, timeouts, and idempotency).