Update modeling_sdar.py (#2)
Browse files- Update modeling_sdar.py (fb3dd55ee5da84e0c564a5201f2ca224a7a7dedd)
123456789101137 unmodified lines49505152535455725 unmodified lines78178278378478578678778878942 unmodified lines832833834835836837838# This file is modified based on https://github.com/huggingface/transformers/blob/v4.52.4/src/transformers/models/qwen3/modeling_qwen3.py.## π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨# This file was automatically generated from src/transformers/models/qwen3/modular_qwen3.py.# Do NOT edit this file manually as any edits will be overwritten by the generation of# the file from the modular. If any change should be done, please apply the change to the# modular_qwen3.py file directly. One of our CI enforces this.# π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨π¨# coding=utf-8# Copyright 2025 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.#37 unmodified linesfrom transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModelfrom transformers.processing_utils import Unpackfrom transformers.utils import (LossKwargs,auto_docstring,can_return_tuple,is_torch_flex_attn_available,725 unmodified linesreturn causal_maskclass KwargsForCausalLM(FlashAttentionKwargs, LossKwargs): ...@auto_docstringclass SDARForCausalLM(SDARPreTrainedModel, GenerationMixin):_tied_weights_keys = ["lm_head.weight"]42 unmodified linesoutput_hidden_states: Optional[bool] = None,cache_position: Optional[torch.LongTensor] = None,logits_to_keep: Union[int, torch.Tensor] = 0,**kwargs: Unpack[KwargsForCausalLM],) -> CausalLMOutputWithPast:r"""labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):1234567837 unmodified lines464748495051725 unmodified lines77777877978078178242 unmodified lines825826827828829830831# SPDX-License-Identifier: MIT# Adapted from https://huggingface.co/Gen-Verse/TraDo-8B-Instruct/blob/main/modeling_sdar.py# This file is modified based on https://github.com/huggingface/transformers/blob/v4.52.4/src/transformers/models/qwen3/modeling_qwen3.py.## coding=utf-8# Copyright 2025 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.#37 unmodified linesfrom transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModelfrom transformers.processing_utils import Unpackfrom transformers.utils import (auto_docstring,can_return_tuple,is_torch_flex_attn_available,725 unmodified linesreturn causal_mask@auto_docstringclass SDARForCausalLM(SDARPreTrainedModel, GenerationMixin):_tied_weights_keys = ["lm_head.weight"]42 unmodified linesoutput_hidden_states: Optional[bool] = None,cache_position: Optional[torch.LongTensor] = None,logits_to_keep: Union[int, torch.Tensor] = 0,**kwargs: dict,) -> CausalLMOutputWithPast:r"""labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
modeling_sdar.py+4-11