-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: add EvolInstruct alike methods to camel/datagen
#1747
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
base: master
Are you sure you want to change the base?
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
| # simulate random scores in range (1, 10) for now | ||
| scores = [random.randint(1, 10) for _ in batch_results[1:]] if keep_original else [random.randint(1, 10) for _ in batch_results] | ||
| else: | ||
| # TODO: implement instruction scoring module, e.g., complexity/quality scorer or by reward advantage |
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.
left a future feature on scorer which evaluates instructions, that can be rule-based or by a generative agent. some references:
- https://arxiv.org/pdf/2312.15685 using instruction complexity (by llm judge) as the score
- https://arxiv.org/pdf/2411.00062 using reward advantage as the score
- other metric for data selection/sampling: perplexities, reward variance, ...
| IN_BREADTH_KEYS = ['persona', 'shift-in', 'shift-out', 'mix', 'abstract'] | ||
| IN_DEPTH_KEYS = ['constraints', 'deepening', 'concretizing', 'reasoning', 'expansion'] | ||
|
|
||
| EVOL_METHODS = { |
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.
notes: we can define more domain-specific templates (e.g., for math/coding/...).
also, currently the evolving happens independently for each prompt (x' ~ LLM( | x, ins)); we should improve this later so that the evolving becomes multi-prompt / group based (x' ~ LLM( | a cluster of x, ins)), where the LLM can crossover and mutate in a group.
regarding the prompt groups -- some time ago, @lightaime mentioned message-passing based sampling. we can also include support for this in our pipeline.
zjrwtx
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.
Great thanks for your work @ZIYU-DEEP ,but some docstring need to be polished
| self, | ||
| agent: ChatAgent, | ||
| ): | ||
| """ |
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.
| """ | |
| r""" |
zjrwtx
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.
great thanks for your work @ZIYU-DEEP
EvolInstruct alike methods to camel/datagenEvolInstruct alike methods to camel/datagen
|
Ziyu @ZIYU-DEEP and I had a discussion about the current
We will collaborate to improve these aspects. If you have any ideas, feel free to discuss them with us! |
Wendong-Fan
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.
thanks @ZIYU-DEEP for the contribution and sorry for the late review, left some comments below, we also need to add unit test to this feature, please run pre-commit run --all-files locally in your terminal to check the pre commit error now existing~
|
|
||
| def _set_method( | ||
| self, | ||
| method: Optional[Union[str, List[str]]] = "uniform", |
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.
string could be too general? how about use Literal
method: Optional[Union[Literal["uniform", "in-breadth", "in-depth",....]
| def _generate_single( | ||
| self, | ||
| prompt: str, # for a single prompt | ||
| method: str = "uniform", |
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.
use Literal?
| else: | ||
| # TODO: implement instruction scoring module, e.g., complexity/quality scorer or by reward advantage | ||
| raise NotImplementedError(f"Scorer '{scorer}' is not implemented.") | ||
|
|
||
| # select the prompt with the highest score | ||
| best_index = scores.index(max(scores)) | ||
| current_prompt = batch_results[best_index + 1][0] if keep_original else batch_results[best_index][0] |
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.
seems if best_index is the last element in scores (e.g., if the last generated prompt has the highest score), then best_index + 1 would point to an element beyond the bounds of batch_results?
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.
keep_original will add one more prompt to the list prior to this.
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.
could we move the .ipynb under docs/cookbooks/data_generation?
|
Thanks a lot @Wendong-Fan! just resolved some minor issues. converting this PR a draft and handing over to @Zhangzeyu97 to work on the |
Description
Describe your changes in detail (optional if the linked issue already contains a detailed description of the changes).
Fixes #1737. Changes made in:
./examples/datagen/evol_instruct./camel/datagen/evol_instructChecklist
Go over all the following points, and put an
xin all the boxes that apply.Fixes #issue-numberin the PR description (required)pyproject.tomlandpoetry.lockNotes for Reviewers
The current data handling of
EvolInstructandSelfInstructdiffers and could be improved. Let's discuss how to better align them with a base class?