TangYeqing commited on
Commit
d180ef2
Β·
verified Β·
1 Parent(s): d4a7310

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +97 -0
README.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model:
4
+ - Qwen/Qwen3-1.7B-Base
5
+ library_name: transformers
6
+ ---
7
+ # CS-552 Ma Que β€” General Knowledge Model
8
+
9
+ General knowledge expert for the EPFL CS-552 (Modern NLP, Spring 2026) group project
10
+ "Building a robust small language model for edge devices" (Group 11, Ma Que).
11
+ This is an individual model; the team also maintains a merged
12
+ group model (https://huggingface.co/cs-552-2026-ma-que/group_model).
13
+
14
+ ## What it is
15
+
16
+ - Base model: Qwen/Qwen3-1.7B-Base (https://huggingface.co/Qwen/Qwen3-1.7B-Base) (1.7B params).
17
+ - Post-training: LoRA SFT using nlp_project/sft_thinking.py with the configuration in nlp_project/cfgs_thinking.yml. The run uses LoRA rank 256, alpha 256, dropout
18
+ 0, and targets q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, and down_proj. Training uses bf16, gradient checkpointing, Liger kernel, assistant-only loss,
19
+ max sequence length 6144, learning rate 2e-4, cosine scheduler, 5% warmup, batch size 20, gradient accumulation 1, and 2 epochs.
20
+ - Task: general knowledge multiple-choice answering with reasoning-style responses. The model reads a question with lettered options and commits to one boxed option
21
+ letter.
22
+ - Output contract: the final answer is emitted once as \boxed{X} (X is a single capital option letter), for the course OpenCompass/vLLM parser. Thinking mode is ON.
23
+ - How behaviour is set: the Qwen3 chat template is applied automatically by tokenizer.apply_chat_template(messages, add_generation_prompt=True). Training examples
24
+ include assistant reasoning traces with <think>...</think>, and the model is intended to answer in thinking mode before producing the final boxed answer.
25
+
26
+ ## Inference / decoding
27
+
28
+ Values below are exactly those in generation_config.json:
29
+
30
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
31
+ β”‚ param β”‚ value β”‚
32
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
33
+ β”‚ do_sample β”‚ true β”‚
34
+ β”‚ temperature β”‚ 0.6 β”‚
35
+ β”‚ top_k β”‚ 20 β”‚
36
+ β”‚ top_p β”‚ 0.95 β”‚
37
+ β”‚ max_new_tokens β”‚ not set in generation_config.json; use 16384 for final grading β”‚
38
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
39
+
40
+ Usage:
41
+
42
+ from transformers import AutoModelForCausalLM, AutoTokenizer
43
+
44
+ repo = "cs-552-2026-ma-que/general_knowledge_model"
45
+ tok = AutoTokenizer.from_pretrained(repo)
46
+ model = AutoModelForCausalLM.from_pretrained(
47
+ repo,
48
+ torch_dtype="auto",
49
+ device_map="auto",
50
+ )
51
+
52
+ messages = [{"role": "user", "content":
53
+ "Which planet is known as the Red Planet?\n"
54
+ "A) Venus\nB) Mars\nC) Jupiter\nD) Mercury"}]
55
+
56
+ text = tok.apply_chat_template(
57
+ messages,
58
+ tokenize=False,
59
+ add_generation_prompt=True,
60
+ )
61
+
62
+ out = model.generate(
63
+ **tok(text, return_tensors="pt").to(model.device),
64
+ max_new_tokens=16384,
65
+ )
66
+
67
+ print(tok.decode(out[0], skip_special_tokens=True)) # -> ... \boxed{B}
68
+
69
+ The model is also vLLM-loadable for batched evaluation.
70
+
71
+ ## Training data
72
+
73
+ The thinking model was trained with sft_thinking.py using the dataset
74
+ TangYeqing/maque-data, as configured in cfgs_thinking.yml.
75
+
76
+ The script loads the dataset's train split and performs a local
77
+ train_test_split(test_size=0.005, seed=42). Each row contains conversational
78
+ messages; if a row has no system message, the training script prepends:
79
+
80
+ You are a helpful assistant that provides step-by-step solutions to math problems.
81
+
82
+ The assistant turns already contain literal <think>...</think> reasoning traces,
83
+ which are preserved during SFT. Training uses assistant-only loss, so the loss is
84
+ computed on the assistant response, including the thinking trace and final boxed
85
+ answer.
86
+
87
+ ## Intended use & limitations
88
+
89
+ Research artifact for the CS-552 general knowledge benchmark; produces boxed
90
+ multiple-choice answers only. It is not an authoritative factual system and may
91
+ encode outdated, incomplete, or incorrect facts, so outputs should be verified
92
+ before any real-world or safety-critical use.
93
+
94
+ ## Citation
95
+
96
+ Built on Qwen3-1.7B (Qwen Team, 2025), arXiv:2505.09388 β€”
97
+ https://arxiv.org/abs/2505.09388