File size: 666 Bytes
9dc9975
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""Reuse the reviewed normalized loss with maize-specific output token spans."""
from functools import lru_cache
from pathlib import Path
import sys
from typing import Any

sys.path.insert(0, str(Path(__file__).resolve().parent))
from planner_grouped_loss_plugin import PlannerGroupedLoss, loss_map
from wgsr_v9.maize.grouped_loss import token_groups


class MaizePlannerGroupedLoss(PlannerGroupedLoss):
    def __init__(self, args: Any, trainer: Any) -> None:
        super().__init__(args, trainer)
        self.classify = lru_cache(maxsize=4096)(lambda ids: token_groups(ids, self.tokenizer))


loss_map["wgsr_maize_planner_grouped_v1"] = MaizePlannerGroupedLoss