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

Class MessageWeight

olmo/preprocessing/text_preprocessor.py:21–43  ·  view source on GitHub ↗

How to weight a message

Source from the content-addressed store, hash-verified

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

Callers 4

get_training_mixtureFunction · 0.90
with_overridesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected