Update configuration
Browse files- configuration_dlm.py +57 -0
configuration_dlm.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import PretrainedConfig, AutoConfig
|
| 2 |
+
|
| 3 |
+
class DiscreteDiffusionConfig(PretrainedConfig):
|
| 4 |
+
model_type = "discrete_diffusion"
|
| 5 |
+
|
| 6 |
+
def __init__(
|
| 7 |
+
self,
|
| 8 |
+
backbone_config=None,
|
| 9 |
+
num_diffusion_timesteps=50,
|
| 10 |
+
diffusion_type="absorbing",
|
| 11 |
+
attention_strategy="full",
|
| 12 |
+
vocab_pad_to_multiple=1,
|
| 13 |
+
lora=False,
|
| 14 |
+
lora_target_modules=["query", "value"],
|
| 15 |
+
lora_alpha=16,
|
| 16 |
+
lora_rank=16,
|
| 17 |
+
lora_bias="none",
|
| 18 |
+
lora_dropout=0,
|
| 19 |
+
mask_token_id=None,
|
| 20 |
+
bos_token_id=None,
|
| 21 |
+
eos_token_id=None,
|
| 22 |
+
pad_token_id=None,
|
| 23 |
+
argmax_decoding=True, # Default to True for deterministic inference
|
| 24 |
+
**kwargs
|
| 25 |
+
):
|
| 26 |
+
super().__init__(**kwargs)
|
| 27 |
+
self.backbone_config = backbone_config
|
| 28 |
+
self.num_diffusion_timesteps = num_diffusion_timesteps
|
| 29 |
+
self.diffusion_type = diffusion_type
|
| 30 |
+
self.attention_strategy = attention_strategy
|
| 31 |
+
self.vocab_pad_to_multiple = vocab_pad_to_multiple
|
| 32 |
+
self.lora = lora
|
| 33 |
+
self.lora_target_modules = lora_target_modules
|
| 34 |
+
self.lora_alpha = lora_alpha
|
| 35 |
+
self.lora_rank = lora_rank
|
| 36 |
+
self.lora_bias = lora_bias
|
| 37 |
+
self.lora_dropout = lora_dropout
|
| 38 |
+
self.mask_token_id = mask_token_id
|
| 39 |
+
self.bos_token_id = bos_token_id
|
| 40 |
+
self.eos_token_id = eos_token_id
|
| 41 |
+
self.pad_token_id = pad_token_id
|
| 42 |
+
self.argmax_decoding = argmax_decoding
|
| 43 |
+
|
| 44 |
+
if backbone_config is None:
|
| 45 |
+
self.backbone_config = AutoConfig.from_pretrained("FacebookAI/xlm-roberta-large").to_dict()
|
| 46 |
+
elif isinstance(backbone_config, PretrainedConfig):
|
| 47 |
+
self.backbone_config = backbone_config.to_dict()
|
| 48 |
+
else:
|
| 49 |
+
self.backbone_config = backbone_config
|
| 50 |
+
|
| 51 |
+
# Expose backbone attributes
|
| 52 |
+
self.hidden_size = self.backbone_config.get("hidden_size", 1024)
|
| 53 |
+
self.num_attention_heads = self.backbone_config.get("num_attention_heads", 16)
|
| 54 |
+
self.intermediate_size = self.backbone_config.get("intermediate_size", 4096)
|
| 55 |
+
self.max_position_embeddings = self.backbone_config.get("max_position_embeddings", 514)
|
| 56 |
+
self.tie_word_embeddings = self.backbone_config.get("tie_word_embeddings", True)
|
| 57 |
+
|