Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding preprocessors for QA and messages datasets #1700

Merged
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions llmfoundry/data/finetuning/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,3 +1161,31 @@ def shareGPT_format_preprocessor(inp: dict) -> ChatFormattedDict:
except Exception as e:
raise UnableToProcessPromptResponseError(inp) from e
return {'messages': messages}


@dataset_constructor.register('math-ai/StackMathQA')
def QA_format_preprocessor(inp: dict) -> ChatFormattedDict:
"""Convert from QA format to our chat format."""
try:
Q = inp['Q']
A = inp['A']
messages: list[dict[str, str]] = [{
'role': 'user',
'content': Q,
}, {
'role': 'assistant',
'content': A,
}]
except Exception as e:
raise UnableToProcessPromptResponseError(inp) from e
return {'messages': messages}


@dataset_constructor.register('AI-MO/NuminaMath-CoT')
def messages_format_preprocessor(inp: dict) -> ChatFormattedDict:
"""Convert from QA format to our chat format."""
try:
messages = inp['messages']
except Exception as e:
raise UnableToProcessPromptResponseError(inp) from e
return {'messages': messages}
Loading