-
Notifications
You must be signed in to change notification settings - Fork 13
Feature/zero shot evaluation #28
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
Conversation
- Add query generator for generating evaluation queries - Add response collector for collecting model responses - Add rubric generator for creating evaluation rubrics - Add evaluator for running evaluations - Add checkpoint support for resumable evaluations - Add example configurations
- Add comprehensive documentation for zero-shot evaluation feature - Include usage guide, configuration, and best practices - Add to mkdocs navigation under Applications section
Summary of ChangesHello @XiaoBoAI, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request delivers a powerful Zero-Shot Evaluation framework, enabling users to efficiently benchmark and compare various AI models and agent configurations. By automating the entire evaluation lifecycle from query generation to result analysis, it removes the dependency on pre-labeled datasets, significantly accelerating the assessment of new models or pipelines. The framework is designed for flexibility, offering both command-line and programmatic interfaces, and incorporates advanced techniques to ensure the quality and diversity of generated test cases. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces a comprehensive zero-shot evaluation cookbook, which is a significant new feature. The implementation is well-structured, with clear separation of concerns into components for configuration, query generation, response collection, evaluation, and checkpointing. The code is generally of high quality, with good use of modern Python features like asyncio and pydantic. I've identified a couple of high-severity race conditions in the parallel query generation logic that could lead to duplicate queries. I've also left some medium-severity comments regarding maintainability, such as removing hardcoded filenames and improving import style. Overall, this is a great addition, and with these fixes, it will be even more robust.
| # Validate and deduplicate | ||
| is_valid, reason = QueryValidator.validate(query_obj) | ||
| if not is_valid: | ||
| logger.debug(f"Batch {batch_id}: Skipping invalid query: {reason}") | ||
| continue | ||
|
|
||
| if self.deduplicator.add(query_obj.query): | ||
| queries.append(query_obj) | ||
| else: | ||
| logger.debug(f"Batch {batch_id}: Skipping duplicate query") | ||
|
|
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.
The use of self.deduplicator.add() inside this method, which is called in parallel, creates a race condition. The stateful deduplicator is not safe for concurrent writes. Multiple coroutines can check for duplicates before any of them has updated the deduplicator's state, leading to duplicate queries being added.
Deduplication should be performed after all parallel generation is complete. Please remove the deduplication logic from this method and move it to the generate method, after _parallel_generate returns.
# Validate query
is_valid, reason = QueryValidator.validate(query_obj)
if not is_valid:
logger.debug(f"Batch {batch_id}: Skipping invalid query: {reason}")
continue
queries.append(query_obj)| # Validate and deduplicate | ||
| is_valid, _ = QueryValidator.validate(evolved_query) | ||
| if is_valid and self.deduplicator.add(evolved_query.query): | ||
| evolved.append(evolved_query) |
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.
Similar to _generate_batch, this method has a race condition when using self.deduplicator.add() because _evolve_single is called concurrently. This can lead to duplicate queries being added. Deduplication should be performed after all parallel evolution tasks are complete.
# Validate and add evolved query
is_valid, _ = QueryValidator.validate(evolved_query)
if is_valid:
evolved.append(evolved_query)| self._checkpoint_mgr.update_stage( | ||
| EvaluationStage.QUERIES_GENERATED, | ||
| total_queries=len(self._queries), | ||
| queries_file=str(self._checkpoint_mgr.output_dir / "queries.json"), | ||
| ) |
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.
The filename queries.json is hardcoded here. To improve maintainability and reduce coupling, it's better to use the QUERIES_FILE constant defined in the CheckpointManager class. This ensures that if the filename ever changes, it only needs to be updated in one place. This same issue applies to responses.json and rubrics.json in the subsequent checkpoint updates in this file.
| self._checkpoint_mgr.update_stage( | |
| EvaluationStage.QUERIES_GENERATED, | |
| total_queries=len(self._queries), | |
| queries_file=str(self._checkpoint_mgr.output_dir / "queries.json"), | |
| ) | |
| self._checkpoint_mgr.update_stage( | |
| EvaluationStage.QUERIES_GENERATED, | |
| total_queries=len(self._queries), | |
| queries_file=str(self._checkpoint_mgr.output_dir / self._checkpoint_mgr.QUERIES_FILE), | |
| ) |
| # ============================================================================= | ||
|
|
||
|
|
||
| from pydantic import BaseModel, Field |
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.
… components - Move core modules to top-level directory (checkpoint, schema, query_generator, response_collector, zero_shot_pipeline) - Add pairwise_analyzer to openjudge/analyzer - Add rubric_generator to openjudge/generator - Update imports and exports in __init__.py files - Simplify core/__init__.py to re-export from parent module
- Remove RubricGenerationConfig class, pass parameters directly to constructor - Add DEFAULT_RUBRICS constant for fallback rubrics - Update zero_shot_evaluation docs with pre-defined queries usage guide - Simplify related tests
- Fix line too long in pairwise_analyzer.py (C0301) - Remove unnecessary lambda in generator.py (W0108) - Fix parameter renaming issue in _generate_rubrics method (W0237) - Remove unused DEFAULT_RUBRICS import - Apply isort and black formatting fixes
XieLipeng0830
left a comment
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.
The implementation in the simple_rubric module, including generator.py and rubric_generator.py, successfully supports the intended functionality as specified.
No description provided.