From JSON to Vector Search: What I Learned Storing Structured User Data for AI
说明与用途
文章说明了 SpendWise 如何将结构化用户数据集成到向量数据库中以实现语义搜索,同时保留关系数据库以处理确定性查询。
问题
How to make structured user data retrievable for an AI when the user asks context‑dependent questions?
结果
The hybrid architecture allowed SpendWise to provide contextually relevant user information to the LLM without over‑loading the vector store with data that is better served by SQL queries.
工作流
- Collect structured user data during onboarding
- Convert relevant fields to a natural‑language paragraph
- Generate embeddings with an embedding model
- Store embeddings in a vector database with metadata linking back to the original JSON
- When a user asks a question, determine if it requires semantic similarity or exact match
- If semantic, query vector store for relevant context
- If deterministic, query PostgreSQL directly
- Feed retrieved context to the LLM for response
证据
When we were building SpendWise, one of the things we wanted was pretty simple: The AI should know something about the user before answering them.
The AI might need context such as: {"investment_experience":"Beginner","risk_preference":"Moderate","financial_goal":"Buy a house in 5 years"}
If I need: expenses > ₹10,000 ... SQL is extremely good at that.
- 记录日期: 2026-10-06T19:41:01.743Z