Skip to content

Dage 16: response validation Schemas#171

Merged
Intrinsical-AI merged 16 commits into
dataset-generatorfrom
DAGE-16/LLM-pydantic-schemas
Jul 28, 2025
Merged

Dage 16: response validation Schemas#171
Intrinsical-AI merged 16 commits into
dataset-generatorfrom
DAGE-16/LLM-pydantic-schemas

Conversation

@Intrinsical-AI

@Intrinsical-AI Intrinsical-AI commented Jul 18, 2025

Copy link
Copy Markdown
Collaborator

TASK TICKET

DAGE-16 – Introduces Pydantic model LLMScoreResponse and refactors LLMService to enforce structured output and "free" validation / checks.

Last update: back to basics

We decide to use simple data-structures (dicts / lists) for simplicity / efficiency. Pydantic it's (yet) an over kill - but might come back around.

-> Back to simple approaches. Used simple data structures to perform validation of LLM responses in the LLM Service


Previous (Pydantic Approach)

Changes

  • Added pydantic schemas for LLM service. Needed to re-write the generate_queries output.
  • Added LLMScoreResponse schema with score validation logic
  • Refactored generate_score() to use structured parsing and stricter output checks
  • Split and extended tests into tests/unit/llm/ for generate_score() and generate_queries()
  • Parametrized valid/invalid score scenarios, malformed JSON, and hallucinated outputs
  • Improved validation error handling and logging

MrCabss69 added 2 commits July 18, 2025 15:58
- Add LLMQueryResponse Pydantic model with JSON array validation
- Update LLMService to use LLMQueryResponse
- Add proper type hints and documentation
- Add LLMQueryResponse Pydantic model with JSON array validation
- Update LLMService to use LLMQueryResponse
- Add proper type hints and documentation
Comment thread rre-dataset-generator/src/model/llm_schemas.py Outdated
Comment thread rre-dataset-generator/src/model/llm_schemas.py Outdated
Comment thread rre-dataset-generator/src/llm/llm_service.py Outdated
Comment thread rre-dataset-generator/src/llm/llm_service.py Outdated
@Intrinsical-AI Intrinsical-AI requested a review from nseidan July 22, 2025 11:53
@nicolo-rinaldi nicolo-rinaldi changed the title Dage 16/llm pydantic schemas Dage 16: llm pydantic schemas Jul 22, 2025

@nicolo-rinaldi nicolo-rinaldi 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.

I left just minor comments. I'd add some logging along the way. The comments are a bit ugly to look at. Maybe is better to keep them in separate files(?)

Comment thread rre-dataset-generator/src/model/llm_schemas.py Outdated
Comment thread rre-dataset-generator/src/llm/llm_service.py Outdated
Comment thread rre-dataset-generator/src/llm/llm_service.py
MrCabss69 added 4 commits July 23, 2025 12:14
…MService basic tests to adopt JSON format; and added a custom test file. Also: removed comments as feedback was asking for
…tests. Impact in pipeline and other points in the code --> We will need a refactor; this is a breaking change
nseidan
nseidan previously approved these changes Jul 23, 2025
Comment thread rre-dataset-generator/src/llm/llm_service.py
Comment thread rre-dataset-generator/src/llm/llm_service.py Outdated
Comment thread rre-dataset-generator/src/model/llm_schemas.py Outdated
Comment thread rre-dataset-generator/src/model/llm_schemas.py Outdated
Comment thread rre-dataset-generator/src/model/llm_schemas.py Outdated
Comment thread rre-dataset-generator/src/model/llm_schemas.py Outdated
Comment thread rre-dataset-generator/tests/unit/llm/test_llm_service_queries.py Outdated
Comment thread rre-dataset-generator/tests/unit/llm/test_llm_service_score.py
…iel - splited in 2 files - added exhaustive tests - updated llm_service
Comment thread rre-dataset-generator/src/model/query_response.py
@Intrinsical-AI Intrinsical-AI changed the title Dage 16: llm pydantic schemas Dage 16: response validation Schemas Jul 28, 2025
Comment thread rre-dataset-generator/src/model/query_response.py
@Intrinsical-AI Intrinsical-AI merged commit 51c66e7 into dataset-generator Jul 28, 2025
1 check passed
nicolo-rinaldi pushed a commit that referenced this pull request Jul 28, 2025
* Minor fixes / improvements
* Used simple data structures to perform validation of LLM responses in the LLM Service
* Explored Pydantic, decided simple dict / lists / custom objetcts
description = (" - 0: the query is NOT relevant to the given document"
" - 1: the query may be relevant to the given document"
" - 2: the document proposed is the answer to the query")
allowed = {0, 1, 2}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

allowed is assigned but never used.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hello Naz, you're right. Feel free to update as discussed!

Returns the validated score.

Returns:
The validated score.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

duplicate description

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will bring up the Docstring unification in next standups

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