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

[WIP] System Prompt Mapping for Instruct DS #2514

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all 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
15 changes: 13 additions & 2 deletions torchtune/data/_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,23 @@ def __call__(self, sample: Mapping[str, Any]) -> Mapping[str, Any]:
eot=True,
),
]
if self.new_system_prompt is not None:

system_column = self.column_map.get("system", "system")
system_prompt = None

if (system_column in sample and sample[system_column] and sample[system_column].strip()):
system_prompt = sample[system_column]

elif self.new_system_prompt is not None:
system_prompt = self.new_system_prompt

if system_prompt is not None:
messages = [
Message(
role="system", content=self.new_system_prompt, masked=True, eot=True
role="system", content=system_prompt, masked=True, eot=True
)
] + messages

return {"messages": messages}


Expand Down