MCPcopy Create free account
hub / github.com/allenai/molmoact2 / MessageWeight

Class MessageWeight

experiments/olmo/preprocessing/text_preprocessor.py:23–46  ·  view source on GitHub ↗

How to weight a message

Source from the content-addressed store, hash-verified

21
22@dataclasses.dataclass
23class MessageWeight(BaseConfig):
24 """
25 How to weight a message
26 """
27 weight: Optional[float] = None
28 """Scale by weights by this much"""
29
30 root_subsegments: Optional[bool] = None
31 """Divide by 1/sqrt(n_subsegments)"""
32
33 root_length: Optional[bool] = None
34 """Divide by 2/sqrt(n_loss_tokens)"""
35
36 def with_overrides(self, other: Union[None, float, 'MessageWeight']) -> 'MessageWeight':
37 if other is None:
38 return self
39 if isinstance(other, (int, float)):
40 return MessageWeight(
41 weight=other, root_subsegments=self.root_subsegments, root_length=self.root_length)
42 return MessageWeight(
43 weight=self.weight if other.weight is None else other.weight,
44 root_subsegments=self.root_subsegments if other.root_subsegments is None else other.root_subsegments,
45 root_length=self.root_length if other.root_length is None else other.root_length,
46 )
47
48
49@dataclasses.dataclass

Callers 4

get_training_mixtureFunction · 0.90
with_overridesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected