Tiktok TechJam 2026 Submission - Track 4 - Team Taisp Taisp Baby

Overview

This project is an AI-powered conversational shopping agent built for the TechJam E-Commerce Search Challenge. The goal of the agent is to act as a shopping copilot, conversing with customers to uncover their hidden target product within a maximum of 10 conversational turns. It is built to operate efficiently against a frozen catalog of 50,000 products from the Amazon Reviews 2023 dataset (Clothing, Shoes, and Jewelry).

The project is structured with a deterministic, scored baseline that relies entirely on the Python standard library, alongside an LLM path that introduces generative AI components as robust fallbacks.

System Architecture: Scored vs. LLM Path

The pipeline is split into the official scored path (fast, deterministic, zero-dependency) and an LLM path. If any LLM component fails or rejects the input, the system seamlessly falls back to the deterministic path.

1. Understanding & State Tracking

  • Scored Path: A template and dialogue-act regex parser instantly converts customer messages into a typed state of constraints (e.g., size, color) and handles exact retractions/refusals.
  • LLM Path (Fall-through): If the user inputs free text that the regex parser cannot match, the message falls through to a local Qwen/Qwen2.5-1.5B-Instruct model for extraction. This preserves exactness on the benchmark while providing robustness for real-world dialogue.

2. Retrieval Pipeline

  • Scored Path (Sparse): Uses field-weighted exact-match full-text searches against an in-memory SQLite FTS5 BM25 database.
  • LLM Path (Dense Hybrid): Uses Qwen to rewrite the semantic query (incorporating background preference_tags), then retrieves vectors using a local sentence-transformers/all-MiniLM-L6-v2 model. The sparse and dense results are then fused using Weighted Reciprocal-Rank Fusion (RRF).

3. Constraint Reranking

  • Scored Path: A constraint-aware reranker evaluates the Top 100 products from retrieval, verifying each stated constraint against the product metadata (exact, overlap, or miss scoring) to guarantee the final Top 10 recommendations adhere strictly to user requirements.

4. Clarification & Question Policy

  • Scored Path: Defaults to a deterministic, static other question policy (e.g., "What other preferences should I consider?").
  • LLM Path (Shannon Entropy): Dynamically calculates which product attribute is mathematically most useful to ask about next. It uses Shannon Entropy and Expected Information Gain over the reranked candidate product pool to choose the question that will most effectively reduce uncertainty in the next turn.

Information-Theoretic Question Policy (Shannon Entropy)

In the LLM path, instead of relying on a language model or a static fallback to guess what to ask next, the agent dynamically decides which product attribute (e.g., "color" vs. "style") is mathematically most useful to ask about by calculating Shannon Entropy and Expected Information Gain over the candidate product pool.

The Mathematical Foundation

The system assumes that before a question is asked, any of the N candidate products is equally likely to be the user's hidden target. Thus, the prior entropy (uncertainty) is given by:

$$ H_{\text{prior}} = \log_2(N) $$

When the agent evaluates a potential question about a specific attribute (e.g., "material"), it partitions the candidate products into distinct groups based on their value for that attribute. The probability of a product belonging to a specific group is simply the number of candidates in that group divided by the total number of candidate products. The expected posterior entropy after asking the question is the weighted sum of the entropies of these new groups:

$$ H_{\text{posterior}} = \sum_{g} P(g) \log_2(C_g) = \sum_{g} \frac{C_g}{N} \log_2(C_g) $$

The Information Gain (entropy reduction) achieved by asking about that attribute is:

$$ \text{Information Gain} = H_{\text{prior}} - H_{\text{posterior}} = \log_2(N) - \sum_{g} \frac{C_g}{N} \log_2(C_g) $$

The Scoring Algorithm

For each possible question attribute, the agent calculates a final utility score using this formula:

$$ \text{Score} = W \times \left( \frac{\text{Information Gain}}{\log_2(N)} \right) \times R^P $$

Where:

  • Normalized Info Gain: The information gain divided by the prior entropy, which scales the value between 0 and 1.
  • Coverage Rate: The percentage of candidate products that actually possess metadata for this attribute.
  • Coverage Power: A hyperparameter used to penalize attributes that have low coverage.
  • Prior Weight: A hardcoded bias used to slightly favor natural-sounding questions.

Local Demo Console (UI)

The project includes a custom-built, lightweight local web UI designed for real-time visualization of the agent's decision-making process.

  • Zero-Dependency Backend: Powered entirely by Python's built-in http.server.
  • Vanilla Frontend: A single-file index.html application that renders the data safely without network calls.
  • Fail-Soft Introspection: A custom defensive probe (ui/probe.py) intercepts the agent's internal state.

Technical Stack

  • Languages: Python, HTML/JS/CSS.
  • Databases: SQLite (with FTS5).
  • AI/ML: Local Qwen2.5-1.5B-Instruct (Extraction, Rewrite, Generation), Local all-MiniLM-L6-v2 (Embeddings), transformers, torch, sentence-transformers.
  • Algorithms: BM25, Reciprocal Rank Fusion, Shannon Entropy.

Built With

Share this project:

Updates

Submission history