Skip to content

Conversation

@LucianPopaIBM
Copy link

@LucianPopaIBM LucianPopaIBM commented Jan 31, 2026

Component PR

Description

Add support for the query_clarification RAG intrinsic, which detects ambiguous user queries and generates clarifying questions to help narrow down the user's intent.

Changes

  • Add clarify_query() function to rag.py that wraps the query_clarification intrinsic
  • Register query_clarification intrinsic in the adapter catalog (LoRA only)
  • Add example script (docs/examples/intrinsics/query_clarification.py) demonstrating usage with positive and negative test cases
  • Add comprehensive tests (test_query_clarification_positive and test_query_clarification_negative)
  • Add test data JSON files for both ambiguous and clear query scenarios

Behavior

  • Returns a clarification question string for ambiguous queries (e.g., "Do you mean A or B?")
  • Returns the string "CLEAR" when no clarification is needed

Testing

Both tests verified passing on granite-4.0-micro with query_clarification LoRA adapter from ibm-granite/granite-lib-rag-r1.0:

  • test_query_clarification_positive: ✅ 1 passed in 284.80s
  • test_query_clarification_negative: ✅ 1 passed in 29.89s

@mergify
Copy link

mergify bot commented Jan 31, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|release)(?:\(.+\))?:

@github-actions
Copy link
Contributor

The PR description has been updated. Please fill out the template for your PR to be reviewed.

@LucianPopaIBM LucianPopaIBM force-pushed the feat/add-query-clarification-tests branch from 1c172db to 993b994 Compare February 2, 2026 23:01
Add support for the query_clarification RAG intrinsic, which detects
ambiguous queries and generates clarification questions.

Changes:
- Add clarify_query() function to rag.py
- Register query_clarification intrinsic in catalog
- Add example script demonstrating usage
- Add comprehensive tests for positive and negative cases
- Add test data JSON files for both test scenarios
- Add "Wight" to codespell ignore list (Isle of Wight is a place name)

The intrinsic returns a clarification question for ambiguous queries
or the string "CLEAR" when no clarification is needed.

Tests verified passing on granite-4.0-micro with query_clarification
LoRA adapter from ibm-granite/granite-lib-rag-r1.0.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@LucianPopaIBM LucianPopaIBM force-pushed the feat/add-query-clarification-tests branch from 993b994 to a1e1b18 Compare February 2, 2026 23:08
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.

1 participant