dummy.py 1009 Bytes
Newer Older
1
import random
2

3
4
from tqdm import tqdm

5
6
from lm_eval.api.model import LM
from lm_eval.api.registry import register_model
Jason Phang's avatar
checkin  
Jason Phang committed
7
8


9
@register_model("dummy")
Jason Phang's avatar
checkin  
Jason Phang committed
10
class DummyLM(LM):
Ethan Smith's avatar
Ethan Smith committed
11
    def __init__(self) -> None:
baberabb's avatar
baberabb committed
12
        super().__init__()
13
14

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

18
    def loglikelihood(self, requests, disable_tqdm: bool = False):
19
        res = []
20

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

24
        return res
25

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

Amine Elhattami's avatar
Amine Elhattami committed
29
        for request in tqdm(requests, disable=disable_tqdm):
Leo Gao's avatar
Leo Gao committed
30
            res.append("lol")
Amine Elhattami's avatar
Amine Elhattami committed
31
            assert request.arguments[0].strip() != ""
Leo Gao's avatar
Leo Gao committed
32
33

        return res
Leo Gao's avatar
Leo Gao committed
34

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

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

41
        return res