Skip to content

feat(flows): add new brazilian portuguese translation for epic-jade-656 - #850

Open
JoelitonEPJ wants to merge 6 commits into
Red-Hat-AI-Innovation-Team:mainfrom
llm-pt-ibm:qa_flow_pt_br
Open

JoelitonEPJ wants to merge 6 commits into
Red-Hat-AI-Innovation-Team:mainfrom
llm-pt-ibm:qa_flow_pt_br

Conversation

@JoelitonEPJ

@JoelitonEPJ JoelitonEPJ commented Jun 16, 2026

Copy link
Copy Markdown

Summary

This PR introduces the Portuguese translation for the epic-jade-656 flow. The goal is to provide the same synthetic data generation pipeline already available in other languages, an option that was previously unavailable for Portuguese.

Changes

  • Translated all prompt templates into Portuguese (evaluate_faithfulness_pt_br, extractive_summary_pt_br, generate_answers_pt_br, generate_question_list_pt_br)
  • Adjusted formatting, syntax, and linguistic nuances to ensure natural and accurate generation in the new language.

Test Plan

  • Executed the flow locally with the new language.
  • Made sure that the flow conforms to the required structure and passes the tests.
  • Verified that the translated outputs render correctly without breaking the flow's execution.

Checklist

  • Tests pass (uv run pytest)
  • Structural tests pass (uv run pytest tests/structural/)
  • Lint clean (uv run ruff check src/ tests/)
  • Types clean (uv run mypy src/sdg_hub)
  • Docs updated if public API changed
  • No new lint warnings introduced

Summary by CodeRabbit

  • New Features
    • Added Portuguese language support for extractive summary generation and automated question-answer dataset creation
    • New knowledge infusion pipeline generates high-quality Portuguese Q&A pairs with built-in faithfulness evaluation to validate answer accuracy

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new Portuguese-language extractive summary knowledge tuning dataset generation flow under enhanced_multi_summary_qa_pt_br/extractive_summary/. The addition includes one pipeline flow.yaml (206 lines) and four Portuguese prompt YAML templates covering extractive summary, question list generation, answer generation, and faithfulness evaluation.

Changes

PT-BR Extractive Summary QA Pipeline

Layer / File(s) Summary
Portuguese prompt templates
src/sdg_hub/flows/knowledge_infusion/enhanced_multi_summary_qa_pt_br/extractive_summary/prompts/extractive_summary_pt_br.yaml, ...prompts/generate_question_list_pt_br.yaml, ...prompts/generate_answers_pt_br.yaml, ...prompts/evaluate_faithfulness_pt_br.yaml
Four new PT-BR prompt YAML files define system/user instructions and template placeholders for extractive summary annotation, [QUESTION]/[END]-delimited question generation, document-grounded answer generation, and SIM/NÃO faithfulness judgment with two worked examples.
Flow pipeline orchestration
src/sdg_hub/flows/knowledge_infusion/enhanced_multi_summary_qa_pt_br/extractive_summary/flow.yaml
Defines flow metadata, dataset column requirements, and five sequential pipeline stages: extractive summary generation (with column rename to raw_document/document), question list generation, answer generation with reasoning saving, faithfulness evaluation via an eval LLM, and a final filter retaining only rows where faithfulness_judgment equals "YES".

Sequence Diagram(s)

sequenceDiagram
  participant Dataset as Input Dataset
  participant SummaryLLM as Summary LLM
  participant QuestionLLM as Question LLM
  participant AnswerLLM as Answer LLM
  participant EvalLLM as Faithfulness Eval LLM
  participant Filter as YES Filter

  Dataset->>SummaryLLM: document + document_outline
  SummaryLLM-->>Dataset: extractive summary → raw_document / document
  Dataset->>QuestionLLM: document + domain + ICL examples
  QuestionLLM-->>Dataset: question list (QUESTION/END delimited)
  Dataset->>AnswerLLM: question + document + document_outline
  AnswerLLM-->>Dataset: response + reasoning
  Dataset->>EvalLLM: document + response
  EvalLLM-->>Dataset: explanation + faithfulness_judgment (SIM/NÃO)
  Dataset->>Filter: faithfulness_judgment
  Filter-->>Dataset: rows where judgment == YES
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Red-Hat-AI-Innovation-Team/sdg_hub#592: Introduced the extractive_summary flow structure with the same prompt_config_path-based prompt separation pattern that this PT-BR flow follows.
  • Red-Hat-AI-Innovation-Team/sdg_hub#392: Added an earlier YAML extractive-summary QA knowledge-tuning pipeline with the same generate-questions → generate-answers → evaluate-faithfulness chain structure.
  • Red-Hat-AI-Innovation-Team/sdg_hub#426: Added a knowledge-tuning dataset generation flow with the same question-list → answer generation → faithfulness evaluation with tagged parsing and YES filtering pattern.

