"official/nlp/bert/bert_models.py" did not exist on "440f31ab89297f250bf5a9913d6f4c78fba13ed1"
dummy.py 991 Bytes
Newer Older
Rayyyyy's avatar
Rayyyyy committed
1
2
import random

Rayyyyy's avatar
Rayyyyy committed
3
from tqdm import tqdm
Rayyyyy's avatar
Rayyyyy committed
4

Rayyyyy's avatar
Rayyyyy committed
5
6
7
8
9
from lm_eval.api.model import LM
from lm_eval.api.registry import register_model


@register_model("dummy")
Rayyyyy's avatar
Rayyyyy committed
10
class DummyLM(LM):
Rayyyyy's avatar
Rayyyyy committed
11
12
    def __init__(self) -> None:
        super().__init__()
Rayyyyy's avatar
Rayyyyy committed
13
14
15
16
17

    @classmethod
    def create_from_arg_string(cls, arg_string, additional_config=None):
        return cls()

Rayyyyy's avatar
Rayyyyy committed
18
    def loglikelihood(self, requests, disable_tqdm: bool = False):
Rayyyyy's avatar
Rayyyyy committed
19
20
        res = []

Rayyyyy's avatar
Rayyyyy committed
21
        for _ in tqdm(requests, disable=disable_tqdm):
Rayyyyy's avatar
Rayyyyy committed
22
23
24
25
            res.append((-random.random(), False))

        return res

Rayyyyy's avatar
Rayyyyy committed
26
    def generate_until(self, requests, disable_tqdm: bool = False):
Rayyyyy's avatar
Rayyyyy committed
27
28
        res = []

Rayyyyy's avatar
Rayyyyy committed
29
        for ctx, _ in tqdm(requests, disable=disable_tqdm):
Rayyyyy's avatar
Rayyyyy committed
30
31
32
33
34
            res.append("lol")
            assert ctx.strip() != ""

        return res

Rayyyyy's avatar
Rayyyyy committed
35
    def loglikelihood_rolling(self, requests, disable_tqdm: bool = False):
Rayyyyy's avatar
Rayyyyy committed
36
37
        res = []

Rayyyyy's avatar
Rayyyyy committed
38
        for _ in tqdm(requests, disable=disable_tqdm):
Rayyyyy's avatar
Rayyyyy committed
39
40
41
            res.append(-random.random())

        return res