| --- |
| license: cc-by-sa-4.0 |
| language: |
| - en |
| task_categories: |
| - text-generation |
| - question-answering |
| tags: |
| - e-commerce |
| - query-rewriting |
| - context-aware |
| - conversational-search |
| - conversational-ai |
| - nlp |
| - llm |
| - fine-tuning |
| - intent-classification |
| - dialogue-systems |
| - retail |
| - search |
| pretty_name: E-Commerce Query Rewriting Dataset |
| size_categories: |
| - 1K<n<10K |
| --- |
| |
| # [#e-commerce-query-rewriting-dataset](#e-commerce-query-rewriting-dataset) E-Commerce Query Rewriting Dataset |
|
|
| **Hub:** [`mudasir13cs/ecommerce-query-rewriting`](https://huggingface.co/datasets/mudasir13cs/ecommerce-query-rewriting) |
|
|
| A dataset of **10,000 examples** pairing ambiguous, context-dependent user queries with their fully resolved, context-aware rewrites for e-commerce product search. Built for fine-tuning LLMs to resolve pronouns, ellipsis, ordinals, and other conversational shortcuts using prior search context — the kind of resolution real shopping assistants need to handle turns like *"show me that one"* or *"the cheaper one"*. |
|
|
| - [Dataset summary](#dataset-summary) |
| - [Dataset structure](#dataset-structure) |
| - [Dataset statistics](#dataset-statistics) |
| - [Query rewriting patterns](#query-rewriting-patterns) |
| - [Loading the dataset](#loading-the-dataset) |
| - [Training formats](#training-formats) |
| - [Use cases](#use-cases) |
| - [Quality assurance](#quality-assurance) |
| - [Citation](#citation) |
| - [License](#license) |
| - [Acknowledgments](#acknowledgments) |
| - [Author / contact](#author--contact) |
|
|
| ## [#dataset-summary](#dataset-summary) Dataset summary |
|
|
| Conversational commerce agents constantly receive queries that only make sense given prior turns — a pronoun ("it"), an ordinal ("the second one"), or a fragment ("with better camera"). This dataset provides supervised pairs of `(ambiguous query, conversation context) → (unambiguous rewritten query)` so models can learn to perform this resolution reliably before handing the query off to search or a product-detail lookup. |
|
|
| **Key features** |
|
|
| - Real-world-style e-commerce data spanning **Flipkart**, **Amazon**, and **MyOnlineShop** product catalogs |
| - Rich conversational context: previous search term, UI state, product list, and last executed command |
| - **7 distinct rewriting patterns** covering the most common ambiguity types in shopping dialogue |
| - Variable product-list sizes (1–10 items) for realistic search-result scenarios |
| - Ready-to-use instruction-tuning format for both **query rewriting** and **intent classification** |
|
|
| ## [#dataset-structure](#dataset-structure) Dataset structure |
|
|
| Each example contains: |
|
|
| | Field | Type | Description | |
| |---|---|---| |
| | `original_query` | `string` | Ambiguous user query requiring context resolution | |
| | `context.last_search_query` | `string` | Previous search category or term | |
| | `context.current_state` | `string` | UI state — `SEARCH_RESULTS`, `PRODUCT_DETAIL`, or `INITIAL` | |
| | `context.product_titles` | `list[string]` | Product names from the last search (1–10 items) | |
| | `context.last_command` | `string` | Previously executed system command | |
| | `context.product_count` | `int` | Number of products in context (1–10) | |
| | `rewritten_query` | `string` | Clear, unambiguous query with references resolved | |
| | `intent` | `string` | User intent — `search`, `show_detail`, `go_back`, `close` | |
| | `command` | `string` | System command — `show_list`, `show_item`, `go_back`, `close` | |
|
|
| **Example** |
|
|
| ```json |
| { |
| "original_query": "show me that one", |
| "context": { |
| "last_search_query": "Smartphones", |
| "current_state": "SEARCH_RESULTS", |
| "product_titles": [ |
| "iPhone 15 Pro", |
| "Samsung Galaxy S24", |
| "OnePlus 12", |
| "Google Pixel 8", |
| "Xiaomi 14", |
| "Nothing Phone 2" |
| ], |
| "last_command": "show_list", |
| "product_count": 6 |
| }, |
| "rewritten_query": "show me details of iPhone 15 Pro from Smartphones search", |
| "intent": "show_detail", |
| "command": "show_item" |
| } |
| ``` |
|
|
| ## [#dataset-statistics](#dataset-statistics) Dataset statistics |
|
|
| **Overall** |
|
|
| - Total examples: **10,000** |
| - Product sources: Flipkart, Amazon, MyOnlineShop |
| - Format: JSON, instruction–input–output ready |
|
|
| **Intent distribution** |
|
|
| | Intent | Count | % | |
| |---|---|---| |
| | `show_detail` | 6,000 | 60.0% | |
| | `search` | 3,500 | 35.0% | |
| | `navigation` | 500 | 5.0% | |
|
|
| **Command distribution** |
|
|
| | Command | Count | % | |
| |---|---|---| |
| | `show_item` | 6,000 | 60.0% | |
| | `show_list` | 3,500 | 35.0% | |
| | `go_back` | 500 | 5.0% | |
|
|
| **State distribution** |
|
|
| | State | Count | % | |
| |---|---|---| |
| | `SEARCH_RESULTS` | 8,024 | 80.2% | |
| | `PRODUCT_DETAIL` | 1,976 | 19.8% | |
|
|
| ## [#query-rewriting-patterns](#query-rewriting-patterns) Query rewriting patterns |
|
|
| | # | Pattern | Share | Example | |
| |---|---|---|---| |
| | 1 | **Pronoun resolution** | ~30% | `"show me that one"` → `"show me details of iPhone 15 Pro from Smartphones search"` | |
| | 2 | **Ellipsis** | ~20% | `"find cheaper"` → `"find Smartphones cheaper than 50000"` | |
| | 3 | **Ordinals** | ~15% | `"show me first"` → `"show me details of iPhone 15 Pro from Smartphones search"` | |
| | 4 | **Product references** | ~15% | `"tell me about iPhone"` → `"show me details of iPhone 15 Pro from Smartphones search"` | |
| | 5 | **Price / category** | ~10% | `"show me under 50000"` → `"show me Smartphones under 50000"` | |
| | 6 | **Navigation** | ~5% | `"go back"` → `"return to Smartphones search results"` | |
| | 7 | **Refinements** | ~5% | `"higher rating"` → `"find Smartphones higher rating"` | |
|
|
| ## [#loading-the-dataset](#loading-the-dataset) Loading the dataset |
|
|
| **Using 🤗 Datasets (recommended)** |
|
|
| ```python |
| from datasets import load_dataset |
| |
| dataset = load_dataset("mudasir13cs/ecommerce-query-rewriting") |
| |
| train_data = dataset["train"] |
| print(train_data[0]) |
| ``` |
|
|
| **Direct JSON loading** |
|
|
| ```python |
| import json |
| |
| with open("dataset_complete.json", "r") as f: |
| data = json.load(f) |
| ``` |
|
|
| ## [#training-formats](#training-formats) Training formats |
|
|
| **Query rewriter** |
|
|
| ```json |
| { |
| "instruction": "Rewrite the ambiguous query using the provided context to make it clear and searchable.", |
| "input": "Context:\nPrevious search: Smartphones\nState: SEARCH_RESULTS\nProducts (6): iPhone 15 Pro, Samsung Galaxy S24, ...\n\nQuery: show me that one", |
| "output": "show me details of iPhone 15 Pro from Smartphones search" |
| } |
| ``` |
|
|
| **Intent classifier** |
|
|
| ```json |
| { |
| "instruction": "Classify the user's intent based on the query and context.", |
| "input": "Context:\nPrevious search: Smartphones\nState: SEARCH_RESULTS\nProducts (6): iPhone 15 Pro, Samsung Galaxy S24, ...\n\nQuery: show me that one", |
| "output": "show_detail" |
| } |
| ``` |
|
|
| ## [#use-cases](#use-cases) Use cases |
|
|
| - **Fine-tuning query rewriting models** — train LLMs to resolve ambiguous queries with `(context, query) → rewritten_query` pairs |
| - **Intent classification** — train classifiers on the `intent` field for dialogue-state routing |
| - **Conversational search systems** — build production agents that maintain and resolve context across turns |
| - **Research & evaluation** — benchmark rewriting approaches, study ambiguity resolution, and analyze conversational search patterns |
|
|
| ```python |
| def rewrite_query(query, context): |
| # Use a fine-tuned model to resolve the query against context |
| return model.predict(query, context) |
| ``` |
|
|
| ## [#quality-assurance](#quality-assurance) Quality assurance |
|
|
| Every example is validated for: |
|
|
| - Presence of both `original_query` and `rewritten_query` |
| - Complete, well-formed `context` object |
| - Rewritten query is strictly longer and more specific than the original |
| - Valid `intent` and `command` values |
| - `product_count` within the valid range (1–10) |
|
|
| ## [#citation](#citation) Citation |
|
|
| If you use this dataset in your research, please cite: |
|
|
| ```bibtex |
| @dataset{ecommerce_query_rewriting_2026, |
| title={E-Commerce Query Rewriting Dataset for Context-Aware Conversational Search}, |
| author={Syed Mudasir}, |
| year={2026}, |
| url={https://huggingface.co/datasets/mudasir13cs/ecommerce-query-rewriting}, |
| note={Dataset for fine-tuning context-aware query rewriting models in e-commerce} |
| } |
| ``` |
|
|
| ## [#license](#license) License |
|
|
| Released under **Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)**. |
|
|
| - ✅ Commercial use allowed |
| - ✅ Modification allowed |
| - ✅ Distribution allowed |
| - ✅ Private use allowed |
| - ⚠️ Attribution required |
| - ⚠️ ShareAlike — derivatives must use the same license |
|
|
| ## [#acknowledgments](#acknowledgments) Acknowledgments |
|
|
| - Product data sources: **Flipkart**, **Amazon**, **MyOnlineShop** |
| - The open-source ML community for tooling and frameworks |
| - **Hugging Face** for dataset hosting infrastructure |
|
|
| ## [#author--contact](#author--contact) Author / contact |
|
|
| **Mudasir** — multimodal AI, VLM fine-tuning, retrieval/RAG research, and applied NLP engineering; **MS AI Convergence**, [Soongsil University](https://ssu.ac.kr/), Seoul. More projects and publications: **[mudasir13cs.github.io](https://mudasir13cs.github.io/)** |
|
|
| - **Hugging Face:** [@mudasir13cs](https://huggingface.co/mudasir13cs) |
| - **GitHub:** [@mudasir13cs](https://github.com/mudasir13cs) |
| - **Email:** mudasir13cs@gmail.com |
|
|
| --- |
|
|
| **Version:** 1.0 · **Last updated:** July 2026 |