Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/source/en/model_doc/olmo.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,8 @@ print(tokenizer.decode(output[0]))

[[autodoc]] OlmoForCausalLM
- forward

## OlmoForSequenceClassification

[[autodoc]] OlmoForSequenceClassification
- forward
5 changes: 5 additions & 0 deletions docs/source/en/model_doc/olmo2.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,8 @@ print(tokenizer.decode(output[0], skip_special_tokens=True))

[[autodoc]] Olmo2ForCausalLM
- forward

## Olmo2ForSequenceClassification

[[autodoc]] Olmo2ForSequenceClassification
- forward
5 changes: 5 additions & 0 deletions docs/source/en/model_doc/olmo3.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ print(tokenizer.decode(output[0], skip_special_tokens=True))

[[autodoc]] Olmo3ForCausalLM

## Olmo3ForSequenceClassification

[[autodoc]] Olmo3ForSequenceClassification
- forward

## Olmo3Model

[[autodoc]] Olmo3Model
Expand Down
3 changes: 3 additions & 0 deletions src/transformers/models/auto/modeling_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,9 @@ class _BaseModelWithGenerate(PreTrainedModel, GenerationMixin):
("nemotron", "NemotronForSequenceClassification"),
("nomic_bert", "NomicBertForSequenceClassification"),
("nystromformer", "NystromformerForSequenceClassification"),
("olmo", "OlmoForSequenceClassification"),
("olmo2", "Olmo2ForSequenceClassification"),
("olmo3", "Olmo3ForSequenceClassification"),
("openai-gpt", "OpenAIGPTForSequenceClassification"),
("opt", "OPTForSequenceClassification"),
("perceiver", "PerceiverForSequenceClassification"),
Expand Down
8 changes: 6 additions & 2 deletions src/transformers/models/olmo/modeling_olmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from ...generation import GenerationMixin
from ...integrations import use_kernelized_func
from ...masking_utils import create_causal_mask
from ...modeling_layers import GradientCheckpointingLayer
from ...modeling_layers import GenericForSequenceClassification, GradientCheckpointingLayer
from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
from ...modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
Expand Down Expand Up @@ -496,4 +496,8 @@ def forward(
)


__all__ = ["OlmoForCausalLM", "OlmoModel", "OlmoPreTrainedModel"]
class OlmoForSequenceClassification(GenericForSequenceClassification, OlmoPreTrainedModel):
pass


__all__ = ["OlmoForCausalLM", "OlmoForSequenceClassification", "OlmoModel", "OlmoPreTrainedModel"]
6 changes: 6 additions & 0 deletions src/transformers/models/olmo/modular_olmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
LlamaAttention,
LlamaDecoderLayer,
LlamaForCausalLM,
LlamaForSequenceClassification,
LlamaMLP,
LlamaModel,
LlamaRotaryEmbedding,
Expand Down Expand Up @@ -182,8 +183,13 @@ class OlmoForCausalLM(LlamaForCausalLM):
pass


class OlmoForSequenceClassification(LlamaForSequenceClassification):
pass


__all__ = [
"OlmoForCausalLM",
"OlmoForSequenceClassification",
"OlmoModel",
"OlmoPreTrainedModel", # noqa: F822
]
8 changes: 6 additions & 2 deletions src/transformers/models/olmo2/modeling_olmo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from ...generation import GenerationMixin
from ...integrations import use_kernel_forward_from_hub, use_kernelized_func
from ...masking_utils import create_causal_mask
from ...modeling_layers import GradientCheckpointingLayer
from ...modeling_layers import GenericForSequenceClassification, GradientCheckpointingLayer
from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
from ...modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
Expand Down Expand Up @@ -500,4 +500,8 @@ def forward(
)


__all__ = ["Olmo2ForCausalLM", "Olmo2Model", "Olmo2PreTrainedModel"]
class Olmo2ForSequenceClassification(GenericForSequenceClassification, Olmo2PreTrainedModel):
pass


__all__ = ["Olmo2ForCausalLM", "Olmo2ForSequenceClassification", "Olmo2Model", "Olmo2PreTrainedModel"]
6 changes: 6 additions & 0 deletions src/transformers/models/olmo2/modular_olmo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
OlmoAttention,
OlmoDecoderLayer,
OlmoForCausalLM,
OlmoForSequenceClassification,
OlmoModel,
OlmoRotaryEmbedding,
apply_rotary_pos_emb,
Expand Down Expand Up @@ -222,9 +223,14 @@ class Olmo2ForCausalLM(OlmoForCausalLM):
pass


