reflexlm 0.2.0__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.
@@ -0,0 +1,35 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ test:
14
+ name: Test (Python ${{ matrix.python-version }})
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ python-version: ["3.11", "3.12"]
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+ - uses: astral-sh/setup-uv@v5
26
+ - name: Sync dependencies
27
+ run: uv sync --locked --extra dev
28
+ - name: Lint with Ruff
29
+ run: uv run ruff check .
30
+ - name: Type-check with Mypy
31
+ run: uv run mypy src
32
+ - name: Run Pytest
33
+ run: uv run pytest -q
34
+ - name: Build package
35
+ run: uv build
@@ -0,0 +1,55 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ release:
8
+ types: [published]
9
+ workflow_dispatch:
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ jobs:
15
+ build:
16
+ name: Test & Build distributions
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: actions/setup-python@v5
21
+ with:
22
+ python-version: "3.12"
23
+ - uses: astral-sh/setup-uv@v5
24
+ - name: Run quality checks & tests
25
+ run: |
26
+ uv sync --locked --extra dev
27
+ uv run ruff check .
28
+ uv run mypy src
29
+ uv run pytest -q
30
+ - name: Build sdist and wheel
31
+ run: uv build
32
+ - name: Upload distribution artifacts
33
+ uses: actions/upload-artifact@v4
34
+ with:
35
+ name: python-package-distributions
36
+ path: dist/
37
+
38
+ pypi-publish:
39
+ name: Publish release to PyPI
40
+ needs: build
41
+ runs-on: ubuntu-latest
42
+ environment:
43
+ name: pypi
44
+ url: https://pypi.org/p/reflexlm
45
+ permissions:
46
+ id-token: write
47
+ contents: read
48
+ steps:
49
+ - name: Download distribution artifacts
50
+ uses: actions/download-artifact@v4
51
+ with:
52
+ name: python-package-distributions
53
+ path: dist/
54
+ - name: Publish package distributions to PyPI
55
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,13 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ dist/
5
+ build/
6
+ *.egg-info/
7
+ .pytest_cache/
8
+ .ruff_cache/
9
+ .mypy_cache/
10
+ checkpoints/
11
+ runs/
12
+ *.pt
13
+ *.safetensors
reflexlm-0.2.0/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright 2026 NIZAMUDHEEN_T_I
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
@@ -0,0 +1,157 @@
1
+ Metadata-Version: 2.5
2
+ Name: reflexlm
3
+ Version: 0.2.0
4
+ Summary: Unified pretraining, continual pretraining (CPT), SFT, and reference-free post-training (SimPO/ORPO/DPO/System-1 distillation) toolkit for Small Language Models (SLMs) and fast System-1 inference.
5
+ Project-URL: Homepage, https://github.com/nizamudheenti/slmforge
6
+ Project-URL: Repository, https://github.com/nizamudheenti/slmforge
7
+ Project-URL: Issues, https://github.com/nizamudheenti/slmforge/issues
8
+ Author-email: NIZAMUDHEEN_T_I <33263597+nizamudheenti@users.noreply.github.com>
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: continual-pretraining,distillation,dpo,fine-tuning,inference,llm,orpo,post-training,pretraining,simpo,slm,system-1
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: click>=8.1
23
+ Requires-Dist: pydantic>=2.7
24
+ Requires-Dist: pyyaml>=6.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: mypy>=1.11; extra == 'dev'
27
+ Requires-Dist: pytest>=8.0; extra == 'dev'
28
+ Requires-Dist: ruff>=0.8; extra == 'dev'
29
+ Requires-Dist: types-pyyaml>=6.0; extra == 'dev'
30
+ Provides-Extra: hf
31
+ Requires-Dist: accelerate>=1.0; extra == 'hf'
32
+ Requires-Dist: datasets>=3.0; extra == 'hf'
33
+ Requires-Dist: peft>=0.13; extra == 'hf'
34
+ Requires-Dist: torch>=2.3; extra == 'hf'
35
+ Requires-Dist: transformers>=4.45; extra == 'hf'
36
+ Provides-Extra: torch
37
+ Requires-Dist: torch>=2.3; extra == 'torch'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # reflexlm
41
+
42
+ [![PyPI version](https://img.shields.io/pypi/v/reflexlm.svg)](https://pypi.org/project/reflexlm/)
43
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
44
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
45
+
46
+ **Unified pretraining, continual pretraining (CPT), SFT, and reference-free post-training toolkit built specifically for Small Language Models (SLMs) and fast System-1 inference.**
47
+
48
+ Modern reasoning models (System-2) spend hundreds of tokens inside `<think>` blocks. Production routing, classification, tool-calling, extraction, and edge/mobile workloads need **System-1 SLMs (100M–4B params)** that answer directly in tens of milliseconds with minimal KV-cache footprint.
49
+
50
+ `reflexlm` connects every stage of the SLM lifecycle directly to your inference SLA:
51
+
52
+ ```mermaid
53
+ flowchart LR
54
+ A["Pretrain<br/>WSD + EOS Packing"] --> B["CPT<br/>Replay Buffer Mixing"]
55
+ B --> C["System-1 SFT<br/>Strip Thinking + Assistant Mask"]
56
+ C --> D["Post-Train<br/>SimPO / ORPO / DPO / Distill"]
57
+ D --> E["System-1 Audit<br/>TTFT + GQA KV + vLLM"]
58
+ ```
59
+
60
+ ## Key Features
61
+
62
+ - **Pretraining (`pretrain`):** Compact GQA + RMSNorm + SwiGLU SLM presets (`sys1-150m`, `sys1-350m`, `sys1-1b`), constant-length EOS sequence packing, deterministic cross-process tokenization, and **Warmup-Stable-Decay (WSD)** & Cosine LR schedules.
63
+ - **Continual Pretraining (`cpt`):** Built-in **replay-buffer mixing** (`mix_cpt_replay_stream`) to adapt SLMs to new domains without catastrophic forgetting.
64
+ - **System-1 SFT (`sft`):** Assistant-only loss masking (`-100` on prompt tokens), `max_target_tokens` conciseness capping, and robust **System-2 thinking-tag stripping** (closed `<think>...</think>`, R1/Qwen orphan `</think>`, truncated unclosed `<think>`, Gemma4 `<|channel>thought...<channel|>`, and Plan-Re-Act `/*PLANNING*/.../*FINAL_ANSWER*/`).
65
+ - **Reference-Free Post-Training (`posttrain`):** Single-GPU-friendly **SimPO** (with optional System-1 length shaping), **ORPO**, **DPO**, and **System-1 Knowledge Distillation** (KL + CE).
66
+ - **Optional PyTorch Engine (`reflexlm.torch_backend`):** Real Llama-style `CompactSLM` (`nn.Module` with GQA, RMSNorm, SwiGLU, tied embeddings), batch `torch_simpo_loss`, and `run_torch_lm_steps` causal-LM trainer.
67
+ - **Inference-Aware Auditing (`audit`):** Computes exact parameter counts, weights + GQA KV-cache VRAM (`fp16`/`bf16`/`int8`/`int4`, `fp8` KV), prefill TTFT + decode roofline latency (`ms`), System-1 SLA pass/fail, and ready-to-run `vllm serve` commands.
68
+
69
+ ## Installation
70
+
71
+ ```bash
72
+ pip install reflexlm
73
+ # Optional PyTorch / Hugging Face / PEFT backends:
74
+ pip install "reflexlm[torch]"
75
+ pip install "reflexlm[hf]"
76
+ ```
77
+
78
+ ## Quickstart (CLI)
79
+
80
+ ```bash
81
+ # 1. Generate a full Pretrain -> CPT -> SFT -> Post-Train YAML recipe
82
+ reflexlm init --preset sys1-350m --output reflexlm.yaml
83
+
84
+ # 2. Validate JSONL datasets and plan/pack any pipeline stage
85
+ reflexlm plan pretrain --config reflexlm.yaml
86
+ reflexlm plan cpt --config reflexlm.yaml
87
+ reflexlm plan sft --config reflexlm.yaml
88
+ reflexlm plan posttrain --config reflexlm.yaml
89
+
90
+ # 3. Audit System-1 VRAM, GQA KV-cache, TTFT, and decode latency SLA on an L4 GPU
91
+ reflexlm audit --config reflexlm.yaml --hardware L4 --weight-dtype bf16 --kv-dtype fp8 --concurrency 16
92
+
93
+ # 4. Distill a System-2 trace into a clean System-1 target
94
+ reflexlm strip-thinking "<think>Checking weather API...</think>Sunny, 22C in Paris."
95
+ ```
96
+
97
+ ## JSONL Dataset Schemas
98
+
99
+ - **Pretrain / CPT (`data/pretrain.jsonl`, `data/domain_cpt.jsonl`):**
100
+ ```json
101
+ {"text": "Domain document or pretraining passage..."}
102
+ ```
103
+ - **System-1 SFT (`data/sft.jsonl`) — supports `prompt`/`response` or OpenAI chat `messages`:**
104
+ ```json
105
+ {"prompt": "Classify intent: Cancel my order", "response": "<think>User wants cancellation</think>{\"intent\": \"cancel_order\"}"}
106
+ {"messages": [{"role": "user", "content": "2 + 2?"}, {"role": "assistant", "content": "4"}]}
107
+ ```
108
+ - **Post-Training Preferences (`data/preferences.jsonl`):**
109
+ ```json
110
+ {"prompt": "Summarize status", "chosen": "All systems operational.", "rejected": "Well, let me think carefully through every subsystem..."}
111
+ ```
112
+
113
+ ## Quickstart (Python)
114
+
115
+ ```python
116
+ from reflexlm import (
117
+ SLMArchitectureConfig,
118
+ audit_system1_budget,
119
+ mix_cpt_replay_stream,
120
+ simpo_loss,
121
+ strip_system2_thinking,
122
+ )
123
+
124
+ # 1. Audit your SLM architecture against a 250ms System-1 SLA (TTFT + decode)
125
+ arch = SLMArchitectureConfig(name="sys1-350m", num_layers=20, num_heads=16, num_kv_heads=4)
126
+ report = audit_system1_budget(
127
+ arch,
128
+ hardware="L4",
129
+ kv_dtype="fp8",
130
+ prompt_tokens=256,
131
+ target_output_tokens=48,
132
+ system1_sla_ms=250.0,
133
+ )
134
+ print(report.est_ttft_ms, report.est_decode_tok_s, report.est_response_latency_ms)
135
+ print(report.vllm_command)
136
+
137
+ # 2. Clean System-2 teacher traces for System-1 SFT
138
+ clean = strip_system2_thinking("Reasoning first...</think>{\"intent\": \"refund\"}")
139
+
140
+ # 3. Mix 15% general replay data into domain CPT to prevent forgetting
141
+ cpt_docs = mix_cpt_replay_stream(["domain doc"] * 20, ["general doc"] * 5, replay_ratio=0.15)
142
+
143
+ # 4. Reference-free SimPO loss with System-1 length shaping
144
+ loss = simpo_loss(
145
+ chosen_avg_logp=-0.4,
146
+ rejected_avg_logp=-0.9,
147
+ beta=2.0,
148
+ gamma=0.5,
149
+ length_penalty=0.05,
150
+ chosen_len=24,
151
+ rejected_len=140,
152
+ )
153
+ ```
154
+
155
+ ## License
156
+
157
+ Apache License 2.0
@@ -0,0 +1,118 @@
1
+ # reflexlm
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/reflexlm.svg)](https://pypi.org/project/reflexlm/)
4
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
5
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
6
+
7
+ **Unified pretraining, continual pretraining (CPT), SFT, and reference-free post-training toolkit built specifically for Small Language Models (SLMs) and fast System-1 inference.**
8
+
9
+ Modern reasoning models (System-2) spend hundreds of tokens inside `<think>` blocks. Production routing, classification, tool-calling, extraction, and edge/mobile workloads need **System-1 SLMs (100M–4B params)** that answer directly in tens of milliseconds with minimal KV-cache footprint.
10
+
11
+ `reflexlm` connects every stage of the SLM lifecycle directly to your inference SLA:
12
+
13
+ ```mermaid
14
+ flowchart LR
15
+ A["Pretrain<br/>WSD + EOS Packing"] --> B["CPT<br/>Replay Buffer Mixing"]
16
+ B --> C["System-1 SFT<br/>Strip Thinking + Assistant Mask"]
17
+ C --> D["Post-Train<br/>SimPO / ORPO / DPO / Distill"]
18
+ D --> E["System-1 Audit<br/>TTFT + GQA KV + vLLM"]
19
+ ```
20
+
21
+ ## Key Features
22
+
23
+ - **Pretraining (`pretrain`):** Compact GQA + RMSNorm + SwiGLU SLM presets (`sys1-150m`, `sys1-350m`, `sys1-1b`), constant-length EOS sequence packing, deterministic cross-process tokenization, and **Warmup-Stable-Decay (WSD)** & Cosine LR schedules.
24
+ - **Continual Pretraining (`cpt`):** Built-in **replay-buffer mixing** (`mix_cpt_replay_stream`) to adapt SLMs to new domains without catastrophic forgetting.
25
+ - **System-1 SFT (`sft`):** Assistant-only loss masking (`-100` on prompt tokens), `max_target_tokens` conciseness capping, and robust **System-2 thinking-tag stripping** (closed `<think>...</think>`, R1/Qwen orphan `</think>`, truncated unclosed `<think>`, Gemma4 `<|channel>thought...<channel|>`, and Plan-Re-Act `/*PLANNING*/.../*FINAL_ANSWER*/`).
26
+ - **Reference-Free Post-Training (`posttrain`):** Single-GPU-friendly **SimPO** (with optional System-1 length shaping), **ORPO**, **DPO**, and **System-1 Knowledge Distillation** (KL + CE).
27
+ - **Optional PyTorch Engine (`reflexlm.torch_backend`):** Real Llama-style `CompactSLM` (`nn.Module` with GQA, RMSNorm, SwiGLU, tied embeddings), batch `torch_simpo_loss`, and `run_torch_lm_steps` causal-LM trainer.
28
+ - **Inference-Aware Auditing (`audit`):** Computes exact parameter counts, weights + GQA KV-cache VRAM (`fp16`/`bf16`/`int8`/`int4`, `fp8` KV), prefill TTFT + decode roofline latency (`ms`), System-1 SLA pass/fail, and ready-to-run `vllm serve` commands.
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install reflexlm
34
+ # Optional PyTorch / Hugging Face / PEFT backends:
35
+ pip install "reflexlm[torch]"
36
+ pip install "reflexlm[hf]"
37
+ ```
38
+
39
+ ## Quickstart (CLI)
40
+
41
+ ```bash
42
+ # 1. Generate a full Pretrain -> CPT -> SFT -> Post-Train YAML recipe
43
+ reflexlm init --preset sys1-350m --output reflexlm.yaml
44
+
45
+ # 2. Validate JSONL datasets and plan/pack any pipeline stage
46
+ reflexlm plan pretrain --config reflexlm.yaml
47
+ reflexlm plan cpt --config reflexlm.yaml
48
+ reflexlm plan sft --config reflexlm.yaml
49
+ reflexlm plan posttrain --config reflexlm.yaml
50
+
51
+ # 3. Audit System-1 VRAM, GQA KV-cache, TTFT, and decode latency SLA on an L4 GPU
52
+ reflexlm audit --config reflexlm.yaml --hardware L4 --weight-dtype bf16 --kv-dtype fp8 --concurrency 16
53
+
54
+ # 4. Distill a System-2 trace into a clean System-1 target
55
+ reflexlm strip-thinking "<think>Checking weather API...</think>Sunny, 22C in Paris."
56
+ ```
57
+
58
+ ## JSONL Dataset Schemas
59
+
60
+ - **Pretrain / CPT (`data/pretrain.jsonl`, `data/domain_cpt.jsonl`):**
61
+ ```json
62
+ {"text": "Domain document or pretraining passage..."}
63
+ ```
64
+ - **System-1 SFT (`data/sft.jsonl`) — supports `prompt`/`response` or OpenAI chat `messages`:**
65
+ ```json
66
+ {"prompt": "Classify intent: Cancel my order", "response": "<think>User wants cancellation</think>{\"intent\": \"cancel_order\"}"}
67
+ {"messages": [{"role": "user", "content": "2 + 2?"}, {"role": "assistant", "content": "4"}]}
68
+ ```
69
+ - **Post-Training Preferences (`data/preferences.jsonl`):**
70
+ ```json
71
+ {"prompt": "Summarize status", "chosen": "All systems operational.", "rejected": "Well, let me think carefully through every subsystem..."}
72
+ ```
73
+
74
+ ## Quickstart (Python)
75
+
76
+ ```python
77
+ from reflexlm import (
78
+ SLMArchitectureConfig,
79
+ audit_system1_budget,
80
+ mix_cpt_replay_stream,
81
+ simpo_loss,
82
+ strip_system2_thinking,
83
+ )
84
+
85
+ # 1. Audit your SLM architecture against a 250ms System-1 SLA (TTFT + decode)
86
+ arch = SLMArchitectureConfig(name="sys1-350m", num_layers=20, num_heads=16, num_kv_heads=4)
87
+ report = audit_system1_budget(
88
+ arch,
89
+ hardware="L4",
90
+ kv_dtype="fp8",
91
+ prompt_tokens=256,
92
+ target_output_tokens=48,
93
+ system1_sla_ms=250.0,
94
+ )
95
+ print(report.est_ttft_ms, report.est_decode_tok_s, report.est_response_latency_ms)
96
+ print(report.vllm_command)
97
+
98
+ # 2. Clean System-2 teacher traces for System-1 SFT
99
+ clean = strip_system2_thinking("Reasoning first...</think>{\"intent\": \"refund\"}")
100
+
101
+ # 3. Mix 15% general replay data into domain CPT to prevent forgetting
102
+ cpt_docs = mix_cpt_replay_stream(["domain doc"] * 20, ["general doc"] * 5, replay_ratio=0.15)
103
+
104
+ # 4. Reference-free SimPO loss with System-1 length shaping
105
+ loss = simpo_loss(
106
+ chosen_avg_logp=-0.4,
107
+ rejected_avg_logp=-0.9,
108
+ beta=2.0,
109
+ gamma=0.5,
110
+ length_penalty=0.05,
111
+ chosen_len=24,
112
+ rejected_len=140,
113
+ )
114
+ ```
115
+
116
+ ## License
117
+
118
+ Apache License 2.0
@@ -0,0 +1,91 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "reflexlm"
7
+ version = "0.2.0"
8
+ description = "Unified pretraining, continual pretraining (CPT), SFT, and reference-free post-training (SimPO/ORPO/DPO/System-1 distillation) toolkit for Small Language Models (SLMs) and fast System-1 inference."
9
+ readme = "README.md"
10
+ license = { text = "Apache-2.0" }
11
+ requires-python = ">=3.11"
12
+ authors = [{ name = "NIZAMUDHEEN_T_I", email = "33263597+nizamudheenti@users.noreply.github.com" }]
13
+ keywords = [
14
+ "slm",
15
+ "llm",
16
+ "system-1",
17
+ "pretraining",
18
+ "continual-pretraining",
19
+ "fine-tuning",
20
+ "post-training",
21
+ "simpo",
22
+ "orpo",
23
+ "dpo",
24
+ "distillation",
25
+ "inference",
26
+ ]
27
+ classifiers = [
28
+ "Development Status :: 4 - Beta",
29
+ "Intended Audience :: Developers",
30
+ "Intended Audience :: Science/Research",
31
+ "License :: OSI Approved :: Apache Software License",
32
+ "Programming Language :: Python :: 3",
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12",
35
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
36
+ "Typing :: Typed",
37
+ ]
38
+ dependencies = [
39
+ "pydantic>=2.7",
40
+ "pyyaml>=6.0",
41
+ "click>=8.1",
42
+ ]
43
+
44
+ [project.optional-dependencies]
45
+ torch = [
46
+ "torch>=2.3",
47
+ ]
48
+ hf = [
49
+ "torch>=2.3",
50
+ "transformers>=4.45",
51
+ "peft>=0.13",
52
+ "datasets>=3.0",
53
+ "accelerate>=1.0",
54
+ ]
55
+ dev = [
56
+ "pytest>=8.0",
57
+ "ruff>=0.8",
58
+ "mypy>=1.11",
59
+ "types-PyYAML>=6.0",
60
+ ]
61
+
62
+ [project.scripts]
63
+ reflexlm = "reflexlm.cli:main"
64
+
65
+ [project.urls]
66
+ Homepage = "https://github.com/nizamudheenti/slmforge"
67
+ Repository = "https://github.com/nizamudheenti/slmforge"
68
+ Issues = "https://github.com/nizamudheenti/slmforge/issues"
69
+
70
+ [tool.hatch.build.targets.wheel]
71
+ packages = ["src/reflexlm"]
72
+
73
+ [tool.ruff]
74
+ target-version = "py311"
75
+ line-length = 100
76
+
77
+ [tool.ruff.lint]
78
+ select = ["E", "F", "I", "UP", "B"]
79
+
80
+ [tool.mypy]
81
+ python_version = "3.11"
82
+ strict = true
83
+ warn_unreachable = true
84
+ mypy_path = ["src"]
85
+
86
+ [[tool.mypy.overrides]]
87
+ module = ["torch", "torch.*"]
88
+ ignore_missing_imports = true
89
+
90
+ [tool.pytest.ini_options]
91
+ testpaths = ["tests"]
@@ -0,0 +1,80 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """reflexlm: Pretraining, CPT, SFT, and Post-Training for System-1 SLMs."""
3
+
4
+ from reflexlm.config import (
5
+ CPTConfig,
6
+ PipelineConfig,
7
+ PostTrainConfig,
8
+ PretrainConfig,
9
+ SFTConfig,
10
+ SLMArchitectureConfig,
11
+ )
12
+ from reflexlm.data import (
13
+ IGNORE_INDEX,
14
+ DeterministicTokenizer,
15
+ MaskedSFTExample,
16
+ PreferenceExample,
17
+ build_sft_loss_mask,
18
+ load_preference_jsonl,
19
+ load_sft_jsonl,
20
+ load_text_jsonl,
21
+ mix_cpt_replay_stream,
22
+ pack_token_sequences,
23
+ strip_system2_thinking,
24
+ )
25
+ from reflexlm.inference import HARDWARE_PROFILES, System1BudgetReport, audit_system1_budget
26
+ from reflexlm.losses import (
27
+ dpo_loss,
28
+ orpo_loss,
29
+ simpo_loss,
30
+ system1_distill_loss,
31
+ )
32
+ from reflexlm.pipeline import (
33
+ StageSummary,
34
+ evaluate_posttrain_step,
35
+ plan_cpt_stage,
36
+ plan_posttrain_stage,
37
+ plan_pretrain_stage,
38
+ plan_sft_stage,
39
+ run_stage_from_files,
40
+ )
41
+ from reflexlm.schedules import cosine_lr, wsd_lr
42
+
43
+ __version__ = "0.2.0"
44
+
45
+ __all__ = [
46
+ "CPTConfig",
47
+ "DeterministicTokenizer",
48
+ "HARDWARE_PROFILES",
49
+ "IGNORE_INDEX",
50
+ "MaskedSFTExample",
51
+ "PipelineConfig",
52
+ "PostTrainConfig",
53
+ "PreferenceExample",
54
+ "PretrainConfig",
55
+ "SFTConfig",
56
+ "SLMArchitectureConfig",
57
+ "StageSummary",
58
+ "System1BudgetReport",
59
+ "__version__",
60
+ "audit_system1_budget",
61
+ "build_sft_loss_mask",
62
+ "cosine_lr",
63
+ "dpo_loss",
64
+ "evaluate_posttrain_step",
65
+ "load_preference_jsonl",
66
+ "load_sft_jsonl",
67
+ "load_text_jsonl",
68
+ "mix_cpt_replay_stream",
69
+ "orpo_loss",
70
+ "pack_token_sequences",
71
+ "plan_cpt_stage",
72
+ "plan_posttrain_stage",
73
+ "plan_pretrain_stage",
74
+ "plan_sft_stage",
75
+ "run_stage_from_files",
76
+ "simpo_loss",
77
+ "strip_system2_thinking",
78
+ "system1_distill_loss",
79
+ "wsd_lr",
80
+ ]