File size: 7,561 Bytes
a9bd396
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!--Copyright 2025 The LG AI Research and The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

โš ๏ธ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->

# EXAONE 4

## ๊ฐœ์š”

**[EXAONE 4.0](https://github.com/LG-AI-EXAONE/EXAONE-4.0)** ๋ชจ๋ธ๊ตฐ์€ [EXAONE 3.5](https://github.com/LG-AI-EXAONE/EXAONE-3.5) ๋ชจ๋ธ๊ตฐ์˜ ๋†’์€ ์‹ค์šฉ์„ฑ๊ณผ [EXAONE Deep](https://github.com/LG-AI-EXAONE/EXAONE-Deep) ๋ชจ๋ธ๊ตฐ์˜ ํ–ฅ์ƒ๋œ ์‚ฌ๊ณ  ์ถ”๋ก  ๋Šฅ๋ ฅ์„ ๊ฐ๊ฐ Non-reasoning mode์™€ Reasoning mode๋กœ ํ†ตํ•ฉํ•œ ์ž์—ฐ์–ด ๋ชจ๋ธ(language model)์ž…๋‹ˆ๋‹ค. ์—์ด์ „ํ‹ฑ(agentic) AI ์‹œ๋Œ€์— ๋ฐœ๋งž์ถฐ EXAONE 4.0์€ ์—์ด์ „ํ‹ฑ ๋„๊ตฌ ์‚ฌ์šฉ ๋Šฅ๋ ฅ๊ณผ ๊ฐ™์€ ํ•ต์‹ฌ ๊ธฐ๋Šฅ์„ ํ†ตํ•ฉํ–ˆ๊ณ , ๊ธฐ์กด์˜ ๋‹ค๊ตญ์–ด ๋Šฅ๋ ฅ์„ ์˜์–ด, ํ•œ๊ตญ์–ด์™€ ๋”๋ถˆ์–ด ์ŠคํŽ˜์ธ์–ด๊นŒ์ง€ ํ™•์žฅํ–ˆ์Šต๋‹ˆ๋‹ค. 

EXAONE 4.0 ๋ชจ๋ธ๊ตฐ์€ ๋‘ ๊ฐœ์˜ ๋ชจ๋ธ: ๋†’์€ ์„ฑ๋Šฅ์„ ์œ„ํ•ด ์ตœ์ ํ™”๋œ 32B ์ค‘ํ˜• ๋ชจ๋ธ, ๊ทธ๋ฆฌ๊ณ  ์˜จ-๋””๋ฐ”์ด์Šค ํ™œ์šฉ์„ ์œ„ํ•ด ๋””์ž์ธ๋œ 1.2B ์†Œํ˜• ๋ชจ๋ธ์œผ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

EXAONE 4.0์˜ ๋ชจ๋ธ ๊ตฌ์กฐ๋Š” ์ด์ „ EXAONE ๋ชจ๋ธ๋“ค๊ณผ ๋‹ค๋ฅธ ์•„ํ‚คํ…์ฒ˜ ๋””์ž์ธ์„ ์ฑ„ํƒํ–ˆ์Šต๋‹ˆ๋‹ค.

1. **Hybrid Attention**: 32B ๋ชจ๋ธ์€ *Local attention (sliding window attention)*๊ณผ *Global attention (full attention)*์„ 3:1 ๋น„์œจ๋กœ ์—ฐ๊ฒฐํ•œ hybrid attention ๊ตฌ์กฐ๋ฅผ ์ฑ„ํƒํ–ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ ์ „์ฒด ๋ฌธ๋งฅ์„ ๋” ์ž˜ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋„๋ก global attention์—์„œ RoPE๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.
2. **QK-Reorder-Norm**: ๋” ๋‚˜์€ downstream tasks ์„ฑ๋Šฅ์„ ์œ„ํ•ด ์—ฐ์‚ฐ๋Ÿ‰์˜ ์ฆ๊ฐ€๋ฅผ ๊ฐ์ˆ˜ํ•˜๋ฉฐ ์ „ํ†ต์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๊ณ  ์žˆ๋˜ Pre-LN ๋ฐฉ์‹์„ ๋ณ€๊ฒฝํ–ˆ์Šต๋‹ˆ๋‹ค. LayerNorm์˜ ์œ„์น˜๋ฅผ attention๊ณผ MLP์˜ ์ถœ๋ ฅ์— ์ ์šฉ๋˜๋„๋ก ์žฌ๋ฐฐ์น˜ํ–ˆ๊ณ , Q์™€ K projection ์งํ›„์—๋„ RMS normalization์„ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค. 

๋” ์ž์„ธํ•œ ์ •๋ณด๋Š” [๊ธฐ์ˆ  ๋ณด๊ณ ์„œ](https://huggingface.co/papers/2507.11407), [HuggingFace ๋…ผ๋ฌธ](https://huggingface.co/papers/2507.11407), [๋ธ”๋กœ๊ทธ](https://www.lgresearch.ai/blog/view?seq=576), [๊ณต์‹ GitHub](https://github.com/LG-AI-EXAONE/EXAONE-4.0) ํŽ˜์ด์ง€๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์‹œ๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.

๊ณต๊ฐœ๋œ ๋ชจ๋“  ๋ชจ๋ธ ์ฒดํฌํฌ์ธํŠธ๋Š” [HuggingFace ์ฝœ๋ ‰์…˜](https://huggingface.co/collections/LGAI-EXAONE/exaone-40-686b2e0069800c835ed48375)์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


## ๋ชจ๋ธ ์„ธ๋ถ€ ์ •๋ณด

| Model Configuration | 32B | 1.2B |
|:-------------------|:-----:|:------:|
| d_model | 5,120 | 2,048 |
| Number of layers | 64 | 30 |
| Normalization | QK-Reorder-LN | QK-Reorder-LN |
| Non-linearity | SwiGLU | SwiGLU |
| Feedforward dimension | 27,392 | 4,096 |
| Attention type | Hybrid (3:1 Local-Global) | Global |
| Head type | GQA | GQA |
| Number of heads | 40 | 32 |
| Number of KV heads | 8 | 8 |
| Head size | 128 | 64 |
| Max sequence length | 131,072 | 65,536 |
| RoPE theta | 1,000,000 | 1,000,000 |
| Tokenizer | BBPE | BBPE |
| Vocab size | 102,400 | 102,400 |
| Tied word embedding | False | True |
| Knowledge cut-off | Nov. 2024 | Nov. 2024 |


## ์‚ฌ์šฉ ํŒ

### Non-reasoning mode

์ผ๋ฐ˜์ ์ธ ๋Œ€ํ™”์˜ ๊ฒฝ์šฐ ์•„๋ž˜ ์˜ˆ์ œ์™€ ๊ฐ™์ด EXAONE 4.0์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "LGAI-EXAONE/EXAONE-4.0-32B"

model = AutoModelForCausalLM.from_pretrained(
    model_name,
    dtype="bfloat16",
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)

# ์›ํ•˜๋Š” ์ž…๋ ฅ์„ ์„ ํƒํ•˜์„ธ์š”
prompt = "Explain how wonderful you are"
prompt = "Explica lo increรญble que eres"
prompt = "๋„ˆ๊ฐ€ ์–ผ๋งˆ๋‚˜ ๋Œ€๋‹จํ•œ์ง€ ์„ค๋ช…ํ•ด ๋ด"

messages = [
    {"role": "user", "content": prompt}
]
input_ids = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_tensors="pt"
)

output = model.generate(
    input_ids.to(model.device),
    max_new_tokens=128,
    do_sample=False,
)
print(tokenizer.decode(output[0]))
```

### Reasoning mode

The EXAONE 4.0 models have reasoning capabilities for handling complex problems. You can activate reasoning mode by using the `enable_thinking=True` argument with the tokenizer, which opens a reasoning block that starts with `<think>` tag without closing it.

EXAONE 4.0 ๋ชจ๋ธ๊ตฐ์€ ๋ณต์žกํ•œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•œ ์‚ฌ๊ณ  ์ถ”๋ก  ๋Šฅ๋ ฅ์„ ๊ฐ–์ถ”๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํ† ํฌ๋‚˜์ด์ €์—์„œ `enable_thinking=True` ์ธ์ž๋ฅผ ์‚ฌ์šฉํ•ด์„œ reasoning mode๋กœ ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ฒฝ์šฐ `<think>` ํ† ํฐ์œผ๋กœ ์ถ”๋ก  ๋ธ”๋ก์„ ์—ฐ ๋’ค, ๋‹ซ์ง€ ์•Š๊ณ  ์ถ”๋ก ์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.

```python
messages = [
    {"role": "user", "content": "Which one is bigger, 3.12 vs 3.9?"}
]
input_ids = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_tensors="pt",
    enable_thinking=True,
)

output = model.generate(
    input_ids.to(model.device),
    max_new_tokens=128,
    do_sample=True,
    temperature=0.6,
    top_p=0.95
)
print(tokenizer.decode(output[0]))
```

> [!IMPORTANT]
> ๋ชจ๋ธ์„ reasoning mode๋กœ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ, ์ƒ์„ฑ๋˜๋Š” ๋‹ต๋ณ€์ด sampling parameters์— ๊ต‰์žฅํžˆ ๋ฏผ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๋” ๋‚˜์€ ์ƒ์„ฑ ํ’ˆ์งˆ์„ ์œ„ํ•ด ๊ณต์‹ [Usage Guideline](https://github.com/LG-AI-EXAONE/EXAONE-4.0#usage-guideline)๋ฅผ ์ฐธ์กฐํ•ด ์ฃผ์‹œ๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.

### Agentic tool use

EXAONE 4.0 ๋ชจ๋ธ์€ ๋„๊ตฌ ์‚ฌ์šฉ ๋Šฅ๋ ฅ์„ ๊ฐ–์ถ˜ ๋•๋ถ„์— Agent๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด์„œ๋Š” ์•„๋ž˜ ์˜ˆ์ œ์™€ ๊ฐ™์ด ๋„๊ตฌ ๋ช…์„ธ๋ฅผ ๋ชจ๋ธ์—๊ฒŒ ์ œ๊ณตํ•ด ์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

```python
import random

def roll_dice(max_num: int):
    return random.randint(1, max_num)

tools = [
    {
        "type": "function",
        "function": {
            "name": "roll_dice",
            "description": "Roll a dice with the number 1 to N. User can select the number N.",
            "parameters": {
                "type": "object",
                "required": ["max_num"],
                "properties": {
                    "max_num": {
                        "type": "int",
                        "description": "Max number of the dice"
                    }
                }
            }
        }
    }
]

messages = [
    {"role": "user", "content": "Roll D6 dice twice!"}
]
input_ids = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_tensors="pt",
    tools=tools,
)

output = model.generate(
    input_ids.to(model.device),
    max_new_tokens=1024,
    do_sample=True,
    temperature=0.6,
    top_p=0.95,
)
print(tokenizer.decode(output[0]))
```

## Exaone4Config

[[autodoc]] Exaone4Config

## Exaone4Model

[[autodoc]] Exaone4Model
    - forward

## Exaone4ForCausalLM

[[autodoc]] Exaone4ForCausalLM
    - forward

## Exaone4ForSequenceClassification

[[autodoc]] Exaone4ForSequenceClassification
    - forward

## Exaone4ForTokenClassification

[[autodoc]] Exaone4ForTokenClassification
    - forward

## Exaone4ForQuestionAnswering

[[autodoc]] Exaone4ForQuestionAnswering
    - forward