Skip to content

Rapids manager

RapidsManager #

RapidsManager()

Can be used to build different types of rapids. That can then be added to Validation sets

Source code in src/rapidata/rapidata_client/validation/rapids/rapids_manager.py
def __init__(self):
    pass

classification_rapid #

classification_rapid(
    instruction: str,
    answer_options: list[str],
    datapoint: str,
    truths: list[str],
    data_type: str = MEDIA,
    metadata: Sequence[Metadata] = [],
) -> ClassificationRapid

Build a classification rapid

Parameters:

Name Type Description Default
instruction str

The instruction/question to be shown to the labeler.

required
answer_options list[str]

The options that the labeler can choose from to answer the question.

required
datapoint str

The datapoint that the labeler will be labeling.

required
truths list[str]

The correct answers to the question.

required
data_type str

The type of the datapoint. Defaults to RapidataDataTypes.MEDIA.

MEDIA
metadata Sequence[Metadata]

The metadata that is attached to the rapid. Defaults to [].

[]
Source code in src/rapidata/rapidata_client/validation/rapids/rapids_manager.py
def classification_rapid(self,
        instruction: str,
        answer_options: list[str],
        datapoint: str,
        truths: list[str],
        data_type: str = RapidataDataTypes.MEDIA,
        metadata: Sequence[Metadata] = [],
) -> ClassificationRapid:
    """Build a classification rapid

    Args:
        instruction (str): The instruction/question to be shown to the labeler.
        answer_options (list[str]): The options that the labeler can choose from to answer the question.
        datapoint (str): The datapoint that the labeler will be labeling.
        truths (list[str]): The correct answers to the question.
        data_type (str, optional): The type of the datapoint. Defaults to RapidataDataTypes.MEDIA.
        metadata (Sequence[Metadata], optional): The metadata that is attached to the rapid. Defaults to [].
    """

    if data_type == RapidataDataTypes.MEDIA:
        asset = MediaAsset(datapoint)
    elif data_type == RapidataDataTypes.TEXT:
        asset = TextAsset(datapoint)
    else:
        raise ValueError(f"Unsupported data type: {data_type}")

    return ClassificationRapid(
            instruction=instruction,
            answer_options=answer_options,
            asset=asset,
            truths=truths,
            metadata=metadata,
            )

compare_rapid #

compare_rapid(
    instruction: str,
    truth: str,
    datapoint: list[str],
    data_type: str = MEDIA,
    metadata: Sequence[Metadata] = [],
) -> CompareRapid

Build a compare rapid

Parameters:

Name Type Description Default
instruction str

The instruction that the labeler will be comparing the assets on.

required
truth str

The correct answer to the comparison. (has to be one of the assets)

required
datapoint list[str]

The two assets that the labeler will be comparing.

required
data_type str

The type of the datapoint. Defaults to RapidataDataTypes.MEDIA.

MEDIA
metadata Sequence[Metadata]

The metadata that is attached to the rapid. Defaults to [].

[]
Source code in src/rapidata/rapidata_client/validation/rapids/rapids_manager.py
def compare_rapid(self,
        instruction: str,
        truth: str,
        datapoint: list[str],
        data_type: str = RapidataDataTypes.MEDIA,
        metadata: Sequence[Metadata] = [],
) -> CompareRapid:
    """Build a compare rapid

    Args:
        instruction (str): The instruction that the labeler will be comparing the assets on.
        truth (str): The correct answer to the comparison. (has to be one of the assets)
        datapoint (list[str]): The two assets that the labeler will be comparing.
        data_type (str, optional): The type of the datapoint. Defaults to RapidataDataTypes.MEDIA.
        metadata (Sequence[Metadata], optional): The metadata that is attached to the rapid. Defaults to [].
    """

    if data_type == RapidataDataTypes.MEDIA:
        assets = [MediaAsset(image) for image in datapoint]
    elif data_type == RapidataDataTypes.TEXT:
        assets = [TextAsset(text) for text in datapoint]
    else:
        raise ValueError(f"Unsupported data type: {data_type}")

    asset = MultiAsset(assets)

    return CompareRapid(
            instruction=instruction,
            asset=asset,
            truth=truth,
            metadata=metadata,
            )

select_words_rapid #

