-
Notifications
You must be signed in to change notification settings - Fork 557
Feature/moderation hallucination eval multilingual translation #1265
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
Open
SnowMasaya
wants to merge
20
commits into
NVIDIA-NeMo:develop
Choose a base branch
from
SnowMasaya:feature/moderation_hallucination_eval_multilingual_translation
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e0a54ea
feat: add multilingual translation dependencies
masayaOgushi a7f05c4
feat: implement multilingual translation system
masayaOgushi d4f53f2
feat: integrate multilingual support in evaluation pipeline
masayaOgushi 2f6e7d8
test: add comprehensive translation system tests
masayaOgushi 42d6eaf
fix: add langchain-nvidia-ai-endpoint, remove pyproject-toml
masayaOgushi 250acca
fix: copilot advice base
masayaOgushi 6c09697
fix: remove extra test
masayaOgushi 890f2a9
fix: multilingual translation dependencies
masayaOgushi 2ee28d1
fix: make pre_commit related issues
masayaOgushi 03102ef
fix: Remove redundant test files
masayaOgushi 0c9f1ef
fix: add wanring, common process
masayaOgushi 5af4f19
fix: add configurable endpoint support for RivaTranslator and refacto…
masayaOgushi e9f85d8
fix: update translation tests for configurable endpoint feature
masayaOgushi d788905
docs: add configurable endpoint examples to langproviders README
masayaOgushi 0d82ce3
fix: add white space
masayaOgushi 4650acb
fix: None value case support
masayaOgushi 6b45738
Fix: README, pyptoject.toml
masayaOgushi a4e9809
# Update
masayaOgushi 79e4ea3
# fix test code
masayaOgushi 3b9741f
# Add eiva config yaml
masayaOgushi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,8 @@ def __init__( | |
| output_dir: str = "outputs/moderation", | ||
| write_outputs: bool = True, | ||
| split: str = "harmful", | ||
| enable_translation: bool = False, | ||
| translation_config: str = None, | ||
| ): | ||
| """ | ||
| A moderation rails evaluation has the following parameters: | ||
|
|
@@ -54,6 +56,8 @@ def __init__( | |
| - output_dir: directory to write the moderation predictions | ||
| - write_outputs: whether to write the predictions to file | ||
| - split: whether the dataset is harmful or helpful | ||
| - enable_translation: whether to enable translation functionality | ||
| - translation_config: path to translation configuration file | ||
| """ | ||
|
|
||
| self.config_path = config | ||
|
|
@@ -67,7 +71,29 @@ def __init__( | |
| self.check_output = check_output | ||
|
|
||
| self.num_samples = num_samples | ||
| self.dataset = load_dataset(self.dataset_path)[: self.num_samples] | ||
| self.enable_translation = enable_translation | ||
| self.translation_config = translation_config | ||
|
|
||
| # Initialize translation provider if enabled | ||
| self.translator = None | ||
| if self.enable_translation: | ||
| try: | ||
| from nemoguardrails.evaluate.utils_translate import _load_langprovider | ||
|
|
||
| self.translator = _load_langprovider(self.translation_config) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is done again in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. I try it. |
||
| print(f"✓ Translation provider initialized") | ||
| except Exception as e: | ||
| print(f"⚠ Translation provider not available: {e}") | ||
| self.enable_translation = False | ||
|
|
||
| # Load dataset with optional translation | ||
| if self.enable_translation and self.translator: | ||
| self.dataset = load_dataset( | ||
| self.dataset_path, translation_config=self.translation_config | ||
| )[: self.num_samples] | ||
| else: | ||
| self.dataset = load_dataset(self.dataset_path)[: self.num_samples] | ||
|
|
||
| self.split = split | ||
| self.write_outputs = write_outputs | ||
| self.output_dir = output_dir | ||
|
|
@@ -266,6 +292,6 @@ def run(self): | |
| ) | ||
|
|
||
| with open(output_path, "w") as f: | ||
| json.dump(moderation_check_predictions, f, indent=4) | ||
| json.dump(moderation_check_predictions, f, indent=4, ensure_ascii=False) | ||
|
|
||
| print(f"Predictions written to file {output_path}") | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should print a warning if translation is enable , but the translator in None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK