-
Notifications
You must be signed in to change notification settings - Fork 42
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
Introduce data mixing recipe yaml files #203
Conversation
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! This looks great @bbrowning 🚢
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.
Some minor comments, but I think the point about what recipe_path
is relative to is probably important - e.g. has this been tested with ilab data generate
?
src/instructlab/sdg/configs/knowledge/data_recipe/default_recipe.yaml
Outdated
Show resolved
Hide resolved
Marking as draft while I work on absolute vs relative paths a bit, as well as address the other feedback here. |
src/instructlab/sdg/configs/skills/data_recipe/default_recipe.yaml
Outdated
Show resolved
Hide resolved
Ok, lots of great discussion in these threads. It's a lot to absorb, but I think it boils down to a pretty straightforward set of changes Default recipes - downstream If a downstream user/packager wants to add default recipes (and datasets), they should install them in
Default recipes - testing Since we won't have default recipes in the library, we do need some way of ensuring this code path is tested - this can be done with a unit test. But it is a requirement to merge this PR IMO. Community dataset recipe - upstream Assuming we have at least unit testing of recipes, I don't think this is a blocker to merging this PR - I'm fine with just filing an issue to capture this. We want to enable upstream users to mix the They would download the dataset and place it in It can be supplied with e.g. This path could be tested in our e2e CI, which would also improve automated testing coverage of the library. Hugging Face downloads in library Given the above, there is no need for the library to have support for downloading from Hugging Face Relative paths There is no requirement to support relative paths to recipes files. Paths to dataset should be considered relative to the recipe file. Empty recipes
sys_prompt It sounds like we never want to use the Move |
Thank you @markmc , that is super helpful. I've pushed a commit that should adjust to the |
For reference, the generated recipe yaml files now look like this: datasets:
- path: instructlab/InstructLabCommunity
sampling_size: 1.0
- path: node_datasets_2024-07-25T10_27_12/knowledge_tonsils_overview_e2e-tonsils_p10.jsonl
sampling_size: 1.0
metadata:
sys_prompt: "I am, Red Hat\xAE Instruct Model based on Granite 7B, an AI language\
\ model developed by Red Hat and IBM Research, based on the Granite-7b-base language\
\ model. My primary function is to be a chat assistant." I've updated the original comment at the top of this PR to reflect the current state as well. |
e6bdfc2
to
cc2aa1d
Compare
cc2aa1d
to
4e43bad
Compare
Assuming CI passes, I believe all concerns are addressed now. @markmc added in support for loading of default recipe files from #201 was opened and expanded with more details as a result of the conversations in this PR to figure out how to properly get the precomputed dataset from HuggingFace into the upstream This PR no longer includes downloading anything from HuggingFace, as several valid concerns were brought up about doing that silently and without explicit user intent. Empty We do not load sys_prompt from the recipe files, but do write it out to them under a new |
This pull request has merge conflicts that must be resolved before it can be |
9f8bcee
to
9c4f64f
Compare
src/instructlab/sdg/datamixing.py
Outdated
# Mixed data is written out relative to a recipe's own | ||
# path, so update the recipe's path to the newly written | ||
# one before writing out its datasets | ||
recipe.recipe_path = full_recipe_path |
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.
Maybe I'm being dumb, but I really don't understand what's going on here
We've just written a recipe file to a path, and setting recipe.recipe_path
is going to influence where the dataset gets written? But save_mixed_dataset()
doesn't use recipe_path
?
Thanks!
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.
save_mixed_dataset()
DOES use recipe_path
, as it reads the datasets in from disk to mix them. I wasn't very happy with this when I wrote it, and I should have recognized the code smell myself when I wrote that comment explaining what it's doing. What happens is we loaded a default recipe from whatever path - say /default_recipes/skills.yaml
(or instantiated an empty Recipe()
, perhaps). Then, we save the recipe to a new path - like /generated_data/skills_train_recipe.yaml
. At this point, the actual Recipe instance we have still thinks its recipe_path
is /default_recipes/skills.yaml
, even though we wrote it out to a different path. The fix staring me in the face as I type this is that when someone calls save_recipe
, that should update the Recipe's recipe_path
to the new path it just wrote itself out to.
The datasets are added to the recipe with a relative path, the recipe is written to a new path, and we then need to update the recipe to know its new path so that it can successfully load the datasets from the relative path, which is relative to the newly written location versus the original location.
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.
I pushed one more commit that adjusts this that feels better for me, and keeps this detail encapsulated within the Recipe class instead of leaking out to consumers.
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.
Looks good to me, thanks @bbrowning
Happy for you to merge this when CI passes
Thanks! Will squash commits, unmark from Draft, and merge when CI is good. |
This introduces Recipe yaml files, which are used both as an input into the data mixing process and as an output of the process. As an input, we have some default recipe files that specify any precomputed datasets that should be mixed with data from new skills when generating the overall mix of samples that will be sent to the training process. If a downstream user/packager wants to add default recipes (and datasets), they should install them to a path like `/usr/share/instructlab/sdg` (varies by platform, uses Python's `platformdirs.PlatformDirs` to respect platform conventions). Recipes should be in sdg/default_data_recipes/{knowledge,skills}.yaml Datasets should be in sdg/datasets but this location is not enforced. Currently we are not shipping any default recipe files in the upstream, but there is a unit test in place to ensure the functionality to load default recipes from disk works once we decide how we want to ship a precomputed dataset to our upstream users. As an output of the data generation process, we write recipe yamls to document which datasets were mixed together and in what proportions along with the system prompt that was used during the generation. Here's an example of a recipe yaml put into the output directory after running data generation: ```yaml datasets: - path: node_datasets_2024-07-25T17_49_46/knowledge_tonsils_overview_e2e-tonsils_p10.jsonl sampling_size: 1.0 metadata: sys_prompt: "I am, Red Hat\xAE Instruct Model based on Granite 7B, an AI language\ \ model developed by Red Hat and IBM Research, based on the Granite-7b-base language\ \ model. My primary function is to be a chat assistant." ``` Datasets may be referenced by relative paths, which are relative to the recipe's own directory. Or, they may use absolute filesystem paths. Anything written out under the metadata section (currently just sys_prompt) is purely informational for the user and ignored when loading recipes. Parts of this are extracted and rebased from aakankshaduggal#4 aakankshaduggal#20 Refs instructlab#162, instructlab#171, instructlab#185, instructlab#201. Co-authored-by: shivchander <[email protected]> Co-authored-by: Khaled Sulayman <[email protected]> Co-authored-by: abhi1092 <[email protected]> Co-authored-by: Aakanksha Duggal <[email protected]> Co-authored-by: Mark McLoughlin <[email protected]> Signed-off-by: Ben Browning <[email protected]>
6ab40d8
to
fcfacfc
Compare
This introduces Recipe yaml files, which are used both as an input into the data mixing process and as an output of the process.
As an input, we have some default recipe files that specify any precomputed datasets that should be mixed with data from new skills when generating the overall mix of samples that will be sent to the training process. In our specific case, we're adding in a single precomputed dataset of
instructlab/InstructLabCommunity
that gets pulled from HuggingFace and mixed with new skill samples.As an output of the data generation process, we write recipe yamls to document which datasets were mixed together and in what proportions along with the system prompt that was used during the generation. Here's an example of a recipe yaml put into the output directory after running data generation:
While this change is relatively small, it came from some much larger PRs that were co-authored by multiple people so giving credit to all of those here.
Parts of this are extracted and rebased from
aakankshaduggal#4
aakankshaduggal#20
Refs #162, #171, #185, #201.