Datasets:
File size: 9,158 Bytes
9463616 ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec 9463616 ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec ec45f80 f8e11ec | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | ---
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 |