初始化项目,由ModelHub XC社区提供模型

Model: cs-552-2026-databand/general_knowledge_model
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-07-26 13:35:08 +08:00
commit 97b87e6912
9 changed files with 365 additions and 0 deletions

36
.gitattributes vendored Normal file
View File

@@ -0,0 +1,36 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text
tokenizer.json filter=lfs diff=lfs merge=lfs -text

183
README.md Normal file
View File

@@ -0,0 +1,183 @@
---
license: apache-2.0
base_model: Qwen/Qwen3-1.7B
library_name: transformers
pipeline_tag: text-generation
tags:
- qwen3
- multiple-choice
- general-knowledge
- lora
- sft
- boxed-answer
---
# General Knowledge Model
This is the final General Knowledge individual model for the CS-552 Modern NLP Spring 2026 standardized project.
The submitted model is the **SFT-only merged model**. A later DPO experiment was run on ARC/CommonsenseQA mistakes, but it reduced external benchmark accuracy, so it was **not selected** as the final model.
## Model behavior
The model is specialized for multiple-choice general knowledge questions. It is prompted to output exactly one final boxed answer, for example:
\boxed{A}
The chat template enforces concise answer-only behavior and supports choices labeled from A through T.
## Training setup
Starting point:
- Baseline working model folder with the project chat template and generation config
- LoRA SFT on top of the baseline model
- Final model produced by merging the LoRA adapter into the baseline model
Training method:
- LoRA supervised fine-tuning
- Loss masked so that only the final assistant boxed answer contributes to training
- Prompt, system message, question text, choices, chat markers, and template tokens are masked with -100
- Assistant target format: \boxed{LETTER}
LoRA configuration:
- r = 16
- lora_alpha = 32
- lora_dropout = 0.05
- Target modules:
- q_proj
- k_proj
- v_proj
- o_proj
- gate_proj
- up_proj
- down_proj
Main training hyperparameters:
- Learning rate: 8e-5
- Epochs: 1
- Batch size per device: 1
- Gradient accumulation steps: 8
- Max sequence length: 8192
- Precision: bf16
- Scheduler: cosine
- Warmup steps: 20
## SFT datasets
The SFT training data was built from:
1. Kaggle LLM Science
2. EduQG
3. EduAdapt, MCQ-only questions
4. NCERT_MCQs
5. SciQ train
6. OpenBookQA train
Final SFT data sizes:
- Train: 26,120
- Validation: 2,000
The answer labels were balanced uniformly across A through T separately for train and validation.
Train answer distribution:
- A through T: 1,306 examples each
Validation answer distribution:
- A through T: 100 examples each
## Evaluation
The final selected model is the SFT-only merged model.
The “SFT validation” set in the table is the held-out validation set created from the same six dataset families used for LoRA SFT training: Kaggle LLM Science, EduQG, EduAdapt MCQ, NCERT_MCQs, SciQ, and OpenBookQA. It contains 2,000 examples and is answer-balanced across A through T.
External benchmark sets:
- MMLU Pro: 2,000 examples, uniformly sampled across categories
- MMLU Redux: 2,000 examples, uniformly sampled across subjects
- SuperGPQA: 2,000 examples, uniformly sampled across disciplines
| Evaluation set | Baseline boxed | Baseline accuracy | SFT-only boxed | SFT-only accuracy | SFT + DPO boxed | SFT + DPO accuracy |
|---|---:|---:|---:|---:|---:|---:|
| SFT validation 2k | 19.20% | 16.00% | 100.00% | 85.30% | 100.00% | 79.75% |
| MMLU Pro 2k | 60.25% | 18.05% | 100.00% | 37.85% | 100.00% | 35.25% |
| MMLU Redux 2k | 26.65% | 11.40% | 100.00% | 56.25% | 100.00% | 50.90% |
| SuperGPQA 2k | 66.95% | 15.85% | 99.95% | 27.55% | 100.00% | 23.45% |
The DPO experiment improved neither the selected SFT validation score nor the external benchmark scores. Therefore, the SFT-only merged model was selected as the final model.
### SFT validation details
SFT-only evaluation on the held-out SFT validation set:
- Total: 2,000
- Extracted boxed answer: 2,000 / 2,000 = 100.00%
- Accuracy: 1,706 / 2,000 = 85.30%
Accuracy by validation source:
| Source | Accuracy | Boxed extraction |
|---|---:|---:|
| eduadapt | 82.35% (14/17) | 100.00% (17/17) |
| eduqg | 76.86% (93/121) | 100.00% (121/121) |
| kaggle_llm_science | 58.30% (130/223) | 100.00% (223/223) |
| ncert_mcqs | 93.33% (14/15) | 100.00% (15/15) |
| openbookqa | 80.83% (430/532) | 100.00% (532/532) |
| sciq | 93.86% (1025/1092) | 100.00% (1092/1092) |
### SuperGPQA boxed-answer edge case
The SFT-only model produced boxed answers for 1,999 out of 2,000 SuperGPQA examples. The single unboxed example was a long, LaTeX-heavy numerical analysis question whose answer choices contained multi-line mathematical derivations. Instead of producing a boxed option, the model continued/copy-completed part of one answer choice, generating text beginning with:
mathrm{d} x^{2} = 2.1730$ and $| R_{1} | ...
Increasing max_new_tokens from 20 to 64 did not change this outcome. The reported SuperGPQA result therefore keeps the strict extraction score of 99.95%.
## Expected input format
The model expects a multiple-choice question formatted like:
Question text here?
Choices:
A. first option
B. second option
C. third option
D. fourth option
It should answer with only:
\boxed{A}
## Reproducibility notes
In the Github repo CS-552/standard-project-m3-databand/tree/main, you can find in the folder code/general_knowledge all scripts and files needed for reproducibility.
A README.md file is also present in code/general_knowledge folder, documenting all script functionalities and how to run them to reproduce both SFT and SFT+DPO experiments.
Important files from the code/general_knowledge folder:
- SFT trainer: scripts/train_v3_lora_sft_masked.py
- SFT data builder: scripts/build_my_sft_data_balanced.py
- DPO trainer used for the unselected experiment: scripts/train_v3_lora_dpo_boxed.py
- Merge script: scripts/merge_v3_lora_adapter.py
- Evaluation script: scripts/evaluate_mcq_accuracy.py
Final selected model folder before upload:
outputs/lora_sft_v3_boxed_only/merged_full_model
SFT LoRA adapter:
outputs/lora_sft_v3_boxed_only/final_adapter
DPO adapter, experimental and not selected:
outputs/lora_dpo_arc_csqa_on_sft/final_adapter

