AryanSudhirDev commited on
Commit
3039eea
·
verified ·
1 Parent(s): 9ffcc6a

Replace Chronos release with selected Python repair adapter

Browse files

Publish the byte-exact balanced-short-v1-seed42-01 step120 LoRA adapter with pinned Qwen base revision, tokenizer, safe text-only repair helper and honest saved results including external regressions. Original Chronos release preserved under chronos-forecast-archive-20261120. Obsolete forecasting assets will be removed from main; no history rewrite.

LICENSE CHANGED
@@ -173,3 +173,30 @@
173
  defend, and hold each Contributor harmless for any liability
174
  incurred by, or claims asserted against, such Contributor by reason
175
  of your accepting any such warranty or additional liability.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  defend, and hold each Contributor harmless for any liability
174
  incurred by, or claims asserted against, such Contributor by reason
175
  of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2024 Alibaba Cloud
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
NOTICE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
-
3
- DE-LU forecasting research and release additions
4
- Copyright 2026 Aryan Sudhir
 
1
+ Based on Qwen/Qwen2.5-Coder-1.5B-Instruct, revision 2e1fd397ee46e1388853d2af2c993145b0f1098a.
2
+ Original model authors: Qwen team / Alibaba Cloud.
3
+ This repository distributes a separately trained Python repair LoRA adapter.
4
+ Base-model weights are obtained from the original Qwen repository.
README.md CHANGED
@@ -1,145 +1,131 @@
1
  ---
2
  license: apache-2.0
3
- library_name: chronos-forecasting
4
- pipeline_tag: time-series-forecasting
5
- base_model: amazon/chronos-2
6
- base_model_relation: finetune
 
 
7
  tags:
8
- - time-series
9
- - electricity-price-forecasting
10
- - chronos-2
11
- - lora
12
- - safetensors
 
 
13
  ---
14
 
