def validate_target_settings(
    target_prompts: str,
    target_responses: str,
    decoder_only_format: bool,
):
    """Raises an error if target settings are invalid."""
    if (not decoder_only_format
       ) and (target_prompts != 'none' or target_responses != 'last'):
        raise ValueError(
            f'When using encoder_decoder format, you must use target_prompts="none" and target_responses="last".',
        )

    if target_responses not in {'all', 'last'}:
        raise ValueError(
            f'target_responses must be either "last" or "all" but {target_responses=}',
        )

    if target_prompts.startswith('length>='):
        cutoff = target_prompts[8:]
        if not cutoff.isdigit():
            raise ValueError(
                f'target_prompts starts with "length>=" but the rest of the string is not digits ({target_prompts=}). ' +\
                'To use this configuration option, set target_prompts "length>=XX" where "XX" is a positive integer indicating ' +\
                'the length cutoff. Prompts of at least XX tokens in length will be treated as targets.',
            )
        cutoff = int(cutoff)
        if cutoff <= 0:
            raise ValueError(
                f'You are trying to set the target_prompts length cutoff to a negative number {cutoff=}. This is not allowed.',
            )
    elif target_prompts not in {'all', 'none'}:
        raise ValueError(
            f'target_prompts must either be "all", "none" or "length>=XX" where "XX" is a positive integer, but {target_prompts=}',
        )
Raises an error if target settings are invalid.
llmfoundry/data/finetuning/collator.py