autoforge-trainer 1.0.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.
Files changed (133) hide show
  1. autoforge_trainer-1.0.2/.gitignore +9 -0
  2. autoforge_trainer-1.0.2/AGENTS.md +100 -0
  3. autoforge_trainer-1.0.2/CHANGELOG.md +31 -0
  4. autoforge_trainer-1.0.2/LICENSE +21 -0
  5. autoforge_trainer-1.0.2/PKG-INFO +216 -0
  6. autoforge_trainer-1.0.2/README.md +134 -0
  7. autoforge_trainer-1.0.2/autoforge/__init__.py +3 -0
  8. autoforge_trainer-1.0.2/autoforge/agents/__init__.py +0 -0
  9. autoforge_trainer-1.0.2/autoforge/agents/loop.py +168 -0
  10. autoforge_trainer-1.0.2/autoforge/agents/providers.py +272 -0
  11. autoforge_trainer-1.0.2/autoforge/api.py +330 -0
  12. autoforge_trainer-1.0.2/autoforge/cli/__init__.py +0 -0
  13. autoforge_trainer-1.0.2/autoforge/cli/agent.py +102 -0
  14. autoforge_trainer-1.0.2/autoforge/cli/data.py +42 -0
  15. autoforge_trainer-1.0.2/autoforge/cli/hpo.py +98 -0
  16. autoforge_trainer-1.0.2/autoforge/cli/main.py +112 -0
  17. autoforge_trainer-1.0.2/autoforge/cli/models.py +172 -0
  18. autoforge_trainer-1.0.2/autoforge/cli/output.py +40 -0
  19. autoforge_trainer-1.0.2/autoforge/cli/packs.py +185 -0
  20. autoforge_trainer-1.0.2/autoforge/cli/quickstart.py +61 -0
  21. autoforge_trainer-1.0.2/autoforge/cli/runs.py +233 -0
  22. autoforge_trainer-1.0.2/autoforge/config.py +31 -0
  23. autoforge_trainer-1.0.2/autoforge/data/__init__.py +0 -0
  24. autoforge_trainer-1.0.2/autoforge/data/profile.py +99 -0
  25. autoforge_trainer-1.0.2/autoforge/data/registry.py +47 -0
  26. autoforge_trainer-1.0.2/autoforge/engine/__init__.py +0 -0
  27. autoforge_trainer-1.0.2/autoforge/engine/context.py +125 -0
  28. autoforge_trainer-1.0.2/autoforge/engine/diagnose.py +134 -0
  29. autoforge_trainer-1.0.2/autoforge/engine/hpo.py +355 -0
  30. autoforge_trainer-1.0.2/autoforge/engine/runner.py +380 -0
  31. autoforge_trainer-1.0.2/autoforge/engine/store.py +207 -0
  32. autoforge_trainer-1.0.2/autoforge/engine/validate.py +172 -0
  33. autoforge_trainer-1.0.2/autoforge/engine/worker.py +68 -0
  34. autoforge_trainer-1.0.2/autoforge/errors.py +17 -0
  35. autoforge_trainer-1.0.2/autoforge/examples/__init__.py +0 -0
  36. autoforge_trainer-1.0.2/autoforge/examples/churn.csv +601 -0
  37. autoforge_trainer-1.0.2/autoforge/gui/__init__.py +0 -0
  38. autoforge_trainer-1.0.2/autoforge/gui/app.py +243 -0
  39. autoforge_trainer-1.0.2/autoforge/gui/static/app.js +546 -0
  40. autoforge_trainer-1.0.2/autoforge/gui/static/index.html +26 -0
  41. autoforge_trainer-1.0.2/autoforge/gui/static/style.css +83 -0
  42. autoforge_trainer-1.0.2/autoforge/hardware/__init__.py +0 -0
  43. autoforge_trainer-1.0.2/autoforge/hardware/detect.py +161 -0
  44. autoforge_trainer-1.0.2/autoforge/packs/__init__.py +0 -0
  45. autoforge_trainer-1.0.2/autoforge/packs/authoring.py +203 -0
  46. autoforge_trainer-1.0.2/autoforge/packs/errors.py +42 -0
  47. autoforge_trainer-1.0.2/autoforge/packs/index.py +149 -0
  48. autoforge_trainer-1.0.2/autoforge/packs/installer.py +241 -0
  49. autoforge_trainer-1.0.2/autoforge/packs/manifest.py +192 -0
  50. autoforge_trainer-1.0.2/autoforge/policy/__init__.py +0 -0
  51. autoforge_trainer-1.0.2/autoforge/policy/privacy.py +68 -0
  52. autoforge_trainer-1.0.2/autoforge/registry/__init__.py +0 -0
  53. autoforge_trainer-1.0.2/autoforge/registry/models.py +350 -0
  54. autoforge_trainer-1.0.2/autoforge/schemas/__init__.py +0 -0
  55. autoforge_trainer-1.0.2/autoforge/schemas/core.py +137 -0
  56. autoforge_trainer-1.0.2/autoforge/serve/__init__.py +0 -0
  57. autoforge_trainer-1.0.2/autoforge/serve/mcp_server.py +293 -0
  58. autoforge_trainer-1.0.2/autoforge/serve/model_mcp.py +98 -0
  59. autoforge_trainer-1.0.2/autoforge/serve/rest.py +87 -0
  60. autoforge_trainer-1.0.2/docs/AGENT.md +73 -0
  61. autoforge_trainer-1.0.2/docs/ARCHITECTURE.md +192 -0
  62. autoforge_trainer-1.0.2/docs/DEPLOY.md +126 -0
  63. autoforge_trainer-1.0.2/docs/GUI.md +35 -0
  64. autoforge_trainer-1.0.2/docs/IMPROVE.md +79 -0
  65. autoforge_trainer-1.0.2/docs/MCP.md +96 -0
  66. autoforge_trainer-1.0.2/docs/PACK_SPEC.md +119 -0
  67. autoforge_trainer-1.0.2/docs/RELEASE.md +51 -0
  68. autoforge_trainer-1.0.2/docs/ROADMAP.md +38 -0
  69. autoforge_trainer-1.0.2/docs/index.md +56 -0
  70. autoforge_trainer-1.0.2/examples/churn_plan.yaml +18 -0
  71. autoforge_trainer-1.0.2/examples/data/churn.csv +601 -0
  72. autoforge_trainer-1.0.2/packs/anomaly-detection/KNOWLEDGE.md +37 -0
  73. autoforge_trainer-1.0.2/packs/anomaly-detection/pack.yaml +9 -0
  74. autoforge_trainer-1.0.2/packs/anomaly-detection/recipes/isolation_forest.yaml +12 -0
  75. autoforge_trainer-1.0.2/packs/anomaly-detection/tests/test_smoke.py +44 -0
  76. autoforge_trainer-1.0.2/packs/anomaly-detection/trainers/iforest.py +79 -0
  77. autoforge_trainer-1.0.2/packs/image-classification/KNOWLEDGE.md +48 -0
  78. autoforge_trainer-1.0.2/packs/image-classification/pack.yaml +10 -0
  79. autoforge_trainer-1.0.2/packs/image-classification/recipes/timm_finetune.yaml +16 -0
  80. autoforge_trainer-1.0.2/packs/image-classification/tests/test_smoke.py +56 -0
  81. autoforge_trainer-1.0.2/packs/image-classification/trainers/timm_train.py +179 -0
  82. autoforge_trainer-1.0.2/packs/llm-finetune/KNOWLEDGE.md +47 -0
  83. autoforge_trainer-1.0.2/packs/llm-finetune/pack.yaml +10 -0
  84. autoforge_trainer-1.0.2/packs/llm-finetune/recipes/sft_lora.yaml +16 -0
  85. autoforge_trainer-1.0.2/packs/llm-finetune/tests/test_smoke.py +48 -0
  86. autoforge_trainer-1.0.2/packs/llm-finetune/trainers/sft.py +216 -0
  87. autoforge_trainer-1.0.2/packs/tabular-classic/KNOWLEDGE.md +43 -0
  88. autoforge_trainer-1.0.2/packs/tabular-classic/pack.yaml +10 -0
  89. autoforge_trainer-1.0.2/packs/tabular-classic/recipes/logistic_regression.yaml +14 -0
  90. autoforge_trainer-1.0.2/packs/tabular-classic/recipes/random_forest.yaml +15 -0
  91. autoforge_trainer-1.0.2/packs/tabular-classic/tests/test_smoke.py +43 -0
  92. autoforge_trainer-1.0.2/packs/tabular-classic/trainers/sklearn_trainers.py +153 -0
  93. autoforge_trainer-1.0.2/packs/text-classification/KNOWLEDGE.md +45 -0
  94. autoforge_trainer-1.0.2/packs/text-classification/pack.yaml +10 -0
  95. autoforge_trainer-1.0.2/packs/text-classification/recipes/tfidf_linear.yaml +13 -0
  96. autoforge_trainer-1.0.2/packs/text-classification/recipes/transformer_finetune.yaml +14 -0
  97. autoforge_trainer-1.0.2/packs/text-classification/tests/test_smoke.py +58 -0
  98. autoforge_trainer-1.0.2/packs/text-classification/trainers/common.py +33 -0
  99. autoforge_trainer-1.0.2/packs/text-classification/trainers/tfidf.py +47 -0
  100. autoforge_trainer-1.0.2/packs/text-classification/trainers/transformer.py +134 -0
  101. autoforge_trainer-1.0.2/packs/timeseries-forecast/KNOWLEDGE.md +39 -0
  102. autoforge_trainer-1.0.2/packs/timeseries-forecast/pack.yaml +9 -0
  103. autoforge_trainer-1.0.2/packs/timeseries-forecast/recipes/lag_gbm.yaml +14 -0
  104. autoforge_trainer-1.0.2/packs/timeseries-forecast/tests/test_smoke.py +44 -0
  105. autoforge_trainer-1.0.2/packs/timeseries-forecast/trainers/forecast.py +97 -0
  106. autoforge_trainer-1.0.2/pyproject.toml +77 -0
  107. autoforge_trainer-1.0.2/tests/conftest.py +37 -0
  108. autoforge_trainer-1.0.2/tests/fixtures/engine-pack/KNOWLEDGE.md +3 -0
  109. autoforge_trainer-1.0.2/tests/fixtures/engine-pack/pack.yaml +5 -0
  110. autoforge_trainer-1.0.2/tests/fixtures/engine-pack/recipes/adjustable.yaml +6 -0
  111. autoforge_trainer-1.0.2/tests/fixtures/engine-pack/recipes/crash.yaml +6 -0
  112. autoforge_trainer-1.0.2/tests/fixtures/engine-pack/recipes/needs_missing_pkg.yaml +5 -0
  113. autoforge_trainer-1.0.2/tests/fixtures/engine-pack/recipes/quick.yaml +6 -0
  114. autoforge_trainer-1.0.2/tests/fixtures/engine-pack/recipes/score.yaml +9 -0
  115. autoforge_trainer-1.0.2/tests/fixtures/engine-pack/recipes/slow.yaml +6 -0
  116. autoforge_trainer-1.0.2/tests/fixtures/engine-pack/recipes/stubborn.yaml +6 -0
  117. autoforge_trainer-1.0.2/tests/fixtures/engine-pack/trainers/toy.py +55 -0
  118. autoforge_trainer-1.0.2/tests/test_agent.py +294 -0
  119. autoforge_trainer-1.0.2/tests/test_cli.py +27 -0
  120. autoforge_trainer-1.0.2/tests/test_cli_packs.py +53 -0
  121. autoforge_trainer-1.0.2/tests/test_cli_runs.py +49 -0
  122. autoforge_trainer-1.0.2/tests/test_data_privacy.py +65 -0
  123. autoforge_trainer-1.0.2/tests/test_engine.py +155 -0
  124. autoforge_trainer-1.0.2/tests/test_gui.py +133 -0
  125. autoforge_trainer-1.0.2/tests/test_hardware.py +19 -0
  126. autoforge_trainer-1.0.2/tests/test_index.py +60 -0
  127. autoforge_trainer-1.0.2/tests/test_installer.py +112 -0
  128. autoforge_trainer-1.0.2/tests/test_manifest.py +46 -0
  129. autoforge_trainer-1.0.2/tests/test_mcp.py +136 -0
  130. autoforge_trainer-1.0.2/tests/test_p5.py +173 -0
  131. autoforge_trainer-1.0.2/tests/test_p6.py +197 -0
  132. autoforge_trainer-1.0.2/tests/test_p7.py +153 -0
  133. autoforge_trainer-1.0.2/tests/test_privacy.py +25 -0
