Skip to content

fix: chat dataset#1921

Merged
akoumpa merged 2 commits intomainfrom
akoumparouli/fix_chat_dataset
Apr 21, 2026
Merged

fix: chat dataset#1921
akoumpa merged 2 commits intomainfrom
akoumparouli/fix_chat_dataset

Conversation

@akoumpa
Copy link
Copy Markdown
Contributor

@akoumpa akoumpa commented Apr 20, 2026

What does this PR do ?

Changes

nemo_automodel/components/datasets/llm/chat_dataset.py (_normalize_tool_calls):

  • Missing/empty id → auto-filled with f"call_{idx}".
  • Missing/empty type → auto-filled with "function".
  • Wrong-type values (e.g. id: 123) still raise — catches real data bugs.
  • Normalized id/type are written back into the returned dict so downstream chat templates see them populated.

tests/unit_tests/datasets/llm/test_chat_dataset.py:

  • The two parametrize cases that previously required missing id/type to raise now pass a wrong-type value instead (still expects raise).
  • Added test_normalize_tool_calls_autofills_missing_id_and_type covering both missing-key and empty-string forms.

Both OpenAI-style data (with id) and customizer-style data (without) now flow through the same validator.

  • With id (OpenAI-style)
  {"messages":[{"role":"user","content":"Weather in Seattle?"},{"role":"assistant","content":"","tool_calls":[{"id":"call_abc","type":"function","function":{"name":"get_weather","arguments":{"city":"Seattle"}}}]
  },{"role":"tool","tool_call_id":"call_abc","content":"72F sunny"},{"role":"assistant","content":"It's 72F and sunny."}]}
  • Without id (customizer-style)
  {"messages":[{"role":"user","content":"Weather in Seattle?"},{"role":"assistant","content":"","tool_calls":[{"type":"function","function":{"name":"get_weather","arguments":{"city":"Seattle"}}}]}]}

Differences:

  • No id on the tool_call (auto-filled to "call_0" by the normalizer).
  • No follow-up tool role message / final assistant reply — customizer data trains the model to emit the call, not to consume its response.

Changelog

  • Add specific line by line info of high level changes in this PR.

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?

If you haven't finished some of the above items you can still open "Draft" PR.

Additional Information

  • Related to # (issue)

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Apr 20, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
@akoumpa akoumpa force-pushed the akoumparouli/fix_chat_dataset branch from 2ffed1a to f4864e6 Compare April 20, 2026 21:07
@akoumpa akoumpa added the r0.4.0 Auto-cherrypick to release branch. Apply before merge; cherrypick happens after merge. label Apr 20, 2026
@akoumpa
Copy link
Copy Markdown
Contributor Author

akoumpa commented Apr 20, 2026

/ok to test d58fd8e

@akoumpa
Copy link
Copy Markdown
Contributor Author

akoumpa commented Apr 20, 2026

/claude review

Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@akoumpa akoumpa marked this pull request as ready for review April 20, 2026 22:50
@akoumpa akoumpa requested review from a team, HuiyingLi, adil-a and hemildesai as code owners April 20, 2026 22:50
@akoumpa akoumpa enabled auto-merge (squash) April 21, 2026 01:57
@akoumpa akoumpa merged commit fc46ae5 into main Apr 21, 2026
96 of 100 checks passed
@akoumpa akoumpa deleted the akoumparouli/fix_chat_dataset branch April 21, 2026 03:20
akoumpa added a commit that referenced this pull request Apr 21, 2026
fix: chat dataset (#1921)

handle missing id in chatdataset

Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
Signed-off-by: NeMo Bot <nemo-bot@nvidia.com>
Co-authored-by: Alexandros Koumparoulis <153118171+akoumpa@users.noreply.github.com>
linnanwang pushed a commit that referenced this pull request Apr 24, 2026
handle missing id in chatdataset

Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

r0.4.0 Auto-cherrypick to release branch. Apply before merge; cherrypick happens after merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants