Datasets:
Download sources/tiny/src/compact_fact_extraction/factsetnet/config.py from Monyzik/compactfact-training-data: direct link, hf CLI and curl.
- Browser
- Download file 1.95 kB
-
https://huggingface.co/datasets/Monyzik/compactfact-training-data/resolve/main/sources/tiny/src/compact_fact_extraction/factsetnet/config.py
- Command line
-
hf download hf://datasets/Monyzik/compactfact-training-data/sources/tiny/src/compact_fact_extraction/factsetnet/config.py
-
curl -L -o config.py https://huggingface.co/datasets/Monyzik/compactfact-training-data/resolve/main/sources/tiny/src/compact_fact_extraction/factsetnet/config.py
1.95 kB
| """Serializable architecture settings shared by training and inference.""" | |
| from dataclasses import asdict, dataclass | |
| class ModelConfig: | |
| backbone: str = "ai-forever/ruBert-base" | |
| hidden_size: int = 256 | |
| attention_heads: int = 8 | |
| decoder_layers: int = 2 | |
| queries: int = 16 | |
| max_length: int = 512 | |
| overlap: int = 128 | |
| dropout: float = 0.1 | |
| temporal_spans: bool = False | |
| date_candidate_pool: str = "legacy" | |
| date_encoder: str = "linear" | |
| date_span_features: bool = True | |
| def __post_init__(self): | |
| if self.hidden_size <= 0 or self.attention_heads <= 0: | |
| raise ValueError("Hidden size and attention heads must be positive") | |
| if self.hidden_size % self.attention_heads: | |
| raise ValueError("Hidden size must be divisible by attention heads") | |
| if not 0 <= self.overlap < self.max_length - 2: | |
| raise ValueError("Overlap must fit within the token window") | |
| if self.queries < 1 or self.decoder_layers < 1: | |
| raise ValueError("Queries and decoder layers must be positive") | |
| if not 0 <= self.dropout < 1: | |
| raise ValueError("Dropout must be in [0, 1)") | |
| if self.date_candidate_pool not in {"legacy", "extended"}: | |
| raise ValueError("date_candidate_pool must be legacy or extended") | |
| if self.date_encoder not in {"linear", "nonlinear"}: | |
| raise ValueError("date_encoder must be linear or nonlinear") | |
| def to_dict(self): | |
| return asdict(self) | |
| VARIANTS = { | |
| "tiny": ModelConfig( | |
| backbone="cointegrated/rubert-tiny2", hidden_size=192, | |
| attention_heads=6, decoder_layers=1, | |
| ), | |
| "base": ModelConfig(), | |
| "large": ModelConfig( | |
| backbone="ai-forever/ruRoberta-large", hidden_size=384, | |
| ), | |
| } | |
| ATTRIBUTES = ("service_state", "tariff", "ticket_status", "action", "agreement") | |
| OBJECT_TYPES = ("service", "device", "ticket", "client") | |