31
chat_template.jinja Normal file
View File

@@ -0,0 +1,31 @@
{%- set enable_thinking = false -%}
{%- set default_system_message = "You are a multiple-choice general knowledge answerer.\n\nThe user will provide a question and a list of choices. Choose exactly one option.\n\nThe choices may have any number of labels, for example A, B, C, D, ... up to T. Your answer must be the letter of the best choice.\n\nYour entire response must be exactly one boxed answer, such as \\boxed{A}, \\boxed{C}, \\boxed{J}, or \\boxed{T}.\n\nDo not explain. Do not show reasoning. Do not write words. Do not add punctuation. Do not write anything before or after the boxed answer." -%}
{%- if messages and messages[0]['role'] == 'system' -%}
{%- set system_message = default_system_message + '\n\n' + messages[0]['content'] -%}
{%- set loop_messages = messages[1:] -%}
{%- else -%}
{%- set system_message = default_system_message -%}
{%- set loop_messages = messages -%}
{%- endif -%}
{{- '<|im_start|>system\n' + system_message + '<|im_end|>\n' }}
{%- for message in loop_messages -%}
{%- if message['role'] == 'user' -%}
{{- '<|im_start|>user\n' + message['content'] + '<|im_end|>\n' }}
{%- elif message['role'] == 'assistant' -%}
{{- '<|im_start|>assistant\n' }}
{%- if enable_thinking is defined and enable_thinking is false -%}
{{- '<think>\n\n</think>\n\n' }}
{%- endif -%}
{{- message['content'] + '<|im_end|>\n' }}
{%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt -%}
{{- '<|im_start|>assistant\n' }}
{%- if enable_thinking is defined and enable_thinking is false -%}
{{- '<think>\n\n</think>\n\n' }}
{%- endif -%}
{%- endif -%}

63
config.json Normal file
View File

@@ -0,0 +1,63 @@
{
"architectures": [
"Qwen3ForCausalLM"
],
"attention_bias": false,
"attention_dropout": 0.0,
"bos_token_id": 151643,
"dtype": "bfloat16",
"eos_token_id": 151645,
"head_dim": 128,
"hidden_act": "silu",
"hidden_size": 2048,
"initializer_range": 0.02,
"intermediate_size": 6144,
"layer_types": [
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention"
],
"max_position_embeddings": 40960,
"max_window_layers": 28,
"model_type": "qwen3",
"num_attention_heads": 16,
"num_hidden_layers": 28,
"num_key_value_heads": 8,
"pad_token_id": 151643,
"rms_norm_eps": 1e-06,
"rope_parameters": {
"rope_theta": 1000000,
"rope_type": "default"
},
"sliding_window": null,
"tie_word_embeddings": true,
"transformers_version": "5.7.0",
"use_cache": true,
"use_sliding_window": false,
"vocab_size": 151936
}

13
generation_config.json Normal file
View File

@@ -0,0 +1,13 @@
{
"bos_token_id": 151643,
"do_sample": true,
"eos_token_id": [
151645,
151643
],
"pad_token_id": 151643,
"temperature": 0.1,
"top_k": 20,
"top_p": 0.8,
"transformers_version": "4.51.0"
}

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bbac80fd49d664b0096daf5c93346809d1275bde1375705d0bda731204b5ab90
size 3441185608

3
tokenizer.json Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:be75606093db2094d7cd20f3c2f385c212750648bd6ea4fb2bf507a6a4c55506
size 11422650

30
tokenizer_config.json Normal file
View File

@@ -0,0 +1,30 @@
{
"add_prefix_space": false,
"backend": "tokenizers",
"bos_token": null,
"clean_up_tokenization_spaces": false,
"eos_token": "<|im_end|>",
"errors": "replace",
"extra_special_tokens": [
"<|im_start|>",
"<|im_end|>",
"<|object_ref_start|>",
"<|object_ref_end|>",
"<|box_start|>",
"<|box_end|>",
"<|quad_start|>",
"<|quad_end|>",
"<|vision_start|>",
"<|vision_end|>",
"<|vision_pad|>",
"<|image_pad|>",
"<|video_pad|>"
],
"is_local": true,
"local_files_only": false,
"model_max_length": 131072,
"pad_token": "<|endoftext|>",
"split_special_tokens": false,
"tokenizer_class": "Qwen2Tokenizer",
"unk_token": null
}

3
training_args.bin Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f3f7e3941a0de7499e3168b07e258108060907a86cc3584f99173330ef33589d
size 7185