Skip to content

DAGE-23: Add llm explainability feature#191

Merged
nseidan merged 6 commits into
dataset-generatorfrom
DAGE-23_llm_explainability
Aug 7, 2025
Merged

DAGE-23: Add llm explainability feature#191
nseidan merged 6 commits into
dataset-generatorfrom
DAGE-23_llm_explainability

Conversation

@nseidan

@nseidan nseidan commented Jul 29, 2025

Copy link
Copy Markdown

Jira: https://sease.atlassian.net/browse/DAGE-23

  • Added llm explanability feature for the generated scores
  • Introduced save_llm_explanation , llm_explanation_destination in configuration
  • Added a unit test
  • Removed e2e folder

Comment thread rre-dataset-generator/src/config.py Outdated
Comment thread rre-dataset-generator/dataset_generator.py
Comment thread rre-dataset-generator/src/model/score_response.py Outdated
Comment thread rre-dataset-generator/src/model/query_rating_context.py
@nseidan nseidan requested a review from nicolo-rinaldi July 30, 2025 05:26

@Intrinsical-AI Intrinsical-AI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The test updates and cleanup look good. However, the LLM reasoning implementation seems too complex for what it needs. Open to discussing the reasoning behind this design.

Data persistence

This PR should be approved soon. It includes new persistence functions in data_store, which align 100% with your task but go a bit further.

  • I don’t think a new writer is needed. The reasoning dump could be handled by slightly extending data_store and LLM_service (e.g., adding a reasoning param). See linked PR for context.

Use of dataclasses

Not sure about the choice to use a dataclass for Rating, especially after pushing to remove the Pydantic version. It’s a simple dict[int, Optional[str]].

  • Why use a dataclass here?
  • What advantages does it bring over Pydantic?
  • Why not apply the same logic to more complex models like Query_Rating_Context, as I proposed since the beginning, which would benefit more from structured classes?

I love dataclasses, but mixing patterns without strong reasoning, adds inconsistency. Open to hearing you.

Comment thread rre-dataset-generator/src/writers/llm_explanation_writer.py Outdated
Comment thread rre-dataset-generator/src/model/rating.py Outdated
Comment thread rre-dataset-generator/tests/unit/llm/test_llm_service_score.py
@Intrinsical-AI

Intrinsical-AI commented Jul 31, 2025

Copy link
Copy Markdown
Collaborator

Note: I keep the previous feedback, but just realized maybe you were not aware on the PR, which now implements saving / loading functions for a common json file, since it's recent (past Friday)

query_id: str = data_store.add_query(query_text, doc.id)
data_store.add_rating_score(query_id, doc.id, max(config.relevance_label_set))
data_store.add_rating_score(query_id, doc.id, max(config.relevance_label_set),
"Human Reasoning: max rating score is assigned when generated query")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Default max rating is assigned because the query is generated by the document

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

updated

try:
score = json.loads(raw)['score']
score_reasoning = None
if reasoning:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would rename readinging to exiplaination or something like that

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

changed to explanation

("graded", 1, "Camry is a car, so it is relevant."),
("graded", 2, "This exactly matches the definition of 'car of the year'."),
])
def test_generate_score_with_reasoning_returns_explanation(scale, valid_score, explanation, example_doc):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

<what you test>__expect__<what you expect>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

updated

('graded', '{"score": null}', 'Score must be 0, 1, or 2 for graded scale, got None'),
])
def test_generate_score_with_invalid_llm_responses_EXPECTED_value_error(scale, response_json, expected_error, example_doc):
def test_generate_score_with_invalid_llm_responses_EXPECTED_value_error(scale, response_json, expected_error,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

__expect__ lowercase

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

updated

for doc_id, doc_data in documents.items():
self.add_document(doc_id, Document.model_validate(doc_data))

def export_all_records_with_reasoning(self, output_path: str | Path) -> None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we have a test for this functionality?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

added

@nseidan nseidan requested a review from dantuzi August 6, 2025 12:58
@nseidan nseidan merged commit 8e81e86 into dataset-generator Aug 7, 2025
1 check passed
@nseidan nseidan deleted the DAGE-23_llm_explainability branch August 7, 2025 10:30
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