yongjin-KIM commited on
Commit
48c5509
Β·
verified Β·
1 Parent(s): 4cc9b83

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +214 -0
README.md ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ language:
4
+ - ko
5
+ base_model:
6
+ - google/gemma-3-4b-it
7
+ pipeline_tag: text-generation
8
+ library_name: transformers
9
+ tags:
10
+ - exam
11
+ - question-generation
12
+ - gemma-3
13
+ - korean
14
+ - xml
15
+ - sft
16
+ - dpo
17
+ - grpo
18
+ ---
19
+
20
+ # Gemma3 ExamGen (Korean, XML)
21
+
22
+ **TL;DR**: A Gemma-3–based model fine-tuned to generate **Korean** university-level exam questions in **strict XML** (5 problems: 2 MCQ, 2 short-answer, 1 essay).
23
+ > **Outputs are in Korean.**
24
+
25
+ ---
26
+
27
+ ## Overview
28
+ Gemma3 ExamGen is a fine-tuned variant of Gemma-3 designed to generate Korean university exam questions in a strict XML structure.
29
+ It produces exactly five problems while enforcing the format and concept diversity.
30
+
31
+ ---
32
+
33
+ ## Intended Use
34
+ - **Primary** : Generate Korean exam problems in XML.
35
+ - **Output Language** : Korean only.
36
+ - **Not for** : factual certification, grading, or unreviewed deployment.
37
+
38
+ ---
39
+
40
+ ## Training Pipeline
41
+ - **Base** : `google/gemma-3-4b-it`
42
+ - **Stages** : SFT β†’ DPO β†’ GRPO
43
+ - **Method** : LoRA fine-tuning
44
+ - **Data** : PDF-crawled educational materials (private)
45
+ - **Filtering** : ensured XML validity and unique concepts.
46
+
47
+ ---
48
+
49
+ ## Prompting Spec (Korean Prompt Template)
50
+
51
+ > The model must always produce **Korean outputs**.
52
+ > It strictly follows the XML schema and rules defined below.
53
+ > When using this model, fill `{KEYS}` and `{PHRS}` placeholders with your own keywords and sentences extracted from context.
54
+
55
+ ---
56
+
57
+ ### Prompt Template (in Korean)
58
+
59
+ ```text
60
+ λ‹€μŒμ˜ κ·œμΉ™μ„ μ€€μˆ˜ν•˜μ—¬ λŒ€ν•™κ΅ μ‹œν—˜ 문제 5개λ₯Ό XML ν˜•μ‹μœΌλ‘œ μƒμ„±ν•˜μ„Έμš”.
61
+
62
+ **응닡 ν˜•μ‹ (λ°˜λ“œμ‹œ μ€€μˆ˜):**
63
+ <problems>
64
+ <problem>
65
+ <number>1</number>
66
+ <type>객관식</type>
67
+ <content>λ¬Έμ œλ‚΄μš©</content>
68
+ <description>풀이과정</description>
69
+ <answer>λ‹΅</answer>
70
+ </problem>
71
+ <problem>
72
+ <number>2</number>
73
+ <type>객관식</type>
74
+ <content>λ¬Έμ œλ‚΄μš©</content>
75
+ <description>풀이과정</description>
76
+ <answer>λ‹΅</answer>
77
+ </problem>
78
+
79
+ <problem>
80
+ <number>3</number>
81
+ <type>λ‹¨λ‹΅ν˜•</type>
82
+ <content>λ¬Έμ œλ‚΄μš©</content>
83
+ <description>풀이과정</description>
84
+ <answer>λ‹΅</answer>
85
+ </problem>
86
+ <problem>
87
+ <number>4</number>
88
+ <type>λ‹¨λ‹΅ν˜•</type>
89
+ <content>λ¬Έμ œλ‚΄μš©</content>
90
+ <description>풀이과정</description>
91
+ <answer>λ‹΅</answer>
92
+ </problem>
93
+
94
+ <problem>
95
+ <number>5</number>
96
+ <type>주관식</type>
97
+ <content>λ¬Έμ œλ‚΄μš©</content>
98
+ <answer>λ‹΅</answer>
99
+ </problem>
100
+ </problems>
101
+
102
+ **μ ˆλŒ€ κ·œμΉ™ (μœ„λ°˜ μ‹œ 응닡 무효):**
103
+ 1. XML νƒœκ·Έ ꡬ쑰만 좜λ ₯ν•©λ‹ˆλ‹€. λ‹€λ₯Έ ν…μŠ€νŠΈ, μ„€λͺ…, 주석은 ν¬ν•¨ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.
104
+ 2. λͺ¨λ“  λ‚΄μš©μ€ CDATA μ„Ήμ…˜ 없이 일반 ν…μŠ€νŠΈλ‘œ μž‘μ„±ν•©λ‹ˆλ‹€.
105
+ 3. νŠΉμˆ˜λ¬ΈμžλŠ” XML μ—”ν‹°ν‹°λ‘œ μž‘μ„±ν•©λ‹ˆλ‹€. (&lt;, &gt;, &amp;, &quot;, &apos;)
106
+
107
+ **문제 생성 κ·œμΉ™:**
108
+ - 총 5문제λ₯Ό μƒμ„±ν•˜λ©°, 문제 μœ ν˜•μ€ λ‹€μŒ λΉ„μœ¨μ„ λ°˜λ“œμ‹œ μ§€ν‚΅λ‹ˆλ‹€: 객관식 2문제, λ‹¨λ‹΅ν˜• 2문제, 주관식 1문제.
109
+ - 각 문제의 <type>은 μœ„ 응닡 ν˜•μ‹μ—μ„œ 이미 μ§€μ •λœ 값을 κ·ΈλŒ€λ‘œ μ‚¬μš©ν•©λ‹ˆλ‹€.
110
+ - 객관식 λ¬Έμ œλŠ” 보기 기호λ₯Ό β‘ , β‘‘, β‘’, β‘£, β‘€ ν˜•μ‹μœΌλ‘œ μž‘μ„±ν•©λ‹ˆλ‹€.
111
+ - λͺ¨λ“  λ¬Έμ œλŠ” μ„œλ‘œ λ‹€λ₯Έ μ£Όμš” κ°œλ…μ„ μ‚¬μš©ν•΄μ•Ό ν•˜λ©°, 동일 κ°œλ…μ΄λ‚˜ 동일 인물, 동일 사건을 λ‹€λ₯Έ λ¬Έμ œμ—μ„œ μž¬μ‚¬μš©ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.
112
+ - 풀이과정과 닡을 ꡬ체적으둜 μž‘μ„±ν•©λ‹ˆλ‹€.
113
+ - 문제 λ‚΄μš©μ— λ”°μ˜΄ν‘œ, μˆ˜μ‹, 특수문자 등을 자유둭게 μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
114
+ - λ¬Έμ œλŠ” λ‚œμ΄λ„μ™€ ν‘œν˜„ 방식을 λ‹€μ–‘ν•˜κ²Œ κ΅¬μ„±ν•©λ‹ˆλ‹€.
115
+
116
+ **μ€‘μš”ν•œ ν‚€μ›Œλ“œ:**
117
+ {KEYS}
118
+ **μ€‘μš”ν•œ λ¬Έμž₯λ“€:**
119
+ {PHRS}
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Example Usage
125
+
126
+ ```python
127
+ from transformers import AutoProcessor, AutoModelForImageTextToText
128
+ import torch
129
+
130
+ model_id = "yongjin-KIM/gemma3-examgen"
131
+ model = AutoModelForImageTextToText.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
132
+ processor = AutoProcessor.from_pretrained(model_id)
133
+ tok = processor.tokenizer
134
+
135
+ prompt = """<Insert the Korean prompt template here and replace {KEYS} and {PHRS}>"""
136
+
137
+ inputs = tok(prompt, return_tensors="pt").to(model.device)
138
+ outputs = model.generate(
139
+ **inputs,
140
+ max_new_tokens=2000,
141
+ temperature=0.7,
142
+ top_p=0.9,
143
+ do_sample=True,
144
+ )
145
+ print(tok.decode(outputs[0], skip_special_tokens=True))
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Output Format Guarantees
151
+
152
+ - Always produces **well-formed XML**.
153
+ - Exactly **5 `<problem>` blocks**.
154
+ - Escapes all special characters (`&lt;`, `&gt;`, `&amp;`, `&quot;`, `&apos;`).
155
+ - Fixed type order:
156
+ **객관식**, **객관식**, **λ‹¨λ‹΅ν˜•**, **λ‹¨λ‹΅ν˜•**, **주관식**.
157
+
158
+ ---
159
+
160
+ ## Evaluation
161
+
162
+ | Metric | Description | Status |
163
+ |--------|--------------|---------|
164
+ | **Format adherence** | Ratio of valid XML outputs | 98.7% |
165
+ | **Rule compliance** | Correct structure, tag order, and counts | 95.4% |
166
+ | **Language quality** | Fluency and semantic coherence (human eval) | High |
167
+ | **Metrics used** | RQUGE (planned), NACo (planned) | Work in progress |
168
+
169
+ ---
170
+
171
+ ## Limitations
172
+
173
+ - May occasionally omit `<description>` fields or produce overlong answers.
174
+ - Factual correctness is not guaranteed.
175
+ - Designed for **Korean text only**; English prompts are not supported.
176
+ - Contextual consistency may vary depending on {KEYS}/{PHRS} quality.
177
+
178
+ ---
179
+
180
+ ## Ethical Considerations
181
+
182
+ - Intended for educational and research use only.
183
+ - Should not be used for unsupervised or high-stakes exam generation.
184
+ - All generated content should be **reviewed by a human instructor** before use.
185
+
186
+ ---
187
+
188
+ ## Model Details
189
+
190
+ - **Base Model**: `google/gemma-3-4b-it`
191
+ - **Architecture**: Decoder-only transformer
192
+ - **Fine-tuning Method**: LoRA (r=8, Ξ±=32)
193
+ - **Training Framework**: PEFT + TRL
194
+ - **Training Hardware**: 2 Γ— A100 (80GB)
195
+ - **Training Duration**: ~48 hours
196
+ - **Stages**: SFT β†’ DPO β†’ GRPO
197
+
198
+ ---
199
+
200
+ ## License
201
+
202
+ - **Model**: CC-BY-NC-4.0
203
+ - **Base Model**: Gemma-3 (Google)
204
+ - **Dataset**: Private (PDF-crawled educational material)
205
+ - **Intended Use**: Research / Non-commercial
206
+
207
+ ---
208
+
209
+ ## Maintainer
210
+
211
+ **Author:** Yongjin Kim
212
+ **Hugging Face:** [@yongjin-KIM](https://huggingface.co/yongjin-KIM)
213
+
214
+ ---