File size: 1,750 Bytes
7381480
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
"""Configuration for the SPEV multimodal decision model."""

import math
from typing import ClassVar

from transformers import PretrainedConfig, Qwen3OmniMoeThinkerConfig


class SPEVConfig(PretrainedConfig):
    model_type = "spev"
    sub_configs: ClassVar[dict] = {"thinker_config": Qwen3OmniMoeThinkerConfig}

    def __init__(
        self,
        thinker_config=None,
        adapter_rank=32,
        adapter_alpha=64,
        head_width=256,
        temperature=1.0,
        max_tokens=8192,
        **kwargs,
    ):
        if isinstance(thinker_config, dict):
            thinker_config = Qwen3OmniMoeThinkerConfig(**thinker_config)
        self.thinker_config = thinker_config or Qwen3OmniMoeThinkerConfig()
        for name, value in (
            ("adapter_rank", adapter_rank),
            ("head_width", head_width),
            ("max_tokens", max_tokens),
        ):
            if not isinstance(value, int) or isinstance(value, bool) or value <= 0:
                raise ValueError(f"{name} must be a positive integer")
        if not math.isfinite(adapter_alpha) or adapter_alpha <= 0:
            raise ValueError("adapter_alpha must be positive and finite")
        if not math.isfinite(temperature) or temperature <= 0:
            raise ValueError("temperature must be positive and finite")
        self.adapter_rank = adapter_rank
        self.adapter_alpha = adapter_alpha
        self.head_width = head_width
        self.temperature = temperature
        self.max_tokens = max_tokens
        kwargs.setdefault("tie_word_embeddings", False)
        super().__init__(**kwargs)

    def get_text_config(self, decoder=False, encoder=False):
        return self.thinker_config.text_config


SPEVConfig.register_for_auto_class()