fix(week6): Add comprehensive moderation filtering to resolve fine-tuning eval errors #723
+17,416
−498
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes critical issue where OpenAI fine-tuning jobs fail during post-training safety evaluations (
refusals_v3
) due to sensitive content in product descriptions.Problem
When running the Week 6 Day 5 fine-tuning exercise, users encounter this error:
Root Cause: The Amazon product dataset contains items with sensitive keywords (weapon, knife, tactical, combat, etc.) that trigger OpenAI's post-training safety checks.
Solution
1. Updated Notebook (
day5.ipynb
)Added
check_moderation()
function that:2. Standalone Scripts
fix_moderation.py
: Batch filtering script with 25+ sensitive keywordstest_moderation.py
: JSONL verification utility3. Documentation
DAY5_MODERATION_FIX_README.md
: PR-focused documentationMODERATION_FIX_README.md
: Technical deep-diveResults
Before Fix
After Fix
Testing
Verified with successful fine-tuning job:
ftjob-moQGns3ajsS5UWIxxxxx
ft:gpt-4o-mini-2024-07-18:personal:pricer:CQUNxxxx
Benefits
Files Changed
week6/day5.ipynb
- Added moderation functionweek6/fix_moderation.py
- New filtering scriptweek6/test_moderation.py
- New verification utilityweek6/DAY5_MODERATION_FIX_README.md
- New documentationweek6/MODERATION_FIX_README.md
- New technical docsCompatibility
Community Contribution - Week 6 Day 5 Moderation Fix by @bilallamal07