Skip to content
Snippets Groups Projects
dummy_model.py 1.5 KiB
Newer Older
Dipam Chakraborty's avatar
Dipam Chakraborty committed
from typing import List
spmohanty's avatar
spmohanty committed
import random
import os

# please use this seed consistently across your code
AICROWD_RUN_SEED = int(os.getenv("AICROWD_RUN_SEED", 3142))
Dipam Chakraborty's avatar
Dipam Chakraborty committed


class DummyModel:
    """
spmohanty's avatar
spmohanty committed
    TODO
Dipam Chakraborty's avatar
Dipam Chakraborty committed
    """
spmohanty's avatar
spmohanty committed

Dipam Chakraborty's avatar
Dipam Chakraborty committed
    def __init__(self):
spmohanty's avatar
spmohanty committed
        """Initialize your models here"""
        random.seed(AICROWD_RUN_SEED)
spmohanty's avatar
spmohanty committed
    def predict(self, prompt: str, is_multiple_choice: bool) -> str:
Dipam Chakraborty's avatar
Dipam Chakraborty committed
        """
spmohanty's avatar
spmohanty committed
        Standard inferface for all tasks and tracks.
spmohanty's avatar
spmohanty committed
        The goal is for your model to be able to infer the task type,
        and respond with a string that is compatible with the task specific parser.
spmohanty's avatar
spmohanty committed
        Note: Even if the development dataset has the task_type information,
        During the actual evaluations, your code will only have access to the prompt,
        and the boolean variable indicating if its a multiple choice question.
Dipam Chakraborty's avatar
Dipam Chakraborty committed
        """
spmohanty's avatar
spmohanty committed

        potential_response = [1, 2, 3, 4]
        if is_multiple_choice:
            return str(random.choice(potential_response))
        else:
            # For Ranking, Retrieval, and Named Entity Recognition tasks
            # the expected response is a string that can be parsed with
            # `ast.literal_eval` (see parsers.py for more details)
            random.shuffle(potential_response)
            return str(potential_response)

            # Note: For the generation task, the expected response is a string
            # And, as this is a dummy response, we are just returning the
            # shuffled version of list, but in your case, it can be any string