codegen-classroom 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/PKG-INFO +133 -105
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/README.md +126 -102
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/__init__.py +1 -1
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/agent_config.py +11 -5
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/agents.py +61 -20
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/agents_test.py +155 -4
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/classroom_integration_test.py +5 -1
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/data_utils.py +206 -1
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/data_utils_test.py +105 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/plotting.py +258 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/reporting.py +1 -1
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/student_learning.py +1 -1
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/student_learning_test.py +37 -2
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/AGENTS.md +6 -5
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/README.md +303 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/__init__.py +15 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/config.py +670 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/data_loader.py +788 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/efficiency.py +868 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/esc50.ipynb +536 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/extract_embeddings.py +326 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/leaderboard.tsv +17 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/run_esc50.py +1629 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/run_esc50_test.py +1890 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/solutions/efficient/esc50_efficient_5s_10c_r1_20261117.md +986 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/solutions/efficient/esc50_efficient_5s_12c_r4_20261119.md +1459 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/solutions/efficient/esc50_efficient_5s_8c_r3_20261118.md +1114 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/solutions/fm/esc50_fm_5s_12c_r1_20261117.md +570 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/solutions/fm/esc50_fm_5s_6c_r2_20261117.md +671 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/esc50/solutions/fm/esc50_fm_5s_8c_r3_20261118.md +820 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/README.md +235 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/__init__.py +15 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/config.py +406 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/data_loader.py +511 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/fashion_mnist.ipynb +434 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/leaderboard.tsv +10 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/run_fashion_mnist.py +1184 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/run_fashion_mnist_test.py +1289 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/solutions/fashion_mnist_4s_6c_r2_20261117.md +741 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/solutions/fashion_mnist_5s_12c_r4_20261119.md +817 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/fashion_mnist/solutions/fashion_mnist_5s_8c_r3_20261118.md +1082 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/housing/README.md +28 -17
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/housing/config.py +3 -9
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/leaderboard.tsv +19 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/housing/run_housing.py +7 -4
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/solutions/housing_5s_12c_r3_20261118.md +1635 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/housing/solutions/housing_5s_8c_r2_20261118.md +1888 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/template/README.md +25 -1
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/template/config.py +3 -8
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/template/leaderboard.tsv +2 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/template/solutions/template_5s_12c_r1_20261119.md +1451 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/template/solutions/template_5s_15c_r2_20261119.md +954 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/README.md +157 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/__init__.py +15 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/config.py +398 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/data_loader.py +225 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/leaderboard.tsv +12 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/run_wearable.py +899 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/run_wearable_test.py +280 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/solutions/wearable_5s_12c_r3_20261119.md +752 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/solutions/wearable_6s_12c_20261105.md +737 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/solutions/wearable_6s_12c_v4_20261105.md +689 -0
- codegen_classroom-0.1.2/codegen_classroom/tasks/wearable/wearable.ipynb +442 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom.egg-info/PKG-INFO +133 -105
- codegen_classroom-0.1.2/codegen_classroom.egg-info/SOURCES.txt +89 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom.egg-info/requires.txt +6 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/pyproject.toml +8 -2
- codegen_classroom-0.1.1/codegen_classroom/tasks/housing/leaderboard.tsv +0 -17
- codegen_classroom-0.1.1/codegen_classroom/tasks/housing/solutions/housing_4s_12c_20261103.md +0 -1207
- codegen_classroom-0.1.1/codegen_classroom/tasks/housing/solutions/housing_6s_12c_20261104.md +0 -843
- codegen_classroom-0.1.1/codegen_classroom/tasks/template/solutions/template_6s_12c_v3_20261027.md +0 -890
- codegen_classroom-0.1.1/codegen_classroom/tasks/template/solutions/template_6s_12c_v5_20261104.md +0 -557
- codegen_classroom-0.1.1/codegen_classroom.egg-info/SOURCES.txt +0 -51
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/LICENSE +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/code_execution.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/code_execution_test.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/metrics.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/metrics_test.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/scoring.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/scoring_test.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/__init__.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/housing/__init__.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/housing/data_loader.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/housing/housing.ipynb +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/housing/run_housing_test.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/housing/solutions/housing_6s_12c_v2_20261022.md +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/template/__init__.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/template/data_loader.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/template/run_template.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/template/run_template_test.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/template/solutions/template_6s_12c_20261023.md +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/tasks/template/task_example.ipynb +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/verify_task.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom/verify_task_test.py +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom.egg-info/dependency_links.txt +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/codegen_classroom.egg-info/top_level.txt +0 -0
- {codegen_classroom-0.1.1 → codegen_classroom-0.1.2}/setup.cfg +0 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codegen-classroom
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A framework for iterative code generation and recursive self-improvement (RSI) on ML and data analysis tasks using parallel LLM agents, optimized for local and Colab deployments.
|
|
5
|
-
Author: Google LLC
|
|
6
|
-
Author-email: Jake Garrison <jakegarrison@google.com>
|
|
5
|
+
Author: Google LLC, Jake Garrison
|
|
7
6
|
License:
|
|
8
7
|
Apache License
|
|
9
8
|
Version 2.0, January 2004
|
|
@@ -247,6 +246,9 @@ Provides-Extra: jax
|
|
|
247
246
|
Requires-Dist: jax; extra == "jax"
|
|
248
247
|
Provides-Extra: lightgbm
|
|
249
248
|
Requires-Dist: lightgbm; extra == "lightgbm"
|
|
249
|
+
Provides-Extra: audio
|
|
250
|
+
Requires-Dist: librosa; extra == "audio"
|
|
251
|
+
Requires-Dist: resampy; extra == "audio"
|
|
250
252
|
Provides-Extra: dev
|
|
251
253
|
Requires-Dist: pytest; extra == "dev"
|
|
252
254
|
Requires-Dist: pytest-mock; extra == "dev"
|
|
@@ -258,6 +260,8 @@ Requires-Dist: torch; extra == "all"
|
|
|
258
260
|
Requires-Dist: torchvision; extra == "all"
|
|
259
261
|
Requires-Dist: jax; extra == "all"
|
|
260
262
|
Requires-Dist: lightgbm; extra == "all"
|
|
263
|
+
Requires-Dist: librosa; extra == "all"
|
|
264
|
+
Requires-Dist: resampy; extra == "all"
|
|
261
265
|
Requires-Dist: pytest; extra == "all"
|
|
262
266
|
Requires-Dist: pytest-mock; extra == "all"
|
|
263
267
|
Dynamic: license-file
|
|
@@ -272,10 +276,10 @@ Dynamic: license-file
|
|
|
272
276
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
273
277
|
[](https://github.com/google-research/codegen-classroom/stargazers)
|
|
274
278
|
|
|
275
|
-
**Authors:** [Jake Garrison](
|
|
276
|
-
[Zhihan Zhang](
|
|
277
|
-
[Deon Kouatchou](
|
|
278
|
-
[Girish Narayanswamy](
|
|
279
|
+
**Authors:** [Jake Garrison](https://github.com/jake-g),
|
|
280
|
+
[Zhihan Zhang](https://github.com/iamZhihanZhang),
|
|
281
|
+
[Deon Kouatchou](https://github.com/dkouatch),
|
|
282
|
+
[Girish Narayanswamy](https://github.com/girishvn)
|
|
279
283
|
|
|
280
284
|
**Created:** August 2025
|
|
281
285
|
|
|
@@ -300,6 +304,69 @@ optimization.
|
|
|
300
304
|
|
|
301
305
|
--------------------------------------------------------------------------------
|
|
302
306
|
|
|
307
|
+
## Classroom Learning Method
|
|
308
|
+
|
|
309
|
+
Each cycle evolves parallel **Student Agents** across four stages:
|
|
310
|
+
|
|
311
|
+
1. **Generate, Self-Debug, and Execute**: Each student writes a Python
|
|
312
|
+
`solution(x_train, y_train, x_val)` function executed in a timed sandbox,
|
|
313
|
+
automatically repairing runtime or output contract errors before returning
|
|
314
|
+
predictions and diagnostic `feedback` (e.g., CV scores or feature
|
|
315
|
+
importances).
|
|
316
|
+
2. **Multi-Objective Scoring**: Predictions are evaluated against weighted task
|
|
317
|
+
metrics (e.g., R², MAPE, Macro-F1) and execution time, updating each
|
|
318
|
+
student's `best_score` and `best_solution`.
|
|
319
|
+
3. **Guided Refinement and Peer Crossover**: Students refine their code using
|
|
320
|
+
domain prompts and self-logged `feedback`. After `early_stopping_patience`
|
|
321
|
+
stagnant cycles, a student applies a **Mutation Strategy** (retiring after
|
|
322
|
+
`max_mutation_count` mutations):
|
|
323
|
+
* `SELF_BEST_CODE`: Re-anchors on the student's own best solution.
|
|
324
|
+
* `BEST_PEER_CROSSOVER` / `BEST_PEER_REPLACEMENT`: Adopts feature
|
|
325
|
+
engineering and modeling ideas from top-scoring peers.
|
|
326
|
+
* `CONTRASTIVE_PEER_CROSSOVER`: Contrasts top peer solutions against
|
|
327
|
+
weaker attempts to combine winning patterns and avoid failure modes.
|
|
328
|
+
4. **Final Evaluation and Analysis**: Each student's `first`, `last`, and
|
|
329
|
+
`best` validation solutions are retrained on the full learning split and
|
|
330
|
+
evaluated once on the held-out test set, while `SolutionAnalysisAgent`
|
|
331
|
+
synthesizes results into `report.md` and `leaderboard.tsv`.
|
|
332
|
+
|
|
333
|
+

|
|
334
|
+
|
|
335
|
+
*Four student agents over four cycles (illustrative scores): each student
|
|
336
|
+
writes, runs, and scores its own solution, refines from its own feedback, and
|
|
337
|
+
borrows ideas from the top peer when it stalls.*
|
|
338
|
+
|
|
339
|
+
--------------------------------------------------------------------------------
|
|
340
|
+
|
|
341
|
+
## Tasks
|
|
342
|
+
|
|
343
|
+
Self-contained benchmark suites live under
|
|
344
|
+
[`codegen_classroom/tasks/<task>/`](./codegen_classroom/tasks/). Each task
|
|
345
|
+
includes a shared configuration (`config.py`), dataset loader
|
|
346
|
+
(`data_loader.py`), headless runner (`run_<task>.py`), unit tests
|
|
347
|
+
(`run_<task>_test.py`), companion notebook (`<task>.ipynb`), `leaderboard.tsv`,
|
|
348
|
+
and archived top solutions (`solutions/`). To add a new task, copy
|
|
349
|
+
[`tasks/template/`](./codegen_classroom/tasks/template/) or prompt a coding
|
|
350
|
+
agent with [`tasks/AGENTS.md`](./codegen_classroom/tasks/AGENTS.md).
|
|
351
|
+
|
|
352
|
+
| Task | Summary | Notebook |
|
|
353
|
+
| :--- | :--- | :---: |
|
|
354
|
+
| [`template`](./codegen_classroom/tasks/template/) *(Thermal Load Prediction)* | Synthetic multi-regime thermal load regression template (`N = 1,500`, 10 features) scored on R², MAE, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/template/task_example.ipynb) |
|
|
355
|
+
| [`housing`](./codegen_classroom/tasks/housing/) *(California Housing Prices)* | California housing price tabular regression (`N = 20,433`, 12 features) scored on R², MAPE, Pearson, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/housing/housing.ipynb) |
|
|
356
|
+
| [`wearable`](./codegen_classroom/tasks/wearable/) *(Physical Activity Recognition)* | Multi-class physiological activity classification from Apple Watch and Fitbit sensors (`N = 6,264`, 17 features, 6 classes) scored on Macro-F1, Accuracy, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/wearable/wearable.ipynb) |
|
|
357
|
+
| [`fashion_mnist`](./codegen_classroom/tasks/fashion_mnist/) *(Clothing Image Classification)* | 10-class garment image classification (`N = 70,000`, 28x28 grayscale images) scored on Accuracy, Macro-F1, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/fashion_mnist/fashion_mnist.ipynb) |
|
|
358
|
+
| [`esc50`](./codegen_classroom/tasks/esc50/) *(Environmental Sound Classification)* | 50-class environmental audio classification (`N = 2,000`, 5-second clips) across `fm` embedding probe and `efficient` compact CNN variants. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/esc50/esc50.ipynb) |
|
|
359
|
+
|
|
360
|
+

|
|
361
|
+
|
|
362
|
+
*Method families used by the winning solution of each of the 18 cohort runs on
|
|
363
|
+
the five tasks above: counts stacked by task (left) and the share of each
|
|
364
|
+
task's runs using each family (right). Calibration / reweighting (`14/18`),
|
|
365
|
+
neural networks (`13/18`), domain / spectral feature engineering (`12/18`), and
|
|
366
|
+
cross-validation / out-of-fold training (`9/18`) appear most often.*
|
|
367
|
+
|
|
368
|
+
--------------------------------------------------------------------------------
|
|
369
|
+
|
|
303
370
|
## Installation
|
|
304
371
|
|
|
305
372
|
Requires Python 3.9+ and a [`GEMINI_API_KEY`](https://ai.google.dev/gemini-api/docs/api-key):
|
|
@@ -311,23 +378,80 @@ source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
|
311
378
|
|
|
312
379
|
# 2. Install from PyPI
|
|
313
380
|
pip install codegen-classroom
|
|
314
|
-
# Or latest from
|
|
381
|
+
# Or latest from GitHub: pip install "codegen-classroom @ git+https://github.com/google-research/codegen-classroom.git"
|
|
315
382
|
|
|
316
383
|
# Optional extras:
|
|
317
384
|
pip install "codegen-classroom[lightgbm]" # LightGBM
|
|
318
385
|
pip install "codegen-classroom[notebook]" # Plotly and IPython for notebooks
|
|
319
386
|
pip install "codegen-classroom[torch]" # PyTorch and TorchVision
|
|
320
387
|
pip install "codegen-classroom[jax]" # JAX
|
|
388
|
+
pip install "codegen-classroom[audio]" # Audio processing (librosa, resampy)
|
|
321
389
|
pip install "codegen-classroom[all]" # All optional dependencies and pytest
|
|
322
390
|
|
|
323
391
|
# 3. Configure GEMINI_API_KEY
|
|
324
392
|
export GEMINI_API_KEY="your-api-key" # Or copy .env.example to .env
|
|
325
393
|
```
|
|
326
394
|
|
|
395
|
+
For Gemini Developer API key clients, the library defaults to API version
|
|
396
|
+
`v1beta` (to support preview models alongside stable models). Set
|
|
397
|
+
`GOOGLE_GENAI_API_VERSION` to override this default (for example `v1`); it is
|
|
398
|
+
left unset automatically when Vertex AI mode is selected via
|
|
399
|
+
`GOOGLE_GENAI_USE_VERTEXAI` or `GOOGLE_GENAI_USE_ENTERPRISE`.
|
|
400
|
+
|
|
401
|
+
--------------------------------------------------------------------------------
|
|
402
|
+
|
|
403
|
+
## Library Structure
|
|
404
|
+
|
|
405
|
+
* [agent_config.py](./codegen_classroom/agent_config.py): Default model
|
|
406
|
+
configurations, generation parameters, pricing, environment resolution, and
|
|
407
|
+
execution timeouts.
|
|
408
|
+
* [agents.py](./codegen_classroom/agents.py): `StudentAgent` and
|
|
409
|
+
`SolutionAnalysisAgent` state management, token/cost tracking, refinement
|
|
410
|
+
prompts, and peer mutation strategies.
|
|
411
|
+
* [code_execution.py](./codegen_classroom/code_execution.py): Python code
|
|
412
|
+
extraction and timed subprocess execution capturing `stdout`, `stderr`, and
|
|
413
|
+
return values.
|
|
414
|
+
* [data_utils.py](./codegen_classroom/data_utils.py): Data loading, file
|
|
415
|
+
operations (`etils.epath`), run ID generation, and `leaderboard.tsv`
|
|
416
|
+
tracking.
|
|
417
|
+
* [metrics.py](./codegen_classroom/metrics.py): Performance metrics (MAE, R²,
|
|
418
|
+
Pearson, Macro-F1, Worst-Group Accuracy) and score normalization.
|
|
419
|
+
* [plotting.py](./codegen_classroom/plotting.py): Progress and final
|
|
420
|
+
evaluation plots via Matplotlib (headless PNG export) or Plotly (notebooks).
|
|
421
|
+
* [reporting.py](./codegen_classroom/reporting.py): Structured logging,
|
|
422
|
+
Markdown table formatting, and report export (`report.md`).
|
|
423
|
+
* [scoring.py](./codegen_classroom/scoring.py): Prediction validation (shape,
|
|
424
|
+
index, NaN checks) and weighted composite scoring.
|
|
425
|
+
* [student_learning.py](./codegen_classroom/student_learning.py): Parallel
|
|
426
|
+
classroom cycle orchestration and final test evaluation across `first`,
|
|
427
|
+
`last`, and `best` strategies.
|
|
428
|
+
* [verify_task.py](./codegen_classroom/verify_task.py): Automated structural,
|
|
429
|
+
notebook, solution report, and prompt hygiene verifier.
|
|
430
|
+
* [tasks/](./codegen_classroom/tasks/): Benchmark task suites,
|
|
431
|
+
[Task Authoring Guide](./codegen_classroom/tasks/AGENTS.md), and
|
|
432
|
+
[canonical template](./codegen_classroom/tasks/template/).
|
|
433
|
+
|
|
327
434
|
--------------------------------------------------------------------------------
|
|
328
435
|
|
|
329
436
|
## Quickstart
|
|
330
437
|
|
|
438
|
+
### Run a Built-In Benchmark Task
|
|
439
|
+
|
|
440
|
+
```bash
|
|
441
|
+
# Run a benchmark task headlessly (evaluates held-out test split, writes report.md,
|
|
442
|
+
# appends to leaderboard.tsv, and exports top runs to solutions/):
|
|
443
|
+
python -m codegen_classroom.tasks.template.run_template
|
|
444
|
+
|
|
445
|
+
# Rebuild report.md for an existing run without re-executing student code:
|
|
446
|
+
python -m codegen_classroom.tasks.template.run_template --report_only=latest
|
|
447
|
+
|
|
448
|
+
# Verify a single task or all tasks:
|
|
449
|
+
python -m codegen_classroom.verify_task --task template --strict
|
|
450
|
+
python -m codegen_classroom.verify_task --all
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
### Run on a Custom Dataset in Python
|
|
454
|
+
|
|
331
455
|
Run an iterative classroom loop on any custom `pandas` dataset:
|
|
332
456
|
|
|
333
457
|
```python
|
|
@@ -347,7 +471,7 @@ y_test = pd.DataFrame({"target": [14.0]})
|
|
|
347
471
|
# 2. Configure student agents
|
|
348
472
|
student_configs = student_learning.get_classroom_student_configs(
|
|
349
473
|
system_instruction="You are an expert ML engineer.",
|
|
350
|
-
model_names=["gemini-3.
|
|
474
|
+
model_names=["gemini-3.8-flash"],
|
|
351
475
|
api_key=os.environ.get("GEMINI_API_KEY"),
|
|
352
476
|
)
|
|
353
477
|
classroom = [agents.StudentAgent(cfg) for cfg in student_configs]
|
|
@@ -390,102 +514,6 @@ print("Final evaluation completed:", eval_results)
|
|
|
390
514
|
|
|
391
515
|
--------------------------------------------------------------------------------
|
|
392
516
|
|
|
393
|
-
## Tasks
|
|
394
|
-
|
|
395
|
-
Self-contained benchmark suites live under
|
|
396
|
-
[`codegen_classroom/tasks/<task>/`](./codegen_classroom/tasks/). Each task
|
|
397
|
-
includes a shared configuration (`config.py`), dataset loader
|
|
398
|
-
(`data_loader.py`), headless runner (`run_<task>.py`), unit tests
|
|
399
|
-
(`run_<task>_test.py`), companion notebook (`<task>.ipynb`), `leaderboard.tsv`,
|
|
400
|
-
and archived top solutions (`solutions/`).
|
|
401
|
-
|
|
402
|
-
| Task | Summary | Notebook |
|
|
403
|
-
| :--- | :--- | :---: |
|
|
404
|
-
| [`housing`](./codegen_classroom/tasks/housing/) *(California Housing Prices)* | California housing price tabular regression (`N = 20,433`, 12 features) scored on R², MAPE, Pearson, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/housing/housing.ipynb) |
|
|
405
|
-
| [`template`](./codegen_classroom/tasks/template/) *(Thermal Load Prediction)* | Synthetic multi-regime thermal load regression template (`N = 1,500`, 10 features) scored on R², MAE, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/template/task_example.ipynb) |
|
|
406
|
-
|
|
407
|
-
```bash
|
|
408
|
-
# Run a benchmark task headlessly:
|
|
409
|
-
python -m codegen_classroom.tasks.template.run_template
|
|
410
|
-
|
|
411
|
-
# Verify a single task or all tasks:
|
|
412
|
-
python -m codegen_classroom.verify_task --task template --strict
|
|
413
|
-
python -m codegen_classroom.verify_task --all
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
A normal run (without `--mock_students`) ends by running the held-out final
|
|
417
|
-
evaluation, writing `report.md` and saved predictions to the run directory,
|
|
418
|
-
appending a row to the task's `leaderboard.tsv`, and exporting the top runs to
|
|
419
|
-
`solutions/`. `--report_only=<run_dir|latest>` only rebuilds `report.md` for an
|
|
420
|
-
existing run and never re-executes student code.
|
|
421
|
-
|
|
422
|
-
To add a new benchmark task, copy
|
|
423
|
-
[`tasks/template/`](./codegen_classroom/tasks/template/) or prompt a coding
|
|
424
|
-
agent with [`tasks/AGENTS.md`](./codegen_classroom/tasks/AGENTS.md) to scaffold
|
|
425
|
-
one end-to-end.
|
|
426
|
-
|
|
427
|
-
--------------------------------------------------------------------------------
|
|
428
|
-
|
|
429
|
-
## Classroom Learning Method
|
|
430
|
-
|
|
431
|
-
Each RSI cycle evolves parallel **Student Agents** across four stages:
|
|
432
|
-
|
|
433
|
-
1. **Generate, Self-Debug, and Execute**: Each student writes a Python
|
|
434
|
-
`solution(x_train, y_train, x_val)` function executed in a timed sandbox,
|
|
435
|
-
automatically repairing runtime or output contract errors before returning
|
|
436
|
-
predictions and diagnostic `feedback` (e.g., CV scores or feature
|
|
437
|
-
importances).
|
|
438
|
-
2. **Multi-Objective Scoring**: Predictions are evaluated against weighted task
|
|
439
|
-
metrics (e.g., R², MAPE, Macro-F1) and execution time, updating each
|
|
440
|
-
student's `best_score` and `best_solution`.
|
|
441
|
-
3. **Guided Refinement and Peer Crossover**: Students refine their code using
|
|
442
|
-
domain prompts and self-logged `feedback`. After `max_mutation_count`
|
|
443
|
-
stagnant cycles, a student applies a **Mutation Strategy**:
|
|
444
|
-
* `SELF_BEST_CODE`: Re-anchors on the student's own best solution.
|
|
445
|
-
* `BEST_PEER_CROSSOVER` / `BEST_PEER_REPLACEMENT`: Adopts feature
|
|
446
|
-
engineering and modeling ideas from top-scoring peers.
|
|
447
|
-
* `CONTRASTIVE_PEER_CROSSOVER`: Contrasts top peer solutions against
|
|
448
|
-
weaker attempts to combine winning patterns and avoid failure modes.
|
|
449
|
-
4. **Final Evaluation and Analysis**: Each student's `first`, `last`, and
|
|
450
|
-
`best` validation solutions are retrained on the full learning split and
|
|
451
|
-
evaluated once on the held-out test set, while `SolutionAnalysisAgent`
|
|
452
|
-
synthesizes results into `report.md` and `leaderboard.tsv`.
|
|
453
|
-
|
|
454
|
-
--------------------------------------------------------------------------------
|
|
455
|
-
|
|
456
|
-
## Library Structure
|
|
457
|
-
|
|
458
|
-
* [agent_config.py](./codegen_classroom/agent_config.py): Default model
|
|
459
|
-
configurations, generation parameters, pricing, environment resolution, and
|
|
460
|
-
execution timeouts.
|
|
461
|
-
* [agents.py](./codegen_classroom/agents.py): `StudentAgent` and
|
|
462
|
-
`SolutionAnalysisAgent` state management, token/cost tracking, refinement
|
|
463
|
-
prompts, and peer mutation strategies.
|
|
464
|
-
* [code_execution.py](./codegen_classroom/code_execution.py): Python code
|
|
465
|
-
extraction and timed subprocess execution capturing `stdout`, `stderr`, and
|
|
466
|
-
return values.
|
|
467
|
-
* [data_utils.py](./codegen_classroom/data_utils.py): Data loading, file
|
|
468
|
-
operations (`etils.epath`), run ID generation, and `leaderboard.tsv`
|
|
469
|
-
tracking.
|
|
470
|
-
* [metrics.py](./codegen_classroom/metrics.py): Performance metrics (MAE, R²,
|
|
471
|
-
Pearson, Macro-F1, Worst-Group Accuracy) and score normalization.
|
|
472
|
-
* [plotting.py](./codegen_classroom/plotting.py): Progress and final
|
|
473
|
-
evaluation plots via Matplotlib (headless PNG export) or Plotly (notebooks).
|
|
474
|
-
* [reporting.py](./codegen_classroom/reporting.py): Structured logging,
|
|
475
|
-
Markdown table formatting, and report export (`report.md`).
|
|
476
|
-
* [scoring.py](./codegen_classroom/scoring.py): Prediction validation (shape,
|
|
477
|
-
index, NaN checks) and weighted composite scoring.
|
|
478
|
-
* [student_learning.py](./codegen_classroom/student_learning.py): Parallel
|
|
479
|
-
classroom cycle orchestration and final test evaluation across `first`,
|
|
480
|
-
`last`, and `best` strategies.
|
|
481
|
-
* [verify_task.py](./codegen_classroom/verify_task.py): Automated structural,
|
|
482
|
-
notebook, solution report, and prompt hygiene verifier.
|
|
483
|
-
* [tasks/](./codegen_classroom/tasks/): Benchmark task suites,
|
|
484
|
-
[Task Authoring Guide](./codegen_classroom/tasks/AGENTS.md), and
|
|
485
|
-
[canonical template](./codegen_classroom/tasks/template/).
|
|
486
|
-
|
|
487
|
-
--------------------------------------------------------------------------------
|
|
488
|
-
|
|
489
517
|
## Disclaimer
|
|
490
518
|
|
|
491
519
|
**This is not an officially supported Google product.**
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
9
9
|
[](https://github.com/google-research/codegen-classroom/stargazers)
|
|
10
10
|
|
|
11
|
-
**Authors:** [Jake Garrison](
|
|
12
|
-
[Zhihan Zhang](
|
|
13
|
-
[Deon Kouatchou](
|
|
14
|
-
[Girish Narayanswamy](
|
|
11
|
+
**Authors:** [Jake Garrison](https://github.com/jake-g),
|
|
12
|
+
[Zhihan Zhang](https://github.com/iamZhihanZhang),
|
|
13
|
+
[Deon Kouatchou](https://github.com/dkouatch),
|
|
14
|
+
[Girish Narayanswamy](https://github.com/girishvn)
|
|
15
15
|
|
|
16
16
|
**Created:** August 2025
|
|
17
17
|
|
|
@@ -36,6 +36,69 @@ optimization.
|
|
|
36
36
|
|
|
37
37
|
--------------------------------------------------------------------------------
|
|
38
38
|
|
|
39
|
+
## Classroom Learning Method
|
|
40
|
+
|
|
41
|
+
Each cycle evolves parallel **Student Agents** across four stages:
|
|
42
|
+
|
|
43
|
+
1. **Generate, Self-Debug, and Execute**: Each student writes a Python
|
|
44
|
+
`solution(x_train, y_train, x_val)` function executed in a timed sandbox,
|
|
45
|
+
automatically repairing runtime or output contract errors before returning
|
|
46
|
+
predictions and diagnostic `feedback` (e.g., CV scores or feature
|
|
47
|
+
importances).
|
|
48
|
+
2. **Multi-Objective Scoring**: Predictions are evaluated against weighted task
|
|
49
|
+
metrics (e.g., R², MAPE, Macro-F1) and execution time, updating each
|
|
50
|
+
student's `best_score` and `best_solution`.
|
|
51
|
+
3. **Guided Refinement and Peer Crossover**: Students refine their code using
|
|
52
|
+
domain prompts and self-logged `feedback`. After `early_stopping_patience`
|
|
53
|
+
stagnant cycles, a student applies a **Mutation Strategy** (retiring after
|
|
54
|
+
`max_mutation_count` mutations):
|
|
55
|
+
* `SELF_BEST_CODE`: Re-anchors on the student's own best solution.
|
|
56
|
+
* `BEST_PEER_CROSSOVER` / `BEST_PEER_REPLACEMENT`: Adopts feature
|
|
57
|
+
engineering and modeling ideas from top-scoring peers.
|
|
58
|
+
* `CONTRASTIVE_PEER_CROSSOVER`: Contrasts top peer solutions against
|
|
59
|
+
weaker attempts to combine winning patterns and avoid failure modes.
|
|
60
|
+
4. **Final Evaluation and Analysis**: Each student's `first`, `last`, and
|
|
61
|
+
`best` validation solutions are retrained on the full learning split and
|
|
62
|
+
evaluated once on the held-out test set, while `SolutionAnalysisAgent`
|
|
63
|
+
synthesizes results into `report.md` and `leaderboard.tsv`.
|
|
64
|
+
|
|
65
|
+

|
|
66
|
+
|
|
67
|
+
*Four student agents over four cycles (illustrative scores): each student
|
|
68
|
+
writes, runs, and scores its own solution, refines from its own feedback, and
|
|
69
|
+
borrows ideas from the top peer when it stalls.*
|
|
70
|
+
|
|
71
|
+
--------------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
## Tasks
|
|
74
|
+
|
|
75
|
+
Self-contained benchmark suites live under
|
|
76
|
+
[`codegen_classroom/tasks/<task>/`](./codegen_classroom/tasks/). Each task
|
|
77
|
+
includes a shared configuration (`config.py`), dataset loader
|
|
78
|
+
(`data_loader.py`), headless runner (`run_<task>.py`), unit tests
|
|
79
|
+
(`run_<task>_test.py`), companion notebook (`<task>.ipynb`), `leaderboard.tsv`,
|
|
80
|
+
and archived top solutions (`solutions/`). To add a new task, copy
|
|
81
|
+
[`tasks/template/`](./codegen_classroom/tasks/template/) or prompt a coding
|
|
82
|
+
agent with [`tasks/AGENTS.md`](./codegen_classroom/tasks/AGENTS.md).
|
|
83
|
+
|
|
84
|
+
| Task | Summary | Notebook |
|
|
85
|
+
| :--- | :--- | :---: |
|
|
86
|
+
| [`template`](./codegen_classroom/tasks/template/) *(Thermal Load Prediction)* | Synthetic multi-regime thermal load regression template (`N = 1,500`, 10 features) scored on R², MAE, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/template/task_example.ipynb) |
|
|
87
|
+
| [`housing`](./codegen_classroom/tasks/housing/) *(California Housing Prices)* | California housing price tabular regression (`N = 20,433`, 12 features) scored on R², MAPE, Pearson, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/housing/housing.ipynb) |
|
|
88
|
+
| [`wearable`](./codegen_classroom/tasks/wearable/) *(Physical Activity Recognition)* | Multi-class physiological activity classification from Apple Watch and Fitbit sensors (`N = 6,264`, 17 features, 6 classes) scored on Macro-F1, Accuracy, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/wearable/wearable.ipynb) |
|
|
89
|
+
| [`fashion_mnist`](./codegen_classroom/tasks/fashion_mnist/) *(Clothing Image Classification)* | 10-class garment image classification (`N = 70,000`, 28x28 grayscale images) scored on Accuracy, Macro-F1, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/fashion_mnist/fashion_mnist.ipynb) |
|
|
90
|
+
| [`esc50`](./codegen_classroom/tasks/esc50/) *(Environmental Sound Classification)* | 50-class environmental audio classification (`N = 2,000`, 5-second clips) across `fm` embedding probe and `efficient` compact CNN variants. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/esc50/esc50.ipynb) |
|
|
91
|
+
|
|
92
|
+

|
|
93
|
+
|
|
94
|
+
*Method families used by the winning solution of each of the 18 cohort runs on
|
|
95
|
+
the five tasks above: counts stacked by task (left) and the share of each
|
|
96
|
+
task's runs using each family (right). Calibration / reweighting (`14/18`),
|
|
97
|
+
neural networks (`13/18`), domain / spectral feature engineering (`12/18`), and
|
|
98
|
+
cross-validation / out-of-fold training (`9/18`) appear most often.*
|
|
99
|
+
|
|
100
|
+
--------------------------------------------------------------------------------
|
|
101
|
+
|
|
39
102
|
## Installation
|
|
40
103
|
|
|
41
104
|
Requires Python 3.9+ and a [`GEMINI_API_KEY`](https://ai.google.dev/gemini-api/docs/api-key):
|
|
@@ -47,23 +110,80 @@ source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
|
47
110
|
|
|
48
111
|
# 2. Install from PyPI
|
|
49
112
|
pip install codegen-classroom
|
|
50
|
-
# Or latest from
|
|
113
|
+
# Or latest from GitHub: pip install "codegen-classroom @ git+https://github.com/google-research/codegen-classroom.git"
|
|
51
114
|
|
|
52
115
|
# Optional extras:
|
|
53
116
|
pip install "codegen-classroom[lightgbm]" # LightGBM
|
|
54
117
|
pip install "codegen-classroom[notebook]" # Plotly and IPython for notebooks
|
|
55
118
|
pip install "codegen-classroom[torch]" # PyTorch and TorchVision
|
|
56
119
|
pip install "codegen-classroom[jax]" # JAX
|
|
120
|
+
pip install "codegen-classroom[audio]" # Audio processing (librosa, resampy)
|
|
57
121
|
pip install "codegen-classroom[all]" # All optional dependencies and pytest
|
|
58
122
|
|
|
59
123
|
# 3. Configure GEMINI_API_KEY
|
|
60
124
|
export GEMINI_API_KEY="your-api-key" # Or copy .env.example to .env
|
|
61
125
|
```
|
|
62
126
|
|
|
127
|
+
For Gemini Developer API key clients, the library defaults to API version
|
|
128
|
+
`v1beta` (to support preview models alongside stable models). Set
|
|
129
|
+
`GOOGLE_GENAI_API_VERSION` to override this default (for example `v1`); it is
|
|
130
|
+
left unset automatically when Vertex AI mode is selected via
|
|
131
|
+
`GOOGLE_GENAI_USE_VERTEXAI` or `GOOGLE_GENAI_USE_ENTERPRISE`.
|
|
132
|
+
|
|
133
|
+
--------------------------------------------------------------------------------
|
|
134
|
+
|
|
135
|
+
## Library Structure
|
|
136
|
+
|
|
137
|
+
* [agent_config.py](./codegen_classroom/agent_config.py): Default model
|
|
138
|
+
configurations, generation parameters, pricing, environment resolution, and
|
|
139
|
+
execution timeouts.
|
|
140
|
+
* [agents.py](./codegen_classroom/agents.py): `StudentAgent` and
|
|
141
|
+
`SolutionAnalysisAgent` state management, token/cost tracking, refinement
|
|
142
|
+
prompts, and peer mutation strategies.
|
|
143
|
+
* [code_execution.py](./codegen_classroom/code_execution.py): Python code
|
|
144
|
+
extraction and timed subprocess execution capturing `stdout`, `stderr`, and
|
|
145
|
+
return values.
|
|
146
|
+
* [data_utils.py](./codegen_classroom/data_utils.py): Data loading, file
|
|
147
|
+
operations (`etils.epath`), run ID generation, and `leaderboard.tsv`
|
|
148
|
+
tracking.
|
|
149
|
+
* [metrics.py](./codegen_classroom/metrics.py): Performance metrics (MAE, R²,
|
|
150
|
+
Pearson, Macro-F1, Worst-Group Accuracy) and score normalization.
|
|
151
|
+
* [plotting.py](./codegen_classroom/plotting.py): Progress and final
|
|
152
|
+
evaluation plots via Matplotlib (headless PNG export) or Plotly (notebooks).
|
|
153
|
+
* [reporting.py](./codegen_classroom/reporting.py): Structured logging,
|
|
154
|
+
Markdown table formatting, and report export (`report.md`).
|
|
155
|
+
* [scoring.py](./codegen_classroom/scoring.py): Prediction validation (shape,
|
|
156
|
+
index, NaN checks) and weighted composite scoring.
|
|
157
|
+
* [student_learning.py](./codegen_classroom/student_learning.py): Parallel
|
|
158
|
+
classroom cycle orchestration and final test evaluation across `first`,
|
|
159
|
+
`last`, and `best` strategies.
|
|
160
|
+
* [verify_task.py](./codegen_classroom/verify_task.py): Automated structural,
|
|
161
|
+
notebook, solution report, and prompt hygiene verifier.
|
|
162
|
+
* [tasks/](./codegen_classroom/tasks/): Benchmark task suites,
|
|
163
|
+
[Task Authoring Guide](./codegen_classroom/tasks/AGENTS.md), and
|
|
164
|
+
[canonical template](./codegen_classroom/tasks/template/).
|
|
165
|
+
|
|
63
166
|
--------------------------------------------------------------------------------
|
|
64
167
|
|
|
65
168
|
## Quickstart
|
|
66
169
|
|
|
170
|
+
### Run a Built-In Benchmark Task
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Run a benchmark task headlessly (evaluates held-out test split, writes report.md,
|
|
174
|
+
# appends to leaderboard.tsv, and exports top runs to solutions/):
|
|
175
|
+
python -m codegen_classroom.tasks.template.run_template
|
|
176
|
+
|
|
177
|
+
# Rebuild report.md for an existing run without re-executing student code:
|
|
178
|
+
python -m codegen_classroom.tasks.template.run_template --report_only=latest
|
|
179
|
+
|
|
180
|
+
# Verify a single task or all tasks:
|
|
181
|
+
python -m codegen_classroom.verify_task --task template --strict
|
|
182
|
+
python -m codegen_classroom.verify_task --all
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Run on a Custom Dataset in Python
|
|
186
|
+
|
|
67
187
|
Run an iterative classroom loop on any custom `pandas` dataset:
|
|
68
188
|
|
|
69
189
|
```python
|
|
@@ -83,7 +203,7 @@ y_test = pd.DataFrame({"target": [14.0]})
|
|
|
83
203
|
# 2. Configure student agents
|
|
84
204
|
student_configs = student_learning.get_classroom_student_configs(
|
|
85
205
|
system_instruction="You are an expert ML engineer.",
|
|
86
|
-
model_names=["gemini-3.
|
|
206
|
+
model_names=["gemini-3.8-flash"],
|
|
87
207
|
api_key=os.environ.get("GEMINI_API_KEY"),
|
|
88
208
|
)
|
|
89
209
|
classroom = [agents.StudentAgent(cfg) for cfg in student_configs]
|
|
@@ -126,102 +246,6 @@ print("Final evaluation completed:", eval_results)
|
|
|
126
246
|
|
|
127
247
|
--------------------------------------------------------------------------------
|
|
128
248
|
|
|
129
|
-
## Tasks
|
|
130
|
-
|
|
131
|
-
Self-contained benchmark suites live under
|
|
132
|
-
[`codegen_classroom/tasks/<task>/`](./codegen_classroom/tasks/). Each task
|
|
133
|
-
includes a shared configuration (`config.py`), dataset loader
|
|
134
|
-
(`data_loader.py`), headless runner (`run_<task>.py`), unit tests
|
|
135
|
-
(`run_<task>_test.py`), companion notebook (`<task>.ipynb`), `leaderboard.tsv`,
|
|
136
|
-
and archived top solutions (`solutions/`).
|
|
137
|
-
|
|
138
|
-
| Task | Summary | Notebook |
|
|
139
|
-
| :--- | :--- | :---: |
|
|
140
|
-
| [`housing`](./codegen_classroom/tasks/housing/) *(California Housing Prices)* | California housing price tabular regression (`N = 20,433`, 12 features) scored on R², MAPE, Pearson, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/housing/housing.ipynb) |
|
|
141
|
-
| [`template`](./codegen_classroom/tasks/template/) *(Thermal Load Prediction)* | Synthetic multi-regime thermal load regression template (`N = 1,500`, 10 features) scored on R², MAE, and runtime. | [](https://colab.research.google.com/github/google-research/codegen-classroom/blob/main/codegen_classroom/tasks/template/task_example.ipynb) |
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
# Run a benchmark task headlessly:
|
|
145
|
-
python -m codegen_classroom.tasks.template.run_template
|
|
146
|
-
|
|
147
|
-
# Verify a single task or all tasks:
|
|
148
|
-
python -m codegen_classroom.verify_task --task template --strict
|
|
149
|
-
python -m codegen_classroom.verify_task --all
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
A normal run (without `--mock_students`) ends by running the held-out final
|
|
153
|
-
evaluation, writing `report.md` and saved predictions to the run directory,
|
|
154
|
-
appending a row to the task's `leaderboard.tsv`, and exporting the top runs to
|
|
155
|
-
`solutions/`. `--report_only=<run_dir|latest>` only rebuilds `report.md` for an
|
|
156
|
-
existing run and never re-executes student code.
|
|
157
|
-
|
|
158
|
-
To add a new benchmark task, copy
|
|
159
|
-
[`tasks/template/`](./codegen_classroom/tasks/template/) or prompt a coding
|
|
160
|
-
agent with [`tasks/AGENTS.md`](./codegen_classroom/tasks/AGENTS.md) to scaffold
|
|
161
|
-
one end-to-end.
|
|
162
|
-
|
|
163
|
-
--------------------------------------------------------------------------------
|
|
164
|
-
|
|
165
|
-
## Classroom Learning Method
|
|
166
|
-
|
|
167
|
-
Each RSI cycle evolves parallel **Student Agents** across four stages:
|
|
168
|
-
|
|
169
|
-
1. **Generate, Self-Debug, and Execute**: Each student writes a Python
|
|
170
|
-
`solution(x_train, y_train, x_val)` function executed in a timed sandbox,
|
|
171
|
-
automatically repairing runtime or output contract errors before returning
|
|
172
|
-
predictions and diagnostic `feedback` (e.g., CV scores or feature
|
|
173
|
-
importances).
|
|
174
|
-
2. **Multi-Objective Scoring**: Predictions are evaluated against weighted task
|
|
175
|
-
metrics (e.g., R², MAPE, Macro-F1) and execution time, updating each
|
|
176
|
-
student's `best_score` and `best_solution`.
|
|
177
|
-
3. **Guided Refinement and Peer Crossover**: Students refine their code using
|
|
178
|
-
domain prompts and self-logged `feedback`. After `max_mutation_count`
|
|
179
|
-
stagnant cycles, a student applies a **Mutation Strategy**:
|
|
180
|
-
* `SELF_BEST_CODE`: Re-anchors on the student's own best solution.
|
|
181
|
-
* `BEST_PEER_CROSSOVER` / `BEST_PEER_REPLACEMENT`: Adopts feature
|
|
182
|
-
engineering and modeling ideas from top-scoring peers.
|
|
183
|
-
* `CONTRASTIVE_PEER_CROSSOVER`: Contrasts top peer solutions against
|
|
184
|
-
weaker attempts to combine winning patterns and avoid failure modes.
|
|
185
|
-
4. **Final Evaluation and Analysis**: Each student's `first`, `last`, and
|
|
186
|
-
`best` validation solutions are retrained on the full learning split and
|
|
187
|
-
evaluated once on the held-out test set, while `SolutionAnalysisAgent`
|
|
188
|
-
synthesizes results into `report.md` and `leaderboard.tsv`.
|
|
189
|
-
|
|
190
|
-
--------------------------------------------------------------------------------
|
|
191
|
-
|
|
192
|
-
## Library Structure
|
|
193
|
-
|
|
194
|
-
* [agent_config.py](./codegen_classroom/agent_config.py): Default model
|
|
195
|
-
configurations, generation parameters, pricing, environment resolution, and
|
|
196
|
-
execution timeouts.
|
|
197
|
-
* [agents.py](./codegen_classroom/agents.py): `StudentAgent` and
|
|
198
|
-
`SolutionAnalysisAgent` state management, token/cost tracking, refinement
|
|
199
|
-
prompts, and peer mutation strategies.
|
|
200
|
-
* [code_execution.py](./codegen_classroom/code_execution.py): Python code
|
|
201
|
-
extraction and timed subprocess execution capturing `stdout`, `stderr`, and
|
|
202
|
-
return values.
|
|
203
|
-
* [data_utils.py](./codegen_classroom/data_utils.py): Data loading, file
|
|
204
|
-
operations (`etils.epath`), run ID generation, and `leaderboard.tsv`
|
|
205
|
-
tracking.
|
|
206
|
-
* [metrics.py](./codegen_classroom/metrics.py): Performance metrics (MAE, R²,
|
|
207
|
-
Pearson, Macro-F1, Worst-Group Accuracy) and score normalization.
|
|
208
|
-
* [plotting.py](./codegen_classroom/plotting.py): Progress and final
|
|
209
|
-
evaluation plots via Matplotlib (headless PNG export) or Plotly (notebooks).
|
|
210
|
-
* [reporting.py](./codegen_classroom/reporting.py): Structured logging,
|
|
211
|
-
Markdown table formatting, and report export (`report.md`).
|
|
212
|
-
* [scoring.py](./codegen_classroom/scoring.py): Prediction validation (shape,
|
|
213
|
-
index, NaN checks) and weighted composite scoring.
|
|
214
|
-
* [student_learning.py](./codegen_classroom/student_learning.py): Parallel
|
|
215
|
-
classroom cycle orchestration and final test evaluation across `first`,
|
|
216
|
-
`last`, and `best` strategies.
|
|
217
|
-
* [verify_task.py](./codegen_classroom/verify_task.py): Automated structural,
|
|
218
|
-
notebook, solution report, and prompt hygiene verifier.
|
|
219
|
-
* [tasks/](./codegen_classroom/tasks/): Benchmark task suites,
|
|
220
|
-
[Task Authoring Guide](./codegen_classroom/tasks/AGENTS.md), and
|
|
221
|
-
[canonical template](./codegen_classroom/tasks/template/).
|
|
222
|
-
|
|
223
|
-
--------------------------------------------------------------------------------
|
|
224
|
-
|
|
225
249
|
## Disclaimer
|
|
226
250
|
|
|
227
251
|
**This is not an officially supported Google product.**
|
|
@@ -25,20 +25,20 @@ from etils import epath
|
|
|
25
25
|
# Default model used for standard agents and generic tasks.
|
|
26
26
|
# See available models at: https://ai.google.dev/gemini-api/docs/models
|
|
27
27
|
DEFAULT_MODEL = os.environ.get(
|
|
28
|
-
"CODEGEN_DEFAULT_MODEL", os.environ.get("GEMINI_MODEL", "gemini-3.
|
|
28
|
+
"CODEGEN_DEFAULT_MODEL", os.environ.get("GEMINI_MODEL", "gemini-3.8-flash")
|
|
29
29
|
)
|
|
30
30
|
|
|
31
|
-
# Default Gemini models available for student
|
|
31
|
+
# Default Gemini models available for student agents.
|
|
32
32
|
DEFAULT_GEMINI_MODELS = (
|
|
33
|
-
"gemini-
|
|
33
|
+
"gemini-4-argon", # "gemini-4-carbon"
|
|
34
|
+
"gemini-4-hydrogen",
|
|
34
35
|
"gemini-3.1-pro-preview",
|
|
35
36
|
"gemini-3.5-flash-lite",
|
|
36
|
-
"gemini-4-argon",
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
# Default Gemma open-weight models available for student agents.
|
|
40
40
|
DEFAULT_GEMMA_MODELS = (
|
|
41
|
-
"gemma-4-26b-a4b-it",
|
|
41
|
+
# "gemma-4-26b-a4b-it", # Prefer 31b.
|
|
42
42
|
"gemma-4-31b-it",
|
|
43
43
|
)
|
|
44
44
|
|
|
@@ -58,7 +58,10 @@ DEFAULT_STUDENT_MODELS = DEFAULT_GEMINI_MODELS + DEFAULT_GEMMA_MODELS
|
|
|
58
58
|
# https://aistudio.google.com/docs/pricing.md
|
|
59
59
|
MODEL_PRICING_PER_1M_TOKENS: dict[str, tuple[float, float]] = {
|
|
60
60
|
"gemini-4-argon": (2.00, 10.00),
|
|
61
|
+
"gemini-4-carbon": (2.00, 10.00),
|
|
62
|
+
"gemini-4-hydrogen": (1.50, 7.50),
|
|
61
63
|
"gemini-3.8-flash": (0.75, 3.75),
|
|
64
|
+
"gemini-3.7-flash": (0.75, 3.75),
|
|
62
65
|
"gemini-3.6-flash": (0.75, 3.75),
|
|
63
66
|
"gemini-3.5-flash": (0.50, 3.00),
|
|
64
67
|
"gemini-3-flash-preview": (0.50, 3.00),
|
|
@@ -90,6 +93,9 @@ DEFAULT_EXECUTION_TIMEOUT_SECONDS = 30
|
|
|
90
93
|
# Default HTTP request timeout in milliseconds for GenAI API calls.
|
|
91
94
|
DEFAULT_HTTP_TIMEOUT_MS = 300_000
|
|
92
95
|
|
|
96
|
+
# Default Gemini Developer API version passed to google-genai HttpOptions.
|
|
97
|
+
DEFAULT_API_VERSION = "v1beta"
|
|
98
|
+
|
|
93
99
|
# Default environment variables used to cap BLAS/OpenMP thread pools per worker.
|
|
94
100
|
DEFAULT_THREAD_LIMIT_ENV_VARS = (
|
|
95
101
|
"OMP_NUM_THREADS",
|