LemonDecider / configuration_lemondecider.py
niqun123123's picture
Full sync: LemonDecider 4B v3.2 (submit/LemonDecider-4B-v3.2)
85f8ee9 verified
Raw History Blame Contribute Delete
2.38 kB
"""LemonDecider inference configuration. See LICENSE and NOTICE for attribution."""
import math
from transformers.models.qwen3_5.configuration_qwen3_5 import Qwen3_5Config
class LemonDeciderConfig(Qwen3_5Config):
model_type = 'lemondecider_decision'
def __init__(self, codes=None, token_ids=None, max_options=255, temperature=0.835655,
max_input_length=8192, attention_mode='noncausal_full_attention',
pooling='last', model_id='LemonDecider-4B-v3.2',
inference_protocol=None, **kwargs):
auto_map = kwargs.pop('auto_map', None)
super().__init__(**kwargs)
if attention_mode != 'noncausal_full_attention' or pooling != 'last':
raise ValueError('Unsupported inference configuration')
if type(max_options) is not int or not 1 <= max_options <= 255:
raise ValueError('max_options must be in 1..255')
if not math.isfinite(float(temperature)) or temperature <= 0:
raise ValueError('temperature must be positive and finite')
if type(max_input_length) is not int or max_input_length < 1:
raise ValueError('max_input_length must be positive')
self.codes, self.token_ids = list(codes or []), list(token_ids or [])
if self.codes or self.token_ids:
if (len(self.codes) != max_options or len(self.token_ids) != max_options
or len(set(self.codes)) != max_options or len(set(self.token_ids)) != max_options
or any(type(t) is not int or not 0 <= t < self.text_config.vocab_size for t in self.token_ids)):
raise ValueError('Invalid option code table')
self.max_options = max_options
self.temperature = float(temperature)
self.max_input_length = max_input_length
self.attention_mode, self.pooling = attention_mode, pooling
self.model_id = model_id
self.inference_protocol = inference_protocol or {
'version':1, 'marker':'<|fim_suffix|>', 'read_twice':False, 'twice_max_tokens':3000}
if self.inference_protocol != {
'version':1, 'marker':'<|fim_suffix|>', 'read_twice':False, 'twice_max_tokens':3000}:
raise ValueError('Unsupported inference protocol')
self.text_config.is_causal = False
if auto_map is not None:
self.auto_map = auto_map