Transformers documentation
EXAONE 4.5
This model was released on 2026-04-09 and added to Hugging Face Transformers on 2026-04-30.
EXAONE 4.5
개요
EXAONE 4.5 모델은 LG AI연구원에서 공개한 최초의 오픈 웨이트(open-weight) 비전-자연어 모델(vision-language model)입니다. 전용 비전 인코더를 기존 개발된 EXAONE 4.0 프레임워크에 통합하여 모델의 능력을 비전과 자연어를 고려한 멀티모달리티로 확장했습니다. EXAONE 4.5는 1.2B 크기의 비전 인코더를 포함해 총 33B 크기의 모델로 구성됩니다. EXAONE 4.5는 이전 EXAONE 모델군으로부터 이어져 온 강력한 언어 처리 능력 덕분에 범용 벤치마크에서 경쟁력 있는 성능을 달성함과 동시에, 동등 규모의 최신 SOTA 모델을 능가하는 문서 이해 능력과 한국 문화적 추론 능력을 갖추고 있습니다.
EXAONE 4.5는 EXAONE 4.0을 기반으로 몇 가지 핵심 개선 사항을 적용했습니다. 어휘 크기를 153,600으로 확장했으며, 컨텍스트 윈도우는 최대 256K 토큰까지 지원합니다. 또한 MTP(Multi-Token Prediction) 메커니즘을 도입해 모델 성능을 한층 더 높였습니다.
더 자세한 정보는 기술 보고서, 블로그, 공식 GitHub 페이지를 참고해 주세요.
양자화된 버전을 포함한 공개된 모든 체크포인트는 Huggingface 콜렉션에서 확인할 수 있습니다.
사용 팁
기대한 성능을 얻기 위해 다음 설정 사용을 권장합니다.
- 범용 용도로는
temperature=1.0,top_p=0.95,presence_penalty=1.5를 권장합니다.- OCR/문서 관련 작업과 한국어 입력에는
temperature=0.6,top_p=0.95,presence_penalty=1.5,top_k=20을 권장합니다.- 텍스트 전용 입력에는
temperature=1.0,top_p=0.95를 권장합니다.- EXAONE-4.0과 달리 EXAONE 4.5는 기본값으로
enable_thinking=True를 사용합니다. 따라서 non-reasoning 모드를 사용할 때는enable_thinking=False로 설정해야 합니다.- EXAONE 4.5는 질문에 답할 때
\boxed{}형식을 선호합니다. 파싱 정확도를 높이려면 해당 형식 지시문과 함께 사용하는 것을 권장합니다.
정확한 결과가 중요한 작업에서는 EXAONE 4.5 모델을 reasoning 모드로 실행할 수 있습니다. 반면에 지연 시간이 정확도보다 중요한 작업에서는 EXAONE 4.5 모델을 non-reasoning 모드로 실행할 수 있습니다.
다음은 EXAONE 4.5 모델을 reasoning 모드로 사용하는 예제 코드입니다.
import torch
from transformers import AutoProcessor, AutoModelForImageTextToText
from transformers.image_utils import load_image
model_id = "LGAI-EXAONE/EXAONE-4.5-33B"
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForImageTextToText.from_pretrained(
model_id,
device_map="auto",
)
image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"
image = load_image(image_url)
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image_url},
{"type": "text", "text": "이 이미지를 설명해 줘."},
],
}
]
text = processor.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=True, # default: True
)
inputs = processor(
text=[text],
images=[image],
padding=True,
return_tensors="pt",
)
inputs = inputs.to(model.device)
generated_ids = model.generate(**inputs, max_new_tokens=64)
generated_text = processor.batch_decode(
generated_ids[:, inputs["input_ids"].shape[-1]:],
skip_special_tokens=True,
)[0]
print(generated_text)Exaone4_5_Config
class transformers.Exaone4_5_Config
< source >( transformers_version: str | None = None architectures: list[str] | None = None output_hidden_states: bool | None = False return_dict: bool | None = True dtype: typing.Union[str, ForwardRef('torch.dtype'), NoneType] = 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: typing.Optional[typing.Literal['regression', 'single_label_classification', 'multi_label_classification']] = None text_config: dict | transformers.configuration_utils.PreTrainedConfig | None = None vision_config: dict | transformers.configuration_utils.PreTrainedConfig | None = None image_token_id: int = 67 video_token_id: int = 68 tie_word_embeddings: bool = False )
Parameters
- text_config (
Union[dict, ~configuration_utils.PreTrainedConfig], optional) — The config object or dictionary of the text backbone. - vision_config (
Union[dict, ~configuration_utils.PreTrainedConfig], optional) — The config object or dictionary of the vision backbone. - image_token_id (
int, optional, defaults to67) — The image token index used as a placeholder for input images. - video_token_id (
int, optional, defaults to68) — The video token index used as a placeholder for input videos. - tie_word_embeddings (
bool, optional, defaults toFalse) — Whether to tie weight embeddings according to model’stied_weights_keysmapping.
This is the configuration class to store the configuration of a Exaone4_5_Model. It is used to instantiate a Exaone4 5 model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of the LGAI-EXAONE/EXAONE-4.5-33B
Configuration objects inherit from PreTrainedConfig and can be used to control the model outputs. Read the documentation from PreTrainedConfig for more information.
Exaone4_5_VisionConfig
class transformers.Exaone4_5_VisionConfig
< source >( transformers_version: str | None = None architectures: list[str] | None = None output_hidden_states: bool | None = False return_dict: bool | None = True dtype: typing.Union[str, ForwardRef('torch.dtype'), NoneType] = 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: typing.Optional[typing.Literal['regression', 'single_label_classification', 'multi_label_classification']] = None depth: int = 32 hidden_size: int = 3584 hidden_act: str = 'silu' intermediate_size: int = 3420 num_heads: int = 16 in_channels: int = 3 patch_size: int | list[int] | tuple[int, int] = 14 spatial_merge_size: int = 2 temporal_patch_size: int | list[int] | tuple[int, int] = 2 tokens_per_second: int = 4 window_size: int = 112 out_hidden_size: int = 3584 fullatt_block_indexes: list[int] | tuple[int, ...] = (7, 15, 23, 31) initializer_range: float = 0.02 num_key_value_heads: int = 8 )
Parameters
- depth (
int, optional, defaults to32) — Number of Transformer layers in the vision encoder. - hidden_size (
int, optional, defaults to3584) — Dimension of the hidden representations. - hidden_act (
str, optional, defaults tosilu) — The non-linear activation function (function or string) in the decoder. For example,"gelu","relu","silu", etc. - intermediate_size (
int, optional, defaults to3420) — Dimension of the MLP representations. - num_heads (
int, optional, defaults to16) — Number of attention heads for each attention layer in the Transformer decoder. - in_channels (
int, optional, defaults to3) — The number of input channels. - patch_size (
Union[int, list[int], tuple[int, int]], optional, defaults to14) — The size (resolution) of each patch. - spatial_merge_size (
int, optional, defaults to2) — The size of the spatial merge window used to reduce the number of visual tokens by merging neighboring patches. - temporal_patch_size (
Union[int, list[int], tuple[int, int]], optional, defaults to2) — Temporal patch size used in the 3D patch embedding for video inputs. - tokens_per_second (
int, optional, defaults to 41) — Number of tokens to merge for each second of video. - window_size (
int, optional, defaults to 11) — Size of windows. - out_hidden_size (
int, optional, defaults to 3584) — The output hidden size of the vision model. - fullatt_block_indexes (
int, optional, defaults to[7, 15, 23, 31]) — Indices of layers with full attention - initializer_range (
float, optional, defaults to0.02) — The standard deviation of the truncated_normal_initializer for initializing all weight matrices. - num_key_value_heads (
int, optional, defaults to8) — This is the number of key_value heads that should be used to implement Grouped Query Attention. Ifnum_key_value_heads=num_attention_heads, the model will use Multi Head Attention (MHA), ifnum_key_value_heads=1the model will use Multi Query Attention (MQA) otherwise GQA is used. When converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed by meanpooling all the original heads within that group. For more details, check out this paper. If it is not specified, will default tonum_attention_heads.
This is the configuration class to store the configuration of a Exaone4_5_Model. It is used to instantiate a Exaone4 5 model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar configuration to that of the LGAI-EXAONE/EXAONE-4.5-33B
Configuration objects inherit from PreTrainedConfig and can be used to control the model outputs. Read the documentation from PreTrainedConfig for more information.
Exaone4_5_Processor
class transformers.Exaone4_5_Processor
< source >( image_processor = None tokenizer = None video_processor = None chat_template = None **kwargs )
Parameters
- image_processor (
Qwen2VLImageProcessor) — The image processor is a required input. - tokenizer (
tokenizer_class) — The tokenizer is a required input. - video_processor (
Qwen2VLVideoProcessor) — The video processor is a required input. - chat_template (
str) — A Jinja template to convert lists of messages in a chat into a tokenizable string.
Constructs a Exaone4_5_Processor which wraps a image processor, a tokenizer, and a video processor into a single processor.
Exaone4_5_Processor offers all the functionalities of Qwen2VLImageProcessor, tokenizer_class, and Qwen2VLVideoProcessor. See the
~Qwen2VLImageProcessor, ~tokenizer_class, and ~Qwen2VLVideoProcessor for more information.
post_process_image_text_to_text
< source >( generated_outputs skip_special_tokens = True clean_up_tokenization_spaces = False **kwargs ) → list[str]
Parameters
- generated_outputs (
torch.Tensorornp.ndarray) — The output of the modelgeneratefunction. The output is expected to be a tensor of shape(batch_size, sequence_length)or(sequence_length,). - skip_special_tokens (
bool, optional, defaults toTrue) — Whether or not to remove special tokens in the output. Argument passed to the tokenizer’sbatch_decodemethod. - clean_up_tokenization_spaces (
bool, optional, defaults toFalse) — Whether or not to clean up the tokenization spaces. Argument passed to the tokenizer’sbatch_decodemethod. - **kwargs —
Additional arguments to be passed to the tokenizer’s
batch_decode method.
Returns
list[str]
The decoded text.
Post-process the output of the model to decode the text.
Exaone4_5_VisionModel
class transformers.Exaone4_5_VisionModel
< source >( config: Exaone4_5_VisionConfig *inputs **kwargs )
forward
< source >( hidden_states: Tensor grid_thw: Tensor **kwargs: typing_extensions.Unpack[transformers.utils.generic.TransformersKwargs] ) → torch.Tensor
Exaone4_5_Model
class transformers.Exaone4_5_Model
< source >( config: Exaone4_5_Config )
Parameters
- config (Exaone4_5_Config) — Model configuration class with all the parameters of the model. Initializing with a config file does not load the weights associated with the model, only the configuration. Check out the from_pretrained() method to load the model weights.
The bare Exaone4 5 Model outputting raw hidden-states without any specific head on top.
This model inherits from PreTrainedModel. Check the superclass documentation for the generic methods the library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads etc.)
This model is also a PyTorch torch.nn.Module subclass. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and behavior.
forward
< source >( input_ids: torch.LongTensor | None = None attention_mask: torch.Tensor | None = None position_ids: torch.LongTensor | None = None past_key_values: transformers.cache_utils.Cache | None = None inputs_embeds: torch.FloatTensor | None = None use_cache: bool | None = None pixel_values: torch.Tensor | None = None pixel_values_videos: torch.FloatTensor | None = None image_grid_thw: torch.LongTensor | None = None video_grid_thw: torch.LongTensor | None = None second_per_grid_ts: torch.Tensor | None = None **kwargs: typing_extensions.Unpack[transformers.utils.generic.TransformersKwargs] ) → BaseModelOutputWithPast or tuple(torch.FloatTensor)
Parameters
- input_ids (
torch.LongTensorof shape(batch_size, sequence_length), optional) — Indices of input sequence tokens in the vocabulary. Padding will be ignored by default.Indices can be obtained using AutoTokenizer. See PreTrainedTokenizer.encode() and PreTrainedTokenizer.call() for details.
- attention_mask (
torch.Tensorof shape(batch_size, sequence_length), optional) — Mask to avoid performing attention on padding token indices. Mask values selected in[0, 1]:- 1 for tokens that are not masked,
- 0 for tokens that are masked.
- position_ids (
torch.LongTensorof shape(batch_size, sequence_length), optional) — Indices of positions of each input sequence tokens in the position embeddings. Selected in the range[0, config.n_positions - 1]. - past_key_values (
~cache_utils.Cache, optional) — Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention blocks) that can be used to speed up sequential decoding. This typically consists in thepast_key_valuesreturned by the model at a previous stage of decoding, whenuse_cache=Trueorconfig.use_cache=True.Only Cache instance is allowed as input, see our kv cache guide. If no
past_key_valuesare passed, DynamicCache will be initialized by default.The model will output the same cache format that is fed as input.
If
past_key_valuesare used, the user is expected to input only unprocessedinput_ids(those that don’t have their past key value states given to this model) of shape(batch_size, unprocessed_length)instead of allinput_idsof shape(batch_size, sequence_length). - inputs_embeds (
torch.FloatTensorof shape(batch_size, sequence_length, hidden_size), optional) — Optionally, instead of passinginput_idsyou can choose to directly pass an embedded representation. This is useful if you want more control over how to convertinput_idsindices into associated vectors than the model’s internal embedding lookup matrix. - use_cache (
bool, optional) — If set toTrue,past_key_valueskey value states are returned and can be used to speed up decoding (seepast_key_values). - pixel_values (
torch.Tensorof shape(batch_size, num_channels, image_size, image_size), optional) — The tensors corresponding to the input images. Pixel values can be obtained using Qwen2VLImageProcessor. SeeQwen2VLImageProcessor.__call__()for details (Exaone4_5_Processor uses Qwen2VLImageProcessor for processing images). - pixel_values_videos (
torch.FloatTensorof shape(batch_size, num_frames, num_channels, frame_size, frame_size), optional) — The tensors corresponding to the input video. Pixel values for videos can be obtained usingQwen2VLVideoProcessor. SeeQwen2VLVideoProcessor.__call__()for details (Exaone4_5_Processor usesQwen2VLVideoProcessorfor processing videos). - image_grid_thw (
torch.LongTensorof shape(num_images, 3), optional) — The temporal, height and width of feature shape of each image in LLM. - video_grid_thw (
torch.LongTensorof shape(num_videos, 3), optional) — The temporal, height and width of feature shape of each video in LLM. - second_per_grid_ts (
torch.Tensorof shape(num_videos), optional) — The time interval (in seconds) for each grid along the temporal dimension in the 3D position IDs.
Returns
BaseModelOutputWithPast or tuple(torch.FloatTensor)
A BaseModelOutputWithPast or a tuple of
torch.FloatTensor (if return_dict=False is passed or when config.return_dict=False) comprising various
elements depending on the configuration (Exaone4_5_Config) and inputs.
The Exaone4_5_Model forward method, overrides the __call__ special method.
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the pre and post processing steps while the latter silently ignores them.
last_hidden_state (
torch.FloatTensorof shape(batch_size, sequence_length, hidden_size)) — Sequence of hidden-states at the output of the last layer of the model.If
past_key_valuesis used only the last hidden-state of the sequences of shape(batch_size, 1, hidden_size)is output.past_key_values (
Cache, optional, returned whenuse_cache=Trueis passed or whenconfig.use_cache=True) — It is a Cache instance. For more details, see our kv cache guide.Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
config.is_encoder_decoder=Truein the cross-attention blocks) that can be used (seepast_key_valuesinput) to speed up sequential decoding.hidden_states (
tuple(torch.FloatTensor), optional, returned whenoutput_hidden_states=Trueis passed or whenconfig.output_hidden_states=True) — Tuple oftorch.FloatTensor(one for the output of the embeddings, if the model has an embedding layer, + one for the output of each layer) of shape(batch_size, sequence_length, hidden_size).Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
attentions (
tuple(torch.FloatTensor), optional, returned whenoutput_attentions=Trueis passed or whenconfig.output_attentions=True) — Tuple oftorch.FloatTensor(one for each layer) of shape(batch_size, num_heads, sequence_length, sequence_length).Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Exaone4_5_ForConditionalGeneration
Main EXAONE 4.5 conditional generation class.
Note: Unlike Qwen2VL, the EXAONE 4.5 vision encoder uses 2D rotary positional embeddings (2D-RoPE) and adopts a Grouped Query Attention (GQA) structure throughout the multimodal stack.
forward
< source >( input_ids: torch.LongTensor | None = None attention_mask: torch.Tensor | None = None position_ids: torch.LongTensor | None = None past_key_values: transformers.cache_utils.Cache | None = None inputs_embeds: torch.FloatTensor | None = None labels: torch.LongTensor | None = None use_cache: bool | None = None pixel_values: torch.Tensor | None = None pixel_values_videos: torch.FloatTensor | None = None image_grid_thw: torch.LongTensor | None = None video_grid_thw: torch.LongTensor | None = None second_per_grid_ts: torch.Tensor | None = None logits_to_keep: int | torch.Tensor = 0 **kwargs: typing_extensions.Unpack[transformers.utils.generic.TransformersKwargs] ) → CausalLMOutputWithPast or tuple(torch.FloatTensor)
Parameters
- input_ids (
torch.LongTensorof shape(batch_size, sequence_length), optional) — Indices of input sequence tokens in the vocabulary. Padding will be ignored by default.Indices can be obtained using AutoTokenizer. See PreTrainedTokenizer.encode() and PreTrainedTokenizer.call() for details.
- attention_mask (
torch.Tensorof shape(batch_size, sequence_length), optional) — Mask to avoid performing attention on padding token indices. Mask values selected in[0, 1]:- 1 for tokens that are not masked,
- 0 for tokens that are masked.
- position_ids (
torch.LongTensorof shape(batch_size, sequence_length), optional) — Indices of positions of each input sequence tokens in the position embeddings. Selected in the range[0, config.n_positions - 1]. - past_key_values (
~cache_utils.Cache, optional) — Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention blocks) that can be used to speed up sequential decoding. This typically consists in thepast_key_valuesreturned by the model at a previous stage of decoding, whenuse_cache=Trueorconfig.use_cache=True.Only Cache instance is allowed as input, see our kv cache guide. If no
past_key_valuesare passed, DynamicCache will be initialized by default.The model will output the same cache format that is fed as input.
If
past_key_valuesare used, the user is expected to input only unprocessedinput_ids(those that don’t have their past key value states given to this model) of shape(batch_size, unprocessed_length)instead of allinput_idsof shape(batch_size, sequence_length). - inputs_embeds (
torch.FloatTensorof shape(batch_size, sequence_length, hidden_size), optional) — Optionally, instead of passinginput_idsyou can choose to directly pass an embedded representation. This is useful if you want more control over how to convertinput_idsindices into associated vectors than the model’s internal embedding lookup matrix. - labels (
torch.LongTensorof shape(batch_size, sequence_length), optional) — Labels for computing the masked language modeling loss. Indices should either be in[0, ..., config.vocab_size]or -100 (seeinput_idsdocstring). Tokens with indices set to-100are ignored (masked), the loss is only computed for the tokens with labels in[0, ..., config.vocab_size]. - use_cache (
bool, optional) — If set toTrue,past_key_valueskey value states are returned and can be used to speed up decoding (seepast_key_values). - pixel_values (
torch.Tensorof shape(batch_size, num_channels, image_size, image_size), optional) — The tensors corresponding to the input images. Pixel values can be obtained using Qwen2VLImageProcessor. SeeQwen2VLImageProcessor.__call__()for details (Exaone4_5_Processor uses Qwen2VLImageProcessor for processing images). - pixel_values_videos (
torch.FloatTensorof shape(batch_size, num_frames, num_channels, frame_size, frame_size), optional) — The tensors corresponding to the input video. Pixel values for videos can be obtained usingQwen2VLVideoProcessor. SeeQwen2VLVideoProcessor.__call__()for details (Exaone4_5_Processor usesQwen2VLVideoProcessorfor processing videos). - image_grid_thw (
torch.LongTensorof shape(num_images, 3), optional) — The temporal, height and width of feature shape of each image in LLM. - video_grid_thw (
torch.LongTensorof shape(num_videos, 3), optional) — The temporal, height and width of feature shape of each video in LLM. - second_per_grid_ts (
torch.Tensorof shape(num_videos), optional) — The time interval (in seconds) for each grid along the temporal dimension in the 3D position IDs. - logits_to_keep (
Union[int, torch.Tensor], optional, defaults to0) — If anint, compute logits for the lastlogits_to_keeptokens. If0, calculate logits for allinput_ids(special case). Only last token logits are needed for generation, and calculating them only for that token can save memory, which becomes pretty significant for long sequences or large vocabulary size. If atorch.Tensor, must be 1D corresponding to the indices to keep in the sequence length dimension. This is useful when using packed tensor format (single dimension for batch and sequence length).
Returns
CausalLMOutputWithPast or tuple(torch.FloatTensor)
A CausalLMOutputWithPast or a tuple of
torch.FloatTensor (if return_dict=False is passed or when config.return_dict=False) comprising various
elements depending on the configuration (Exaone4_5_Config) and inputs.
The Exaone4_5_ForConditionalGeneration forward method, overrides the __call__ special method.
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the pre and post processing steps while the latter silently ignores them.
loss (
torch.FloatTensorof shape(1,), optional, returned whenlabelsis provided) — Language modeling loss (for next-token prediction).logits (
torch.FloatTensorof shape(batch_size, sequence_length, config.vocab_size)) — Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).past_key_values (
Cache, optional, returned whenuse_cache=Trueis passed or whenconfig.use_cache=True) — It is a Cache instance. For more details, see our kv cache guide.Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
past_key_valuesinput) to speed up sequential decoding.hidden_states (
tuple(torch.FloatTensor), optional, returned whenoutput_hidden_states=Trueis passed or whenconfig.output_hidden_states=True) — Tuple oftorch.FloatTensor(one for the output of the embeddings, if the model has an embedding layer, + one for the output of each layer) of shape(batch_size, sequence_length, hidden_size).Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
attentions (
tuple(torch.FloatTensor), optional, returned whenoutput_attentions=Trueis passed or whenconfig.output_attentions=True) — Tuple oftorch.FloatTensor(one for each layer) of shape(batch_size, num_heads, sequence_length, sequence_length).Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Example:
>>> from transformers import AutoProcessor, Exaone4_5_ForConditionalGeneration
>>> import torch
>>> model = Exaone4_5_ForConditionalGeneration.from_pretrained("LGAI-EXAONE/EXAONE-4.5-33B")
>>> processor = AutoProcessor.from_pretrained("LGAI-EXAONE/EXAONE-4.5-33B")
>>> messages = [
... {
... "role": "user",
... "content": [
... {"type": "image", "image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
... {"type": "text", "text": "Describe the image."},
... ],
... }
... ]
>>> inputs = processor.apply_chat_template(
... messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt"
... )
>>> inputs = {k: v.to(model.device) if isinstance(v, torch.Tensor) else v for k, v in inputs.items()}
>>> generated_ids = model.generate(**inputs, max_new_tokens=64)