gowthamrang commited on
Commit
bc2522f
·
verified ·
1 Parent(s): 7d901c5

Qwen 3.8 27B LoRA (ctrl, seed 0): adapter, calibration, model card

Browse files
README.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: Qwen/Qwen3.8-27B
3
+ library_name: peft
4
+ license: apache-2.0
5
+ language:
6
+ - en
7
+ pipeline_tag: text-generation
8
+ tags:
9
+ - base_model:adapter:Qwen/Qwen3.8-27B
10
+ - lora
11
+ - peft
12
+ - evidenceguard
13
+ - multiple-choice
14
+ - consistency
15
+ ---
16
+
17
+ # EvidenceGuard Qwen 3.8 27B LoRA
18
+
19
+ A LoRA adapter for [Qwen/Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B) that answers multiple-choice questions
20
+ strictly from a supplied context, and says "insufficient information" when the context does not decide the answer.
21
+
22
+ It was trained on EvidenceGuard decision groups. Each group is a base question plus controlled variants: paraphrases,
23
+ reordered options, irrelevant additions (the answer should not change) and decisive edits (the answer should change).
24
+ A group counts as solved only if every variant in it is answered correctly.
25
+
26
+ ## Results
27
+
28
+ Single forward pass, no reasoning; scores after temperature calibration (T = 1.94, fitted on the calibration split).
29
+
30
+ | Evaluation set | Questions correct | Groups fully correct |
31
+ |---|---|---|
32
+ | EvidenceGuard test split | 86.5% | **77.6%** |
33
+ | New LLM-written domains (never trained on) | 75.8% | 31.0% |
34
+
35
+ Median latency is about 0.12 s per question at batch size 1 on one H200.
36
+
37
+ Out-of-domain transfer is limited: on the four new domains most groups still have at least one variant wrong.
38
+
39
+ ## How it scores
40
+
41
+ There is no generation. The prompt lists the options as letters, and the model's logits at the first answer position
42
+ are read for each letter (the max over the `"A"` and `" A"` tokens), then softmaxed over the K options.
43
+
44
+ ```python
45
+ import torch
46
+ from peft import PeftModel
47
+ from transformers import AutoModelForCausalLM, AutoTokenizer
48
+
49
+ base = "Qwen/Qwen3.8-27B"
50
+ tok = AutoTokenizer.from_pretrained(base)
51
+ model = AutoModelForCausalLM.from_pretrained(base, torch_dtype=torch.bfloat16, device_map="auto")
52
+ model = PeftModel.from_pretrained(model, "EvidenceGuard-Experiments/evidenceguard-qwen3.8-27b-lora").eval()
53
+
54
+ SYSTEM = ("You answer multiple-choice questions strictly from the given context. If the context does not contain "
55
+ "enough information to decide, choose the option that says so when one is offered. Reply with the letter only.")
56
+ LETTERS = "ABCDEFGH"
57
+ T = 1.9433390039063905 # calibration.json
58
+
59
+ def answer(context: str, question: str, options: list[str]) -> list[float]:
60
+ opts = "\n".join(f"{LETTERS[i]}. {o}" for i, o in enumerate(options))
61
+ user = f"Context:\n{context}\n\nQuestion: {question}\n\nOptions:\n{opts}\n\nAnswer with the letter of the correct option."
62
+ msgs = [{"role": "system", "content": SYSTEM}, {"role": "user", "content": user}]
63
+ prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True, enable_thinking=False)
64
+ enc = tok(prompt, return_tensors="pt").to(model.device)
65
+ with torch.no_grad():
66
+ last = model(**enc).logits[0, -1].float()
67
+ ids = [sorted({tok.encode(L, add_special_tokens=False)[0], tok.encode(" " + L, add_special_tokens=False)[-1]})
68
+ for L in LETTERS[: len(options)]]
69
+ z = torch.stack([last[i].max() for i in ids])
70
+ return torch.softmax(z / T, -1).tolist()
71
+ ```
72
+
73
+ ## Training
74
+
75
+ - LoRA r = 16, alpha = 32, dropout 0.05 on the attention, linear-attention and MLP projections (108.8M trainable parameters)
76
+ - 1 epoch, learning rate 1e-4, batch size 8, two whole decision groups per batch, seed 0
77
+ - Loss: cross-entropy on the correct option under the letter scorer above (no extra consistency loss)
78
+ - Base revision `1d4bf0f2ff6012fd82039f2fa52739d0dd7c60c0`, PEFT 0.21.2, bf16
79
+
80
+ ## Limitations
81
+
82
+ - Trained and tested on English multiple-choice questions with 2–8 options; not a general chat model.
83
+ - Evaluation labels for the new domains come from three reasoning models and are still being checked by hand.
84
+ - The training data is not public yet.
adapter_config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": {
6
+ "base_model_class": "Qwen3_5ForCausalLM",
7
+ "parent_library": "transformers.models.qwen3_5.modeling_qwen3_5"
8
+ },
9
+ "base_model_name_or_path": "Qwen/Qwen3.8-27B",
10
+ "bias": "none",
11
+ "corda_config": null,
12
+ "ensure_weight_tying": false,
13
+ "eva_config": null,
14
+ "exclude_modules": null,
15
+ "fan_in_fan_out": false,
16
+ "inference_mode": true,
17
+ "init_lora_weights": true,
18
+ "kasa_config": null,
19
+ "layer_replication": null,
20
+ "layers_pattern": null,
21
+ "layers_to_transform": null,
22
+ "loftq_config": {},
23
+ "lora_alpha": 32,
24
+ "lora_bias": false,
25
+ "lora_dropout": 0.05,
26
+ "lora_ga_config": null,
27
+ "megatron_config": null,
28
+ "megatron_core": "megatron.core",
29
+ "modules_to_save": null,
30
+ "monteclora_config": null,
31
+ "peft_type": "LORA",
32
+ "peft_version": "0.21.2",
33
+ "qalora_group_size": 16,
34
+ "r": 16,
35
+ "rank_pattern": {},
36
+ "revision": null,
37
+ "target_modules": [
38
+ "o_proj",
39
+ "down_proj",
40
+ "out_proj",
41
+ "gate_proj",
42
+ "in_proj_qkv",
43
+ "v_proj",
44
+ "in_proj_z",
45
+ "k_proj",
46
+ "q_proj",
47
+ "up_proj"
48
+ ],
49
+ "target_parameters": null,
50
+ "task_type": null,
51
+ "trainable_token_indices": null,
52
+ "use_bdlora": null,
53
+ "use_dora": false,
54
+ "use_qalora": false,
55
+ "use_rslora": false,
56
+ "velora_config": null
57
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:955f0e6506c3db8034dde1a2362219c0012057ad257b2bcbdafc8c787081e508
3
+ size 435268528
calibration.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "temperature": 1.9433390039063905,
3
+ "fitted_on": "calibration",
4
+ "n": 1193
5
+ }