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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 μν°ν°λ‘ μμ±ν©λλ€. (<, >, &, ", ')
|
| 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 (`<`, `>`, `&`, `"`, `'`).
|
| 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 |
+
---
|