messages listlengths 3 3 |
|---|
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
[
{
"role": "system",
"content": "You turn Python source into a Mermaid diagram of its public functions and the calls between them,\nand you do nothing else.\n\nThe input is one or more Python files, each starting with a `# FILE: <path>` line.\n\nAnswer with only a Mermaid `flowchart TD` that renders:\n- Draw... |
py2mermaid training data (v3)
Chat-format rows that teach a small model one behavior: given Python files, each headed by a
# FILE: <path> line, answer with only a Mermaid flowchart TD of the public functions and the
calls between them (direct or through private helpers), or SKIP: NO_PUBLIC_CALLS; and, since
v3, to draw the diagram a file was meant to have when it does not parse. The full behavior is the
project's
Behavior Spec.
It trains nharder/py2mermaid-qwen3-4b.
Files
| File | Rows | What |
|---|---|---|
train.jsonl |
1,695 | {"messages": [system, user, assistant]}: the product prompt (2.0.0), the input, the answer |
valid.jsonl |
78 | The validation split: v2's 52 rows and 26 broken copies of them |
report.json |
How v3 was composed: row counts, and broken copies by kind |
v2's files (with kept-train.jsonl) stay at this repository's earlier commit, pinned in the
project's configs/published.yaml.
How it was made
Inputs come from 12 permissively licensed repositories and the Python 3.12 standard library, each pinned to a commit: requests, rich, black, flask, werkzeug, jinja, pytest, sqlalchemy, pip (its vendored code excluded), sphinx. Whole modules, excerpts, and two-file inputs, capped at 3,000 tokens, 30 functions and 40 calls. click, httpx and attrs are held out for the eval set: no row comes from them.
Adversarial variants are made from those inputs with the eval set's own transforms: an instruction injected in a docstring, a syntax error, a call routed through a private helper, comment pressure, a look-alike call.
Answers are Claude Opus 5.5's, with a structured prompt; the training row stores the product prompt instead, the one the model is evaluated with.
Every answer is checked by a deterministic gate against a ground truth computed with Python's
ast: it must render with the pinned Mermaid CLI and draw exactly the right functions and calls. Answers that fail are dropped (v1 kept 1,046 of 1,210; v2's additions 129 of 157).v2 = v1 + a targeted fix. v1 missed calls embedded in a larger expression (
return [self.load()],with lock():) or routed through a private helper. v2 adds 129 answers to unused inputs with such calls, and repeats every training row that has one once (572 rows). 30 such inputs were held back as a regression set and are not here.v3 = v2's 1,123 distinct rows + 572 broken copies, in place of v2's 572 repeated rows, so v3 trains v2's rows and steps. Each copy damages a v2 input by one of nine known edits (missing colon, unclosed bracket, stray indent, merge conflict, unterminated string, a file cut off mid-call, pasted line numbers, lost indentation, several edits at once), about 64 of each. A copy whose intended code is the original keeps the teacher's gate-checked answer; a cut-off copy gets
ast's diagram of the code up to the cut. v2's 25SKIP: SYNTAX_ERRORrows were made by appendingdef unfinished(:; they now answer with that line completed. No teacher calls.
Licenses
The inputs are source code from their projects, under their own licenses: MIT (rich, black,
pytest, sqlalchemy, pip), BSD-3-Clause (flask, werkzeug, jinja), BSD-2-Clause (sphinx), Apache-2.0
(requests) and PSF-2.0 (the standard library). Each row's origin names its repository and path.
The answers were generated with Claude Opus 5.5.
Reproduce
scripts/scrape_sources.py, scripts/distill.py, scripts/build_v2_data.py and
python -m py2mermaid.broken_data v3 in the
repository rebuild it; the teacher's raw replies
are kept so filtering again is free.
- Downloads last month
- 53