select_words_rapid(
    instruction: str,
    truths: list[int],
    datapoint: str,
    sentence: str,
    strict_grading: bool = True,
) -> SelectWordsRapid

Build a select words rapid

Parameters:

Name Type Description Default
instruction str

The instruction for the labeler.

required
truths list[int]

The indices of the words that are the correct answers.

required
datapoint str

The asset that the labeler will be selecting words from.

required
sentence str

The sentence that the labeler will be selecting words from. (split up by spaces)

required
strict_grading bool

Whether the grading should be strict or not. True means that all correct words and no wrong words have to be selected for the rapid to be marked as correct. False means that at least one correct word and no wrong words have to be selected for the rapid to be marked as correct. Defaults to True.

True
Source code in src/rapidata/rapidata_client/validation/rapids/rapids_manager.py
def select_words_rapid(self,
        instruction: str,
        truths: list[int],
        datapoint: str,
        sentence: str,
        strict_grading: bool = True,
) -> SelectWordsRapid:
    """Build a select words rapid

    Args:
        instruction (str): The instruction for the labeler.
        truths (list[int]): The indices of the words that are the correct answers.
        datapoint (str): The asset that the labeler will be selecting words from.
        sentence (str): The sentence that the labeler will be selecting words from. (split up by spaces)
        strict_grading (bool, optional): Whether the grading should be strict or not. 
            True means that all correct words and no wrong words have to be selected for the rapid to be marked as correct.
            False means that at least one correct word and no wrong words have to be selected for the rapid to be marked as correct. Defaults to True.
    """

    asset = MediaAsset(datapoint)

    return SelectWordsRapid(
            instruction=instruction,
            truths=truths,
            asset=asset,
            sentence=sentence,
            strict_grading=strict_grading,
            )

locate_rapid #

locate_rapid(
    instruction: str,
    truths: list[Box],
    datapoint: str,
    metadata: Sequence[Metadata] = [],
) -> LocateRapid

Build a locate rapid

Parameters:

Name Type Description Default
instruction str

The instruction on what the labeler should do.

required
truths list[Box]

The bounding boxes of the object that the labeler ought to be locating.

required
datapoint str

The asset that the labeler will be locating the object in.

required
metadata Sequence[Metadata]

The metadata that is attached to the rapid. Defaults to [].

[]
Source code in src/rapidata/rapidata_client/validation/rapids/rapids_manager.py
def locate_rapid(self,
        instruction: str,
        truths: list[Box],
        datapoint: str,
        metadata: Sequence[Metadata] = [],
) -> LocateRapid:
    """Build a locate rapid

    Args:
        instruction (str): The instruction on what the labeler should do.
        truths (list[Box]): The bounding boxes of the object that the labeler ought to be locating.
        datapoint (str): The asset that the labeler will be locating the object in.
        metadata (Sequence[Metadata], optional): The metadata that is attached to the rapid. Defaults to [].
    """

    asset = MediaAsset(datapoint)

    return LocateRapid(
            instruction=instruction,
            truths=truths,
            asset=asset,
            metadata=metadata,
            )

draw_rapid #

draw_rapid(
    instruction: str,
    truths: list[Box],
    datapoint: str,
    metadata: Sequence[Metadata] = [],
) -> DrawRapid

Build a draw rapid

Parameters:

Name Type Description Default
instruction str

The instructions on what the labeler

required
truths list[Box]

The bounding boxes of the object that the labeler ought to be drawing.

required
datapoint str

The asset that the labeler will be drawing the object in.

required
metadata Sequence[Metadata]

The metadata that is attached to the rapid. Defaults to [].

[]
Source code in src/rapidata/rapidata_client/validation/rapids/rapids_manager.py
def draw_rapid(self,
        instruction: str,
        truths: list[Box],
        datapoint: str,
        metadata: Sequence[Metadata] = [],
) -> DrawRapid:
    """Build a draw rapid

    Args:
        instruction (str): The instructions on what the labeler
        truths (list[Box]): The bounding boxes of the object that the labeler ought to be drawing.
        datapoint (str): The asset that the labeler will be drawing the object in.
        metadata (Sequence[Metadata], optional): The metadata that is attached to the rapid. Defaults to [].
    """

    asset = MediaAsset(datapoint)

    return DrawRapid(
            instruction=instruction,
            truths=truths,
            asset=asset,
            metadata=metadata,
            )