Datasets:
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,45 +1,318 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
list: string
|
| 18 |
-
- name: rewritten_query
|
| 19 |
-
dtype: string
|
| 20 |
-
- name: intent
|
| 21 |
-
dtype: string
|
| 22 |
-
- name: command
|
| 23 |
-
dtype: string
|
| 24 |
-
splits:
|
| 25 |
-
- name: train
|
| 26 |
-
num_bytes: 3076348
|
| 27 |
-
num_examples: 8000
|
| 28 |
-
- name: validation
|
| 29 |
-
num_bytes: 380874
|
| 30 |
-
num_examples: 1000
|
| 31 |
-
- name: test
|
| 32 |
-
num_bytes: 379162
|
| 33 |
-
num_examples: 1000
|
| 34 |
-
download_size: 887179
|
| 35 |
-
dataset_size: 3836384
|
| 36 |
-
configs:
|
| 37 |
-
- config_name: default
|
| 38 |
-
data_files:
|
| 39 |
-
- split: train
|
| 40 |
-
path: data/train-*
|
| 41 |
-
- split: validation
|
| 42 |
-
path: data/validation-*
|
| 43 |
-
- split: test
|
| 44 |
-
path: data/test-*
|
| 45 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: cc-by-sa-4.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- text-generation
|
| 5 |
+
- conversational-ai
|
| 6 |
+
- question-answering
|
| 7 |
+
tags:
|
| 8 |
+
- e-commerce
|
| 9 |
+
- query-rewriting
|
| 10 |
+
- context-aware
|
| 11 |
+
- conversational-search
|
| 12 |
+
- nlp
|
| 13 |
+
- llm
|
| 14 |
+
- fine-tuning
|
| 15 |
+
size_categories:
|
| 16 |
+
- 10K<n<100K
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
---
|
| 18 |
+
|
| 19 |
+
# E-Commerce Query Rewriting Dataset
|
| 20 |
+
|
| 21 |
+
A comprehensive dataset for fine-tuning context-aware query rewriting models in e-commerce conversational agents.
|
| 22 |
+
|
| 23 |
+
## Dataset Summary
|
| 24 |
+
|
| 25 |
+
This dataset contains **10,000 examples** of ambiguous user queries and their context-aware rewritten versions for e-commerce product search. It is designed to train models that can resolve pronouns, ellipsis, ordinals, and other ambiguous references using conversation context.
|
| 26 |
+
|
| 27 |
+
### Key Features
|
| 28 |
+
|
| 29 |
+
- ✅ **Real-world e-commerce data** from Flipkart, Amazon, and MyOnlineShop
|
| 30 |
+
- ✅ **Multi-context information** including previous searches, product lists, and conversation state
|
| 31 |
+
- ✅ **7 distinct query rewriting patterns** covering common ambiguity types
|
| 32 |
+
- ✅ **Variable product counts** (1-10 products) for realistic scenarios
|
| 33 |
+
- ✅ **Well-structured format** ready for fine-tuning LLMs
|
| 34 |
+
|
| 35 |
+
## Dataset Structure
|
| 36 |
+
|
| 37 |
+
### Fields
|
| 38 |
+
|
| 39 |
+
Each example contains:
|
| 40 |
+
|
| 41 |
+
- **`original_query`** (string): Ambiguous user query requiring context resolution
|
| 42 |
+
- **`context`** (dict): Conversation context including:
|
| 43 |
+
- `last_search_query` (string): Previous search category/term
|
| 44 |
+
- `current_state` (string): Current UI state (SEARCH_RESULTS, PRODUCT_DETAIL, INITIAL)
|
| 45 |
+
- `product_titles` (list): List of product names from last search (1-10 items)
|
| 46 |
+
- `last_command` (string): Previous command executed
|
| 47 |
+
- `product_count` (int): Number of products in context (1-10)
|
| 48 |
+
- **`rewritten_query`** (string): Clear, unambiguous query with resolved references
|
| 49 |
+
- **`intent`** (string): User intent (search, show_detail, go_back, close)
|
| 50 |
+
- **`command`** (string): System command (show_list, show_item, go_back, close)
|
| 51 |
+
|
| 52 |
+
### Example
|
| 53 |
+
|
| 54 |
+
```json
|
| 55 |
+
{
|
| 56 |
+
"original_query": "show me that one",
|
| 57 |
+
"context": {
|
| 58 |
+
"last_search_query": "Smartphones",
|
| 59 |
+
"current_state": "SEARCH_RESULTS",
|
| 60 |
+
"product_titles": [
|
| 61 |
+
"iPhone 15 Pro",
|
| 62 |
+
"Samsung Galaxy S24",
|
| 63 |
+
"OnePlus 12",
|
| 64 |
+
"Google Pixel 8",
|
| 65 |
+
"Xiaomi 14",
|
| 66 |
+
"Nothing Phone 2"
|
| 67 |
+
],
|
| 68 |
+
"last_command": "show_list",
|
| 69 |
+
"product_count": 6
|
| 70 |
+
},
|
| 71 |
+
"rewritten_query": "show me details of iPhone 15 Pro from Smartphones search",
|
| 72 |
+
"intent": "show_detail",
|
| 73 |
+
"command": "show_item"
|
| 74 |
+
}
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
## Dataset Statistics
|
| 78 |
+
|
| 79 |
+
### Overall Statistics
|
| 80 |
+
|
| 81 |
+
- **Total Examples**: 10,000
|
| 82 |
+
- **Product Sources**: Flipkart, Amazon, MyOnlineShop
|
| 83 |
+
- **Format**: JSON with instruction-input-output structure
|
| 84 |
+
|
| 85 |
+
### Intent Distribution
|
| 86 |
+
|
| 87 |
+
- **show_detail**: 6,000 (60.0%)
|
| 88 |
+
- **search**: 3,500 (35.0%)
|
| 89 |
+
- **navigation**: 500 (5.0%)
|
| 90 |
+
|
| 91 |
+
### Command Distribution
|
| 92 |
+
|
| 93 |
+
- **show_item**: 6,000 (60.0%)
|
| 94 |
+
- **show_list**: 3,500 (35.0%)
|
| 95 |
+
- **go_back**: 500 (5.0%)
|
| 96 |
+
|
| 97 |
+
### State Distribution
|
| 98 |
+
|
| 99 |
+
- **SEARCH_RESULTS**: 8,024 (80.2%)
|
| 100 |
+
- **PRODUCT_DETAIL**: 1,976 (19.8%)
|
| 101 |
+
|
| 102 |
+
## Query Rewriting Patterns
|
| 103 |
+
|
| 104 |
+
The dataset covers 7 distinct patterns of query rewriting:
|
| 105 |
+
|
| 106 |
+
### 1. Pronoun Resolution (~30%)
|
| 107 |
+
|
| 108 |
+
Resolves pronouns ("that", "it", "one") to specific product names using context.
|
| 109 |
+
|
| 110 |
+
**Examples:**
|
| 111 |
+
- `"show me that one"` → `"show me details of iPhone 15 Pro from Smartphones search"`
|
| 112 |
+
- `"tell me about it"` → `"show me details of Samsung Galaxy S24 from Smartphones search"`
|
| 113 |
+
|
| 114 |
+
### 2. Ellipsis (~20%)
|
| 115 |
+
|
| 116 |
+
Expands incomplete queries by adding missing information from context.
|
| 117 |
+
|
| 118 |
+
**Examples:**
|
| 119 |
+
- `"find cheaper"` → `"find Smartphones cheaper than 50000"`
|
| 120 |
+
- `"with camera"` → `"find Smartphones with camera"`
|
| 121 |
+
|
| 122 |
+
### 3. Ordinals (~15%)
|
| 123 |
+
|
| 124 |
+
Converts ordinal references ("first", "second") to specific product names.
|
| 125 |
+
|
| 126 |
+
**Examples:**
|
| 127 |
+
- `"show me first"` → `"show me details of iPhone 15 Pro from Smartphones search"`
|
| 128 |
+
- `"details of second"` → `"show me details of Samsung Galaxy S24 from Smartphones search"`
|
| 129 |
+
|
| 130 |
+
### 4. Product References (~15%)
|
| 131 |
+
|
| 132 |
+
Resolves partial product names to full product names.
|
| 133 |
+
|
| 134 |
+
**Examples:**
|
| 135 |
+
- `"tell me about iPhone"` → `"show me details of iPhone 15 Pro from Smartphones search"`
|
| 136 |
+
- `"show Samsung"` → `"show me details of Samsung Galaxy S24 from Smartphones search"`
|
| 137 |
+
|
| 138 |
+
### 5. Price/Category (~10%)
|
| 139 |
+
|
| 140 |
+
Adds missing category or price information to queries.
|
| 141 |
+
|
| 142 |
+
**Examples:**
|
| 143 |
+
- `"show me under 50000"` → `"show me Smartphones under 50000"`
|
| 144 |
+
- `"find below 30000"` → `"show me Smartphones below 30000"`
|
| 145 |
+
|
| 146 |
+
### 6. Navigation (~5%)
|
| 147 |
+
|
| 148 |
+
Converts navigation commands to explicit queries.
|
| 149 |
+
|
| 150 |
+
**Examples:**
|
| 151 |
+
- `"go back"` → `"return to Smartphones search results"`
|
| 152 |
+
- `"show list again"` → `"return to Smartphones search results"`
|
| 153 |
+
|
| 154 |
+
### 7. Refinements (~5%)
|
| 155 |
+
|
| 156 |
+
Expands refinement queries with category information.
|
| 157 |
+
|
| 158 |
+
**Examples:**
|
| 159 |
+
- `"with better camera"` → `"find Smartphones with better camera"`
|
| 160 |
+
- `"higher rating"` → `"find Smartphones higher rating"`
|
| 161 |
+
|
| 162 |
+
## Use Cases
|
| 163 |
+
|
| 164 |
+
### 1. Fine-tuning Query Rewriting Models
|
| 165 |
+
|
| 166 |
+
Train LLMs to rewrite ambiguous queries using conversation context:
|
| 167 |
+
|
| 168 |
+
```python
|
| 169 |
+
from datasets import load_dataset
|
| 170 |
+
|
| 171 |
+
dataset = load_dataset("mudasir13cs/E-commerce-query-rewriting-dataset", private=True)
|
| 172 |
+
|
| 173 |
+
# Format for training
|
| 174 |
+
for example in dataset["train"]:
|
| 175 |
+
input_text = f"Context: {example['context']}\nQuery: {example['original_query']}"
|
| 176 |
+
target_text = example["rewritten_query"]
|
| 177 |
+
# Train model...
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
### 2. Intent Classification
|
| 181 |
+
|
| 182 |
+
Train models to classify user intent from queries and context:
|
| 183 |
+
|
| 184 |
+
```python
|
| 185 |
+
# Use intent field for classification
|
| 186 |
+
for example in dataset["train"]:
|
| 187 |
+
input_text = f"Context: {example['context']}\nQuery: {example['original_query']}"
|
| 188 |
+
intent = example["intent"] # search, show_detail, go_back, close
|
| 189 |
+
# Train classifier...
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
### 3. Conversational Search Systems
|
| 193 |
+
|
| 194 |
+
Build e-commerce conversational agents that understand context:
|
| 195 |
+
|
| 196 |
+
```python
|
| 197 |
+
# Use in production systems
|
| 198 |
+
def rewrite_query(query, context):
|
| 199 |
+
# Use fine-tuned model to rewrite query
|
| 200 |
+
rewritten = model.predict(query, context)
|
| 201 |
+
return rewritten
|
| 202 |
+
```
|
| 203 |
+
|
| 204 |
+
### 4. Research and Evaluation
|
| 205 |
+
|
| 206 |
+
- Benchmark query rewriting approaches
|
| 207 |
+
- Evaluate context-aware search systems
|
| 208 |
+
- Study ambiguity resolution in e-commerce
|
| 209 |
+
- Analyze conversational patterns
|
| 210 |
+
|
| 211 |
+
## Loading the Dataset
|
| 212 |
+
|
| 213 |
+
### Using HuggingFace Datasets
|
| 214 |
+
|
| 215 |
+
```python
|
| 216 |
+
from datasets import load_dataset
|
| 217 |
+
|
| 218 |
+
# Load the dataset (requires authentication for private repos)
|
| 219 |
+
dataset = load_dataset(
|
| 220 |
+
"mudasir13cs/E-commerce-query-rewriting-dataset",
|
| 221 |
+
private=True
|
| 222 |
+
)
|
| 223 |
+
|
| 224 |
+
# Access splits
|
| 225 |
+
train_data = dataset["train"]
|
| 226 |
+
val_data = dataset["validation"]
|
| 227 |
+
test_data = dataset["test"]
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
### Direct JSON Loading
|
| 231 |
+
|
| 232 |
+
```python
|
| 233 |
+
import json
|
| 234 |
+
|
| 235 |
+
# Load from local file
|
| 236 |
+
with open("dataset_complete.json", "r") as f:
|
| 237 |
+
data = json.load(f)
|
| 238 |
+
```
|
| 239 |
+
|
| 240 |
+
## Dataset Format for Training
|
| 241 |
+
|
| 242 |
+
### Query Rewriter Format
|
| 243 |
+
|
| 244 |
+
```json
|
| 245 |
+
{
|
| 246 |
+
"instruction": "Rewrite the ambiguous query using the provided context to make it clear and searchable.",
|
| 247 |
+
"input": "Context:\nPrevious search: Smartphones\nState: SEARCH_RESULTS\nProducts (6): iPhone 15 Pro, Samsung Galaxy S24, ...\n\nQuery: show me that one",
|
| 248 |
+
"output": "show me details of iPhone 15 Pro from Smartphones search"
|
| 249 |
+
}
|
| 250 |
+
```
|
| 251 |
+
|
| 252 |
+
### Intent Classifier Format
|
| 253 |
+
|
| 254 |
+
```json
|
| 255 |
+
{
|
| 256 |
+
"instruction": "Classify the user's intent based on the query and context.",
|
| 257 |
+
"input": "Context:\nPrevious search: Smartphones\nState: SEARCH_RESULTS\nProducts (6): iPhone 15 Pro, Samsung Galaxy S24, ...\n\nQuery: show me that one",
|
| 258 |
+
"output": "show_detail"
|
| 259 |
+
}
|
| 260 |
+
```
|
| 261 |
+
|
| 262 |
+
## Quality Assurance
|
| 263 |
+
|
| 264 |
+
All examples are validated for:
|
| 265 |
+
|
| 266 |
+
- ✅ Has original query
|
| 267 |
+
- ✅ Has rewritten query
|
| 268 |
+
- ✅ Has complete context
|
| 269 |
+
- ✅ Rewritten query is longer/more specific
|
| 270 |
+
- ✅ Has valid intent and command
|
| 271 |
+
- ✅ Product count is within valid range (1-10)
|
| 272 |
+
|
| 273 |
+
## Citation
|
| 274 |
+
|
| 275 |
+
If you use this dataset in your research, please cite:
|
| 276 |
+
|
| 277 |
+
```bibtex
|
| 278 |
+
@dataset{ecommerce_query_rewriting_2025,
|
| 279 |
+
title={E-Commerce Query Rewriting Dataset for Context-Aware Conversational Search},
|
| 280 |
+
author={Syed Mudasir},
|
| 281 |
+
year={2025},
|
| 282 |
+
url={https://huggingface.co/datasets/mudasir13cs/E-commerce-query-rewriting-dataset},
|
| 283 |
+
note={Dataset for fine-tuning context-aware query rewriting models in e-commerce}
|
| 284 |
+
}
|
| 285 |
+
```
|
| 286 |
+
|
| 287 |
+
## License
|
| 288 |
+
|
| 289 |
+
This dataset is released under the **Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0)**.
|
| 290 |
+
|
| 291 |
+
### Terms of Use
|
| 292 |
+
|
| 293 |
+
- ✅ **Commercial use** allowed
|
| 294 |
+
- ✅ **Modification** allowed
|
| 295 |
+
- ✅ **Distribution** allowed
|
| 296 |
+
- ✅ **Private use** allowed
|
| 297 |
+
- ⚠️ **Attribution** required
|
| 298 |
+
- ⚠️ **ShareAlike** - derivatives must use same license
|
| 299 |
+
|
| 300 |
+
## Acknowledgments
|
| 301 |
+
|
| 302 |
+
- **Product Data Sources**: Flipkart, Amazon, MyOnlineShop
|
| 303 |
+
- **Open Source Community** for tools and frameworks
|
| 304 |
+
- **HuggingFace** for dataset hosting infrastructure
|
| 305 |
+
|
| 306 |
+
## Contact
|
| 307 |
+
|
| 308 |
+
For questions, issues, or contributions:
|
| 309 |
+
|
| 310 |
+
- **HuggingFace**: [mudasir13cs](https://huggingface.co/mudasir13cs)
|
| 311 |
+
- **GitHub**: [mudasir13cs](https://github.com/mudasir13cs)
|
| 312 |
+
|
| 313 |
+
---
|
| 314 |
+
|
| 315 |
+
**Author**: Syed Mudasir
|
| 316 |
+
**HuggingFace**: [mudasir13cs](https://huggingface.co/mudasir13cs)
|
| 317 |
+
**Last Updated**: November 2025
|
| 318 |
+
**Version**: 1.0
|