Suggested labels

documentation, enhancement

Suggested reviewers

  • eshwarprasadS
  • shivchander

Poem

🐇 Hop, hop — a new tongue appears,
Portuguese prompts now fill my ears!
Summaries extracted, questions bloom,
Faithfulness judged in each virtual room.
Only "SIM" rows make the cut — hooray!
The rabbit dances in pt-BR today. 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a Brazilian Portuguese translation for the epic-jade-656 flow, which is clearly reflected in the new Portuguese YAML files and prompt templates added throughout the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/sdg_hub/flows/knowledge_infusion/enhanced_multi_summary_qa_pt_br/extractive_summary/flow.yaml`:
- Around line 149-155: The `save_reasoning_content` configuration is currently
placed on the TagParserBlock but should be moved to the
LLMResponseExtractorBlock (the extract_answers block). Remove the
`save_reasoning_content` setting from the TagParserBlock configuration around
line 164 and add it to the LLMResponseExtractorBlock's block_config section
(within the extract_answers block around line 149-155). This corrects the
cross-block contract mismatch and ensures reasoning metadata is properly
preserved during extraction.

In
`@src/sdg_hub/flows/knowledge_infusion/enhanced_multi_summary_qa_pt_br/extractive_summary/prompts/evaluate_faithfulness_pt_br.yaml`:
- Around line 9-14: The prompt file has an inconsistency where lines 9-14 ask
the model to respond with Portuguese tokens (SIM/NÃO) but the evaluation
pipeline on lines 58-60 filters only for English tokens (YES/NO). This causes
valid responses from the model to be silently discarded when it returns SIM.
Unify all judgment responses in the file to use YES/NO tokens only by updating
the instructions in lines 9-14 to ask for YES/NO instead of SIM/NÃO, and ensure
the filter logic on lines 58-60 remains consistent with this English-only
format.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c4e9bf2c-008f-4fae-aad9-e54ee5f7e6a1

📥 Commits

Reviewing files that changed from the base of the PR and between 046d7c0 and 97d74eb.

📒 Files selected for processing (5)
  • src/sdg_hub/flows/knowledge_infusion/enhanced_multi_summary_qa_pt_br/extractive_summary/flow.yaml
  • src/sdg_hub/flows/knowledge_infusion/enhanced_multi_summary_qa_pt_br/extractive_summary/prompts/evaluate_faithfulness_pt_br.yaml
  • src/sdg_hub/flows/knowledge_infusion/enhanced_multi_summary_qa_pt_br/extractive_summary/prompts/extractive_summary_pt_br.yaml
  • src/sdg_hub/flows/knowledge_infusion/enhanced_multi_summary_qa_pt_br/extractive_summary/prompts/generate_answers_pt_br.yaml
  • src/sdg_hub/flows/knowledge_infusion/enhanced_multi_summary_qa_pt_br/extractive_summary/prompts/generate_question_list_pt_br.yaml

Comment on lines +9 to +14
Determine se a informação fornecida corroborou com o contexto apresentado. Responda com SIM se o contexto fundamenta a informação, mesmo parcialmente. Responda NÃO se o contexto não sustentar a informação.

Diretrizes:
- Responda SIM quando o contexto fornece, seja direto ou indiretamente, evidência sustentando a informação. Evidência indireta pode incluir implicações contextuais ou conexões inferidas que sustentam razoavelmente a informação.
- Responda NÃO se o contexto não apresenta nenhuma evidência que o sustente, contradizer claramente a informação, ou se o suporte fornecido pelo contexto for muito vago ou especulatvo para estabelecer uma conexão sólida com a informação.
- Evite usar "parcialmente" em sua resposta. Se o contexto fornece qualquer suporte razoável (direto ou indireto) para a informação, considere-a como SIM.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Unify judgment tokens to YES/NO only.

Line 9–Line 14 asks for SIM/NÃO, but Line 58 asks for YES/NO, and the pipeline filters only "YES". This inconsistency can silently discard valid rows when the model returns SIM.

Suggested prompt fix
-    Determine se a informação fornecida corroborou com o contexto apresentado. Responda com SIM se o contexto fundamenta a informação, mesmo parcialmente. Responda NÃO se o contexto não sustentar a informação.
+    Determine se a informação fornecida é sustentada pelo contexto apresentado. Responda com YES se o contexto fundamenta a informação, mesmo parcialmente. Responda NO se o contexto não sustenta a informação.
@@
-    - Responda SIM quando o contexto fornece, seja direto ou indiretamente, evidência sustentando a informação. Evidência indireta pode incluir implicações contextuais ou conexões inferidas que sustentam razoavelmente a informação.
-    - Responda NÃO se o contexto não apresenta nenhuma evidência que o sustente, contradizer claramente a informação, ou se o suporte fornecido pelo contexto for muito vago ou especulatvo para estabelecer uma conexão sólida com a informação.
+    - Responda YES quando o contexto fornece, seja direto ou indiretamente, evidência sustentando a informação. Evidência indireta pode incluir implicações contextuais ou conexões inferidas que sustentam razoavelmente a informação.
+    - Responda NO se o contexto não apresenta nenhuma evidência que o sustente, contradiz claramente a informação, ou se o suporte fornecido pelo contexto for muito vago ou especulativo para estabelecer uma conexão sólida com a informação.
@@
-    - Evite usar "parcialmente" em sua resposta. Se o contexto fornece qualquer suporte razoável (direto ou indireto) para a informação, considere-a como SIM. 
+    - Evite usar "parcialmente" em sua resposta. Se o contexto fornece qualquer suporte razoável (direto ou indireto) para a informação, considere-a como YES.

Also applies to: 58-60

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/sdg_hub/flows/knowledge_infusion/enhanced_multi_summary_qa_pt_br/extractive_summary/prompts/evaluate_faithfulness_pt_br.yaml`
around lines 9 - 14, The prompt file has an inconsistency where lines 9-14 ask
the model to respond with Portuguese tokens (SIM/NÃO) but the evaluation
pipeline on lines 58-60 filters only for English tokens (YES/NO). This causes
valid responses from the model to be silently discarded when it returns SIM.
Unify all judgment responses in the file to use YES/NO tokens only by updating
the instructions in lines 9-14 to ask for YES/NO instead of SIM/NÃO, and ensure
the filter logic on lines 58-60 remains consistent with this English-only
format.

@shivchander

Copy link
Copy Markdown
Collaborator

Hey @JoelitonEPJ, we have a feature to automatically translate any flow into a target language. Could you try that with this?

Something like this:

from sdg_hub.core.utils.translation import translate_flow

flow = translate_flow(
    flow="extractive-summary-knowledge-tuning",
    lang="Spanish",
    lang_code="es",
    translator_model="openai/gpt-5.2",
    verifier_model="openai/gpt-5.2",
)

@JoelitonEPJ

Copy link
Copy Markdown
Author

Hi @shivchander, thanks for the tip! I tested the translate_flow as suggested.
With gpt-5.2 (as both translator_model and verifier_model), the automatic translation worked well.
However, when trying smaller models, in our case gpt-4.1-nano, which is what we use in the rest of the pipeline for cost reasons, the tool ran into errors. A couple of issues
I noticed:

Smaller models fail to translate the tags correctly
The generated translation doesn't pass the quality tests

Does this behavior sound expected with smaller models, or would it be worth opening a separate issue with the error details/logs so we can investigate further? Happy to share the traces if that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants