Skip to content

Conversation

@SeBorgey
Copy link
Collaborator

No description provided.

@SeBorgey
Copy link
Collaborator Author

  • решить, что делать с дампером
  • странная ошибка с импортом адама

@SeBorgey SeBorgey requested a review from voorhs April 24, 2025 22:18

def __init__(
self,
rnn_config: RNNConfig | str | dict[str, Any] | None = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше делать не так.лусге чтобы все параметры были непосредственными параметрами конструктора. Без этого не будет удобно указывать серч спейс

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


class RNNConfig(BaseModel):
    model_config = ConfigDict(extra="forbid")
    model_name: str = Field("rnn", description="Name of the RNN model.")
    embed_dim: int = Field(128, description="Dimension of word embeddings.")
    hidden_dim: int = Field(512, description="Dimension of hidden states in RNN.")
    n_layers: int = Field(2, description="Number of RNN layers.")
    dropout: float = Field(0.1, description="Dropout rate.")
    device: str = Field(None, description="Torch notation for CPU or CUDA.")
    max_seq_length: int = Field(128, description="Maximum sequence length.")
    padding_idx: int = Field(0, description="Index used for padding.")
    pretrained_embs: Any = Field(None, description="Pretrained embedding weights if available.")
    batch_size: PositiveInt = Field(32, description="Batch size for model inference.")

    @classmethod
    def from_search_config(cls, values: dict[str, Any] | str | BaseModel | None) -> Self:
        if values is None:
            return cls()
        if isinstance(values, BaseModel):
            return values  # type: ignore[return-value]
        if isinstance(values, str):
            return cls(model_name=values)
        return cls(**values)

Я правильно понял, что я должен удалить обратно этот класс, и все параметры продублировать в самом классе везде, где нужно?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тогда init станет очень большим и from_context тоже.
Одни и те же параметры будут перечисляться 3 раза подряд в коде. Сначала в аргументах init, потом в реализации init, затем в аргументах from_context.
ruff запрещает в аргументы функции пихать больше 10 параметров

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в целом верно, если что будем игнорить ошибку ruff, потому что серч спейс важнее

но я вот смотрю, некоторые параметры это не совсем гиперпараметры а действительно конфиг. я бы сделал так:

  • отнести в конфиг: device, max_seq_length, padding_idx
  • отнести в init: embed_dim, hidden_dim, n_layers, dropout
  • убрать: model_name, pretrained_embs

@voorhs
Copy link
Collaborator

voorhs commented Apr 25, 2025

Дампер уже реализован в пр про CNNScorer, но кажется он не работает до конца. Можете обсудить с Лерой и заколлабиться

@SeBorgey SeBorgey requested a review from voorhs April 28, 2025 09:47
@voorhs voorhs merged commit 72cc7dc into dev Jun 18, 2025
21 of 22 checks passed
@voorhs voorhs deleted the rnn_scorer branch June 18, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants