Skip to content
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

Add alpaca reverse augmentation possibility #2342

Merged
merged 10 commits into from Apr 7, 2023

Conversation

CloseChoice
Copy link
Collaborator

closes #2335

  • Add possiblity to reverse question and response for alpaca dataset
  • add debug configs to show how to used

Alpaca with reverse augmentation can be run with:

python trainer_sft.py --configs pythia-70m-deduped

I couldn't run this due to unscale gradient errors, so before this gets merged we should do a run to check whether this reversal really improves the loss.

@github-actions
Copy link

github-actions bot commented Apr 6, 2023

pre-commit failed.
Please run pre-commit run --all-files locally and commit the changes.
Find more information in the repository's CONTRIBUTING.md

@CloseChoice
Copy link
Collaborator Author

Eval dataset is still missing

@CloseChoice
Copy link
Collaborator Author

One thing that is not quite clear to me is if we should the reverse augmentation samples ADDITIONALLY to the train set

@andreaskoepf
Copy link
Collaborator

One thing that is not quite clear to me is if we should the reverse augmentation samples ADDITIONALLY to the train set

Yes, I think forward + reverse could both be part of the training set. Ideally the same examples of the alpaca set should be used for evaluation of both forward/reverse (in order to avoid leaking of eval-data of the other dataset into the train set).

@andreaskoepf
Copy link
Collaborator

I couldn't run this due to unscale gradient errors, so before this gets merged we should do a run to check whether this reversal really improves the loss.

For the smaller models it is necessary to specify dtype: float32 in the configuration to avoid this error.

@CloseChoice
Copy link
Collaborator Author

CloseChoice commented Apr 6, 2023

Added the eval set and also the option to keep the unreversed data in the training set.
Note that if we reverse and keep the unreversed aswell, that the val_split size does not match the quotient len(val) / (len(train) + len(val)) anymore. Don't think that this is an issue though.

@CloseChoice CloseChoice marked this pull request as ready for review April 6, 2023 08:30
@andreaskoepf andreaskoepf added the ml label Apr 6, 2023
Copy link
Collaborator

@andreaskoepf andreaskoepf left a comment

Choose a reason for hiding this comment

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

Very nice, thank you. IMO the now 'blood-empty' AlpacaDataset & CodeAlpacaDataset could be removed.

super().__init__()
self.data = data
if mode not in ["sft", "rl"]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

could be tuple instead of list

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

class Alpaca(AlpacaBase):
def __init__(self, mode: str = "sft", cache_dir: str = None) -> None:
super().__init__(dataset_name="yahma/alpaca-cleaned", mode=mode, cache_dir=cache_dir)
class AlpacaDataset(AlpacaBaseDataset):
Copy link
Collaborator

Choose a reason for hiding this comment

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

If these classes don't add any functionality they could be removed (i.e. base class be used directly).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

manual_seed: int = 287631038922,
reverse_augmentation: bool = False,
keep_unreversed: bool = True,
) -> tuple[AlpacaDataset, AlpacaDataset] | tuple[CodeAlpacaDataset, CodeAlpacaDataset]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

base class type annotation for factory function would be better imo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

model/model_training/custom_datasets/__init__.py Outdated Show resolved Hide resolved
model/model_training/configs/config.yaml Outdated Show resolved Hide resolved
Copy link
Collaborator

@andreaskoepf andreaskoepf left a comment

Choose a reason for hiding this comment

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

lgtm!

@andreaskoepf andreaskoepf enabled auto-merge (squash) April 7, 2023 23:45
@andreaskoepf andreaskoepf merged commit f8c1cd2 into main Apr 7, 2023
1 check passed
@andreaskoepf andreaskoepf deleted the feature/reverse-augmentation-alpaca branch April 7, 2023 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement inversion samples for alpaca.
2 participants