15
- # Chronos-2 DE-LU pre-gate electricity price model
16
-
17
- **Author:** Aryan Sudhir ([AryanSudhirDev](https://huggingface.co/AryanSudhirDev)).
18
- **Source code:** [GitHub repository](https://github.com/AryanSudhirDev/chronos-2-de-lu-pregate).
19
- **Detailed documentation:** [results](docs/RESULTS.md), [research process](docs/METHODOLOGY.md),
20
- [reproduction](docs/REPRODUCIBILITY.md), [data contract](docs/DATA.md), [artifacts](docs/ARTIFACTS.md).
21
-
22
- Research checkpoint for forecasting 24 hourly German/Luxembourg electricity prices in EUR/MWh.
23
- This is the frozen pre-gate paper candidate, exported as standalone merged weights.
24
- It is an electricity model; the source project's folder name reflects an earlier crypto study.
25
-
26
- ## Contents and provenance
27
-
28
- - `model.safetensors` and `config.json`: complete Chronos-2 base plus learned LoRA updates.
29
- - `adapter/`: original learned adapter tensors and portable, revision-pinned configuration.
30
- - `calibration.json`: separate development-only hourly interval expansion, not neural weights.
31
- - `inference.py`: inference from numeric inputs; `requirements.txt`: export environment versions.
32
- - `manifest.json`: file hashes, pinned base revision, and synthetic reload verification.
33
- - `LICENSE`, any upstream `NOTICE`, and `MODIFICATIONS.md`: licensing and change attribution.
34
- - `example_input.json` and `make_example_input.py`: full-schema synthetic example, without real observations.
35
- - `source-release.zip`: code, tests, recorded forecasts, protocols and results from the linked GitHub snapshot.
36
- - `docs/`, `results.png`, `CITATION.cff`: full methodology/results, a labelled results figure and citation.
37
-
38
- Base: [amazon/chronos-2](https://huggingface.co/amazon/chronos-2), revision
39
- `29ec3766d36d6f73f0696f85560a422f50e8498c`. LoRA rank 8, alpha 16, dropout 0,
40
- with attention q/k/v/o and output patch embedding updates. The original base weights
41
- were frozen during adapter training. Export merges the trained updates without additional training.
42
-
43
- The frozen checkpoint is identified by adapter SHA-256
44
- `01fe7c491f30f3bbcb1265d3bbd53db226b5f0cfe3769d0519b94679462c48b5`.
45
- Calibration uses 303 earlier development days ending 2025-06-30.
46
- The holdout record declares a fitting cutoff of 2025-09-01.
47
-
48
- ## Run
49
-
50
- Use Python 3.12 and install `pip install -r requirements.txt` in an isolated environment.
51
- After downloading this repository:
52
-
53
- ```python
54
- from chronos import Chronos2Pipeline
55
-
56
- pipe = Chronos2Pipeline.from_pretrained("/path/to/downloaded/model", device_map="cpu")
57
- # item contains the arrays described below, represented as numpy float32 arrays.
58
- quantiles = pipe.predict([item], prediction_length=24)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  ```
60
 
61
- For JSON input and optional calibrated intervals:
 
62
 
63
- ```sh
64
- python make_example_input.py --output example_input.json
65
- python inference.py --model . --input inputs.json --output forecast.json --calibration calibration.json
 
 
 
66
  ```
67
 
68
- Use `--input example_input.json` for the generated synthetic example; `inputs.json` represents
69
- your own prepared market inputs. The synthetic output is a plumbing check, not an accuracy claim.
70
-
71
- `--device mps` can be used on a compatible Mac. CPU is the portable default.
72
- Merged weights load without PEFT; loading the optional standalone adapter requires PEFT.
73
-
74
- ## Required inputs
75
 
76
- The research inference setup uses 85 days of hourly history (2040 values), flattened
77
- from 24-hour Berlin delivery-day blocks:
78
 
79
- - `target`: historical DE-LU prices, in EUR/MWh.
80
- - `past_covariates`: matching hourly `load_fc`, `wind_fc`, `solar_fc`, plus neighbouring prices
81
- `price_be`, `price_fr`, `price_nl`, `price_dk1`, `price_at`, `price_ch`, `price_cz`.
82
- - `future_covariates`: 24 values each of `load_fc`, `wind_fc`, `solar_fc`.
83
-
84
- All listed channels are required by the helper. It validates finite aligned arrays and accepts
85
- 168–2040 history values; use 2040 to match the research context. Keep original units: prices
86
- in EUR/MWh and load/generation in MW. No external standardization is required.
87
-
88
- Only use information available before the D-1 noon Europe/Berlin auction deadline.
89
- For the forecast day, `wind_fc` and `solar_fc` must be pre-gate weather-derived estimates;
90
- the actual day-ahead TSO forecasts arrive after the deadline. Historical wind/solar covariates
91
- use historical TSO forecasts. The original pipeline maps DST delivery days onto 24 slots.
92
- Model outputs have axes target series, quantile, forecast hour; the helper returns hourly rows.
93
-
94
- Raw feeds, weather-to-generation LightGBM regressors, feed collection, DST preprocessing,
95
- reference models and battery dispatch are external to these neural weights. This package
96
- accepts prepared inputs; it does not reconstruct the full operational research pipeline.
97
- No raw market data or private credentials are included. Original study sources were SMARD,
98
- Energy-Charts and Open-Meteo; consult their terms for any separate data redistribution.
99
-
100
- ## Evaluation and limitations
101
-
102
- The pre-gate candidate's recorded one-time holdout MAE was **15.386 EUR/MWh** over
103
- 372 days, 2025-11-01 through 2026-11-09 (two delivery days missing). LEAR scored approximately
104
- 15.34 on the common window; this candidate did not establish an accuracy improvement
105
- (one-sided daily multivariate Diebold-Mariano p = 0.543). LEAR used post-gate TSO inputs,
106
- so the information sets differ. Other, post-gate Chronos variants performed better,
107
- but those results must not be attributed to this checkpoint.
108
-
109
- Walk-forward development and one-time holdout evaluation used isolated offline forecasting
110
- workers. This does not establish the base model's original pretraining cutoff or rule out
111
- overlap with its pretraining data. Evaluation involved multiple recorded research trials.
112
- Nominal quantiles do not guarantee coverage; interval expansion is a separate historical calibration.
113
- Paper observation stopped at five scored days at the user's request; no claim of a completed
114
- 30-day prospective validation is made.
115
-
116
- This is a research artifact, with no demonstrated live trading edge. Battery simulations
117
- depend on assumptions and do not establish deployable profitability. No trades are placed.
118
- Performance may change with market conditions, data availability and input preparation.
119
-
120
- ## What the broader study achieved
121
-
122
- On the same 372-day holdout, the post-auction research LoRA setup scored **12.3510 MAE**,
123
- versus zero-shot **13.4993** (8.51% lower); a compact blend reached **11.8143** against LEAR
124
- **15.3446** (23.01% lower). Those rows use wind/solar forecasts released after the gate,
125
- and the blend includes components outside these neural weights. The pre-gate setup remains
126
- **15.3860**. The original fit was reused with different future-covariate inputs.
127
-
128
- A later development-only pre-gate comparison (123 days, July–October 2025) scored LoRA
129
- **12.15**, LightGBM **12.69**, and LEAR **14.40**. Interval coverage rose from **71.1% to 83.6%**
130
- after past-only calibration. A single adaptive correction improved MAE but lowered constrained
131
- margin and was rejected. Prospective observation stopped at **five scored days**, with LoRA
132
- MAE **22.36** versus LEAR **20.12**. These follow-ups do not supply another untouched test.
133
 
134
- The research process included naive/LEAR/LightGBM baselines, covariate ablations, zero-shot
135
- Chronos, LoRA/full adaptation, residual stacks, blending, a timing audit, isolated one-time holdout
136
- evaluation and separate readiness/paper work. [Read the full account](docs/METHODOLOGY.md).
137
 
138
- ![Separated evaluation windows; lower MAE is better](results.png)
139
 
140
- ## Citation and licensing
 
 
 
 
 
 
 
141
 
142
- See `CITATION.cff` for this research artifact. Credit Amazon's Chronos-2 base model separately.
143
- The derivative weights and accompanying release code are Apache-2.0. `LICENSE`, upstream
144
- `NOTICE` and `MODIFICATIONS.md` preserve attribution and identify changes. Source data terms
145
- remain separate. No optimizer-resume state or every trained reference-model object is claimed.
 
1
  ---
2
  license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-Coder-1.5B-Instruct
4
+ base_model_relation: adapter
5
+ library_name: peft
6
+ pipeline_tag: text-generation
7
+ language:
8
+ - en
9
  tags:
10
+ - code
11
+ - python
12
+ - code-repair
13
+ - qwen2
14
+ - lora
15
+ - peft
16
+ - safetensors
17
  ---
18
 
19
+ # Python Code Repair — balanced step120
20
+
21
+ A trained LoRA adapter for **Qwen2.5-Coder-1.5B-Instruct** that proposes repairs to
22
+ Python functions while preserving their names, signatures and stated requirements.
23
+ This is the retained `balanced-short-v1-seed42-01` checkpoint at step120.
24
+ The base revision is pinned to `2e1fd397ee46e1388853d2af2c993145b0f1098a`.
25
+
26
+ **This repository now contains a Python repair model, not an electricity-price
27
+ forecaster.** The repository URL is retained at the owner's request. The previous
28
+ Chronos release remains available at revision
29
+ [`9ffcc6a064d27eb2c7657d3763554782710ceaca`](https://huggingface.co/AryanSudhirDev/chronos-2-de-lu-pregate/tree/9ffcc6a064d27eb2c7657d3763554782710ceaca).
30
+ Its forecasting results do not apply to this model.
31
+
32
+ ## What it does
33
+
34
+ Provide buggy Python code and a clear description of its intended behavior. The
35
+ model generates a proposed corrected function. It is a repair specialist trained
36
+ on authored synthetic examples; it is not established as a general coding upgrade.
37
+ Outputs require review. The supplied inference helper prints code and never
38
+ executes it or overwrites your input file.
39
+
40
+ ## Recorded results and limitations
41
+
42
+ These are saved results for this exact checkpoint, not new measurements for this
43
+ release. Development panels were reused, include correlated examples, and are
44
+ not independent confirmation of generalization.
45
+
46
+ | Condition | Base passed | Adapter passed |
47
+ | --- | ---: | ---: |
48
+ | Authored repair development, 72 tasks | 34/72 | 65/72 |
49
+ | Public development, 72 tasks, original three assertions only | 39/72 | 44/72 |
50
+ | Small public MBPP+ development screen, 24 tasks | 10/24 | 14/24 |
51
+ | External Original HumanEval, 164 tasks | 107/164 | 21/164 |
52
+ | External strict HumanEval+ (base AND plus), 164 tasks | 100/164 | 18/164 |
53
+
54
+ **The external assessment showed a strong regression.** The narrow repair gains
55
+ do not establish broader coding improvement. The HumanEval comparison used
56
+ matched greedy768-token decoding and local OS sandbox caps of 60 CPU seconds,
57
+ 65 wall seconds and 4096 MiB sampled RSS per group; this is not exact official CLI
58
+ or leaderboard resource parity. Public pretraining overlap is possible. Finite
59
+ static source reviews cannot prove correctness or noninterference. No OPAL,
60
+ statistical-significance, isolated training-mechanism or deployment-readiness
61
+ claim follows. The newer MBPP+ assessment03 evaluated a different, update-regularized
62
+ adapter and its scores must not be attributed to this checkpoint.
63
+
64
+ The original experiment documentation rejected this adapter as a general coding
65
+ replacement. It is distributed here as the explicitly selected retained repair
66
+ checkpoint, with the negative results preserved. Research remains stopped.
67
+ Machine-readable counts are in `results.json`.
68
+
69
+ ## Use locally
70
+
71
+ This repository ships the adapter and tokenizer, not another copy of the 1.5B
72
+ base weights. The first load obtains the pinned Qwen base. No paid API or hosted
73
+ inference service is included. A Hugging Face model page is not a hosted chat app.
74
+
75
+ ```bash
76
+ python -m pip install -r requirements.txt
77
  ```
78
 
79
+ Download this repository to a local directory with `hf download`, or clone it
80
+ with Git LFS, then run its helper:
81
 
82
+ ```bash
83
+ hf download AryanSudhirDev/chronos-2-de-lu-pregate --local-dir ./python-repair
84
+ python ./python-repair/inference.py \
85
+ --code ./buggy.py \
86
+ --requirements "Describe the required behavior and constraints here" \
87
+ --device cpu
88
  ```
89
 
90
+ On an Apple Silicon Mac, use `--device mps` for bfloat16 inference. CPU uses
91
+ float32. Add `--offline` once the base is cached. The helper uses greedy decoding,
92
+ seed42, at most 384 new tokens and a 3072-token prompt ceiling; it rejects long
93
+ inputs rather than silently truncating. This new free-form usage prompt is a
94
+ convenience interface, not a newly evaluated benchmark condition.
 
 
95
 
96
+ ### Load with Transformers and PEFT
 
97
 
98
+ ```python
99
+ import torch
100
+ from transformers import AutoModelForCausalLM, AutoTokenizer
101
+ from peft import PeftModel
102
+
103
+ repo = "AryanSudhirDev/chronos-2-de-lu-pregate"
104
+ base = "Qwen/Qwen2.5-Coder-1.5B-Instruct"
105
+ revision = "2e1fd397ee46e1388853d2af2c993145b0f1098a"
106
+ tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=False)
107
+ model = AutoModelForCausalLM.from_pretrained(
108
+ base, revision=revision, torch_dtype=torch.float32, trust_remote_code=False,
109
+ attn_implementation="eager",
110
+ )
111
+ model = PeftModel.from_pretrained(model, repo, is_trainable=False).eval()
112
+ ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
+ Use the tokenizer's user/assistant chat template to submit a repair prompt.
115
+ Never execute untrusted generated code directly on your host.
 
116
 
117
+ ## Files and provenance
118
 
119
+ - `adapter_model.safetensors`: byte-exact trained adapter weights.
120
+ - `adapter_config.json`: portable public base-model name and pinned revision;
121
+ the remaining training adapter settings are unchanged.
122
+ - Tokenizer files: copied from the pinned Qwen base.
123
+ - `inference.py`: repair CLI; generates text only, never runs generated code.
124
+ - `training_metadata.json`, `results.json`, `release_manifest.json`: identity,
125
+ recorded evidence and file hashes. No optimizer state, private tests, hidden
126
+ inputs, canonical answers or benchmark task bodies are distributed.
127
 
128
+ LoRA rank8, alpha16, dropout0; attention q/k/v/o projections; training seed42;
129
+ 120 updates. The original base model and tokenizer are by the Qwen team /
130
+ Alibaba Cloud. This adapter does not claim authorship of Qwen. The upstream
131
+ Apache-2.0 license is preserved in `LICENSE` and attribution in `NOTICE`.
adapter_config.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": null,
6
+ "base_model_name_or_path": "Qwen/Qwen2.5-Coder-1.5B-Instruct",
7
+ "bias": "none",
8
+ "corda_config": null,
9
+ "ensure_weight_tying": false,
10
+ "eva_config": null,
11
+ "exclude_modules": null,
12
+ "fan_in_fan_out": false,
13
+ "inference_mode": true,
14
+ "init_lora_weights": true,
15
+ "layer_replication": null,
16
+ "layers_pattern": null,
17
+ "layers_to_transform": null,
18
+ "loftq_config": {},
19
+ "lora_alpha": 16,
20
+ "lora_bias": false,
21
+ "lora_dropout": 0.0,
22
+ "megatron_config": null,
23
+ "megatron_core": "megatron.core",
24
+ "modules_to_save": null,
25
+ "peft_type": "LORA",
26
+ "peft_version": "0.18.0",
27
+ "qalora_group_size": 16,
28
+ "r": 8,
29
+ "rank_pattern": {},
30
+ "revision": "2e1fd397ee46e1388853d2af2c993145b0f1098a",
31
+ "target_modules": [
32
+ "k_proj",
33
+ "q_proj",
34
+ "v_proj",
35
+ "o_proj"
36
+ ],
37
+ "target_parameters": null,
38
+ "task_type": "CAUSAL_LM",
39
+ "trainable_token_indices": null,
40
+ "use_dora": false,
41
+ "use_qalora": false,
42
+ "use_rslora": false
43
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4143f198e544c6901a71ea76eeefbaf6992d6d5602ada6354b2f070f17ae6496
3
+ size 8745704
inference.py CHANGED
@@ -1,63 +1,106 @@
1
- """Forecast from prepared numeric inputs; no data downloads or model training.
2
-
3
- python inference.py --model . --input inputs.json --output forecast.json
4
- Input keys: target (hourly history), past_covariates (matching history arrays),
5
- future_covariates (24-hour arrays). See README.md for the required information set.
6
- """
7
- import argparse
8
- import json
9
  from pathlib import Path
 
 
 
 
10
 
11
- import numpy as np
12
- from chronos import Chronos2Pipeline
13
-
14
- PAST_KEYS = {"load_fc", "wind_fc", "solar_fc", "price_be", "price_fr", "price_nl",
15
- "price_dk1", "price_at", "price_ch", "price_cz"}
16
- FUTURE_KEYS = {"load_fc", "wind_fc", "solar_fc"}
17
-
18
-
19
- def forecast(model_path, item, device="cpu", calibration_path=None):
20
- item = dict(item)
21
- item["target"] = np.asarray(item["target"], dtype=np.float32)
22
- if item["target"].ndim != 1 or not np.isfinite(item["target"]).all():
23
- raise ValueError("target must be a finite hourly vector")
24
- if not 168 <= len(item["target"]) <= 2040:
25
- raise ValueError("supply 168..2040 hourly values; the research setup used 2040")
26
- for key, length in [("past_covariates", len(item["target"])), ("future_covariates", 24)]:
27
- item[key] = {k: np.asarray(v, dtype=np.float32) for k, v in item.get(key, {}).items()}
28
- if any(v.shape != (length,) or not np.isfinite(v).all() for v in item[key].values()):
29
- raise ValueError(f"{key} must contain finite arrays of length {length}")
30
- expected = PAST_KEYS if key == "past_covariates" else FUTURE_KEYS
31
- if set(item[key]) != expected:
32
- raise ValueError(f"{key} requires exactly these keys: {sorted(expected)}")
33
- pipe = Chronos2Pipeline.from_pretrained(model_path, device_map=device)
34
- q = pipe.predict([item], prediction_length=24)[0][0].float().cpu().numpy().T
35
- if not np.isfinite(q).all():
36
- raise ValueError("model produced non-finite quantiles")
37
- levels = np.asarray(pipe.quantiles)
38
- idx = lambda level: int(np.argmin(np.abs(levels - level)))
39
- result = dict(median=q[:, idx(.5)].tolist(), quantile_levels=levels.tolist(), quantiles=q.tolist())
40
- if calibration_path:
41
- adjustment = np.asarray(json.loads(Path(calibration_path).read_text())["adjustment"])
42
- if adjustment.shape != (24,) or not np.isfinite(adjustment).all():
43
- raise ValueError("calibration must contain 24 finite hourly adjustments")
44
- result.update(lower80=(q[:, idx(.1)] - adjustment).tolist(),
45
- upper80=(q[:, idx(.9)] + adjustment).tolist())
46
- return result
47
 
48
 
49
- if __name__ == "__main__":
50
- parser = argparse.ArgumentParser()
51
- parser.add_argument("--model", default=".")
52
- parser.add_argument("--input", required=True)
53
- parser.add_argument("--output", required=True)
54
- parser.add_argument("--device", default="cpu")
55
- parser.add_argument("--calibration", help="Optional path to calibration.json")
56
- parser.add_argument("--threads", type=int, default=4, help="CPU threads (default: 4)")
57
- args = parser.parse_args()
58
- if args.threads < 1:
59
- parser.error("--threads must be positive")
 
 
 
 
 
 
60
  import torch
61
- torch.set_num_threads(args.threads)
62
- result = forecast(args.model, json.loads(Path(args.input).read_text()), args.device, args.calibration)
63
- Path(args.output).write_text(json.dumps(result, indent=2) + "\n")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Generate a proposed Python repair. Never execute the returned code."""
 
 
 
 
 
 
 
2
  from pathlib import Path
3
+ import argparse
4
+ import os
5
+ import re
6
+ import sys
7
 
8
+ BASE_MODEL = "Qwen/Qwen2.5-Coder-1.5B-Instruct"
9
+ BASE_REVISION = "2e1fd397ee46e1388853d2af2c993145b0f1098a"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
 
12
+ def extract_code(answer):
13
+ blocks = re.findall(r"```(?:python|py)?\s*\n(.*?)```", answer, re.S)
14
+ return blocks[-1].strip() if blocks else answer.strip()
15
+
16
+
17
+ def build_prompt(code, requirements):
18
+ return (
19
+ "Repair the Python function below. Preserve its function name, signature, "
20
+ "and every stated requirement. Return only the complete corrected Python "
21
+ "code in a Python code block.\n\nRequirements:\n"
22
+ + requirements + "\n\nBuggy Python code:\n```python\n" + code + "\n```"
23
+ )
24
+
25
+
26
+ def load_model(adapter, device, offline=False):
27
+ if os.environ.get("PYTORCH_ENABLE_MPS_FALLBACK") == "1":
28
+ raise RuntimeError("Unset PYTORCH_ENABLE_MPS_FALLBACK before loading.")
29
  import torch
30
+ from transformers import AutoModelForCausalLM, AutoTokenizer
31
+ from peft import PeftModel
32
+
33
+ if device == "mps" and not torch.backends.mps.is_available():
34
+ raise RuntimeError("MPS unavailable; select --device cpu explicitly.")
35
+ dtype = torch.bfloat16 if device == "mps" else torch.float32
36
+ tokenizer = AutoTokenizer.from_pretrained(
37
+ str(adapter), local_files_only=True, trust_remote_code=False
38
+ )
39
+ model = AutoModelForCausalLM.from_pretrained(
40
+ BASE_MODEL, revision=BASE_REVISION, local_files_only=offline,
41
+ trust_remote_code=False, torch_dtype=dtype,
42
+ attn_implementation="eager",
43
+ )
44
+ model = PeftModel.from_pretrained(model, str(adapter), is_trainable=False)
45
+ return model.to(device).eval(), tokenizer
46
+
47
+
48
+ def propose_repair(model, tokenizer, code, requirements, *, device, max_new_tokens=384):
49
+ import torch
50
+ if not 1 <= max_new_tokens <= 384:
51
+ raise ValueError("max_new_tokens must be between 1 and 384")
52
+ messages = [{"role": "user", "content": build_prompt(code, requirements)}]
53
+ inputs = tokenizer.apply_chat_template(
54
+ messages, tokenize=True, add_generation_prompt=True, return_tensors="pt"
55
+ )
56
+ if inputs.shape[-1] > 3072:
57
+ raise ValueError("Prompt exceeds 3072 tokens; shorten it. No silent truncation.")
58
+ inputs = inputs.to(device)
59
+ torch.manual_seed(42)
60
+ if device == "mps":
61
+ torch.mps.manual_seed(42)
62
+ # Build a fresh greedy configuration rather than inheriting sampling defaults.
63
+ from transformers import GenerationConfig
64
+ config = GenerationConfig(
65
+ do_sample=False, num_beams=1, max_new_tokens=max_new_tokens,
66
+ eos_token_id=model.generation_config.eos_token_id,
67
+ pad_token_id=(tokenizer.pad_token_id if tokenizer.pad_token_id is not None
68
+ else tokenizer.eos_token_id),
69
+ use_cache=True,
70
+ )
71
+ with torch.inference_mode():
72
+ output = model.generate(
73
+ input_ids=inputs, attention_mask=torch.ones_like(inputs),
74
+ generation_config=config,
75
+ )
76
+ answer = tokenizer.decode(output[0, inputs.shape[-1]:], skip_special_tokens=True)
77
+ return extract_code(answer)
78
+
79
+
80
+ def main():
81
+ parser = argparse.ArgumentParser(description=__doc__)
82
+ parser.add_argument("--code", type=Path, help="Buggy Python file; omit to read stdin")
83
+ parser.add_argument("--requirements", required=True, help="Expected behavior and constraints")
84
+ parser.add_argument("--adapter", type=Path, default=Path(__file__).resolve().parent)
85
+ parser.add_argument("--device", choices=["cpu", "mps"], default="cpu")
86
+ parser.add_argument("--offline", action="store_true", help="Require cached base weights")
87
+ parser.add_argument("--max-new-tokens", type=int, default=384)
88
+ args = parser.parse_args()
89
+ if not 1 <= args.max_new_tokens <= 384:
90
+ parser.error("--max-new-tokens must be between 1 and 384")
91
+ if args.code:
92
+ with args.code.open("r", encoding="utf-8") as source:
93
+ code = source.read(1_048_577)
94
+ else:
95
+ code = sys.stdin.read(1_048_577)
96
+ if not code.strip() or len(code) > 1_048_576:
97
+ parser.error("Code must be nonempty and at most 1048576 characters")
98
+ if not args.requirements.strip() or len(args.requirements) > 65_536:
99
+ parser.error("Requirements must be nonempty and at most 65536 characters")
100
+ model, tokenizer = load_model(args.adapter, args.device, args.offline)
101
+ print(propose_repair(model, tokenizer, code, args.requirements,
102
+ device=args.device, max_new_tokens=args.max_new_tokens))
103
+
104
+
105
+ if __name__ == "__main__":
106
+ main()
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
release_manifest.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": 1,
3
+ "repo_id": "AryanSudhirDev/chronos-2-de-lu-pregate",
4
+ "selected_variant": "balanced-short-v1-seed42-01",
5
+ "step": 120,
6
+ "base_model": "Qwen/Qwen2.5-Coder-1.5B-Instruct",
7
+ "base_revision": "2e1fd397ee46e1388853d2af2c993145b0f1098a",
8
+ "previous_chronos_revision": "9ffcc6a064d27eb2c7657d3763554782710ceaca",
9
+ "previous_chronos_archive_tag": "chronos-forecast-archive-20261120",
10
+ "manifest_self_excluded": true,
11
+ "files": {
12
+ "LICENSE": {
13
+ "sha256": "832dd9e00a68dd83b3c3fb9f5588dad7dcf337a0db50f7d9483f310cd292e92e",
14
+ "bytes": 11343
15
+ },
16
+ "NOTICE": {
17
+ "sha256": "fe102a6338b72379694fd26acc93880e050d84158fca2f235cb496eebfc43e8a",
18
+ "bytes": 289
19
+ },
20
+ "README.md": {
21
+ "sha256": "7fa174a90f0ff45e711e33c4e42aa515dd14e41f4a2a26cd7ae5aa1ea344d3fa",
22
+ "bytes": 5726
23
+ },
24
+ "adapter_config.json": {
25
+ "sha256": "88ae3e40951417ba9aaea8421abcc44fd7462e7160b471356b7f52f349cc1a4d",
26
+ "bytes": 1051
27
+ },
28
+ "adapter_model.safetensors": {
29
+ "sha256": "4143f198e544c6901a71ea76eeefbaf6992d6d5602ada6354b2f070f17ae6496",
30
+ "bytes": 8745704
31
+ },
32
+ "inference.py": {
33
+ "sha256": "82bbfca6b5241135617b9f243b5a9d00cd4592a3ca2ea9b160e6789da7db4da9",
34
+ "bytes": 4624
35
+ },
36
+ "merges.txt": {
37
+ "sha256": "599bab54075088774b1733fde865d5bd747cbcc7a547c5bc12610e874e26f5e3",
38
+ "bytes": 1671839
39
+ },
40
+ "requirements.txt": {
41
+ "sha256": "3661e4fa84961630aa0c876b0f6db7325aeba18dd71f43ace040711850fb1fd5",
42
+ "bytes": 90
43
+ },
44
+ "results.json": {
45
+ "sha256": "e817e946b56ede5a8a3e4eb4a7158ed84648eaafc007b18b239e1296ba2585a1",
46
+ "bytes": 1324
47
+ },
48
+ "tokenizer.json": {
49
+ "sha256": "c0382117ea329cdf097041132f6d735924b697924d6f6fc3945713e96ce87539",
50
+ "bytes": 7031645
51
+ },
52
+ "tokenizer_config.json": {
53
+ "sha256": "959e7f1d9a1b7641a6d6ce05ca97b75c7894fcb66cbe5a040406458fb1128ee4",
54
+ "bytes": 7305
55
+ },
56
+ "training_metadata.json": {
57
+ "sha256": "562f73a083a58721e6f82840aa430b9cdbf06f13d01732aca4dc9e938d773598",
58
+ "bytes": 850
59
+ },
60
+ "vocab.json": {
61
+ "sha256": "ca10d7e9fb3ed18575dd1e277a2579c16d108e32f27439684afa0e10b1440910",
62
+ "bytes": 2776833
63
+ }
64
+ }
65
+ }
requirements.txt CHANGED
@@ -1,6 +1,5 @@
1
- chronos-forecasting==2.3.2
2
- peft==0.21.2
3
- torch==2.15.0
4
- transformers==5.22.2
5
- huggingface-hub==2.4.0
6
- numpy==2.5.4
 
1
+ torch==2.9.1
2
+ transformers==4.57.3
3
+ peft==0.18.0
4
+ huggingface_hub==0.36.0
5
+ safetensors==0.7.0
 
results.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "scope": "Saved results only; no new evaluation for this release.",
3
+ "checkpoint": "runs/balanced-short-v1-seed42-01/checkpoint",
4
+ "development": {
5
+ "authored_repair72": {
6
+ "n": 72,
7
+ "base_passed": 34,
8
+ "adapter_passed": 65
9
+ },
10
+ "public_original_assertions72": {
11
+ "n": 72,
12
+ "base_passed": 39,
13
+ "adapter_passed": 44,
14
+ "warning": "Three original assertions per task; not expanded MBPP+."
15
+ },
16
+ "small_public_mbppplus24": {
17
+ "n": 24,
18
+ "base_passed": 10,
19
+ "adapter_passed": 14
20
+ }
21
+ },
22
+ "external_negative": {
23
+ "humaneval_plus": {
24
+ "n": 164,
25
+ "base_passed": 100,
26
+ "adapter_passed": 18
27
+ },
28
+ "original_humaneval": {
29
+ "n": 164,
30
+ "base_passed": 107,
31
+ "adapter_passed": 21
32
+ },
33
+ "condition": "Matched greedy768, prompt3072, seed42, MPS bf16; local OS sandbox60CPU/65wall/4096MiB whole-group caps, not exact officialCLI parity."
34
+ },
35
+ "limits": [
36
+ "Development panels were reused and have correlated templates.",
37
+ "Public tasks may overlap pretraining.",
38
+ "Strong external retention regression: not a general coding improvement.",
39
+ "Static integrity reviews are finite evidence, not proof.",
40
+ "The newer MBPP+ assessment03 evaluated a different update-regularized adapter, not this checkpoint."
41
+ ]
42
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ }
181
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0]['role'] == 'system' %}\n {{- messages[0]['content'] }}\n {%- else %}\n {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}\n {%- endif %}\n {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0]['role'] == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + message.content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n",
199
+ "clean_up_tokenization_spaces": false,
200
+ "eos_token": "<|im_end|>",
201
+ "errors": "replace",
202
+ "model_max_length": 32768,
203
+ "pad_token": "<|endoftext|>",
204
+ "split_special_tokens": false,
205
+ "tokenizer_class": "Qwen2Tokenizer",
206
+ "unk_token": null
207
+ }
training_metadata.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "variant": "balanced-short-v1-seed42-01",
3
+ "step": 120,
4
+ "seed": 42,
5
+ "peft_type": "LORA",
6
+ "rank": 8,
7
+ "alpha": 16,
8
+ "dropout": 0.0,
9
+ "target_modules": [
10
+ "k_proj",
11
+ "o_proj",
12
+ "q_proj",
13
+ "v_proj"
14
+ ],
15
+ "base_model": "Qwen/Qwen2.5-Coder-1.5B-Instruct",
16
+ "base_revision": "2e1fd397ee46e1388853d2af2c993145b0f1098a",
17
+ "historical_config_hash": "7898d4b581fd79c4f409b7bc27128222f3a8710fa6d0f00597c55f0ed5a172be",
18
+ "source_adapter_sha256": "4143f198e544c6901a71ea76eeefbaf6992d6d5602ada6354b2f070f17ae6496",
19
+ "source_complete_sha256": "6fb7802895b4652eb11b1623a27d814b6ec180eb5c0629d8435ce984326f05fc",
20
+ "portable_configuration_changes": [
21
+ "Replaced machine-specific base path with public Qwen repository.",
22
+ "Pinned base revision."
23
+ ],
24
+ "original_checkpoint_modified": false,
25
+ "optimizer_state_included": false
26
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff