File size: 5,172 Bytes
213567b
 
56f3fff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213567b
56f3fff
7fa60e7
d8d248a
7fa60e7
 
 
 
 
 
 
 
 
 
 
 
 
56f3fff
7fa60e7
 
 
56f3fff
7fa60e7
 
 
 
 
 
56f3fff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7fa60e7
 
 
 
 
 
 
56f3fff
7fa60e7
56f3fff
 
7fa60e7
 
 
56f3fff
 
 
7fa60e7
 
 
 
 
56f3fff
 
 
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
---
license: mit
language:
  - en
  - zh
task_categories:
  - text-generation
tags:
  - geometry
  - geometric-constraint-solving
  - reasoning
  - synthetic-data
  - math
pretty_name: PyGeoX
size_categories:
  - 10K<n<100K
configs:
  - config_name: gcs-sft
    data_files: data/PyGeoX-GCS-SFT.jsonl
  - config_name: codegen-sft
    data_files: data/PyGeoX-CodeGen-SFT.jsonl
  - config_name: gcs-rl
    data_files: data/PyGeoX-GCS-RL.jsonl
  - config_name: bench
    data_files: data/PyGeoX-Bench.jsonl
  - config_name: wild
    data_files: data/PyGeoX-Wild.jsonl
---

<p align="center">
  <img src="https://raw.githubusercontent.com/Huawei-AI4Math/PyGeoX/main/docs/_static/logo.png" alt="PyGeoX logo" width="200"/>
</p>

<p align="center">
  <strong>Internalizing Geometric Law: a programmable geometry language for precision-critical LLM generation</strong>
</p>

<p align="center">
  <a href="https://arxiv.org/abs/2606.09278"><img src="https://img.shields.io/badge/arXiv-2606.09278-b31b1b.svg" alt="arXiv"/></a>
  &nbsp;
  <a href="https://github.com/Huawei-AI4Math/PyGeoX"><img src="https://img.shields.io/badge/GitHub-PyGeoX-181717?logo=github" alt="GitHub"/></a>
  &nbsp;
  <a href="https://github.com/Huawei-AI4Math/PyGeoX/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="MIT License"/></a>
</p>

---

Datasets for training and evaluating language models on **geometric constraint solving (GCS)** — reading a natural-language description of a diagram and producing the point coordinates / circle radii that satisfy all stated constraints — plus a supervised set for generating PyGeoX scene code.

<p align="center">
  <img src="https://raw.githubusercontent.com/Huawei-AI4Math/PyGeoX/main/docs/_static/readme/workflow.png" alt="PyGeoX-RL workflow" width="50%"/>
</p>
<p align="center"><em>The agent reasons in code and outputs exact coordinates and radii; PyGeoX verifies each constraint independently via per-constraint residuals.</em></p>

---
## Subsets

| Config | Rows | Task |
|--------|------|------|
| `gcs-sft` | 15,738 | SFT — solve geometry (NL → coordinates), merged master with per-variant reward labels |
| `codegen-sft` | 46,977 | SFT — NL diagram description → PyGeoX code |
| `gcs-rl` | 46,977 | RL — prompts for geometry constraint solving |
| `bench` | 300 | Evaluation benchmark (self-contained) |
| `wild` | 200 | Evaluation — real-world school-geometry questions |

```python
from datasets import load_dataset
ds = load_dataset("rafaelcabral96/PyGeoX", "gcs-rl")
```


## Subset details

### `gcs-sft` — geometry-solving SFT (merged master)
One deduplicated file keyed by (problem, completion). Each row's `splits` map records, per
training variant (`sar`, `sar_sd`, `mse`, `mse_sd`, `sparse`, plus the `full` base),
whether that variant includes it and with what reward/weight. Reconstruct any variant:

```python
rows    = [r for r in ds if r["splits"]["mse_sd"]["in"]]
weights = [r["splits"]["mse_sd"].get("weight", 1.0) for r in rows]
```

### `codegen-sft` — NL → PyGeoX code
`messages` = (user: diagram description + "Please generate PyGeoX code…", assistant:
```python … ``` block), plus `problem_id`, `source_file`, `difficulty`.

### `gcs-rl` — RL prompts
`messages` (system + user), `source_file` (→ reward ground truth), `difficulty`
(`easy`/`medium`/`hard` for 1/2/3 primary objects).

### `bench` — evaluation benchmark (self-contained)
Each record carries everything needed to score a model inline:
`unique_id, nl_description, pygeox_code, Objs, Rels, Points, extra_rel, possible_solution`.
Rebuild the scene directly from a record (no file needed) and score predicted coordinates:

```python
from pygeox.synthetic.llm_client import create_scene_from_json
scene = create_scene_from_json(domain=10, json_data=record, generate_objective_function=True)
reward, details = scene.reward.reward_function(pred_points, pred_circles)
```

### `wild` — real-world school geometry
200 questions from MathVerse, ZhongKaoGeo, and MathVista (`id, question, source,
source_id`). Ground truth is executable PyGeoX `full_code`, shipped in
`data/PyGeoX-Wild-Code.zip` (one `problem_<id>.json` per question, keyed 1:1 by `id`,
each with `full_code` + `possible_solution`). Extract inside `data/`:

## Reward ground truth (`PyGeoX-GCS-RL-Code.zip`)

The problem definitions used to score RL and benchmark outputs are shipped as
`data/PyGeoX-GCS-RL-Code.zip`. The `source_file` field of each `gcs-rl` row points into
this folder. After downloading the repo, extract it **inside `data/`** so the relative
paths resolve:

```bash
cd data && unzip PyGeoX-GCS-RL-Code.zip      # -> data/PyGeoX-GCS-RL-Code/<id>.json
```

All `source_file` paths are written relative to the repo root
(`data/PyGeoX-GCS-RL-Code/<name>.json`), so they are invariant to where the repo lives.

## Citation

```bibtex
@article{cabral2026internalizinggeometriclaw,
  title={Internalizing Geometric Law: Learning from Solver Residuals for Precision-Critical Generation},
  author={Cabral, Rafael and Pang, Zixi and Shou, Ziyi and Xin, Shen},
  journal={arXiv preprint arXiv:2606.09278},
  year={2026}
}
```