Text Generation
PEFT
Safetensors
Transformers
English
lora
qlora
bitsandbytes
connect4
game-playing
causal-lm
Instructions to use RenaudGaudron/Qwen3-0.6B-Connect4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use RenaudGaudron/Qwen3-0.6B-Connect4 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-0.6B-Base") model = PeftModel.from_pretrained(base_model, "RenaudGaudron/Qwen3-0.6B-Connect4") - Transformers
How to use RenaudGaudron/Qwen3-0.6B-Connect4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RenaudGaudron/Qwen3-0.6B-Connect4")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("RenaudGaudron/Qwen3-0.6B-Connect4", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use RenaudGaudron/Qwen3-0.6B-Connect4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RenaudGaudron/Qwen3-0.6B-Connect4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RenaudGaudron/Qwen3-0.6B-Connect4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/RenaudGaudron/Qwen3-0.6B-Connect4
- SGLang
How to use RenaudGaudron/Qwen3-0.6B-Connect4 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "RenaudGaudron/Qwen3-0.6B-Connect4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RenaudGaudron/Qwen3-0.6B-Connect4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "RenaudGaudron/Qwen3-0.6B-Connect4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RenaudGaudron/Qwen3-0.6B-Connect4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use RenaudGaudron/Qwen3-0.6B-Connect4 with Docker Model Runner:
docker model run hf.co/RenaudGaudron/Qwen3-0.6B-Connect4
v2.0.0 update with lower eval loss
Browse files- README.md +38 -33
- adapter_config.json +4 -4
- adapter_model.safetensors +2 -2
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
model_name: Connect4 QLoRA Adapter for Qwen3-0.6B-Base
|
| 3 |
-
version:
|
| 4 |
library_name: peft
|
| 5 |
base_model: Qwen/Qwen3-0.6B-Base
|
| 6 |
license: mit
|
|
@@ -28,7 +28,9 @@ quantization_config:
|
|
| 28 |
|
| 29 |
## Model Summary
|
| 30 |
|
| 31 |
-
This repository distributes a QLoRA adapter trained to steer the **Qwen/Qwen3-0.6B-Base** model toward Connect Four next-move prediction and short-form move generation. Prompts encode game history as concatenated column indices (`0`–`6`) along with the starter and side-to-move context, allowing the adapter to focus on legal column selection. The weights are stored separately from the base checkpoint; load or merge them into the matching base revision before running inference. Runs on a single consumer GPU with 4 GB of VRAM in 4bit mode.
|
|
|
|
|
|
|
| 32 |
|
| 33 |
## How to Use
|
| 34 |
|
|
@@ -110,7 +112,7 @@ model.tokenizer.save_pretrained(OUTPUT_DIR)
|
|
| 110 |
print(f"Merged model saved to {OUTPUT_DIR}. Review the base model license before redistribution.")
|
| 111 |
```
|
| 112 |
|
| 113 |
-
> **Prompt format.**
|
| 114 |
|
| 115 |
## Training Details
|
| 116 |
|
|
@@ -123,65 +125,67 @@ print(f"Merged model saved to {OUTPUT_DIR}. Review the base model license before
|
|
| 123 |
* Target modules: attention projections (`q_proj`, `k_proj`, `v_proj`, `o_proj`) and MLP projections (`gate_proj`, `up_proj`, `down_proj`).
|
| 124 |
* Adapter bias: disabled; only rank update matrices are trainable.
|
| 125 |
|
| 126 |
-
QLoRA keeps the dense Qwen3 backbone quantised to 4-bit NF4 while learning a lightweight
|
| 127 |
|
| 128 |
### Optimisation setup
|
| 129 |
|
| 130 |
* Optimiser: `adamw_torch_fused` with β₂ = 0.98 and ε = 1e-6.
|
| 131 |
-
* Learning rate: 5e-7 with `constant_with_warmup` scheduling and a warmup ratio of 5 %
|
| 132 |
* Weight decay: 0.0.
|
| 133 |
* Gradient accumulation: 8 steps with per-device batch size 8 → effective batch size 64 sequences.
|
| 134 |
-
* Max gradient norm: 25.0 with
|
| 135 |
* Label smoothing: disabled.
|
| 136 |
-
* Attention backend: PyTorch SDPA with math kernel fallback
|
|
|
|
| 137 |
|
| 138 |
### Precision and memory
|
| 139 |
|
| 140 |
-
* Base model loaded in 4-bit NF4 with double quantisation; LoRA weights in float32.
|
| 141 |
-
* Computation dtype:
|
| 142 |
* Gradient checkpointing: disabled.
|
| 143 |
|
| 144 |
### Data
|
| 145 |
|
| 146 |
-
* Dataset: private self-play Connect Four rollouts.
|
| 147 |
-
*
|
| 148 |
-
*
|
| 149 |
-
* Minimum move threshold:
|
| 150 |
-
* Validation split: 10 % stratified
|
| 151 |
|
| 152 |
### Training run
|
| 153 |
|
| 154 |
-
* Epochs: 5 planned
|
| 155 |
-
*
|
| 156 |
-
*
|
| 157 |
-
* Hardware: single-
|
| 158 |
-
* Seed: 42
|
| 159 |
|
| 160 |
## Evaluation
|
| 161 |
|
| 162 |
-
Evaluation
|
| 163 |
|
| 164 |
-
*
|
| 165 |
-
* Best observed validation loss during training: **0.7306** at step 30 000.
|
| 166 |
|
| 167 |
-
|
| 168 |
|
| 169 |
-
Stability controls
|
| 170 |
|
| 171 |
## Special Tokens
|
| 172 |
|
| 173 |
-
The adapter
|
| 174 |
|
| 175 |
## Intended Use & Limitations
|
| 176 |
|
| 177 |
-
**Intended use.**
|
|
|
|
|
|
|
| 178 |
|
| 179 |
**Limitations.**
|
| 180 |
|
| 181 |
-
* The
|
| 182 |
-
* Outputs are single-digit column indices; free-form
|
| 183 |
* The adapter does not include safety layers, toxicity filtering, or alignment for open-domain generation. Avoid deploying it in user-facing production systems.
|
| 184 |
-
* Quality depends
|
| 185 |
|
| 186 |
## Compatibility
|
| 187 |
|
|
@@ -190,22 +194,23 @@ The adapter was trained and validated with the following stack:
|
|
| 190 |
* `transformers` ≥ 4.39.0
|
| 191 |
* `peft` ≥ 0.8.2
|
| 192 |
* `bitsandbytes` ≥ 0.43.0
|
| 193 |
-
* `torch` ≥ 2.1 (CUDA 12.4
|
| 194 |
* `accelerate` ≥ 0.25.0
|
| 195 |
|
| 196 |
-
|
| 197 |
|
| 198 |
## Reproducibility & Seeds
|
| 199 |
|
| 200 |
-
The
|
| 201 |
|
| 202 |
## Changelog
|
| 203 |
|
|
|
|
| 204 |
* **2025-10-25** – Initial public adapter release.
|
| 205 |
|
| 206 |
## License
|
| 207 |
|
| 208 |
-
The adapter is released under the **MIT License**. The base model, **Qwen/Qwen3-0.6B-Base**,
|
| 209 |
|
| 210 |
## Citations
|
| 211 |
|
|
|
|
| 1 |
---
|
| 2 |
model_name: Connect4 QLoRA Adapter for Qwen3-0.6B-Base
|
| 3 |
+
version: 2.0.0
|
| 4 |
library_name: peft
|
| 5 |
base_model: Qwen/Qwen3-0.6B-Base
|
| 6 |
license: mit
|
|
|
|
| 28 |
|
| 29 |
## Model Summary
|
| 30 |
|
| 31 |
+
This repository distributes a QLoRA adapter trained to steer the **Qwen/Qwen3-0.6B-Base** model toward Connect Four next-move prediction and short-form move generation. Prompts encode game history as concatenated column indices (`0`–`6`) along with the starter and side-to-move context, allowing the adapter to focus on legal column selection. The weights are stored separately from the base checkpoint; load or merge them into the matching base revision before running inference. Runs on a single consumer GPU with 4 GB of VRAM in 4bit mode.
|
| 32 |
+
|
| 33 |
+
This updated version includes a larger training set and automatically selected the checkpoint with the lowest evaluation loss for improved reliability and performance.
|
| 34 |
|
| 35 |
## How to Use
|
| 36 |
|
|
|
|
| 112 |
print(f"Merged model saved to {OUTPUT_DIR}. Review the base model license before redistribution.")
|
| 113 |
```
|
| 114 |
|
| 115 |
+
> **Prompt format.** Training examples follow the template above. The `Moves so far` string serialises column indices (`0`–`6`) without separators so column legality remains reconstructible. Use `none` when the board is empty, and always align the move history with the declared starter to avoid illegal column suggestions. Responses remain single digits; deterministic decoding or constrained vocabularies help preserve the format.
|
| 116 |
|
| 117 |
## Training Details
|
| 118 |
|
|
|
|
| 125 |
* Target modules: attention projections (`q_proj`, `k_proj`, `v_proj`, `o_proj`) and MLP projections (`gate_proj`, `up_proj`, `down_proj`).
|
| 126 |
* Adapter bias: disabled; only rank update matrices are trainable.
|
| 127 |
|
| 128 |
+
QLoRA keeps the dense Qwen3 backbone quantised to 4-bit NF4 while learning a lightweight LoRA stack initialised from the resumed checkpoint. The adapters stay in float32 while the quantised backbone executes in 4-bit, keeping peak VRAM well under 8 GB on the training GPU.
|
| 129 |
|
| 130 |
### Optimisation setup
|
| 131 |
|
| 132 |
* Optimiser: `adamw_torch_fused` with β₂ = 0.98 and ε = 1e-6.
|
| 133 |
+
* Learning rate: 5e-7 with `constant_with_warmup` scheduling and a warmup ratio of 5 %.
|
| 134 |
* Weight decay: 0.0.
|
| 135 |
* Gradient accumulation: 8 steps with per-device batch size 8 → effective batch size 64 sequences.
|
| 136 |
+
* Max gradient norm: 25.0 with clipping applied every optimisation step.
|
| 137 |
* Label smoothing: disabled.
|
| 138 |
+
* Attention backend: PyTorch SDPA with math kernel fallback; flash and memory-efficient kernels were unavailable on the training GPU.
|
| 139 |
+
* Length-aware sampling: 64-bucket sampler enabled to reduce padding skew during both training and evaluation.
|
| 140 |
|
| 141 |
### Precision and memory
|
| 142 |
|
| 143 |
+
* Base model loaded in 4-bit NF4 with double quantisation; LoRA weights stored in float32.
|
| 144 |
+
* Computation dtype: BF16 with TF32 matmuls enabled; FP16 disabled.
|
| 145 |
* Gradient checkpointing: disabled.
|
| 146 |
|
| 147 |
### Data
|
| 148 |
|
| 149 |
+
* Dataset source: private self-play Connect Four rollouts across three CSV files.
|
| 150 |
+
* Aggregated examples: 114 363 generated prompts (102 926 train / 11 437 validation) from 4 200 games.
|
| 151 |
+
* Per-file caps: 100 level-0 games (two players making random legal moves), 4 000 games played between Minimax agents of depth 8, and 100 mixed-level games (depth 4 vs 8). Each game is expanded into multiple move-prefix supervision sequences for training.
|
| 152 |
+
* Minimum move threshold: unset (`min_moves=0`) so every legal position contributes.
|
| 153 |
+
* Validation split: 10 % stratified after shuffle.
|
| 154 |
|
| 155 |
### Training run
|
| 156 |
|
| 157 |
+
* Epochs: 5 planned
|
| 158 |
+
* Best observed validation loss: **0.7196** at step 50 000 (saved as the published checkpoint).
|
| 159 |
+
* Training log span: ~60h with periodic evaluations every 1 000 steps.
|
| 160 |
+
* Hardware: single-process Accelerate session on a Windows workstation loading bitsandbytes CUDA 12.4 bindings and operating on a CUDA device.
|
| 161 |
+
* Seed: 42 across Python, NumPy, and PyTorch. Dataloader workers (10) and CUDA kernels may still introduce nondeterminism.
|
| 162 |
|
| 163 |
## Evaluation
|
| 164 |
|
| 165 |
+
Evaluation reuses the training prompt template with `eval_max_seq_length=128` truncation. The primary metric is token-level cross-entropy (reported as loss) measuring next-move prediction quality.
|
| 166 |
|
| 167 |
+
* Published checkpoint validation loss: **0.7196** (best checkpoint at step 50 000).
|
|
|
|
| 168 |
|
| 169 |
+
Loss values indicate that the adapter reliably tracks legal play patterns after the expanded curriculum while remaining sensitive to decoding constraints near terminal states.
|
| 170 |
|
| 171 |
+
Stability controls mirrored training: gradient clipping at norm 25.0, SDPA math kernel fallback, and warmup scheduling. No extra label smoothing or dropout beyond the LoRA stack was introduced.
|
| 172 |
|
| 173 |
## Special Tokens
|
| 174 |
|
| 175 |
+
The adapter ships without introducing new tokens. The bundled tokenizer metadata mirrors the base checkpoint, reusing `<|endoftext|>` as both EOS and padding alongside the stock Qwen multimodal specials.
|
| 176 |
|
| 177 |
## Intended Use & Limitations
|
| 178 |
|
| 179 |
+
**Intended use.**
|
| 180 |
+
|
| 181 |
+
Pair the adapter with **Qwen/Qwen3-0.6B-Base** for Connect Four next-move suggestion or short move-sequence generation. Prompts should follow the documented template for reliable legality.
|
| 182 |
|
| 183 |
**Limitations.**
|
| 184 |
|
| 185 |
+
* The compact 0.6B backbone cannot guarantee optimal play in deep tactical lines; illegal or low-quality moves remain possible, especially near endgame scenarios.
|
| 186 |
+
* Outputs are restricted to single-digit column indices; free-form chat or multi-turn dialogue falls outside the training distribution.
|
| 187 |
* The adapter does not include safety layers, toxicity filtering, or alignment for open-domain generation. Avoid deploying it in user-facing production systems.
|
| 188 |
+
* Quality still depends on accurate, complete move histories and deterministic decoding (e.g., `do_sample=False` or constrained vocab sampling).
|
| 189 |
|
| 190 |
## Compatibility
|
| 191 |
|
|
|
|
| 194 |
* `transformers` ≥ 4.39.0
|
| 195 |
* `peft` ≥ 0.8.2
|
| 196 |
* `bitsandbytes` ≥ 0.43.0
|
| 197 |
+
* `torch` ≥ 2.1 (CUDA 12.4 build per bitsandbytes log)
|
| 198 |
* `accelerate` ≥ 0.25.0
|
| 199 |
|
| 200 |
+
Windows-based CUDA 12.4 bindings powered the training environment. On Linux or alternate CUDA releases, Accelerate falls back to available SDPA kernels; if flash or memory-efficient kernels are missing (as during training), PyTorch defaults to the math implementation. Always load the same **Qwen/Qwen3-0.6B-Base** revision used during fine-tuning to avoid key mismatches.
|
| 201 |
|
| 202 |
## Reproducibility & Seeds
|
| 203 |
|
| 204 |
+
The global seed remained **42** across Python, NumPy, and PyTorch. Despite deterministic settings, CUDA kernel scheduling, dataloader worker ordering, and filesystem timing can introduce minor nondeterminism.
|
| 205 |
|
| 206 |
## Changelog
|
| 207 |
|
| 208 |
+
* **2025-11-04** – Expanded dataset fine-tune with automated best-checkpoint capture.
|
| 209 |
* **2025-10-25** – Initial public adapter release.
|
| 210 |
|
| 211 |
## License
|
| 212 |
|
| 213 |
+
The adapter is released under the **MIT License**. The base model, **Qwen/Qwen3-0.6B-Base**, ships under Apache 2.0. Please ensure that downstream usage respects both licenses before merging, redistributing, or further fine-tuning.
|
| 214 |
|
| 215 |
## Citations
|
| 216 |
|
adapter_config.json
CHANGED
|
@@ -25,13 +25,13 @@
|
|
| 25 |
"rank_pattern": {},
|
| 26 |
"revision": null,
|
| 27 |
"target_modules": [
|
|
|
|
| 28 |
"v_proj",
|
| 29 |
"down_proj",
|
| 30 |
-
"k_proj",
|
| 31 |
-
"o_proj",
|
| 32 |
"q_proj",
|
| 33 |
-
"
|
| 34 |
-
"
|
|
|
|
| 35 |
],
|
| 36 |
"target_parameters": null,
|
| 37 |
"task_type": "CAUSAL_LM",
|
|
|
|
| 25 |
"rank_pattern": {},
|
| 26 |
"revision": null,
|
| 27 |
"target_modules": [
|
| 28 |
+
"k_proj",
|
| 29 |
"v_proj",
|
| 30 |
"down_proj",
|
|
|
|
|
|
|
| 31 |
"q_proj",
|
| 32 |
+
"gate_proj",
|
| 33 |
+
"o_proj",
|
| 34 |
+
"up_proj"
|
| 35 |
],
|
| 36 |
"target_parameters": null,
|
| 37 |
"task_type": "CAUSAL_LM",
|
adapter_model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c71d0547a48a213002ff430fd2d9608266b543bbe6d8038c3254815457a2b237
|
| 3 |
+
size 323014520
|