# EXAONE

EXAONE bao gồm các mô hình ngôn ngữ [EXAONE 3.0](https://huggingface.co/LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct), [EXAONE 3.5](https://huggingface.co/collections/LGAI-EXAONE/exaone-35) và [EXAONE Deep](https://huggingface.co/collections/LGAI-EXAONE/exaone-deep) do [LG AI Research](https://huggingface.co/LGAI-EXAONE) phát triển. Kiến trúc của chúng giống với [Llama](./llama), nhưng có tên tham số và cấu hình khác nhau.

Các lớp auto nạp chúng với cài đặt Llama ([LlamaModel](/docs/transformers/main/vi/model_doc/llama2#transformers.LlamaModel) và [LlamaForCausalLM](/docs/transformers/main/vi/model_doc/llama2#transformers.LlamaForCausalLM)), do đó chỉ có [ExaoneConfig](/docs/transformers/main/vi/model_doc/exaone#transformers.ExaoneConfig) là đặc thù cho EXAONE. Các checkpoint đã phát hành được đổi tên thành tên Llama khi nạp và đổi lại khi lưu.

Ví dụ dưới đây minh họa cách tạo văn bản bằng lớp [AutoModelForCausalLM](/docs/transformers/main/vi/model_doc/auto#transformers.AutoModelForCausalLM).

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("LGAI-EXAONE/EXAONE-3.5-2.4B-Instruct")
model = AutoModelForCausalLM.from_pretrained("LGAI-EXAONE/EXAONE-3.5-2.4B-Instruct", device_map="auto")

messages = [{"role": "user", "content": "Explain the Pythagorean theorem in one sentence."}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True)
output = model.generate(**inputs.to(model.device), max_new_tokens=64)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1] :], skip_special_tokens=True))
```

## ExaoneConfig[[transformers.ExaoneConfig]]

#### transformers.ExaoneConfig[[transformers.ExaoneConfig]]

```python
transformers.ExaoneConfig(transformers_version: str | None = None, architectures: list[str] | None = None, output_hidden_states: bool | None = False, return_dict: bool | None = True, dtype: str | torch.dtype | None = None, chunk_size_feed_forward: int = 0, is_encoder_decoder: bool = False, id2label: dict[int, str] | dict[str, str] | None = None, label2id: dict[str, int] | dict[str, str] | None = None, problem_type: Literal['regression', 'single_label_classification', 'multi_label_classification'] | None = None, vocab_size: int = 102400, hidden_size: int = 4096, intermediate_size: int = 14336, num_hidden_layers: int = 32, num_attention_heads: int = 32, num_key_value_heads: int | None = 8, hidden_act: str = 'silu', max_position_embeddings: int = 4096, initializer_range: float = 0.02, rms_norm_eps: float = 1e-05, use_cache: bool = True, pad_token_id: int | None = 0, bos_token_id: int | None = 1, eos_token_id: int | list[int] | None = 361, tie_word_embeddings: bool = False, rope_parameters: transformers.modeling_rope_utils.RopeParameters | dict | None = None, attention_bias: bool = False, attention_dropout: int | float | None = 0.0, mlp_bias: bool = False, head_dim: int | None = None)
```

[Nguồn](https://github.com/huggingface/transformers/blob/main/src/transformers/models/exaone/configuration_exaone.py#L31)

**Tham số:**

vocab_size (`int`, *tùy chọn*, mặc định là `102400`) : Kích thước từ vựng của mô hình. Xác định số lượng token khác nhau có thể được biểu diễn bởi `input_ids`.

hidden_size (`int`, *tuỳ chọn*, mặc định là `4096`) : Kích thước của các biểu diễn ẩn.

intermediate_size (`int`, *tuỳ chọn*, mặc định là `14336`) : Kích thước của các biểu diễn MLP.

num_hidden_layers (`int`, *tuỳ chọn*, mặc định là `32`) : Số lượng lớp ẩn trong bộ giải mã Transformer.

num_attention_heads (`int`, *tùy chọn*, mặc định là `32`) : Số lượng đầu chú ý cho mỗi lớp chú ý trong bộ giải mã Transformer.

num_key_value_heads (`int`, *optional*, mặc định là `8`) : Đây là số lượng key_value heads cần được sử dụng để triển khai Grouped Query Attention. Nếu `num_key_value_heads=num_attention_heads`, mô hình sẽ sử dụng Multi Head Attention (MHA), nếu `num_key_value_heads=1` mô hình sẽ sử dụng Multi Query Attention (MQA), ngược lại GQA sẽ được sử dụng. Khi chuyển đổi một checkpoint multi-head sang checkpoint GQA, mỗi nhóm key và value head nên được xây dựng bằng cách meanpooling tất cả các head gốc trong nhóm đó. Để biết thêm chi tiết, hãy xem [bài báo này](https://huggingface.co/papers/2305.13245). Nếu không được chỉ định, giá trị mặc định sẽ là `num_attention_heads`.

hidden_act (`str`, *tùy chọn*, mặc định là `silu`) : Hàm kích hoạt phi tuyến tính (hàm hoặc chuỗi) trong bộ giải mã. Ví dụ, `"gelu"`, `"relu"`, `"silu"`, v.v.

max_position_embeddings (`int`, *tuỳ chọn*, mặc định là `4096`) : Độ dài chuỗi tối đa mà mô hình này có thể được sử dụng.

initializer_range (`float`, *optional*, mặc định là `0.02`) : Độ lệch chuẩn của truncated_normal_initializer để khởi tạo tất cả các ma trận trọng số.

rms_norm_eps (`float`, *tuỳ chọn*, mặc định là `1e-05`) : Epsilon được sử dụng bởi các lớp chuẩn hóa rms.

use_cache (`bool`, *tùy chọn*, mặc định là `True`) : Xác định xem mô hình có nên trả về các chú ý key/values cuối cùng hay không (không được sử dụng bởi tất cả các mô hình). Chỉ liên quan nếu `config.is_decoder=True` hoặc khi mô hình là mô hình sinh chỉ có decoder.

pad_token_id (`int`, *tùy chọn*, mặc định là `0`) : Id của token được sử dụng để đệm (padding) trong từ vựng.

bos_token_id (`int`, *tuỳ chọn*, mặc định là `1`) : Id của token được sử dụng cho đầu luồng (beginning-of-stream) trong từ vựng.

eos_token_id (`Union[int, list[int]]`, *tùy chọn*, mặc định là `361`) : Token id được sử dụng cho end-of-stream trong bảng từ vựng.

tie_word_embeddings (`bool`, *tùy chọn*, mặc định là `False`) : Có nên gắn kết các nhúng trọng số theo ánh xạ `tied_weights_keys` của mô hình hay không.

rope_parameters (`Union[~modeling_rope_utils.RopeParameters, dict]`, *optional*) : Từ điển chứa các tham số cấu hình cho các embedding RoPE. Từ điển phải chứa một giá trị cho `rope_theta` và tùy chọn các tham số được sử dụng để mở rộng trong trường hợp bạn muốn sử dụng RoPE với `max_position_embeddings` dài hơn.

attention_bias (`bool`, *tùy chọn*, mặc định là `False`) : Có sử dụng bias trong các lớp chiếu query, key, value và output trong quá trình tự chú ý hay không.

attention_dropout (`Union[int, float]`, *tùy chọn*, mặc định là `0.0`) : Tỷ lệ dropout cho các xác suất chú ý.

mlp_bias (`bool`, *tùy chọn*, mặc định là `False`) : Có sử dụng bias trong các lớp up_proj, down_proj và gate_proj của các lớp MLP hay không.

head_dim (`int`, *optional*) : Kích thước chiều của đầu chú ý. Nếu là None, giá trị mặc định sẽ là hidden_size // num_attention_heads

Đây là lớp cấu hình để lưu trữ cấu hình của một LlamaModel. Nó được sử dụng để khởi tạo một mô hình Exaone theo các đối số được chỉ định, xác định kiến trúc mô hình. Khởi tạo một cấu hình với các giá trị mặc định sẽ tạo ra một cấu hình tương tự như cấu hình của [LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct](https://huggingface.co/LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct)

Các đối tượng cấu hình kế thừa từ [PreTrainedConfig](/docs/transformers/main/vi/main_classes/configuration#transformers.PreTrainedConfig) và có thể được sử dụng để kiểm soát đầu ra của mô hình. Đọc tài liệu từ [PreTrainedConfig](/docs/transformers/main/vi/main_classes/configuration#transformers.PreTrainedConfig) để biết thêm thông tin.

```python
>>> from transformers import AutoModelForCausalLM, ExaoneConfig

>>> # Initializing an EXAONE-3.0-7.8B style configuration
>>> configuration = ExaoneConfig()

>>> # Initializing a model (which uses the Llama implementation) from that configuration
>>> model = AutoModelForCausalLM.from_config(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```

