# ELYRAON Dataset Doctor — JSONL/CSV Fine-Tune Checker (`colt2822/dataset-doctor`) Actor

Inspect JSONL and CSV instruction data before a fine-tune. Flags broken JSON, bad chat-role order, exact duplicates, PII counts, and CSV formula prefixes. Deterministic rules. No model calls.

- **URL**: https://apify.com/colt2822/dataset-doctor.md
- **Developed by:** [Colton Mcclain](https://apify.com/colt2822) (community)
- **Categories:** Developer tools, AI
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 record inspecteds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## ELYRAON Dataset Doctor — AI Training Data Cleaner & Validator

> **Deterministic local validation, syntax repair, PII detection, and quality scoring for LLM fine-tuning datasets.**\
> Supports JSONL (Alpaca, ChatML, ShareGPT, Prompt/Response, Raw Text) and CSV files up to 5,000 records per job.

***

### What Problem Does Dataset Doctor Solve?

Machine learning teams, autonomous coding agents, and automation developers lose compute credits and GPU hours when fine-tuning jobs fail due to:

1. **Syntax & Formatting Failures:** Trailing commas, single-quoted JSON, truncated lines (missing closing brackets), or malformed lines in JSONL files.
2. **Conversational Integrity Hazards:** ShareGPT or ChatML sequences with consecutive user turns, out-of-order system prompts, or empty assistant responses.
3. **Sensitive PII & Secret Leakage:** Accidental inclusion of personal emails, phone numbers, Social Security Numbers, internal IP addresses, and OpenAI/GitHub API keys in training data.
4. **Spreadsheet Formula Injections:** CSV datasets containing malicious formula prefixes (`=`, `+`, `-`, `@`) that execute arbitrary commands when opened in spreadsheet software.
5. **Low-Quality / Boilerplate Noise:** Repetitive non-informative responses that degrade model alignment.

**ELYRAON Dataset Doctor** runs an auditable, deterministic engine that inspects every record, repairs minor syntax defects, neutralizes CSV injection risks, flags sensitive PII, and outputs clean, ready-to-train datasets.

***

### Pricing

Pay per event — no subscription, no free tier:

| Event | Price |
|---|---|
| Actor start | $0.005 per run (1 GB default memory) |
| Record inspected (dataset item) | $0.0005 per record ($0.50 per 1,000) |

A run that fails on invalid input (empty text, unreachable or non-public URL, file over 5 MB) writes no records, so no per-record charges apply, but the $0.005 start event is still charged because Apify charges it automatically when a run starts. A request with no `input_mode` at all is refused by Apify before a run starts and is not charged. Maximum job size is 5,000 records / 5 MB, so a full job costs about $2.51. The `estimated_compute_cost_usd_informational` field in the report is an internal estimate, not your bill.

***

### Example Output (one dataset row per record)

```json
{
  "record_index": 1,
  "status": "repaired",
  "detected_format": "alpaca",
  "cleaned_record": {"instruction": "Say hi", "output": "Mail me at [REDACTED_EMAIL]"},
  "pii_detected": {"email": 1},
  "issues": ["repaired: removed_trailing_comma"],
  "token_count": 11
}
```

`status` is `valid`, `repaired` or `rejected` (rejected rows have `cleaned_record: null` and an explanation in `issues`). The run also stores a JSON summary (`OUTPUT`) and a Markdown report (`REPORT.md`) in the key-value store.

### Privacy and Safety Behavior

- **No values in detection results.** `pii_detected` lists only the PII type and how many matches were found in that record, e.g. `{"email": 1, "ssn": 1}`. Matched values, or fragments of them, are never returned in results, the summary, the report or the run log.
- **Redaction is opt-in.** With **Redact Detected PII** on, emails, phone numbers, SSNs, credit cards and API keys are replaced with `[REDACTED_EMAIL]`, `[REDACTED_SSN]` and so on in `cleaned_record`; the rest of the record stays intact. IP addresses are counted but not redacted. With it off, `cleaned_record` is your data, unmodified.
- **No demo data on your behalf.** Sample mode runs only when you select it. An empty, whitespace-only or conflicting input fails the run with a clear error and produces no results.
- **Safe URL fetching.** Only public `http`/`https` URLs; redirects are re-checked; localhost, private, link-local and metadata addresses are refused; files over 5 MB are refused.
- **In-memory processing.** No third-party model or API calls; nothing is stored beyond the run's own dataset and key-value store.

### Errors You May See

| Message | Meaning |
|---|---|
| `input_mode is required...` | Pick Synthetic sample, Inline text or Remote file URL. |
| `... dataset_text is empty` / `... file_url is empty` | The selected mode has no data. Nothing was processed. |
| `... also provided; choose one source` | Both text and URL (or sample plus data) were supplied. |
| `URL points to a non-public address...` | The URL resolves to a private, loopback or link-local address. |
| `file_url must be an absolute http(s) URL` / `must not contain credentials` | Unsupported scheme or user:password in the URL. |
| `Remote file exceeds the ... limit` / `Input payload exceeds ...` | The file or text is larger than 5 MB. |
| `max_records must be an integer of at least 1` | Invalid record limit (maximum 5,000 per job). |

A run that fails on input writes no records, so no per-record charges apply (the start event is still charged).

### Key Features

- **No Third-Party Model Calls:** 100% deterministic local rules, regular expressions, and AST parsing. No token burn or random drift.
- **Privacy-Safe Execution:** Your datasets are processed in-memory in your Apify container. Data is never uploaded to third-party APIs or used to train models.
- **Dual Output Channels:**
  - **Structured Dataset:** Cleaned and annotated records pushed directly to the Apify Dataset, downloadable as JSON, CSV, or Excel.
  - **Audit Report:** Complete executive summary, issue histogram, PII audit, token distribution statistics, and cost accounting stored in the Key-Value Store (`OUTPUT` and `REPORT.md`).
- **Built-in Synthetic Benchmarks:** Test the Actor immediately using synthetic sample datasets without uploading private files.

***

### Supported Formats

| Format | Structure Inspected | Automatic Repairs |
|---|---|---|
| **Alpaca** | `instruction`, `input`, `output` | Trailing commas, single-quoted JSON, missing closing brackets |
| **ChatML** | `messages`: `[{role, content}]` | Role ordering (system first), non-empty content validation |
| **ShareGPT** | `conversations`: `[{from, value}]` | Turn alternations (`human` → `gpt`), structural consistency |
| **Prompt / Response** | `prompt`, `response` / `completion` | Whitespace normalization, unicode normalization (NFC) |
| **CSV** | Delimited columns | Formula injection neutralization (`=`, `@`, `+`, `-`) |

***

### Example Input

```json
{
  "input_mode": "sample",
  "sample_name": "alpaca_synthetic_dirty",
  "detect_pii": true,
  "redact_pii": false,
  "deduplicate_exact": true,
  "filter_low_info": true,
  "max_records": 1000
}
```

#### Direct Text Input Example (JSONL)

```json
{
  "input_mode": "text",
  "dataset_text": "{\"instruction\": \"Calculate CAGR\", \"input\": \"10k to 25k in 5 yrs\", \"output\": \"CAGR is 20.11%\"}\n{\"instruction\": \"Fix syntax\", \"input\": \"\", \"output\": \"Repaired\",}\n{\"instruction\": \"Trailing comma\", \"input\": \"\", \"output\": \"Repaired\",}\n",
  "detect_pii": true
}
```

***

### Example Output (Key-Value Store: `OUTPUT`)

```json
{
  "service": "ELYRAON Dataset Doctor",
  "version": "1.0.0",
  "timestamp": "2026-11-07T02:14:08Z",
  "source": "sample: alpaca_synthetic_dirty",
  "format_family": "jsonl",
  "summary": {
    "records_inspected": 7,
    "valid_records": 4,
    "repaired_records": 1,
    "rejected_records": 3,
    "pii_records_flagged": 0,
    "formula_injections_neutralized": 0,
    "clean_rate_pct": 57.14
  },
  "issue_breakdown": {
    "syntax_error": 2,
    "structural_validation_failed": 1
  },
  "pii_breakdown": {},
  "token_statistics": {
    "total_tokens": 189,
    "mean_tokens": 27.0,
    "median_tokens": 26,
    "p95_tokens": 48
  },
  "performance_and_costs": {
    "duration_seconds": 0.0129,
    "throughput_records_per_sec": 542.64,
    "peak_memory_mb": 68.94,
    "actual_compute_cost_usd": 0.000000
  }
}
```

***

### Limitations

- Up to **5,000 records per run** (`max_records`); inputs up to ~5 MB for pasted text.
- Rule-based checks only (regex and parsing). It does not judge factual accuracy or semantic quality, and PII detection can miss unusual formats or flag false positives. Review before relying on it for compliance.
- Repairs are limited to simple syntax defects (trailing commas, lines that use single quotes throughout, missing closing brackets; lines mixing quote styles, unquoted keys or raw control characters are rejected, not repaired) and CSV formula neutralization.
- `url` mode fetches one public HTTPS file; private or authenticated URLs are not supported.
- Pricing is pay-per-event (see **Pricing** above): $0.005 per run start plus $0.0005 per record. There is no free tier; the price is shown on the Actor's Store page before you run it.

***

### Developer & Agent Integration

#### Running via Apify Python Client

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")

run = client.actor("colt2822/dataset-doctor").call(run_input={
    "input_mode": "url",
    "file_url": "https://your-host.example/training_data.jsonl",  # replace with your own public file URL
    "detect_pii": True,
    "max_records": 2500
})

## Fetch cleaned dataset items
dataset_items = client.dataset(run["defaultDatasetId"]).list_items().items
print(f"Processed {len(dataset_items)} records.")

## Fetch executive audit summary
audit_report = client.key_value_store(run["defaultKeyValueStoreId"]).get_record("OUTPUT")["value"]
print(f"Clean rate: {audit_report['summary']['clean_rate_pct']}%")
```

#### Running via curl / HTTP API

```bash
curl -X POST "https://api.apify.com/v2/acts/colt2822~dataset-doctor/runs?token=<YOUR_APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
    "input_mode": "sample",
    "sample_name": "chatml_pii_leakage",
    "detect_pii": true
  }'
