Inspiration
Modern e-commerce search relies heavily on static keyword matching, which often fails to capture complex user intent or adapt to mid-conversation changes. We built EntropyAgent, a multi-turn shopping agent that turns vague customer requests into precise, top-ranked recommendations within 10 turns—all while running completely offline, without sending customer data to external cloud services.
What it does
Our agent processes multi-turn shopping interactions through a 5-step pipeline:
1. Structured Memory & Intent Override Handling
Tracks hard constraints, declined preferences, and previously shown products. If a shopper changes their mind, stale constraints are retired automatically.
2. Field-Weighted Lexical Retrieval
Queries a 50,000-product catalog using SQLite FTS5 BM25 with dynamic field weights across titles, categories, features, and details.
3. Catalog-Grounded Concept Reranking
Converts items into up to 16 canonical concepts (e.g., category, material, color, use_case) and reranks candidates using local vector embeddings (when LLM is enabled):
$$\text{Similarity}(q, d) = \frac{\mathbf{q} \cdot \mathbf{d}}{\Vert{}\mathbf{q}\Vert{} \Vert{}\mathbf{d}\Vert{}}$$
4. Information-Gain Clarification
Calculates rank-weighted entropy over the current candidate pool to dynamically select the single most informative attribute question:
$$\text{GainRatio}(A) = \frac{\text{Entropy}(S) - \text{Entropy}_A(S)}{\text{SplitInfo}(A)}$$
5. Grounded Top-10 Output Returns up to 10 valid, unseen product recommendations alongside the next clarification query.
How we built it
• Development Tools: VS Code, Python 3.10+, SQLite FTS5, Codex, Claude Code
• AI & Local Modeling: Ollama (llama3.2:3b for catalog-constrained concept selection and nomic-embed-text-v2-moe for local semantic embeddings)
• Core Algorithms: Custom rank-weighted entropy question selection, field-weighted BM25 lexical indexing, and vector cosine similarity
• Datasets & Assets Used: Amazon Reviews 2023 (50,000-product frozen dataset)
Challenges we ran into
Embedding raw product rows was noisy and slow. We optimized this by generating structured canonical attribute indices (catalog_attributes.jsonl) and embedding unique canonical concepts into SQLite once.
Accomplishments that we're proud of
• Jumped from 12.5% Hit Rate@10 on the baseline to 98.5%, while reducing average resolution speed from 9.8 turns to 3.4 turns.
• Achieved high performance running locally at $0 cloud API cost.
• Designed a deterministic fallback path that operates smoothly even when Ollama is disabled.
What we learned
We gained deep insights into constructing fast SQLite full-text indices, implementing information-gain algorithms for decision trees in conversational recommendation systems, and balancing local embedding quality with real-time response constraints.
We also learned that sometimes, simple is better. Overcomplicating things sometimes lead to worse products.
What's next for We Need Sleep
• Expanding hybrid retrieval tuning across edge-case user scenarios.
• Supporting multi-modal visual search (product images) alongside text-based conversation.



Log in or sign up for Devpost to join the conversation.