| 4 | |
| 5 | @dataclass |
| 6 | class Instance: |
| 7 | request_type: Literal[ |
| 8 | "loglikelihood", |
| 9 | "loglikelihood_rolling", |
| 10 | "generate_until", |
| 11 | "multiple_choice", |
| 12 | ] |
| 13 | doc: dict |
| 14 | arguments: tuple |
| 15 | idx: int |
| 16 | metadata: Tuple[str, int, int] = field( |
| 17 | default_factory=lambda: (None, None, None) |
| 18 | ) # TODO: better typehints here |
| 19 | resps: list = field(default_factory=list) |
| 20 | filtered_resps: dict = field(default_factory=dict) |
| 21 | |
| 22 | # initialized after init |
| 23 | task_name: str = None |
| 24 | doc_id: str = None |
| 25 | repeats: str = None |
| 26 | |
| 27 | def __post_init__(self) -> None: |
| 28 | # unpack metadata field |
| 29 | self.task_name, self.doc_id, self.repeats = self.metadata |
| 30 | |
| 31 | @property |
| 32 | def args(self): |
| 33 | """ |
| 34 | Returns (string,) where `string` is the string to calculate loglikelihood over |
| 35 | """ |
| 36 | return ( |
| 37 | self.arguments if isinstance(self.arguments, tuple) else (self.arguments,) |
| 38 | ) |
no outgoing calls
no test coverage detected