nicolasembleton commited on
Commit
0b6c81b
·
verified ·
1 Parent(s): 3cd0d76

Open-Jev Phase-1 MiniCPM5-2B LoRA adapter (test 0.467→0.702)

Browse files
README.md ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: openbmb/MiniCPM5-2B
3
+ library_name: peft
4
+ license: apache-2.0
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - lora
8
+ - peft
9
+ - open-jev
10
+ - classification
11
+ - logprob
12
+ - minicpm
13
+ - adapters
14
+ datasets:
15
+ - ZefanCai/Open-Jev-v1.1
16
+ ---
17
+
18
+ # Open-Jev Phase-1 LoRA — MiniCPM5-2B
19
+
20
+ PEFT LoRA adapter for [openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B), fine-tuned for **closed-set first-token scoring** on Open-Jev Choice / Noul / Score fields (Bev/Jev-style: one forward pass, candidate-token logits; not free-form generation).
21
+
22
+ ## Results (frozen panel, never in train)
23
+
24
+ | Slice | Metric | Zero-shot | This LoRA | Δ |
25
+ |-------|--------|-----------|-----------|---|
26
+ | Test n=900 | overall accuracy | 0.467 | **0.702** | +23.6 pp |
27
+ | Test | Noul recall | 0.118 | **0.735** | +61.8 pp |
28
+ | OOD n=300 | overall accuracy | 0.473 | **0.710** | +23.7 pp |
29
+
30
+ Scorekeeper planted gold; see local `results/openjev-phase1/RUN_CARD.md` for full tables.
31
+
32
+ ## Recipe
33
+
34
+ - **Base:** `openbmb/MiniCPM5-2B`
35
+ - **Train:** stratified Open-Jev subset, n=6000 (2000 Choice / 2000 Noul / 2000 Score); dataset rev `10ad6888333fa97f8c948192797bad3de3040802`
36
+ - **Objective:** causal LM loss **only** on the gold index-surrogate token after `Answer: `
37
+ - **LoRA:** r=16, α=32, dropout=0.05; targets `q/k/v/o/gate/up/down_proj`
38
+ - **Train:** 1 epoch, lr=2e-4, effective batch 16, max length 2048, bfloat16
39
+ - **Hardware:** Modal A10G (~59.5 min wall, ~15.2 GB peak VRAM)
40
+ - **Seed:** 20260924
41
+
42
+ ## Load
43
+
44
+ ```python
45
+ from transformers import AutoModelForCausalLM, AutoTokenizer
46
+ from peft import PeftModel
47
+
48
+ base_id = "openbmb/MiniCPM5-2B"
49
+ adapter_id = "nicolasembleton/openjev-minicpm5-2b-lora-phase1"
50
+
51
+ tok = AutoTokenizer.from_pretrained(base_id, trust_remote_code=True)
52
+ model = AutoModelForCausalLM.from_pretrained(base_id, trust_remote_code=True, torch_dtype="auto")
53
+ model = PeftModel.from_pretrained(model, adapter_id)
54
+ ```
55
+
56
+ For Open-Jev TypeSafe-compatible scoring, point `OPENJEV_ADAPTER_PATH` at this adapter (or a local checkout) on top of the same base.
57
+
58
+ ## Browser / WebGPU note
59
+
60
+ This repo is the **PEFT adapter only**. In-browser Transformers.js needs a **merged** weights export (and ideally quantized ONNX). That path is separate from this Hub upload.
61
+
62
+ ## Intended use
63
+
64
+ Research and demos of closed-set Choice / Noul / Score scoring on Open-Jev-style prompts. Not a general chat model. Do not treat closed-menu argmax as ground truth without an external scorekeeper.
65
+
66
+ ## License
67
+
68
+ Adapter weights follow the base model license terms for derivatives of MiniCPM5-2B (Apache-2.0 style redistribution where permitted by the base). Training data: Open-Jev v1.1.
adapter_config.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": null,
6
+ "base_model_name_or_path": "openbmb/MiniCPM5-2B",
7
+ "bias": "none",
8
+ "corda_config": null,
9
+ "ensure_weight_tying": false,
10
+ "eva_config": null,
11
+ "exclude_modules": null,
12
+ "fan_in_fan_out": false,
13
+ "inference_mode": true,
14
+ "init_lora_weights": true,
15
+ "kasa_config": null,
16
+ "layer_replication": null,
17
+ "layers_pattern": null,
18
+ "layers_to_transform": null,
19
+ "loftq_config": {},
20
+ "lora_alpha": 32,
21
+ "lora_bias": false,
22
+ "lora_dropout": 0.05,
23
+ "lora_ga_config": null,
24
+ "megatron_config": null,
25
+ "megatron_core": "megatron.core",
26
+ "modules_to_save": null,
27
+ "monteclora_config": null,
28
+ "peft_type": "LORA",
29
+ "peft_version": "0.21.0",
30
+ "qalora_group_size": 16,
31
+ "r": 16,
32
+ "rank_pattern": {},
33
+ "revision": null,
34
+ "target_modules": [
35
+ "gate_proj",
36
+ "v_proj",
37
+ "o_proj",
38
+ "k_proj",
39
+ "up_proj",
40
+ "down_proj",
41
+ "q_proj"
42
+ ],
43
+ "target_parameters": null,
44
+ "task_type": "CAUSAL_LM",
45
+ "trainable_token_indices": null,
46
+ "use_bdlora": null,
47
+ "use_dora": false,
48
+ "use_qalora": false,
49
+ "use_rslora": false,
50
+ "velora_config": null
51
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:acdf695020a1933ee7dc51b22a2b4fcdeb469f0094e0972097bb8c529e91465e
3
+ size 100544848
chat_template.jinja ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- bos_token }}{%- if tools %}
2
+ {%- set tool_definitions %}
3
+ {{- "# Tools\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
4
+ {%- for tool in tools %}
5
+ {{- "\n" }}
6
+ {{- tool | tojson(ensure_ascii=False) }}
7
+ {%- endfor %}
8
+ {{- '\n</tools>\n\nTool usage guidelines:\n- You may call zero or more functions. If no function calls are needed, just answer normally and do not include any <function ... </function>.\n- When calling a function, return an XML object within <function ... </function> using:\n<function name="function-name"><param name="param-name">param-value</param></function>\n- param-value may be multi-line. If it contains <, & or newline characters, wrap it in a CDATA block: <param name="param-name"><![CDATA[...multi-line value...]]></param>' }}
9
+ {%- endset %}
10
+
11
+ {{- '<|im_start|>system\n' }}
12
+ {%- if messages[0].role == 'system' %}
13
+ {%- if '<tool_def_sep>' in messages[0].content %}
14
+ {{- messages[0].content.replace('<tool_def_sep>', tool_definitions) }}
15
+ {%- else %}
16
+ {{- messages[0].content + '\n\n' + tool_definitions }}
17
+ {%- endif %}
18
+ {%- else %}
19
+ {{- tool_definitions.lstrip() }}
20
+ {%- endif %}
21
+ {{- '<|im_end|>\n' }}
22
+ {%- else %}
23
+ {%- if messages[0].role == 'system' %}
24
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
25
+ {%- endif %}
26
+ {%- endif %}
27
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
28
+ {%- for message in messages[::-1] %}
29
+ {%- set index = (messages|length - 1) - loop.index0 %}
30
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
31
+ {%- set ns.multi_step_tool = false %}
32
+ {%- set ns.last_query_index = index %}
33
+ {%- endif %}
34
+ {%- endfor %}
35
+ {%- for message in messages %}
36
+ {%- if message.content is string %}
37
+ {%- set content = message.content %}
38
+ {%- else %}
39
+ {%- set content = '' %}
40
+ {%- endif %}
41
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
42
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
43
+ {%- elif message.role == "assistant" %}
44
+ {%- set reasoning_content = '' %}
45
+ {%- if message.reasoning_content is string %}
46
+ {%- set reasoning_content = message.reasoning_content %}
47
+ {%- else %}
48
+ {%- if '</think>' in content %}
49
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
50
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
51
+ {%- endif %}
52
+ {%- endif %}
53
+
54
+ {%- if message.tool_calls %}
55
+ {%- set content_parts = content.split('<tool_sep>') %}
56
+ {%- set processed_content = content_parts[0] %}
57
+ {%- set tool_calls_count = message.tool_calls|length %}
58
+ {%- set tool_sep_count = content_parts|length - 1 %}
59
+ {%- set min_count = [tool_calls_count, tool_sep_count]|min %}
60
+
61
+ {%- for i in range(1, content_parts|length) %}
62
+ {%- set tool_index = i - 1 %}
63
+ {%- if tool_index < tool_calls_count %}
64
+ {%- set tool_call = message.tool_calls[tool_index] %}
65
+ {%- if tool_call.function %}
66
+ {%- set tool_call = tool_call.function %}
67
+ {%- endif %}
68
+ {%- set single_tool_xml %}
69
+ {{- '<function name="' ~ tool_call.name ~ '">' }}
70
+ {%- if tool_call.arguments %}
71
+ {%- set args_dict = tool_call.arguments %}
72
+ {%- for param_name, param_value in args_dict.items() %}
73
+ {{- '<param name="' ~ param_name ~ '">' }}
74
+ {%- if param_value is string and ('<' in param_value or '&' in param_value or '\n' in param_value) %}
75
+ {{- '<![CDATA[' + param_value + ']]>' }}
76
+ {%- else %}
77
+ {{- param_value }}
78
+ {%- endif %}
79
+ {{- '</param>' }}
80
+ {%- endfor %}
81
+ {%- endif %}
82
+ {{- '</function>' }}
83
+ {%- endset %}
84
+ {%- set processed_content = processed_content + single_tool_xml + content_parts[i] %}
85
+ {%- else %}
86
+ {%- set processed_content = processed_content + content_parts[i] %}
87
+ {%- endif %}
88
+ {%- endfor %}
89
+
90
+ {%- if tool_calls_count > tool_sep_count %}
91
+ {%- for remaining_index in range(tool_sep_count, tool_calls_count) %}
92
+ {%- set tool_call = message.tool_calls[remaining_index] %}
93
+ {%- if tool_call.function %}
94
+ {%- set tool_call = tool_call.function %}
95
+ {%- endif %}
96
+ {%- set remaining_tool_xml %}
97
+ {{- '<function name="' ~ tool_call.name ~ '">' }}
98
+ {%- if tool_call.arguments %}
99
+ {%- set args_dict = tool_call.arguments %}
100
+ {%- for param_name, param_value in args_dict.items() %}
101
+ {{- '<param name="' ~ param_name ~ '">' }}
102
+ {%- if param_value is string and ('<' in param_value or '&' in param_value or '\n' in param_value) %}
103
+ {{- '<![CDATA[' + param_value + ']]>' }}
104
+ {%- else %}
105
+ {{- param_value }}
106
+ {%- endif %}
107
+ {{- '</param>' }}
108
+ {%- endfor %}
109
+ {%- endif %}
110
+ {{- '</function>' }}
111
+ {%- endset %}
112
+ {%- set processed_content = processed_content + remaining_tool_xml %}
113
+ {%- endfor %}
114
+ {%- endif %}
115
+
116
+ {%- set content = processed_content %}
117
+ {%- endif %}
118
+
119
+ {%- if reasoning_content %}
120
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
121
+ {%- elif '<think>' not in content and '</think>' not in content %}
122
+ {{- '<|im_start|>' + message.role + '\n<think>\n\n</think>\n\n' + content.lstrip('\n') }}
123
+ {%- else %}
124
+ {{- '<|im_start|>' + message.role + '\n' + content }}
125
+ {%- endif %}
126
+
127
+ {%- if message.tool_calls and not has_tool_sep %}
128
+ {%- for tool_call in message.tool_calls %}
129
+ {%- if (loop.first and content) or (not loop.first) %}
130
+ {{- '\n' }}
131
+ {%- endif %}
132
+ {%- if tool_call.function %}
133
+ {%- set tool_call = tool_call.function %}
134
+ {%- endif %}
135
+ {{- '<function name="' ~ tool_call.name ~ '">' }}
136
+ {%- if tool_call.arguments %}
137
+ {%- set args_dict = tool_call.arguments %}
138
+ {%- for param_name, param_value in args_dict.items() %}
139
+ {{- '<param name="' ~ param_name ~ '">' }}
140
+ {%- if param_value is string and ('<' in param_value or '&' in param_value or '\n' in param_value) %}
141
+ {{- '<![CDATA[' + param_value + ']]>' }}
142
+ {%- else %}
143
+ {{- param_value }}
144
+ {%- endif %}
145
+ {{- '</param>' }}
146
+ {%- endfor %}
147
+ {%- endif %}
148
+ {{- '</function>' }}
149
+ {%- endfor %}
150
+ {%- endif %}
151
+ {{- '<|im_end|>\n' }}
152
+ {%- elif message.role == "tool" %}
153
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
154
+ {{- '<|im_start|>user' }}
155
+ {%- endif %}
156
+ {{- '\n<tool_response>\n' }}
157
+ {%- if message.content is string %}
158
+ {{- content }}
159
+ {%- else %}
160
+ {{- message.content | tojson(ensure_ascii=False) }}
161
+ {%- endif %}
162
+ {{- '\n</tool_response>' }}
163
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
164
+ {{- '<|im_end|>\n' }}
165
+ {%- endif %}
166
+ {%- endif %}
167
+ {%- endfor %}
168
+ {%- if add_generation_prompt %}
169
+ {{- '<|im_start|>assistant\n' }}
170
+ {%- if enable_thinking is defined %}
171
+ {%- if enable_thinking is false %}
172
+ {{- '<think>\n\n</think>\n\n' }}
173
+ {%- elif enable_thinking is true %}
174
+ {{- '<think>\n' }}
175
+ {%- endif %}
176
+ {%- endif %}
177
+ {%- endif %}
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": null,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<s>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "</s>",
7
+ "is_local": false,
8
+ "legacy": true,
9
+ "local_files_only": false,
10
+ "model_max_length": 131072,
11
+ "pad_token": "</s>",
12
+ "sp_model_kwargs": {},
13
+ "spaces_between_special_tokens": false,
14
+ "tokenizer_class": "TokenizersBackend",
15
+ "unk_token": "<unk>",
16
+ "use_default_system_prompt": false
17
+ }