class Olmo2ForSequenceClassification(OlmoForSequenceClassification):
pass


__all__ = [
"Olmo2Config",
"Olmo2ForCausalLM",
"Olmo2ForSequenceClassification",
"Olmo2Model",
"Olmo2PreTrainedModel",
]
8 changes: 6 additions & 2 deletions src/transformers/models/olmo3/modeling_olmo3.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from ...generation import GenerationMixin
from ...integrations import use_kernel_forward_from_hub, use_kernelized_func
from ...masking_utils import create_causal_mask, create_sliding_window_causal_mask
from ...modeling_layers import GradientCheckpointingLayer
from ...modeling_layers import GenericForSequenceClassification, GradientCheckpointingLayer
from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
from ...modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
Expand Down Expand Up @@ -504,4 +504,8 @@ def forward(
)


__all__ = ["Olmo3ForCausalLM", "Olmo3Model", "Olmo3PreTrainedModel"]
class Olmo3ForSequenceClassification(GenericForSequenceClassification, Olmo3PreTrainedModel):
pass


__all__ = ["Olmo3ForCausalLM", "Olmo3ForSequenceClassification", "Olmo3Model", "Olmo3PreTrainedModel"]
6 changes: 6 additions & 0 deletions src/transformers/models/olmo3/modular_olmo3.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
Olmo2Attention,
Olmo2DecoderLayer,
Olmo2ForCausalLM,
Olmo2ForSequenceClassification,
Olmo2Model,
Olmo2PreTrainedModel,
Olmo2RMSNorm,
Expand Down Expand Up @@ -237,9 +238,14 @@ class Olmo3ForCausalLM(Olmo2ForCausalLM):
pass


class Olmo3ForSequenceClassification(Olmo2ForSequenceClassification):
pass


__all__ = [
"Olmo3Config",
"Olmo3ForCausalLM",
"Olmo3ForSequenceClassification",
"Olmo3Model",
"Olmo3PreTrainedModel",
]
5 changes: 4 additions & 1 deletion tests/models/olmo/test_modeling_olmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

from transformers import (
OlmoForCausalLM,
OlmoForSequenceClassification,
OlmoModel,
)

Expand Down Expand Up @@ -161,11 +162,13 @@ def prepare_config_and_inputs_for_common(self):

@require_torch
class OlmoModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin, unittest.TestCase):
all_model_classes = (OlmoModel, OlmoForCausalLM) if is_torch_available() else ()
all_model_classes = (OlmoModel, OlmoForCausalLM, OlmoForSequenceClassification) if is_torch_available() else ()
pipeline_model_mapping = (
{
"feature-extraction": OlmoModel,
"text-generation": OlmoForCausalLM,
"text-classification": OlmoForSequenceClassification,
"zero-shot": OlmoForSequenceClassification,
}
if is_torch_available()
else {}
Expand Down
5 changes: 4 additions & 1 deletion tests/models/olmo2/test_modeling_olmo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

from transformers import (
Olmo2ForCausalLM,
Olmo2ForSequenceClassification,
Olmo2Model,
)

Expand Down Expand Up @@ -162,11 +163,13 @@ def prepare_config_and_inputs_for_common(self):

@require_torch
class Olmo2ModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin, unittest.TestCase):
all_model_classes = (Olmo2Model, Olmo2ForCausalLM) if is_torch_available() else ()
all_model_classes = (Olmo2Model, Olmo2ForCausalLM, Olmo2ForSequenceClassification) if is_torch_available() else ()
pipeline_model_mapping = (
{
"feature-extraction": Olmo2Model,
"text-generation": Olmo2ForCausalLM,
"text-classification": Olmo2ForSequenceClassification,
"zero-shot": Olmo2ForSequenceClassification,
}
if is_torch_available()
else {}
Expand Down
2 changes: 2 additions & 0 deletions tests/models/olmo3/test_modeling_olmo3.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

from transformers import (
Olmo3ForCausalLM,
Olmo3ForSequenceClassification,
Olmo3Model,
)
from transformers.models.olmo3.modeling_olmo3 import Olmo3RotaryEmbedding
Expand All @@ -46,6 +47,7 @@
class Olmo3ModelTester(CausalLMModelTester):
if is_torch_available():
base_model_class = Olmo3Model
sequence_classification_class = Olmo3ForSequenceClassification


@require_torch
Expand Down
Loading