BLANK commited on
Commit
29ecd3f
·
verified ·
1 Parent(s): f9af343

boxing: proper model card + transformers/PEFT usage

Browse files
Files changed (1) hide show
  1. README.md +111 -7
README.md CHANGED
@@ -1,11 +1,115 @@
1
- # slm-rl-boxing
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- SFT LoRA for ALE Boxing (SLM-RL workshop warm-start).
 
 
4
 
5
- - **Game:** boxing
6
- - **Base model:** LiquidAI/LFM2.5-350M
7
- - **Dataset:** BLANK/slm-rl-boxing
8
- - **Training:** reject_sft on DQN teacher demos
9
- - **Layout:** paste this repo as the playground adapter URL
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  Trained with [SLM-RL](https://github.com/CraftsMan-Labs/SLM-RL).
 
1
+ ---
2
+ library_name: peft
3
+ base_model: LiquidAI/LFM2.5-350M
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - lora
7
+ - peft
8
+ - transformers
9
+ - reinforcement-learning
10
+ - atari
11
+ - slm-rl
12
+ - boxing
13
+ license: apache-2.0
14
+ ---
15
+ # BLANK/slm-rl-boxing
16
 
17
+ PEFT LoRA adapter that warm-starts **Boxing** play for
18
+ [LiquidAI/LFM2.5-350M](https://huggingface.co/LiquidAI/LFM2.5-350M)
19
+ in the [SLM-RL](https://github.com/CraftsMan-Labs/SLM-RL) workshop.
20
 
21
+ | | |
22
+ |---|---|
23
+ | **Game** | `boxing` |
24
+ | **Base model** | `LiquidAI/LFM2.5-350M` |
25
+ | **Adapter layout** | `adapter/` (PEFT `adapter_config.json` + weights) |
26
+ | **Training** | `reject_sft` on DQN teacher demos |
27
+ | **Champion generation** | 1 |
28
+ | **Promoted** | True (reject_sft warm-start) |
29
+ | **Dataset pack** | [BLANK/slm-rl-boxing](https://huggingface.co/datasets/BLANK/slm-rl-boxing) |
30
+ | **DQN teacher** | [BLANK/slm-rl-boxing-dqn](https://huggingface.co/BLANK/slm-rl-boxing-dqn) |
31
+
32
+ Paste `BLANK/slm-rl-boxing` as the playground **adapter URL** (and usually the same id
33
+ as the **dataset URL**).
34
+
35
+ ## Install
36
+
37
+ ```bash
38
+ pip install "transformers>=4.46" peft accelerate torch
39
+ ```
40
+
41
+ ## Load with transformers + PEFT
42
+
43
+ Weights live under the `adapter/` subfolder — pass `subfolder="adapter"`.
44
+
45
+ ```python
46
+ import torch
47
+ from transformers import AutoModelForCausalLM, AutoTokenizer
48
+ from peft import PeftModel
49
+
50
+ BASE = "LiquidAI/LFM2.5-350M"
51
+ ADAPTER = "BLANK/slm-rl-boxing" # this repo
52
+
53
+ device = (
54
+ "cuda" if torch.cuda.is_available()
55
+ else "mps" if torch.backends.mps.is_available()
56
+ else "cpu"
57
+ )
58
+ dtype = torch.bfloat16 if device != "cpu" else torch.float32
59
+
60
+ tokenizer = AutoTokenizer.from_pretrained(BASE)
61
+ if tokenizer.pad_token is None:
62
+ tokenizer.pad_token = tokenizer.eos_token
63
+
64
+ model = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype=dtype)
65
+ model = PeftModel.from_pretrained(model, ADAPTER, subfolder="adapter")
66
+ model.to(device).eval()
67
+
68
+ messages = [
69
+ {"role": "system", "content": "You play Boxing. Reply with ACTION: <id>."},
70
+ {"role": "user", "content": "Legal actions: 1) NOOP 2) UP\nChoose."},
71
+ ]
72
+ prompt = tokenizer.apply_chat_template(
73
+ messages, add_generation_prompt=True, tokenize=False,
74
+ )
75
+ inputs = tokenizer(prompt, return_tensors="pt").to(device)
76
+ with torch.inference_mode():
77
+ out = model.generate(**inputs, max_new_tokens=24, do_sample=False)
78
+ print(tokenizer.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
79
+ ```
80
+
81
+ ### Download only the adapter files
82
+
83
+ ```python
84
+ from huggingface_hub import snapshot_download
85
+
86
+ path = snapshot_download("BLANK/slm-rl-boxing", allow_patterns="adapter/*")
87
+ # then: PeftModel.from_pretrained(base_model, f"{path}/adapter")
88
+ ```
89
+
90
+ ## Workshop / SLM-RL CLI
91
+
92
+ ```bash
93
+ slm-rl evolve --game boxing \
94
+ --dataset-url BLANK/slm-rl-boxing \
95
+ --adapter-url BLANK/slm-rl-boxing \
96
+ --dqn-url BLANK/slm-rl-boxing-dqn \
97
+ --generations 2
98
+ ```
99
+
100
+ ## Train metrics (if recorded)
101
+
102
+ ```json
103
+ {
104
+ "eval": {
105
+ "skipped": true
106
+ },
107
+ "gate": {
108
+ "promoted": true,
109
+ "reason": "reject_sft warm-start"
110
+ },
111
+ "train": {}
112
+ }
113
+ ```
114
 
115
  Trained with [SLM-RL](https://github.com/CraftsMan-Labs/SLM-RL).