tunekeep 0.2.1__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.
tunekeep-0.2.1/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
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 [yyyy] [name of copyright owner]
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.
@@ -0,0 +1,185 @@
1
+ Metadata-Version: 2.4
2
+ Name: tunekeep
3
+ Version: 0.2.1
4
+ Summary: Keep a fine-tuned model working after its provider retires the base model: inventory, record, compare, retrain on open weights.
5
+ Keywords: fine-tuning,openai,llm,lora,migration,evaluation
6
+ Author: Rush Labs
7
+ Author-email: Rush Labs <admin@rushlabs.ai>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Requires-Python: >=3.10
17
+ Project-URL: Homepage, https://rushlabs.ai/lab
18
+ Project-URL: Source, https://github.com/rushlabs-ai/tunekeep
19
+ Project-URL: Issues, https://github.com/rushlabs-ai/tunekeep/issues
20
+ Description-Content-Type: text/markdown
21
+
22
+ # tunekeep
23
+
24
+ Keep a fine-tuned model working after its provider retires the base model.
25
+
26
+ OpenAI shuts down fine-tuned **gpt-4o, gpt-4o-mini, gpt-4.1 and gpt-4.1-mini** models on
27
+ **14 January 2027**, and stops new fine-tuning jobs on **6 January 2027**. The named replacement,
28
+ `gpt-6-luna`, cannot be fine-tuned. Once a model is gone, so is the only exact record of how it behaved.
29
+
30
+ tunekeep helps you get out in time:
31
+
32
+ | Step | Command |
33
+ |---|---|
34
+ | 1. See every fine-tune you own and its days left | `tunekeep inventory` |
35
+ | 2. Record how each model answers, as a golden eval set | `tunekeep record` |
36
+ | 3. Check whether gpt-6-luna (or any model) already matches it | `tunekeep compare` |
37
+ | 4. Retrain an open model with LoRA from your own data | `tunekeep retrain` |
38
+ | 5. One HTML report: quality, speed and tokens side by side | `tunekeep report` |
39
+
40
+ **Do the recording first.** Everything else can happen later; recording cannot happen after the shutdown.
41
+
42
+ ## Install
43
+
44
+ ```sh
45
+ uv tool install tunekeep # or: pipx install tunekeep
46
+ ```
47
+
48
+ Python 3.10+. **No dependencies**: tunekeep uses only the Python standard library. (The retraining
49
+ kit it writes has its own pinned requirements, installed only where you run it.)
50
+
51
+ ## 1. Inventory
52
+
53
+ ```sh
54
+ export OPENAI_API_KEY=sk-... # a key for the org/project that owns the fine-tunes
55
+ tunekeep inventory
56
+ ```
57
+
58
+ ```text
59
+ Fine-tuned models: 1 (plus 1 checkpoint)
60
+ New fine-tuning jobs stop on 2027-01-06 (60 days).
61
+
62
+ MODEL SHUTS DOWN DAYS LEFT SOURCE
63
+ ft:gpt-4o-mini-2024-07-18:acme::AbC123 2027-01-14 68 api
64
+
65
+ Files: 1 saved, 1 training/validation file the API would not return.
66
+ Keep your own copy of these; tunekeep retrains only from your original data:
67
+ - file-train-0 train.jsonl (job ftjob-000)
68
+
69
+ Next: record how each model behaves while it still answers, e.g.
70
+ tunekeep record --model ft:gpt-4o-mini-2024-07-18:acme::AbC123 --prompts prompts.jsonl
71
+ ```
72
+
73
+ `tunekeep-out/inventory.json` holds the full detail: jobs, hyperparameters, checkpoints and their
74
+ metrics, and every file. Result files (training metrics) are downloaded. Files you uploaded for
75
+ training are not: OpenAI does not return them through the API, so keep your own copy.
76
+
77
+ ## 2. Record
78
+
79
+ ```sh
80
+ tunekeep record --model ft:gpt-4o-mini-2024-07-18:acme::AbC123 --prompts prompts.jsonl
81
+ ```
82
+
83
+ - `prompts.jsonl` can be your **training file as-is**. The final assistant message on each line is
84
+ removed before sending and kept as the reference answer. DPO lines (`input.messages`) work too.
85
+ - Real production prompts make the best golden set. Use a few hundred, covering your real traffic.
86
+ - Answers are recorded at `temperature 0` by default. Use `--seed` for more repeatable runs.
87
+ - Safe to stop and re-run: prompts already recorded are skipped, failed ones are retried.
88
+ - `--dry-run` counts prompts and estimated input tokens without sending anything.
89
+
90
+ ## 3. Compare
91
+
92
+ ```sh
93
+ tunekeep compare --golden tunekeep-out/golden-ft_gpt-4o-mini-2024-07-18_acme_AbC123.jsonl \
94
+ --candidate gpt-6-luna --examples train.jsonl --shots 5
95
+ ```
96
+
97
+ Each recorded prompt goes to the candidate, optionally with a few examples from **your own**
98
+ training file, and the answer is scored against the recorded one:
99
+
100
+ - **Tool calls**: matched by function name, arguments compared field by field.
101
+ - **JSON answers**: the share of leaf fields with the same value; invalid JSON scores 0.
102
+ - **Text**: 100% when equal after normalising case and spacing, otherwise word overlap (F1). Overlap
103
+ is a rough signal for free text, so the report shows the biggest differences side by side.
104
+
105
+ GPT-6 Luna reasons by default, and in Chat Completions it accepts `temperature` and function tools
106
+ only with `reasoning_effort: "none"`. tunekeep sends `none` by default (`--reasoning-effort auto`),
107
+ which is also closest to how a fine-tuned gpt-4o-mini answered. Try `--reasoning-effort low` to see
108
+ whether reasoning helps; tunekeep then drops `temperature`, and refuses before sending anything if your
109
+ prompts use tools.
110
+
111
+ Any OpenAI-compatible endpoint works as a candidate: `--candidate-base-url http://127.0.0.1:8080/v1`
112
+ for llama-server, vLLM or Ollama (no key needed on localhost; `--candidate-key-env` for others).
113
+
114
+ ## 4. Retrain
115
+
116
+ ```sh
117
+ tunekeep retrain --data train.jsonl # default base: Qwen/Qwen3-1.7B, pinned revision
118
+ cd tunekeep-out/retrain && modal run modal_app.py
119
+ ```
120
+
121
+ `retrain` converts your OpenAI training file (chat format, tools, legacy `functions`, per-message
122
+ `weight`) and writes a small kit: your data, a config, a training script and a [Modal](https://modal.com)
123
+ app. It uploads nothing itself. The kit:
124
+
125
+ - trains a LoRA adapter with loss only on assistant messages (`"weight": 0` turns are skipped, as on OpenAI);
126
+ - reuses your original job's epoch count when `tunekeep-out/inventory.json` has it;
127
+ - pins every package by hash, the base model by revision, and llama.cpp by commit;
128
+ - stops after a time limit (default 2 hours), which caps the cost of a run;
129
+ - exports merged weights and a q8_0 GGUF for llama-server or Ollama.
130
+
131
+ Use `--check` to only validate and summarise the data. See the kit's own README for running it
132
+ elsewhere and serving the result. Not yet supported: DPO, images and audio in training data.
133
+
134
+ ## 5. Report
135
+
136
+ ```sh
137
+ tunekeep report # reads tunekeep-out/, writes tunekeep-out/report.html
138
+ ```
139
+
140
+ One self-contained HTML file with deadlines, every candidate's scores, latency and token use, and
141
+ the lowest-scoring answers side by side. It loads nothing from the network and runs no scripts, and
142
+ every value from your data is escaped.
143
+
144
+ ## What tunekeep will not do
145
+
146
+ **It never trains on recorded outputs.** OpenAI's Services Agreement (section 3.3(e)) restricts using
147
+ Output to develop competing models. Recorded answers are used only to *evaluate* a replacement.
148
+ Retraining uses only your original training data. If that data was itself generated by an OpenAI
149
+ model, it counts as Output too. Check with your own counsel; this is not legal advice.
150
+
151
+ ## Privacy
152
+
153
+ - tunekeep talks only to the API base URLs you give it. No telemetry, no other network calls.
154
+ - Outputs can contain production prompts, so the output folder is created `0700` and files `0600`.
155
+ - API keys are read from the environment and are never written to disk or printed. A candidate
156
+ endpoint never receives your OpenAI key unless you name that variable with `--candidate-key-env`.
157
+
158
+ ## Other providers
159
+
160
+ - `--base-url` / `OPENAI_BASE_URL` for OpenAI-compatible gateways.
161
+ - `--azure --base-url https://<resource>.openai.azure.com/openai/v1` with `AZURE_OPENAI_API_KEY`
162
+ (**experimental**). Azure retires fine-tuned gpt-4o and gpt-4o-mini deployments on 1 October 2027, and
163
+ the gpt-4.1 family on 14 October 2027.
164
+
165
+ ## Development
166
+
167
+ ```sh
168
+ python -m unittest discover -s tests -v
169
+ ```
170
+
171
+ The tests run against a fake OpenAI server built from the public API reference: pagination, the
172
+ `shutdown_date` field, blocked training-file downloads, rate limits, tool calls and GPT-6 Luna's
173
+ parameter rules. The retraining kit is tested end to end on CPU with Qwen3-0.6B.
174
+ `tools/lock-kit.sh` regenerates the kit's hash-locked requirements.
175
+ **Reports from real accounts are very welcome.** Please open an issue with anything that behaves differently.
176
+
177
+ ## Sources
178
+
179
+ - OpenAI deprecations: https://developers.openai.com/api/docs/deprecations
180
+ - GPT-6 parameters: https://developers.openai.com/api/docs/guides/latest-model
181
+ - Azure retirement schedule: https://learn.microsoft.com/en-us/azure/foundry/openai/concepts/model-retirement-schedule
182
+
183
+ ## Licence
184
+
185
+ Apache-2.0. Built by [Rush Labs](https://rushlabs.ai), an applied AI lab.
@@ -0,0 +1,164 @@
1
+ # tunekeep
2
+
3
+ Keep a fine-tuned model working after its provider retires the base model.
4
+
5
+ OpenAI shuts down fine-tuned **gpt-4o, gpt-4o-mini, gpt-4.1 and gpt-4.1-mini** models on
6
+ **14 January 2027**, and stops new fine-tuning jobs on **6 January 2027**. The named replacement,
7
+ `gpt-6-luna`, cannot be fine-tuned. Once a model is gone, so is the only exact record of how it behaved.
8
+
9
+ tunekeep helps you get out in time:
10
+
11
+ | Step | Command |
12
+ |---|---|
13
+ | 1. See every fine-tune you own and its days left | `tunekeep inventory` |
14
+ | 2. Record how each model answers, as a golden eval set | `tunekeep record` |
15
+ | 3. Check whether gpt-6-luna (or any model) already matches it | `tunekeep compare` |
16
+ | 4. Retrain an open model with LoRA from your own data | `tunekeep retrain` |
17
+ | 5. One HTML report: quality, speed and tokens side by side | `tunekeep report` |
18
+
19
+ **Do the recording first.** Everything else can happen later; recording cannot happen after the shutdown.
20
+
21
+ ## Install
22
+
23
+ ```sh
24
+ uv tool install tunekeep # or: pipx install tunekeep
25
+ ```
26
+
27
+ Python 3.10+. **No dependencies**: tunekeep uses only the Python standard library. (The retraining
28
+ kit it writes has its own pinned requirements, installed only where you run it.)
29
+
30
+ ## 1. Inventory
31
+
32
+ ```sh
33
+ export OPENAI_API_KEY=sk-... # a key for the org/project that owns the fine-tunes
34
+ tunekeep inventory
35
+ ```
36
+
37
+ ```text
38
+ Fine-tuned models: 1 (plus 1 checkpoint)
39
+ New fine-tuning jobs stop on 2027-01-06 (60 days).
40
+
41
+ MODEL SHUTS DOWN DAYS LEFT SOURCE
42
+ ft:gpt-4o-mini-2024-07-18:acme::AbC123 2027-01-14 68 api
43
+
44
+ Files: 1 saved, 1 training/validation file the API would not return.
45
+ Keep your own copy of these; tunekeep retrains only from your original data:
46
+ - file-train-0 train.jsonl (job ftjob-000)
47
+
48
+ Next: record how each model behaves while it still answers, e.g.
49
+ tunekeep record --model ft:gpt-4o-mini-2024-07-18:acme::AbC123 --prompts prompts.jsonl
50
+ ```
51
+
52
+ `tunekeep-out/inventory.json` holds the full detail: jobs, hyperparameters, checkpoints and their
53
+ metrics, and every file. Result files (training metrics) are downloaded. Files you uploaded for
54
+ training are not: OpenAI does not return them through the API, so keep your own copy.
55
+
56
+ ## 2. Record
57
+
58
+ ```sh
59
+ tunekeep record --model ft:gpt-4o-mini-2024-07-18:acme::AbC123 --prompts prompts.jsonl
60
+ ```
61
+
62
+ - `prompts.jsonl` can be your **training file as-is**. The final assistant message on each line is
63
+ removed before sending and kept as the reference answer. DPO lines (`input.messages`) work too.
64
+ - Real production prompts make the best golden set. Use a few hundred, covering your real traffic.
65
+ - Answers are recorded at `temperature 0` by default. Use `--seed` for more repeatable runs.
66
+ - Safe to stop and re-run: prompts already recorded are skipped, failed ones are retried.
67
+ - `--dry-run` counts prompts and estimated input tokens without sending anything.
68
+
69
+ ## 3. Compare
70
+
71
+ ```sh
72
+ tunekeep compare --golden tunekeep-out/golden-ft_gpt-4o-mini-2024-07-18_acme_AbC123.jsonl \
73
+ --candidate gpt-6-luna --examples train.jsonl --shots 5
74
+ ```
75
+
76
+ Each recorded prompt goes to the candidate, optionally with a few examples from **your own**
77
+ training file, and the answer is scored against the recorded one:
78
+
79
+ - **Tool calls**: matched by function name, arguments compared field by field.
80
+ - **JSON answers**: the share of leaf fields with the same value; invalid JSON scores 0.
81
+ - **Text**: 100% when equal after normalising case and spacing, otherwise word overlap (F1). Overlap
82
+ is a rough signal for free text, so the report shows the biggest differences side by side.
83
+
84
+ GPT-6 Luna reasons by default, and in Chat Completions it accepts `temperature` and function tools
85
+ only with `reasoning_effort: "none"`. tunekeep sends `none` by default (`--reasoning-effort auto`),
86
+ which is also closest to how a fine-tuned gpt-4o-mini answered. Try `--reasoning-effort low` to see
87
+ whether reasoning helps; tunekeep then drops `temperature`, and refuses before sending anything if your
88
+ prompts use tools.
89
+
90
+ Any OpenAI-compatible endpoint works as a candidate: `--candidate-base-url http://127.0.0.1:8080/v1`
91
+ for llama-server, vLLM or Ollama (no key needed on localhost; `--candidate-key-env` for others).
92
+
93
+ ## 4. Retrain
94
+
95
+ ```sh
96
+ tunekeep retrain --data train.jsonl # default base: Qwen/Qwen3-1.7B, pinned revision
97
+ cd tunekeep-out/retrain && modal run modal_app.py
98
+ ```
99
+
100
+ `retrain` converts your OpenAI training file (chat format, tools, legacy `functions`, per-message
101
+ `weight`) and writes a small kit: your data, a config, a training script and a [Modal](https://modal.com)
102
+ app. It uploads nothing itself. The kit:
103
+
104
+ - trains a LoRA adapter with loss only on assistant messages (`"weight": 0` turns are skipped, as on OpenAI);
105
+ - reuses your original job's epoch count when `tunekeep-out/inventory.json` has it;
106
+ - pins every package by hash, the base model by revision, and llama.cpp by commit;
107
+ - stops after a time limit (default 2 hours), which caps the cost of a run;
108
+ - exports merged weights and a q8_0 GGUF for llama-server or Ollama.
109
+
110
+ Use `--check` to only validate and summarise the data. See the kit's own README for running it
111
+ elsewhere and serving the result. Not yet supported: DPO, images and audio in training data.
112
+
113
+ ## 5. Report
114
+
115
+ ```sh
116
+ tunekeep report # reads tunekeep-out/, writes tunekeep-out/report.html
117
+ ```
118
+
119
+ One self-contained HTML file with deadlines, every candidate's scores, latency and token use, and
120
+ the lowest-scoring answers side by side. It loads nothing from the network and runs no scripts, and
121
+ every value from your data is escaped.
122
+
123
+ ## What tunekeep will not do
124
+
125
+ **It never trains on recorded outputs.** OpenAI's Services Agreement (section 3.3(e)) restricts using
126
+ Output to develop competing models. Recorded answers are used only to *evaluate* a replacement.
127
+ Retraining uses only your original training data. If that data was itself generated by an OpenAI
128
+ model, it counts as Output too. Check with your own counsel; this is not legal advice.
129
+
130
+ ## Privacy
131
+
132
+ - tunekeep talks only to the API base URLs you give it. No telemetry, no other network calls.
133
+ - Outputs can contain production prompts, so the output folder is created `0700` and files `0600`.
134
+ - API keys are read from the environment and are never written to disk or printed. A candidate
135
+ endpoint never receives your OpenAI key unless you name that variable with `--candidate-key-env`.
136
+
137
+ ## Other providers
138
+
139
+ - `--base-url` / `OPENAI_BASE_URL` for OpenAI-compatible gateways.
140
+ - `--azure --base-url https://<resource>.openai.azure.com/openai/v1` with `AZURE_OPENAI_API_KEY`
141
+ (**experimental**). Azure retires fine-tuned gpt-4o and gpt-4o-mini deployments on 1 October 2027, and
142
+ the gpt-4.1 family on 14 October 2027.
143
+
144
+ ## Development
145
+
146
+ ```sh
147
+ python -m unittest discover -s tests -v
148
+ ```
149
+
150
+ The tests run against a fake OpenAI server built from the public API reference: pagination, the
151
+ `shutdown_date` field, blocked training-file downloads, rate limits, tool calls and GPT-6 Luna's
152
+ parameter rules. The retraining kit is tested end to end on CPU with Qwen3-0.6B.
153
+ `tools/lock-kit.sh` regenerates the kit's hash-locked requirements.
154
+ **Reports from real accounts are very welcome.** Please open an issue with anything that behaves differently.
155
+
156
+ ## Sources
157
+
158
+ - OpenAI deprecations: https://developers.openai.com/api/docs/deprecations
159
+ - GPT-6 parameters: https://developers.openai.com/api/docs/guides/latest-model
160
+ - Azure retirement schedule: https://learn.microsoft.com/en-us/azure/foundry/openai/concepts/model-retirement-schedule
161
+
162
+ ## Licence
163
+
164
+ Apache-2.0. Built by [Rush Labs](https://rushlabs.ai), an applied AI lab.
@@ -0,0 +1,44 @@
1
+ [project]
2
+ name = "tunekeep"
3
+ version = "0.2.1"
4
+ description = "Keep a fine-tuned model working after its provider retires the base model: inventory, record, compare, retrain on open weights."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = "Apache-2.0"
8
+ license-files = ["LICENSE"]
9
+ keywords = [
10
+ "fine-tuning",
11
+ "openai",
12
+ "llm",
13
+ "lora",
14
+ "migration",
15
+ "evaluation",
16
+ ]
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha",
19
+ "Environment :: Console",
20
+ "Intended Audience :: Developers",
21
+ "Operating System :: OS Independent",
22
+ "Programming Language :: Python :: 3",
23
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
24
+ ]
25
+ dependencies = []
26
+
27
+ [[project.authors]]
28
+ name = "Rush Labs"
29
+ email = "admin@rushlabs.ai"
30
+
31
+ [project.scripts]
32
+ tunekeep = "tunekeep.cli:main"
33
+
34
+ [project.urls]
35
+ Homepage = "https://rushlabs.ai/lab"
36
+ Source = "https://github.com/rushlabs-ai/tunekeep"
37
+ Issues = "https://github.com/rushlabs-ai/tunekeep/issues"
38
+
39
+ [build-system]
40
+ requires = ["uv_build==0.13.6"]
41
+ build-backend = "uv_build"
42
+
43
+ [tool.uv]
44
+ exclude-newer = "2026-10-30T00:00:00Z"
@@ -0,0 +1,37 @@
1
+ [project]
2
+ name = "tunekeep"
3
+ version = "0.2.1"
4
+ description = "Keep a fine-tuned model working after its provider retires the base model: inventory, record, compare, retrain on open weights."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = "Apache-2.0"
8
+ license-files = ["LICENSE"]
9
+ authors = [{ name = "Rush Labs", email = "admin@rushlabs.ai" }]
10
+ keywords = ["fine-tuning", "openai", "llm", "lora", "migration", "evaluation"]
11
+ classifiers = [
12
+ "Development Status :: 3 - Alpha",
13
+ "Environment :: Console",
14
+ "Intended Audience :: Developers",
15
+ "Operating System :: OS Independent",
16
+ "Programming Language :: Python :: 3",
17
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
18
+ ]
19
+ # No runtime dependencies: the standard library only.
20
+ dependencies = []
21
+
22
+ [project.scripts]
23
+ tunekeep = "tunekeep.cli:main"
24
+
25
+ [project.urls]
26
+ Homepage = "https://rushlabs.ai/lab"
27
+ Source = "https://github.com/rushlabs-ai/tunekeep"
28
+ Issues = "https://github.com/rushlabs-ai/tunekeep/issues"
29
+
30
+ [build-system]
31
+ # Exact pin, at least 7 days old when chosen (supply-chain policy).
32
+ requires = ["uv_build==0.13.6"]
33
+ build-backend = "uv_build"
34
+
35
+ [tool.uv]
36
+ # Never resolve anything published in the last 7 days.
37
+ exclude-newer = "2026-10-30T00:00:00Z"
@@ -0,0 +1,3 @@
1
+ """tunekeep: keep a fine-tuned model working after its provider retires the base model."""
2
+
3
+ __version__ = "0.2.1"
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ raise SystemExit(main())