Defines the interface that should be implemented by all LM subclasses. LMs are assumed to take text (strings) as input and yield strings as output (inputs/outputs should be tokenization-agnostic.)
(self)
| 18 | |
| 19 | class LM(abc.ABC): |
| 20 | def __init__(self) -> None: |
| 21 | """Defines the interface that should be implemented by all LM subclasses. |
| 22 | LMs are assumed to take text (strings) as input and yield strings as output |
| 23 | (inputs/outputs should be tokenization-agnostic.) |
| 24 | |
| 25 | """ |
| 26 | # set rank and world size to a single process, by default. |
| 27 | self._rank = 0 |
| 28 | self._world_size = 1 |
| 29 | self.cache_hook = CacheHook(None) |
| 30 | |
| 31 | @abc.abstractmethod |
| 32 | def loglikelihood(self, requests) -> List[Tuple[float, bool]]: |