Text Generation
PEFT
Safetensors
English
lora
qwen
qwen3.5
geotechnical-engineering
civil-engineering
Instructions to use Sompote/GeoTech-SLM-9B-LoRA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Sompote/GeoTech-SLM-9B-LoRA with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
Add sd-a30 and grpo-60 LoRA adapters with model card
Browse files- README.md +130 -0
- grpo-60/adapter_config.json +49 -0
- grpo-60/adapter_model.safetensors +3 -0
- sd-a30/adapter_config.json +44 -0
- sd-a30/adapter_model.safetensors +3 -0
README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: Qwen/Qwen3.5-9B
|
| 4 |
+
library_name: peft
|
| 5 |
+
tags:
|
| 6 |
+
- lora
|
| 7 |
+
- peft
|
| 8 |
+
- qwen
|
| 9 |
+
- qwen3.5
|
| 10 |
+
- geotechnical-engineering
|
| 11 |
+
- civil-engineering
|
| 12 |
+
language:
|
| 13 |
+
- en
|
| 14 |
+
pipeline_tag: text-generation
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# GeoTech-SLM-9B-LoRA
|
| 18 |
+
|
| 19 |
+
LoRA adapters for [Qwen/Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B) trained for geotechnical design calculations on GeoTechBench v0.4.1.
|
| 20 |
+
|
| 21 |
+
This repository contains two adapters:
|
| 22 |
+
|
| 23 |
+
| Subfolder | Stage | What it is | Apply on |
|
| 24 |
+
| --- | --- | --- | --- |
|
| 25 |
+
| `sd-a30/` | Stage 1 | Self-distillation SFT (QLoRA, checkpoint 30) | `Qwen/Qwen3.5-9B` (revision `c202236235762e1c871ad0ccb60c8ee5ba337b9a`) |
|
| 26 |
+
| `grpo-60/` | Stage 2 | Dr.GRPO (checkpoint 60) | The **merged** stage-1 model (base + `sd-a30`), as a **runtime** LoRA |
|
| 27 |
+
|
| 28 |
+
The recommended inference setup is thinking mode, a 32,768-token completion cap, and a majority vote of 8 samples at temperature 0.8, top-p 0.95, top-k 20.
|
| 29 |
+
|
| 30 |
+
## Important: keep GRPO as a runtime LoRA
|
| 31 |
+
|
| 32 |
+
`grpo-60` is a small update on top of the merged stage-1 weights. **Do not merge it into bf16.** Merging this adapter into bf16 erases most of the GRPO update. Load `sd-a30`, merge that into the base model, then load `grpo-60` with PEFT or vLLM LoRA and leave it unmerged.
|
| 33 |
+
|
| 34 |
+
Do not load `grpo-60` directly on the untuned base model. It was trained on `/workspace/merged/sd_best`, which is `sd-a30` already merged into `Qwen/Qwen3.5-9B` in bf16.
|
| 35 |
+
|
| 36 |
+
A merged stage-1 full-weight checkpoint is not published here. Merge `sd-a30` locally (see below).
|
| 37 |
+
|
| 38 |
+
## GeoTechBench v0.4.1 holdout (N = 338)
|
| 39 |
+
|
| 40 |
+
Results for the recommended stack (merged `sd-a30` + runtime `grpo-60`), thinking mode, 32,768-token cap:
|
| 41 |
+
|
| 42 |
+
- Vote of 8 (T 0.8, top-p 0.95, top-k 20): **256 / 338 (75.7%)**
|
| 43 |
+
- Single reply: **208 / 338**
|
| 44 |
+
|
| 45 |
+
For comparison, merged `sd-a30` alone (no GRPO) scored 245 / 338 on the same vote-of-8 protocol, and 210 / 338 as a single reply.
|
| 46 |
+
|
| 47 |
+
## Training
|
| 48 |
+
|
| 49 |
+
- **Base model:** `Qwen/Qwen3.5-9B`, snapshot `c202236235762e1c871ad0ccb60c8ee5ba337b9a`.
|
| 50 |
+
- **Stage 1 (`sd-a30`):** QLoRA self-distillation SFT on the base model's own checked traces. 4-bit training (`load_in_4bit`), LoRA rank 16, α 16, learning rate 2e-5, checkpoint 30 (one epoch). Adapter recorded with PEFT 0.22.0.
|
| 51 |
+
- **Stage 2 (`grpo-60`):** Dr.GRPO with TRL (`loss_type="dr_grpo"`, β 0) on the merged stage-1 bf16 weights. 60 steps, completion cap 12,288, learning rate 1e-5, group size 8 generations, 2 prompts per optimizer step. LoRA rank 32, α 64. Apply this adapter at runtime; do not merge it.
|
| 52 |
+
|
| 53 |
+
## Usage (PEFT)
|
| 54 |
+
|
| 55 |
+
```python
|
| 56 |
+
import torch
|
| 57 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 58 |
+
from peft import PeftModel
|
| 59 |
+
|
| 60 |
+
base_id = "Qwen/Qwen3.5-9B"
|
| 61 |
+
adapter_repo = "Sompote/GeoTech-SLM-9B-LoRA"
|
| 62 |
+
revision = "c202236235762e1c871ad0ccb60c8ee5ba337b9a"
|
| 63 |
+
|
| 64 |
+
tokenizer = AutoTokenizer.from_pretrained(base_id, revision=revision)
|
| 65 |
+
base = AutoModelForCausalLM.from_pretrained(
|
| 66 |
+
base_id,
|
| 67 |
+
revision=revision,
|
| 68 |
+
torch_dtype=torch.bfloat16,
|
| 69 |
+
device_map="auto",
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
+
# Stage 1: merge the self-distillation adapter (this merge is intended).
|
| 73 |
+
sd = PeftModel.from_pretrained(base, adapter_repo, subfolder="sd-a30")
|
| 74 |
+
model = sd.merge_and_unload()
|
| 75 |
+
|
| 76 |
+
# Stage 2: apply Dr.GRPO as a runtime LoRA. Do not call merge_and_unload().
|
| 77 |
+
model = PeftModel.from_pretrained(model, adapter_repo, subfolder="grpo-60")
|
| 78 |
+
model.eval()
|
| 79 |
+
|
| 80 |
+
messages = [{"role": "user", "content": prompt}]
|
| 81 |
+
text = tokenizer.apply_chat_template(
|
| 82 |
+
messages,
|
| 83 |
+
tokenize=False,
|
| 84 |
+
add_generation_prompt=True,
|
| 85 |
+
enable_thinking=True,
|
| 86 |
+
)
|
| 87 |
+
inputs = tokenizer(text, return_tensors="pt").to(model.device)
|
| 88 |
+
output = model.generate(
|
| 89 |
+
**inputs,
|
| 90 |
+
max_new_tokens=32768,
|
| 91 |
+
temperature=0.8,
|
| 92 |
+
top_p=0.95,
|
| 93 |
+
top_k=20,
|
| 94 |
+
do_sample=True,
|
| 95 |
+
)
|
| 96 |
+
print(tokenizer.decode(output[0], skip_special_tokens=True))
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
For the reported vote-of-8 result, draw 8 independent samples with those decoding settings and take a majority vote over the graded answers.
|
| 100 |
+
|
| 101 |
+
To save a local merged stage-1 checkpoint for vLLM, run the merge above and then `model.save_pretrained("./GeoTech-SLM-9B")` *before* loading `grpo-60`.
|
| 102 |
+
|
| 103 |
+
## Usage (vLLM)
|
| 104 |
+
|
| 105 |
+
Serve the merged stage-1 weights as the base model, and attach `grpo-60` as a LoRA (rank 32). Do not bake `grpo-60` into the served checkpoint.
|
| 106 |
+
|
| 107 |
+
```bash
|
| 108 |
+
# After saving the merged sd-a30 model to ./GeoTech-SLM-9B
|
| 109 |
+
vllm serve ./GeoTech-SLM-9B \
|
| 110 |
+
--enable-lora \
|
| 111 |
+
--lora-modules grpo-60=Sompote/GeoTech-SLM-9B-LoRA/grpo-60 \
|
| 112 |
+
--max-lora-rank 32
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
Use the tokenizer chat template with `enable_thinking=True`, `max_tokens=32768`, temperature 0.8, top-p 0.95, and top-k 20. For the reported holdout number, sample 8 completions per problem and majority-vote the answers.
|
| 116 |
+
|
| 117 |
+
## License
|
| 118 |
+
|
| 119 |
+
These adapters are released under [Apache 2.0](https://huggingface.co/Qwen/Qwen3.5-9B/blob/main/LICENSE), following the base model [Qwen/Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B).
|
| 120 |
+
|
| 121 |
+
## Citation
|
| 122 |
+
|
| 123 |
+
```bibtex
|
| 124 |
+
@unpublished{youwai2026geotechslm,
|
| 125 |
+
title={A local small language model with frontier-agent fallback for geotechnical design calculations},
|
| 126 |
+
author={Youwai, Sompote},
|
| 127 |
+
year={2026},
|
| 128 |
+
note={Manuscript in preparation}
|
| 129 |
+
}
|
| 130 |
+
```
|
grpo-60/adapter_config.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"astra_config": null,
|
| 6 |
+
"auto_mapping": {
|
| 7 |
+
"base_model_class": "Qwen3_5ForConditionalGeneration",
|
| 8 |
+
"parent_library": "transformers.models.qwen3_5.modeling_qwen3_5",
|
| 9 |
+
"unsloth_fixed": true
|
| 10 |
+
},
|
| 11 |
+
"base_model_name_or_path": "merge_sd-a30_into_Qwen/Qwen3.5-9B_first",
|
| 12 |
+
"bias": "none",
|
| 13 |
+
"corda_config": null,
|
| 14 |
+
"ensure_weight_tying": false,
|
| 15 |
+
"eva_config": null,
|
| 16 |
+
"exclude_modules": null,
|
| 17 |
+
"fan_in_fan_out": false,
|
| 18 |
+
"inference_mode": true,
|
| 19 |
+
"init_lora_weights": true,
|
| 20 |
+
"kasa_config": null,
|
| 21 |
+
"layer_replication": null,
|
| 22 |
+
"layers_pattern": null,
|
| 23 |
+
"layers_to_transform": null,
|
| 24 |
+
"loftq_config": {},
|
| 25 |
+
"lora_alpha": 64,
|
| 26 |
+
"lora_bias": false,
|
| 27 |
+
"lora_dropout": 0.0,
|
| 28 |
+
"lora_ga_config": null,
|
| 29 |
+
"megatron_config": null,
|
| 30 |
+
"megatron_core": "megatron.core",
|
| 31 |
+
"modules_to_save": null,
|
| 32 |
+
"monteclora_config": null,
|
| 33 |
+
"peft_type": "LORA",
|
| 34 |
+
"peft_version": "0.22.0",
|
| 35 |
+
"qalora_group_size": 16,
|
| 36 |
+
"r": 32,
|
| 37 |
+
"rank_pattern": {},
|
| 38 |
+
"revision": null,
|
| 39 |
+
"target_modules": "(?:.*?(?:language|text).*?(?:self_attn|attention|attn|mixer|mlp|feed_forward|ffn|dense|mixer).*?\\.(?:q_proj|k_proj|v_proj|o_proj|gate_proj|up_proj|down_proj))|(?:\\bmodel\\.layers\\.[\\d]{1,}(?!.*\\.experts\\.\\d)\\..*?(?:self_attn|attention|attn|mixer|mlp|feed_forward|ffn|dense|mixer).*?\\.(?:(?:q_proj|k_proj|v_proj|o_proj|gate_proj|up_proj|down_proj)))",
|
| 40 |
+
"target_parameters": null,
|
| 41 |
+
"task_type": "CAUSAL_LM",
|
| 42 |
+
"trainable_token_indices": null,
|
| 43 |
+
"use_bdlora": null,
|
| 44 |
+
"use_dora": false,
|
| 45 |
+
"use_qalora": false,
|
| 46 |
+
"use_rslora": false,
|
| 47 |
+
"velora_config": null,
|
| 48 |
+
"_usage": "This adapter was trained on the stage-1 sd-a30 LoRA after it had been merged into Qwen/Qwen3.5-9B (bf16), original path /workspace/merged/sd_best. Merge subfolder sd-a30 into Qwen/Qwen3.5-9B first, then load this adapter as a runtime LoRA. Do not apply it directly on the untuned base model. Do not merge this adapter into bf16; merging erases most of the GRPO update."
|
| 49 |
+
}
|
grpo-60/adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2777d0f4604894e130273ae9b6dadc37145138dbf629db8238e20ccf6a278e68
|
| 3 |
+
size 232821904
|
sd-a30/adapter_config.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"astra_config": null,
|
| 6 |
+
"auto_mapping": null,
|
| 7 |
+
"base_model_name_or_path": "Qwen/Qwen3.5-9B",
|
| 8 |
+
"bias": "none",
|
| 9 |
+
"corda_config": null,
|
| 10 |
+
"ensure_weight_tying": false,
|
| 11 |
+
"eva_config": null,
|
| 12 |
+
"exclude_modules": null,
|
| 13 |
+
"fan_in_fan_out": false,
|
| 14 |
+
"inference_mode": true,
|
| 15 |
+
"init_lora_weights": true,
|
| 16 |
+
"kasa_config": null,
|
| 17 |
+
"layer_replication": null,
|
| 18 |
+
"layers_pattern": null,
|
| 19 |
+
"layers_to_transform": null,
|
| 20 |
+
"loftq_config": {},
|
| 21 |
+
"lora_alpha": 16,
|
| 22 |
+
"lora_bias": false,
|
| 23 |
+
"lora_dropout": 0.0,
|
| 24 |
+
"lora_ga_config": null,
|
| 25 |
+
"megatron_config": null,
|
| 26 |
+
"megatron_core": "megatron.core",
|
| 27 |
+
"modules_to_save": null,
|
| 28 |
+
"monteclora_config": null,
|
| 29 |
+
"peft_type": "LORA",
|
| 30 |
+
"peft_version": "0.22.0",
|
| 31 |
+
"qalora_group_size": 16,
|
| 32 |
+
"r": 16,
|
| 33 |
+
"rank_pattern": {},
|
| 34 |
+
"revision": "c202236235762e1c871ad0ccb60c8ee5ba337b9a",
|
| 35 |
+
"target_modules": ".*language_model.*\\.(q_proj|k_proj|v_proj|o_proj|in_proj_qkv|in_proj_z|in_proj_a|in_proj_b|out_proj|gate_proj|up_proj|down_proj)$",
|
| 36 |
+
"target_parameters": null,
|
| 37 |
+
"task_type": "CAUSAL_LM",
|
| 38 |
+
"trainable_token_indices": null,
|
| 39 |
+
"use_bdlora": null,
|
| 40 |
+
"use_dora": false,
|
| 41 |
+
"use_qalora": false,
|
| 42 |
+
"use_rslora": false,
|
| 43 |
+
"velora_config": null
|
| 44 |
+
}
|
sd-a30/adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f63190a4be14941c65061473cd062e41b2ad34328bbccad63fba8c82f760842d
|
| 3 |
+
size 86631864
|