初始化项目,由ModelHub XC社区提供模型
Model: cs-552-2026-centralesupechec/general_knowledge_model Source: Original Platform
This commit is contained in:
36
.gitattributes
vendored
Normal file
36
.gitattributes
vendored
Normal 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
|
||||
104
README.md
Normal file
104
README.md
Normal file
@@ -0,0 +1,104 @@
|
||||
---
|
||||
library_name: transformers
|
||||
license: apache-2.0
|
||||
base_model: Qwen/Qwen3-1.7B
|
||||
pipeline_tag: text-generation
|
||||
model_name: general_knowledge_model
|
||||
tags:
|
||||
- general-knowledge
|
||||
- multiple-choice
|
||||
- reasoning
|
||||
- rejection-sampling
|
||||
- rft
|
||||
- lora
|
||||
- cs-552
|
||||
---
|
||||
|
||||
# Model Card for `general_knowledge_model`
|
||||
|
||||
Post-trained version of [`Qwen/Qwen3-1.7B`](https://huggingface.co/Qwen/Qwen3-1.7B)
|
||||
for the **General Knowledge** benchmark of EPFL **CS-552 — Modern NLP** (Spring 2026),
|
||||
team CentraleSupéchec.
|
||||
|
||||
The task is **closed-book multiple-choice QA** (2–20 options). The model reasons
|
||||
inside a `<think> ... </think>` block and ends its reply with the answer wrapped in
|
||||
`\boxed{LETTER}`, which is parsed for `pass@1` scoring.
|
||||
|
||||
## Training
|
||||
|
||||
The model is trained with **Rejection Fine-Tuning (RFT)** — STaR-style
|
||||
self-distillation — with an **answer-only loss**:
|
||||
|
||||
1. Sample `n=8` completions (`T=0.7`) from the base model over a ~4.7k-question
|
||||
pool of **GPQA** and **MMLU-Pro** (excluding Math/CS).
|
||||
2. Keep the 722 questions the base fails at `pass@1` but solves under repeated
|
||||
sampling, producing self-generated correct reasoning traces.
|
||||
3. Fine-tune a **LoRA** adapter (`r=16`, `α=32`) with the cross-entropy loss
|
||||
**masked to the `\boxed{}` answer span only** — the `<think>` reasoning
|
||||
conditions the forward pass but receives no gradient. This preserves the
|
||||
model's pretrained reasoning while sharpening answer commitment and output
|
||||
formatting.
|
||||
|
||||
The chat template (baked into the tokenizer) enforces a strict `\boxed{LETTER}`
|
||||
output and a 16,384-token reasoning budget.
|
||||
|
||||
## Quick start
|
||||
|
||||
```python
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
repo = "cs-552-2026-centralesupechec/general_knowledge_model"
|
||||
tok = AutoTokenizer.from_pretrained(repo)
|
||||
model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype="bfloat16", device_map="cuda")
|
||||
|
||||
question = (
|
||||
"Which of the following is the capital of Australia?\n\n"
|
||||
"Choices:\nA. Sydney\nB. Melbourne\nC. Canberra\nD. Perth"
|
||||
)
|
||||
inputs = tok.apply_chat_template(
|
||||
[{"role": "user", "content": question}],
|
||||
add_generation_prompt=True, return_tensors="pt",
|
||||
).to(model.device)
|
||||
|
||||
out = model.generate(inputs, max_new_tokens=16384, temperature=0.6, top_p=0.95, top_k=20)
|
||||
print(tok.decode(out[0][inputs.shape[1]:], skip_special_tokens=True))
|
||||
# ... reasoning ... \boxed{C}
|
||||
```
|
||||
|
||||
For vLLM, mirror the CI: apply the model's chat template, `seed=42`,
|
||||
`max_new_tokens=16384`, `temperature=0.6`, `top_p=0.95`, `top_k=20`.
|
||||
|
||||
## Generation config
|
||||
|
||||
`max_new_tokens: 16384` · `temperature: 0.6` · `top_p: 0.95` · `top_k: 20` ·
|
||||
`do_sample: true`. The 16k budget is essential: it removes the format failures
|
||||
that occur when reasoning is truncated before the boxed answer.
|
||||
|
||||
## Evaluation
|
||||
|
||||
`pass@1` on held-out sets disjoint from training (n=4, 16k tokens):
|
||||
|
||||
| Set | pass@1 |
|
||||
|---|---|
|
||||
| 650-question MMLU sweep (26 subjects) | ~0.74 |
|
||||
| Internal 100-question expert set | ~0.59 |
|
||||
|
||||
See the project report and code for the full comparison against the base model,
|
||||
full-trace SFT, and GRPO.
|
||||
|
||||
## Framework versions
|
||||
|
||||
- Transformers 5.7.0
|
||||
- PyTorch 2.10.0+cu128
|
||||
- TRL 0.12, PEFT 0.13
|
||||
|
||||
## Citation
|
||||
|
||||
```bibtex
|
||||
@inproceedings{zelikman2022star,
|
||||
title = {{STaR}: Bootstrapping Reasoning With Reasoning},
|
||||
author = {Zelikman, Eric and Wu, Yuhuai and Mu, Jesse and Goodman, Noah D.},
|
||||
booktitle = {Advances in Neural Information Processing Systems},
|
||||
year = {2022}
|
||||
}
|
||||
```
|
||||
29
chat_template.jinja
Normal file
29
chat_template.jinja
Normal file
@@ -0,0 +1,29 @@
|
||||
{#-
|
||||
General Knowledge — thinking-enabled chat template for Qwen3-1.7B.
|
||||
Allows the model to emit a <think>...</think> reasoning block first, then
|
||||
the final \boxed{LETTER} answer.
|
||||
|
||||
The CI calls:
|
||||
tokenizer.apply_chat_template(messages, add_generation_prompt=True)
|
||||
with no extra kwargs, so any behaviour we want must be encoded here.
|
||||
-#}
|
||||
{%- set gk_system = "You are a knowledge expert. Read the question and the labelled options carefully. Reason step by step inside <think> ... </think>, then choose exactly one option. End your reply with the letter of the correct option wrapped in \\boxed{}, e.g. \\boxed{C}. Do not output anything after the boxed answer." -%}
|
||||
|
||||
{%- if messages[0].role == 'system' -%}
|
||||
{{- '<|im_start|>system\n' + messages[0].content + '\n\n' + gk_system + '<|im_end|>\n' -}}
|
||||
{%- set messages = messages[1:] -%}
|
||||
{%- else -%}
|
||||
{{- '<|im_start|>system\n' + gk_system + '<|im_end|>\n' -}}
|
||||
{%- endif -%}
|
||||
|
||||
{%- for message in messages -%}
|
||||
{%- if message.role == 'user' -%}
|
||||
{{- '<|im_start|>user\n' + message.content + '<|im_end|>\n' -}}
|
||||
{%- elif message.role == 'assistant' -%}
|
||||
{{- '<|im_start|>assistant\n' + message.content + '<|im_end|>\n' -}}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
|
||||
{%- if add_generation_prompt -%}
|
||||
{{- '<|im_start|>assistant\n<think>\n' -}}
|
||||
{%- endif -%}
|
||||
63
config.json
Normal file
63
config.json
Normal 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": null,
|
||||
"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
|
||||
}
|
||||
10
generation_config.json
Normal file
10
generation_config.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"do_sample": true,
|
||||
"eos_token_id": 151645,
|
||||
"max_new_tokens": 16384,
|
||||
"pad_token_id": 151643,
|
||||
"temperature": 0.6,
|
||||
"top_k": 20,
|
||||
"top_p": 0.95,
|
||||
"transformers_version": "5.7.0"
|
||||
}
|
||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4ab3886a57655baad8bb2bc6f25efc47cbf66f0dfd613d85c699c0f079605d0b
|
||||
size 3441185608
|
||||
3
tokenizer.json
Normal file
3
tokenizer.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:be75606093db2094d7cd20f3c2f385c212750648bd6ea4fb2bf507a6a4c55506
|
||||
size 11422650
|
||||
31
tokenizer_config.json
Normal file
31
tokenizer_config.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"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,
|
||||
"chat_template": "{#-\n General Knowledge — thinking-enabled chat template for Qwen3-1.7B.\n Allows the model to emit a <think>...</think> reasoning block first, then\n the final \\boxed{LETTER} answer.\n The CI calls:\n tokenizer.apply_chat_template(messages, add_generation_prompt=True)\n with no extra kwargs, so any behaviour we want must be encoded here.\n-#}\n{%- set gk_system = \"You are a knowledge expert. Read the question and the labelled options carefully. Reason step by step inside <think> ... </think>, then choose exactly one option. End your reply with the letter of the correct option wrapped in \\\\boxed{}, e.g. \\\\boxed{C}. Do not output anything after the boxed answer.\" -%}\n{%- if messages[0].role == 'system' -%}\n {{- '<|im_start|>system\\n' + messages[0].content + '\\n\\n' + gk_system + '<|im_end|>\\n' -}}\n {%- set messages = messages[1:] -%}\n{%- else -%}\n {{- '<|im_start|>system\\n' + gk_system + '<|im_end|>\\n' -}}\n{%- endif -%}\n{%- for message in messages -%}\n {%- if message.role == 'user' -%}\n {{- '<|im_start|>user\\n' + message.content + '<|im_end|>\\n' -}}\n {%- elif message.role == 'assistant' -%}\n {{- '<|im_start|>assistant\\n' + message.content + '<|im_end|>\\n' -}}\n {%- endif -%}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n {{- '<|im_start|>assistant\\n<think>\\n' -}}\n{%- endif -%}\n"
|
||||
}
|
||||
Reference in New Issue
Block a user