File size: 1,350 Bytes
dfba102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from __future__ import annotations

from typing import Any, Dict, Optional

from transformers import AutoConfig, PretrainedConfig


class OpenThaiSystemOneConfig(PretrainedConfig):
    """Config = a text-tower config (Qwen3.5 text by default) + slot-head settings."""

    model_type = "openthai_systemone"
    sub_configs = {"text_config": AutoConfig}

    def __init__(
        self,
        text_config: Optional[Dict[str, Any] | PretrainedConfig] = None,
        n_slots: int = 256,
        abstain_slot: int = 255,
        answer_token_id: Optional[int] = None,
        head_bias: bool = True,
        n_temperatures: int = 3,  # per question type: choice / score / noul
        **kwargs,
    ):
        if isinstance(text_config, dict):
            text_config = AutoConfig.for_model(**text_config) if "model_type" in text_config else AutoConfig.for_model("qwen3_5_text", **text_config)
        self.text_config = text_config
        self.n_slots = n_slots
        self.abstain_slot = abstain_slot
        self.answer_token_id = answer_token_id
        self.head_bias = head_bias
        self.n_temperatures = n_temperatures
        super().__init__(**kwargs)

    @property
    def hidden_size(self) -> int:
        return self.text_config.hidden_size

    @property
    def vocab_size(self) -> int:
        return self.text_config.vocab_size