```

***

### Privacy, Security, & Support

- **No Remote Telemetry:** The Actor runs strictly within the Apify task container without communicating with external LLMs or third-party servers.
- **License:** Commercial software by ELYRAON.
- **Engineering Support:** Support and questions: https://elyraon.com.co/contact/
- **Official Website:** [https://elyraon.com.co/dataset-doctor/](https://elyraon.com.co/dataset-doctor/?utm_source=apify\&utm_medium=store\&utm_campaign=dataset_doctor)

# Actor input Schema

## `input_mode` (type: `string`):

Where the data comes from. 'Synthetic sample' runs a built-in demo dataset (nothing of yours is processed). 'Inline text' uses Dataset Content. 'Remote file URL' downloads File URL. Provide only the field that matches the mode you choose; an empty or conflicting source fails the run with an error and processes nothing.

## `sample_name` (type: `string`):

Used only when Input Mode is 'Synthetic sample'. Ignored in other modes.

## `dataset_text` (type: `string`):

Used only when Input Mode is 'Inline text'. Paste raw JSONL or CSV (up to 5 MB). Must not be empty.

## `file_url` (type: `string`):

Used only when Input Mode is 'Remote file URL'. A public http(s) link to a JSONL or CSV file of at most 5 MB. Localhost, private-network and link-local addresses, URLs with embedded credentials, and other schemes are rejected.

## `detect_pii` (type: `boolean`):

Scan records for emails, phone numbers, SSNs, credit cards, IP addresses, and API key patterns. Results report only the type and the number of matches per record, never the matched values.

## `redact_pii` (type: `boolean`):

If enabled, replaces emails, phone numbers, SSNs, credit cards and API keys with \[REDACTED_TYPE] tokens in the cleaned records. IP addresses are detected and counted but not redacted. If disabled, cleaned records contain your data unmodified.

## `deduplicate_exact` (type: `boolean`):

Detect and flag identical records using SHA-256 hashes.

## `deduplicate_near` (type: `boolean`):

Detect near-identical records using 64-bit SimHash with Hamming distance threshold.

## `filter_low_info` (type: `boolean`):

Flag empty, whitespace-only, or repetitive boilerplate records below minimum informative length.

## `max_records` (type: `integer`):

Upper bound on inspected records per job (bounded to 5,000 max for safety).

## Actor input object example

```json
{
  "input_mode": "sample",
  "sample_name": "alpaca_synthetic_dirty",
  "dataset_text": "",
  "file_url": "",
  "detect_pii": true,
  "redact_pii": false,
  "deduplicate_exact": true,
  "deduplicate_near": false,
  "filter_low_info": true,
  "max_records": 1000
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

## `report` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "input_mode": "sample"
};

// Run the Actor and wait for it to finish
const run = await client.actor("colt2822/dataset-doctor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "input_mode": "sample" }

# Run the Actor and wait for it to finish
run = client.actor("colt2822/dataset-doctor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "input_mode": "sample"
}' |
apify call colt2822/dataset-doctor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,colt2822/dataset-doctor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/qlNfZRQ9bkUzs2DRp/builds/E8OHymSFGPLbeCGuH/openapi.json
