mshojaei77's picture
Duplicate from mshojaei77/persian-gk-cleaned
e2c1c59
|
Raw
History Blame Contribute Delete
4.37 kB
---
dataset_info:
features:
- name: messages
list:
- name: content
dtype: string
- name: role
dtype: string
splits:
- name: train
num_bytes: 7201128.0
num_examples: 5897 # Note: Actual count may be slightly lower after cleaning.
download_size: 2969604
dataset_size: 7201128.0
configs:
- config_name: default
data_files:
- split: train
path: data/train-*
license: cc-by-4.0
task_categories:
- question-answering
- text-generation
language:
- fa
tags:
- persian
- farsi
- cleaned
- validated
- chatml
pretty_name: Persian General Knowledge (Cleaned)
---
This is a **cleaned and validated** version of the original [mshojaei77/persian-gk](https://huggingface.co/datasets/mshojaei77/persian-gk) dataset.
The purpose of this version is to ensure robust compatibility with modern fine-tuning workflows that rely on strict chat templates (e.g., `tokenizer.apply_chat_template`). The cleaning process resolves structural errors in the original dataset that could cause `TemplateError` or other silent failures during training with models like Gemma 3N, Llama 3, and others.
## Cleaning and Validation Process
The original dataset was processed with a script to enforce the following structural guarantees:
1. **System Messages Removed:** All messages with the `role: system` were removed from the conversations. While useful for inference, they can break the required alternating pattern for many training templates.
2. **Alternating Roles Enforced:** The script iterated through each conversation to ensure a strict `user`/`assistant`/`user`/`assistant` sequence. Any message that repeated the role of the previous message (e.g., two consecutive `user` messages) was discarded.
3. **Conversation Start Validated:** Any conversation that did not begin with a `user` message after filtering was removed.
4. **Empty/Invalid Content Removed:** A final validation step ensured that all messages contained non-empty, valid string content to prevent tokenization errors.
The resulting dataset is guaranteed to have a clean, alternating `user`/`assistant` structure, making it reliable for use with `tokenizer.apply_chat_template` without requiring manual pre-processing.
---
## Dataset Summary (Original)
`persian-gk` is a structured collection of Persian (Farsi) conversation pairs covering a wide range of general-knowledge topics. Each conversation is formatted in [ChatML](https://github.com/openai/openai-python) style with explicit *system*, *user*, and *assistant* roles, enabling straightforward use for both instruction-tuning and chat-style language-model training.
* **Language:** Persian (fa)
* **Size:** ~5,897 conversations, 2–8 turns each
* **Domains:** programming, Persian heritage, architecture, tourism, and assorted Q&A,...
* **License:** CC-BY-4.0
* **Source:** Curated from public Persian blogs, Q&A resources, and manually written system prompts.
## Supported Tasks and Benchmarks
1. **Instruction Tuning / Chat Completion** – Fine-tune models for Persian dialogue or QA.
2. **Knowledge-Grounded Generation** – Evaluate a model’s factual consistency in Persian.
3. **Domain Adaptation** – Adapt multilingual models to Persian general-knowledge domains.
_No public benchmark results are yet reported._
## Data Splits
The current release provides a single `train` split. The final example count in this cleaned version may be slightly lower than the original due to the filtering of invalid conversations.
| Split | Examples |
|-------|----------|
| train | ~5 897 |
## Usage
```python
from datasets import load_dataset
# Load the cleaned version of the dataset
ds = load_dataset("mshojaei77/persian-gk-cleaned", split="train")
print(ds["messages"])
```
### ChatML to plain prompt
```python
def format_chatml(example):
# Note: 'system' roles are not present in this cleaned version.
return "\n".join(f"<{m['role']}> {m['content']}" for m in example["messages"])
```
## Citation
If you use this dataset, **please cite the original work**:
```
@misc{persian_gk_2024,
title = {persian-gk: Persian General Knowledge Chat Dataset},
author = {Shojaei, M. and Contributors},
year = {2024},
url = {https://huggingface.co/datasets/mshojaei77/persian-gk}
}
```
## License
Licensed under the **Creative Commons Attribution 4.0 International (CC-BY-4.0)** license.