@@ -0,0 +1,9 @@
1
+ __pycache__/
2
+ *.egg-info/
3
+ .venv/
4
+ dist/
5
+ build/
6
+ .pytest_cache/
7
+ runs/
8
+ dist/
9
+ site/
@@ -0,0 +1,100 @@
1
+ # AGENTS.md — 給 AI 的使用說明
2
+
3
+ You are operating AutoForge, a tool that trains AI models on the user's machine.
4
+ Prefer the MCP server (`autoforge mcp`, tools listed in docs/MCP.md) when your client supports MCP;
5
+ the CLI below offers the same operations with `--json`.
6
+
7
+ ## Rules
8
+ 1. Always call `autoforge doctor --json` first to learn the hardware.
9
+ 2. Every command accepts `--json` and returns `{"ok": bool, "data": ..., "error": {"code","message","hint"}}`.
10
+ Branch on `error.code`, and follow `error.hint`.
11
+ 3. Read data contracts with `autoforge schema <Name> --json` instead of guessing fields.
12
+ 4. Privacy: if an error has code `PRIVACY_DENIED`, do not retry. Tell the user the dataset
13
+ is sensitive and needs a local-model brain.
14
+ 5. Training is asynchronous: `run start` returns a `run_id` at once; poll `run status <id>`.
15
+ 6. Identify yourself: pass `--actor ai:<your-name>` (or set AUTOFORGE_ACTOR) so the audit log
16
+ shows who did what. Humans and AI share the same controls.
17
+
18
+ ## Data and privacy
19
+ - `autoforge data profile <path> --json` (MCP: `data_profile`): rows, columns, dtypes, missing values.
20
+ - Data is `internal` unless a human marked it. Cloud AI sees statistics only; `public` data adds
21
+ sample rows; `sensitive` data is refused with PRIVACY_DENIED. Never try to change sensitivity.
22
+
23
+ ## Finding and learning a training method
24
+ 1. `autoforge pack search [keywords] --task <task-type> --fit --json`
25
+ `--fit` keeps only recipes this machine can run. Each hit lists `runnable_recipes`.
26
+ 2. `autoforge pack install <name> --json` installs the commit pinned in the index.
27
+ 3. `autoforge pack info <name> --json` returns the manifest, recipes (defaults, search space)
28
+ and `knowledge` (KNOWLEDGE.md). **Read `knowledge` before planning.**
29
+ 4. If `missing_dependencies` is non-empty, tell the user to `pip install` them.
30
+
31
+ ## Training (P3)
32
+ 1. Write a plan file (schema: `autoforge schema TrainingPlan --json`). Paths are relative to the plan file.
33
+ Example: `examples/churn_plan.yaml`.
34
+ 2. `autoforge plan validate plan.yaml --json`: deterministic checks (pack/recipe/task match,
35
+ data and target column exist, GPU/VRAM, missing packages). Fix every `problems` item.
36
+ 3. `autoforge run start plan.yaml --json --actor ai:<name>` → `data.run_id`
37
+ 4. Poll `autoforge run status <id> --json` (status: pending/running/paused/succeeded/failed/stopped).
38
+ For progress use `autoforge run metrics <id> --json` (last/min/max/count/recent per metric);
39
+ on failure read `autoforge run logs <id> --tail 50 --json`.
40
+ 5. Control: `run pause | resume | stop <id>`; `run retry <id>` reruns the plan and resumes from checkpoints.
41
+ 6. Custom trainers: set `custom_code_path: my_trainer.py[:function]` instead of pack+recipe.
42
+ The code is copied into the run and committed to the run's git repo. Contract: docs/PACK_SPEC.md §5.
43
+
44
+ ## Improving a model (P5)
45
+ - `run diagnose <id>` / MCP `run_diagnose`: findings (failure cause, divergence, plateau, overfitting,
46
+ leakage) with suggestions and the tunable hyperparameters.
47
+ - `hpo start plan.yaml -m <metric> -n <trials>` / MCP `hpo_start` → `hpo_wait`: search; trial 0 is the
48
+ plan's own hyperparameters (baseline); report `improvement`.
49
+ - `run adjust <id> --set k=v` / MCP `run_adjust`: change a live run (trainer must call ctx.check_updates()).
50
+ - `run compare <ids...> -m <metric>` / MCP `run_compare`: pick the best run.
51
+
52
+ ## Deploying a model (P6)
53
+ - `model register <run_id> --name <name>` / MCP `model_register`: versioned model (name:vN) with a card
54
+ (features, labels, metrics). Only succeeded runs; servable when the recipe has a predictor.
55
+ - `model predict <name> --rows '[{...}]'` / MCP `model_predict`: rows need every feature from `model info`.
56
+ - `model export <name> --format bundle|onnx` / MCP `model_export`.
57
+ - Humans run `autoforge serve` (REST) and `autoforge serve-mcp` (each model as tool `predict_<name>`).
58
+
59
+ ## Writing a new pack (P7)
60
+ - MCP `pack_create(name, files)` writes a pack into the workspace and validates it (nothing runs);
61
+ `pack_test(path)` runs its tests; `pack_install(path)` installs it. CLI: `pack new`, `pack test`.
62
+ - To turn a GitHub training repo into a pack: read the repo, write pack.yaml + KNOWLEDGE.md + recipes +
63
+ a trainer using the TrainContext contract (docs/PACK_SPEC.md §5) + a CPU smoke test, then create/test/install.
64
+
65
+ ## Error codes
66
+ | code | meaning | what to do |
67
+ |---|---|---|
68
+ | PACK_NOT_FOUND | name not in index / not installed | search again |
69
+ | PACK_EXISTS | already installed | use it, or reinstall with `--force` |
70
+ | PACK_INVALID | pack fails validation; `data.problems` lists why | do not use it |
71
+ | SHA_MISMATCH | source changed after indexing | do not install; tell the user |
72
+ | INDEX_UNAVAILABLE | index unreachable and no cache | retry later or set AUTOFORGE_INDEX_URL |
73
+ | PACK_SOURCE_ERROR | bad source string or git failure | check the source |
74
+ | PLAN_INVALID | plan fails checks; `data.problems` lists why | fix the plan, validate again |
75
+ | RUN_NOT_FOUND | unknown run_id | `run list` |
76
+ | RUN_STATE_ERROR | action not possible in the run's current state | check `run status` |
77
+ | PRIVACY_DENIED | dataset is sensitive and you are not a local model | stop; tell the user |
78
+ | BAD_REQUEST | invalid argument (e.g. trainer filename, syntax error) | fix and retry |
79
+ | STUDY_NOT_FOUND | unknown study_id | `hpo list` |
80
+ | HPO_UNAVAILABLE | optuna not installed | tell the user: pip install optuna |
81
+ | MODEL_NOT_FOUND | unknown model or version | `model list` |
82
+ | MODEL_NOT_SERVABLE | recipe has no predictor | train with a recipe that has one |
83
+ | INVALID_INPUT | rows missing features / wrong types; `data.features` lists them | fix the rows |
84
+ | MODEL_ERROR | register/export/predict failed | read the message |
85
+ | PACK_AUTHORING_ERROR | bad name, unsafe path, pack exists | fix and retry (overwrite=true to replace) |
86
+ | PACK_TEST_FAILED | pack smoke tests failed; `data.output_tail` | fix the pack |
87
+
88
+ ## Commands available now (1.0)
89
+ - `quickstart` (end-to-end demo on bundled data)
90
+ - `gui` (local web interface for humans; actor "human")
91
+ - `pack new | test`
92
+ - `model register | list | info | predict | export | import | remove`, `serve`, `serve-mcp`
93
+ - `hpo start | status | list | stop`, `run diagnose | adjust | compare`
94
+ - `train "<goal>" --data <path> --brain <provider:model>` (built-in agent; see docs/AGENT.md)
95
+ - `mcp` (MCP server over stdio), `data mark | list | profile`
96
+ - `version`, `doctor`, `schema [Name]`
97
+ - `plan validate`
98
+ - `run start | status | list | pause | resume | stop | retry | logs | metrics | audit`
99
+ - `pack search | install | info | list | remove | validate`
100
+ - `index entry | add | validate` (for index maintainers)
@@ -0,0 +1,31 @@
1
+ # 變更紀錄
2
+
3
+ ## 1.0.2 — 2026-10
4
+
5
+ - **PyPI 套件名稱改為 `autoforge-trainer`**:`autoforge-ml` 在我們發佈前被別人註冊了。指令和 `import autoforge` 都不變。1.0.1 沒有上傳到 PyPI。
6
+
7
+ ## 1.0.1 — 2026-10
8
+
9
+ - **PyPI 套件名稱改為 `autoforge-ml`**:`autoforge-ai` 和 PyPI 上既有的 `autoforgeai` 太相似,無法註冊。指令和 `import autoforge` 都不變。
10
+ - 修正:`run adjust` 的參數修改偶爾沒有寫進訓練資料夾的 git 紀錄(稽核紀錄不受影響)。原因是 `git add -A` 剛好碰到訓練程式寫檔時暫時產生的檔案;現在只加入需要保存版本的檔案。這個問題是 CI 發現的。
11
+
12
+ ## 1.0.0 — 2026-10
13
+
14
+ 第一個正式版本。PyPI 套件名稱為 `autoforge-ai`,指令仍是 `autoforge`。
15
+
16
+ ### 功能(依開發階段)
17
+ - **P1 骨架**:硬體偵測(NVIDIA GPU / CUDA),所有指令都能輸出 JSON,資料結構可匯出 JSON Schema。
18
+ - **P2 方法包**:`pack.yaml` 格式、驗證(不執行程式碼);從本地資料夾或 GitHub 安裝並鎖定 commit;索引放在 `packs-index` 分支。
19
+ - **P3 執行引擎**:每次訓練在獨立行程執行;可以暫停、繼續、停止,也能從 checkpoint 重跑;稽核紀錄寫明是人還是 AI 操作;計畫和程式碼用 git 保存版本。
20
+ - **P4a MCP**:`autoforge mcp`,讓訂閱制 AI(Claude Desktop、Claude Code)直接操作;隱私守衛:敏感資料只給本地模型使用。
21
+ - **P4b 內建 AI 代理**:`autoforge train "需求"`,支援 Claude(官方 SDK)、OpenAI 相容 API、Ollama 和本地模型;開始訓練前會請人確認。
22
+ - **P5 改進模型**:診斷、自動調參(Optuna,第 0 次為基準)、訓練中途調整參數、比較多次訓練。
23
+ - **P6 部署**:模型倉庫(模型會連同訓練它的程式碼一起保存)、REST API、每個模型變成一個 MCP 工具、匯出 bundle 或 ONNX。
24
+ - **P7 方法包**:tabular-classic、text-classification、llm-finetune(LoRA/QLoRA)、image-classification、timeseries-forecast、anomaly-detection;另有 `pack new`、`pack test`、MCP `pack_create`。
25
+ - **P8 網頁介面**:`autoforge gui`,只在本機開放,用一次性 token 保護。
26
+ - **P9 發佈**:`autoforge quickstart`、PyPI 打包、Docker 映像(CPU 和 CUDA)、文件網站、自動發佈流程。
27
+
28
+ ### 已知限制
29
+ - GPU 方法(Transformer、LLM LoRA/QLoRA、timm)只用極小模型在 CPU 上驗證過程式能跑通,尚未在真的 NVIDIA GPU 上實測。
30
+ - 自動調參的最佳分數是用同一份驗證資料挑出來的,會稍微偏樂觀。
31
+ - 內建 AI 代理選方法的品質,還沒用真的 Claude API 做系統性評估。
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Honguan and AutoForge contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,216 @@
1
+ Metadata-Version: 2.5
2
+ Name: autoforge-trainer
3
+ Version: 1.0.2
4
+ Summary: AI that trains AI: analyse your data and hardware, pick a method, train, tune and deploy models on your own machine — from a CLI, MCP, a web GUI or one sentence.
5
+ Project-URL: Homepage, https://github.com/Honguan/autoforge
6
+ Project-URL: Documentation, https://honguan.github.io/autoforge/
7
+ Project-URL: Source, https://github.com/Honguan/autoforge
8
+ Project-URL: Issues, https://github.com/Honguan/autoforge/issues
9
+ Project-URL: Changelog, https://github.com/Honguan/autoforge/blob/main/CHANGELOG.md
10
+ Author: Honguan
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: ai-agent,automl,fine-tuning,llm,lora,machine-learning,mcp,training
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Environment :: Console
16
+ Classifier: Environment :: GPU :: NVIDIA CUDA
17
+ Classifier: Environment :: Web Environment
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Intended Audience :: Science/Research
20
+ Classifier: Natural Language :: Chinese (Traditional)
21
+ Classifier: Natural Language :: English
22
+ Classifier: Operating System :: OS Independent
23
+ Classifier: Programming Language :: Python :: 3
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
26
+ Classifier: Programming Language :: Python :: 3.13
27
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
28
+ Requires-Python: >=3.11
29
+ Requires-Dist: httpx2>=2.0
30
+ Requires-Dist: joblib>=1.3
31
+ Requires-Dist: mcp<3,>=2.3
32
+ Requires-Dist: optuna<6,>=5.0
33
+ Requires-Dist: pandas>=2.0
34
+ Requires-Dist: psutil>=5.9
35
+ Requires-Dist: pydantic>=2.6
36
+ Requires-Dist: python-multipart>=0.0.9
37
+ Requires-Dist: pyyaml>=6.0
38
+ Requires-Dist: scikit-learn>=1.4
39
+ Requires-Dist: starlette>=0.40
40
+ Requires-Dist: typer>=0.12
41
+ Requires-Dist: uvicorn>=0.30
42
+ Provides-Extra: all
43
+ Requires-Dist: accelerate>=0.30; extra == 'all'
44
+ Requires-Dist: anthropic<2,>=1.14; extra == 'all'
45
+ Requires-Dist: nvidia-ml-py>=12.0; extra == 'all'
46
+ Requires-Dist: onnx>=1.16; extra == 'all'
47
+ Requires-Dist: onnxruntime>=1.18; extra == 'all'
48
+ Requires-Dist: onnxscript>=0.1; extra == 'all'
49
+ Requires-Dist: peft>=0.12; extra == 'all'
50
+ Requires-Dist: pillow>=10.0; extra == 'all'
51
+ Requires-Dist: skl2onnx>=1.17; extra == 'all'
52
+ Requires-Dist: timm>=1.0; extra == 'all'
53
+ Requires-Dist: torch>=2.3; extra == 'all'
54
+ Requires-Dist: torchvision>=0.18; extra == 'all'
55
+ Requires-Dist: transformers>=4.45; extra == 'all'
56
+ Provides-Extra: anthropic
57
+ Requires-Dist: anthropic<2,>=1.14; extra == 'anthropic'
58
+ Provides-Extra: deep
59
+ Requires-Dist: accelerate>=0.30; extra == 'deep'
60
+ Requires-Dist: nvidia-ml-py>=12.0; extra == 'deep'
61
+ Requires-Dist: peft>=0.12; extra == 'deep'
62
+ Requires-Dist: pillow>=10.0; extra == 'deep'
63
+ Requires-Dist: timm>=1.0; extra == 'deep'
64
+ Requires-Dist: torch>=2.3; extra == 'deep'
65
+ Requires-Dist: torchvision>=0.18; extra == 'deep'
66
+ Requires-Dist: transformers>=4.45; extra == 'deep'
67
+ Provides-Extra: dev
68
+ Requires-Dist: build>=1.2; extra == 'dev'
69
+ Requires-Dist: playwright>=1.45; extra == 'dev'
70
+ Requires-Dist: pytest>=8.0; extra == 'dev'
71
+ Requires-Dist: twine>=5.0; extra == 'dev'
72
+ Provides-Extra: gpu
73
+ Requires-Dist: nvidia-ml-py>=12.0; extra == 'gpu'
74
+ Requires-Dist: torch>=2.3; extra == 'gpu'
75
+ Provides-Extra: hpo
76
+ Provides-Extra: onnx
77
+ Requires-Dist: onnx>=1.16; extra == 'onnx'
78
+ Requires-Dist: onnxruntime>=1.18; extra == 'onnx'
79
+ Requires-Dist: onnxscript>=0.1; extra == 'onnx'
80
+ Requires-Dist: skl2onnx>=1.17; extra == 'onnx'
81
+ Description-Content-Type: text/markdown
82
+
83
+ # AutoForge
84
+
85
+ 讓 AI 自己分析需求、選擇方法、訓練、評估、部署 AI 模型的可安裝平台。
86
+
87
+ - **三種 AI 大腦**:訂閱制 AI(透過 MCP)、雲端 API、本地模型
88
+ - **硬體**:NVIDIA GPU(CUDA),沒有 GPU 時自動改用 CPU
89
+ - **方法包**:從 GitHub 安裝的「教學包」,AI 讀了就知道怎麼訓練
90
+ - **隱私**:敏感資料只允許本地模型指揮
91
+
92
+ > **1.0.2** · 文件網站:<https://honguan.github.io/autoforge/> · [變更紀錄](CHANGELOG.md)
93
+
94
+ ## 安裝與第一次使用
95
+
96
+ ```bash
97
+ pip install autoforge-trainer # 需要 Python 3.11 以上
98
+ autoforge quickstart # 約 1 分鐘:檢查硬體 → 安裝方法包 → 訓練 → 註冊 → 預測
99
+ autoforge gui # 網頁介面
100
+ ```
101
+
102
+ | 安裝方式 | 包含 |
103
+ |---|---|
104
+ | `pip install autoforge-trainer` | 表格、文字(TF-IDF)、時間序列、異常偵測、自動調參、網頁介面、MCP、REST |
105
+ | `pip install "autoforge-trainer[deep]"` | 再加上 Transformer、LLM 微調(LoRA/QLoRA)、圖片分類(NVIDIA GPU) |
106
+ | `pip install "autoforge-trainer[all]"` | 再加上 Claude 代理、ONNX 匯出 |
107
+ | `docker run --rm -p 127.0.0.1:8800:8800 -v autoforge:/data ghcr.io/honguan/autoforge:cpu` | CPU 映像,預設啟動網頁介面 |
108
+ | `docker run --rm --gpus all -p 127.0.0.1:8800:8800 -v autoforge:/data ghcr.io/honguan/autoforge:cuda` | NVIDIA CUDA 映像,所有方法包 |
109
+
110
+ PyPI 上的 `autoforge` 是另一個不相關的專案(`autoforge-ai`、`autoforge-ml` 也都無法使用),請安裝 **`autoforge-trainer`**;裝好之後指令一樣是 `autoforge`。
111
+
112
+ 操作方式:[網頁介面](docs/GUI.md) · [一句話訓練](docs/AGENT.md) · [讓訂閱制 AI 透過 MCP 操作](docs/MCP.md) · [改進模型](docs/IMPROVE.md) · [部署](docs/DEPLOY.md) · [架構](docs/ARCHITECTURE.md) · [路線圖](docs/ROADMAP.md)
113
+
114
+ ## 內建方法包
115
+
116
+ | 方法包 | 用途 | 方法 | 硬體 |
117
+ |---|---|---|---|
118
+ | `tabular-classic` | 表格分類、回歸 | 邏輯迴歸、隨機森林(可匯出 ONNX) | CPU |
119
+ | `text-classification` | 文字分類(情緒、意圖、主題、垃圾訊息) | TF-IDF + 線性模型;Transformer 微調 | CPU / GPU |
120
+ | `llm-finetune` | 大型語言模型微調 | LoRA / QLoRA(可匯出合併後的權重) | GPU(8GB+) |
121
+ | `image-classification` | 圖片分類 | timm 預訓練模型微調(可匯出 ONNX) | GPU 建議,CPU 可跑小模型 |
122
+ | `timeseries-forecast` | 時間序列預測(銷量、用電、流量) | 落後特徵 + 梯度提升,和「明天=今天」的基準比較 | CPU |
123
+ | `anomaly-detection` | 異常偵測(詐欺、故障、離群值) | Isolation Forest | CPU |
124
+
125
+ 每個方法包都附給 AI 讀的 `KNOWLEDGE.md`,以及在 CPU 上 30 秒內跑完的測試。自己做方法包:`autoforge pack new`(見 [docs/PACK_SPEC.md](docs/PACK_SPEC.md))。
126
+
127
+ ## 從原始碼開發
128
+
129
+ ```bash
130
+ git clone https://github.com/Honguan/autoforge && cd autoforge
131
+ pip install -e ".[dev]" # 加上 ,deep 安裝深度學習方法包的依賴
132
+ pytest -q
133
+ ```
134
+
135
+ ## 網頁介面
136
+
137
+ ```bash
138
+ autoforge gui # 打開瀏覽器:上傳資料 → 選任務 → 選方法 → 訓練 → 調參 → 註冊 → 預測
139
+ ```
140
+
141
+ ## 使用
142
+
143
+ ```bash
144
+ autoforge doctor # 偵測硬體
145
+ autoforge doctor --json # 給 AI 讀的 JSON
146
+ autoforge schema # 列出所有資料結構
147
+ autoforge schema TrainingPlan --json
148
+
149
+ # 方法包
150
+ autoforge pack search csv --fit # 搜尋這台電腦跑得動的方法包
151
+ autoforge pack install tabular-classic # 從索引安裝(鎖定 commit)
152
+ autoforge pack install ./packs/tabular-classic # 從本地資料夾安裝
153
+ autoforge pack install github:owner/repo/subdir@v1.0.0
154
+ autoforge pack info tabular-classic --json # 給 AI 讀的知識和方法
155
+ autoforge pack list
156
+
157
+ # 訓練
158
+ autoforge plan validate examples/churn_plan.yaml # 檢查訓練計畫
159
+ autoforge run start examples/churn_plan.yaml --wait # 訓練並即時顯示進度
160
+ autoforge run start plan.yaml --json # 背景訓練,立即回傳 run_id(給 AI 用)
161
+ autoforge run status <run_id>
162
+ autoforge run pause|resume|stop <run_id>
163
+ autoforge run metrics|logs|audit <run_id>
164
+ autoforge run retry <run_id> # 同計畫重跑,從 checkpoint 接續
165
+ ```
166
+
167
+ 每次訓練的所有檔案都在 `~/.autoforge/runs/<run_id>/`:計畫、模型、checkpoint、日誌、指標、稽核紀錄,計畫和 AI 寫的程式會用 git 版本管理。
168
+
169
+ 方法包格式見 [docs/PACK_SPEC.md](docs/PACK_SPEC.md),索引放在本 repo 的 [`packs-index` 分支](https://github.com/Honguan/autoforge/tree/packs-index)。
170
+
171
+ ## 改進模型
172
+
173
+ ```bash
174
+ autoforge run diagnose <run_id> # 找問題、給建議
175
+ autoforge hpo start examples/churn_plan.yaml -m f1_macro -n 20 --wait # 自動調參(trial 0 = 基準)
176
+ autoforge run adjust <run_id> --set learning_rate=0.0003 # 訓練中途改參數
177
+ autoforge run compare <id1> <id2> -m f1_macro # 比較
178
+ ```
179
+
180
+ ## 部署
181
+
182
+ ```bash
183
+ autoforge model register <run_id> --name churn # 註冊成模型(v1、v2…)
184
+ autoforge model predict churn --rows '[{...}]' # 預測
185
+ autoforge serve # REST API(127.0.0.1:8000)
186
+ autoforge serve-mcp # 每個模型變成 MCP 工具 predict_<名稱>,給其他 AI 呼叫
187
+ autoforge model export churn --format onnx # 匯出
188
+ ```
189
+
190
+ ## 一句話訓練(內建 AI 代理)
191
+
192
+ ```bash
193
+ pip install -e ".[anthropic]"
194
+ autoforge train "預測 churned 欄位" --data examples/data/churn.csv # Claude(預設)
195
+ autoforge train "預測 churned 欄位" --data examples/data/churn.csv --brain ollama:qwen3 # 本地模型
196
+ ```
197
+
198
+ 詳見 [docs/AGENT.md](docs/AGENT.md)。
199
+
200
+ ## 讓 AI 操作(MCP)
201
+
202
+ ```bash
203
+ claude mcp add autoforge -- autoforge mcp --actor ai:claude-code # Claude Code
204
+ ```
205
+
206
+ Claude Desktop 和隱私設定見 [docs/MCP.md](docs/MCP.md)。
207
+
208
+ ```bash
209
+ autoforge data mark ~/data/customers -s sensitive # 敏感資料:雲端 AI 不能使用
210
+ ```
211
+
212
+ ## 測試
213
+
214
+ ```bash
215
+ pytest
216
+ ```
@@ -0,0 +1,134 @@
1
+ # AutoForge
2
+
3
+ 讓 AI 自己分析需求、選擇方法、訓練、評估、部署 AI 模型的可安裝平台。
4
+
5
+ - **三種 AI 大腦**:訂閱制 AI(透過 MCP)、雲端 API、本地模型
6
+ - **硬體**:NVIDIA GPU(CUDA),沒有 GPU 時自動改用 CPU
7
+ - **方法包**:從 GitHub 安裝的「教學包」,AI 讀了就知道怎麼訓練
8
+ - **隱私**:敏感資料只允許本地模型指揮
9
+
10
+ > **1.0.2** · 文件網站:<https://honguan.github.io/autoforge/> · [變更紀錄](CHANGELOG.md)
11
+
12
+ ## 安裝與第一次使用
13
+
14
+ ```bash
15
+ pip install autoforge-trainer # 需要 Python 3.11 以上
16
+ autoforge quickstart # 約 1 分鐘:檢查硬體 → 安裝方法包 → 訓練 → 註冊 → 預測
17
+ autoforge gui # 網頁介面
18
+ ```
19
+
20
+ | 安裝方式 | 包含 |
21
+ |---|---|
22
+ | `pip install autoforge-trainer` | 表格、文字(TF-IDF)、時間序列、異常偵測、自動調參、網頁介面、MCP、REST |
23
+ | `pip install "autoforge-trainer[deep]"` | 再加上 Transformer、LLM 微調(LoRA/QLoRA)、圖片分類(NVIDIA GPU) |
24
+ | `pip install "autoforge-trainer[all]"` | 再加上 Claude 代理、ONNX 匯出 |
25
+ | `docker run --rm -p 127.0.0.1:8800:8800 -v autoforge:/data ghcr.io/honguan/autoforge:cpu` | CPU 映像,預設啟動網頁介面 |
26
+ | `docker run --rm --gpus all -p 127.0.0.1:8800:8800 -v autoforge:/data ghcr.io/honguan/autoforge:cuda` | NVIDIA CUDA 映像,所有方法包 |
27
+
28
+ PyPI 上的 `autoforge` 是另一個不相關的專案(`autoforge-ai`、`autoforge-ml` 也都無法使用),請安裝 **`autoforge-trainer`**;裝好之後指令一樣是 `autoforge`。
29
+
30
+ 操作方式:[網頁介面](docs/GUI.md) · [一句話訓練](docs/AGENT.md) · [讓訂閱制 AI 透過 MCP 操作](docs/MCP.md) · [改進模型](docs/IMPROVE.md) · [部署](docs/DEPLOY.md) · [架構](docs/ARCHITECTURE.md) · [路線圖](docs/ROADMAP.md)
31
+
32
+ ## 內建方法包
33
+
34
+ | 方法包 | 用途 | 方法 | 硬體 |
35
+ |---|---|---|---|
36
+ | `tabular-classic` | 表格分類、回歸 | 邏輯迴歸、隨機森林(可匯出 ONNX) | CPU |
37
+ | `text-classification` | 文字分類(情緒、意圖、主題、垃圾訊息) | TF-IDF + 線性模型;Transformer 微調 | CPU / GPU |
38
+ | `llm-finetune` | 大型語言模型微調 | LoRA / QLoRA(可匯出合併後的權重) | GPU(8GB+) |
39
+ | `image-classification` | 圖片分類 | timm 預訓練模型微調(可匯出 ONNX) | GPU 建議,CPU 可跑小模型 |
40
+ | `timeseries-forecast` | 時間序列預測(銷量、用電、流量) | 落後特徵 + 梯度提升,和「明天=今天」的基準比較 | CPU |
41
+ | `anomaly-detection` | 異常偵測(詐欺、故障、離群值) | Isolation Forest | CPU |
42
+
43
+ 每個方法包都附給 AI 讀的 `KNOWLEDGE.md`,以及在 CPU 上 30 秒內跑完的測試。自己做方法包:`autoforge pack new`(見 [docs/PACK_SPEC.md](docs/PACK_SPEC.md))。
44
+
45
+ ## 從原始碼開發
46
+
47
+ ```bash
48
+ git clone https://github.com/Honguan/autoforge && cd autoforge
49
+ pip install -e ".[dev]" # 加上 ,deep 安裝深度學習方法包的依賴
50
+ pytest -q
51
+ ```
52
+
53
+ ## 網頁介面
54
+
55
+ ```bash
56
+ autoforge gui # 打開瀏覽器:上傳資料 → 選任務 → 選方法 → 訓練 → 調參 → 註冊 → 預測
57
+ ```
58
+
59
+ ## 使用
60
+
61
+ ```bash
62
+ autoforge doctor # 偵測硬體
63
+ autoforge doctor --json # 給 AI 讀的 JSON
64
+ autoforge schema # 列出所有資料結構
65
+ autoforge schema TrainingPlan --json
66
+
67
+ # 方法包
68
+ autoforge pack search csv --fit # 搜尋這台電腦跑得動的方法包
69
+ autoforge pack install tabular-classic # 從索引安裝(鎖定 commit)
70
+ autoforge pack install ./packs/tabular-classic # 從本地資料夾安裝
71
+ autoforge pack install github:owner/repo/subdir@v1.0.0
72
+ autoforge pack info tabular-classic --json # 給 AI 讀的知識和方法
73
+ autoforge pack list
74
+
75
+ # 訓練
76
+ autoforge plan validate examples/churn_plan.yaml # 檢查訓練計畫
77
+ autoforge run start examples/churn_plan.yaml --wait # 訓練並即時顯示進度
78
+ autoforge run start plan.yaml --json # 背景訓練,立即回傳 run_id(給 AI 用)
79
+ autoforge run status <run_id>
80
+ autoforge run pause|resume|stop <run_id>
81
+ autoforge run metrics|logs|audit <run_id>
82
+ autoforge run retry <run_id> # 同計畫重跑,從 checkpoint 接續
83
+ ```
84
+
85
+ 每次訓練的所有檔案都在 `~/.autoforge/runs/<run_id>/`:計畫、模型、checkpoint、日誌、指標、稽核紀錄,計畫和 AI 寫的程式會用 git 版本管理。
86
+
87
+ 方法包格式見 [docs/PACK_SPEC.md](docs/PACK_SPEC.md),索引放在本 repo 的 [`packs-index` 分支](https://github.com/Honguan/autoforge/tree/packs-index)。
88
+
89
+ ## 改進模型
90
+
91
+ ```bash
92
+ autoforge run diagnose <run_id> # 找問題、給建議
93
+ autoforge hpo start examples/churn_plan.yaml -m f1_macro -n 20 --wait # 自動調參(trial 0 = 基準)
94
+ autoforge run adjust <run_id> --set learning_rate=0.0003 # 訓練中途改參數
95
+ autoforge run compare <id1> <id2> -m f1_macro # 比較
96
+ ```
97
+
98
+ ## 部署
99
+
100
+ ```bash
101
+ autoforge model register <run_id> --name churn # 註冊成模型(v1、v2…)
102
+ autoforge model predict churn --rows '[{...}]' # 預測
103
+ autoforge serve # REST API(127.0.0.1:8000)
104
+ autoforge serve-mcp # 每個模型變成 MCP 工具 predict_<名稱>,給其他 AI 呼叫
105
+ autoforge model export churn --format onnx # 匯出
106
+ ```
107
+
108
+ ## 一句話訓練(內建 AI 代理)
109
+
110
+ ```bash
111
+ pip install -e ".[anthropic]"
112
+ autoforge train "預測 churned 欄位" --data examples/data/churn.csv # Claude(預設)
113
+ autoforge train "預測 churned 欄位" --data examples/data/churn.csv --brain ollama:qwen3 # 本地模型
114
+ ```
115
+
116
+ 詳見 [docs/AGENT.md](docs/AGENT.md)。
117
+
118
+ ## 讓 AI 操作(MCP)
119
+
120
+ ```bash
121
+ claude mcp add autoforge -- autoforge mcp --actor ai:claude-code # Claude Code
122
+ ```
123
+
124
+ Claude Desktop 和隱私設定見 [docs/MCP.md](docs/MCP.md)。
125
+
126
+ ```bash
127
+ autoforge data mark ~/data/customers -s sensitive # 敏感資料:雲端 AI 不能使用
128
+ ```
129
+
130
+ ## 測試
131
+
132
+ ```bash
133
+ pytest
134
+ ```
@@ -0,0 +1,3 @@
1
+ """AutoForge: AI that trains AI."""
2
+
3
+ __version__ = "1.0.2"
File without changes