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

Allow "weight: 0" in messages to mask them #1703

Merged

Commits on Jun 12, 2024

  1. Allow "weight: 0" in messages to mask them

    Allow in message objects the additional key `weight`, which can be set
    to 0 (or 1) to cause that message to be masked out (or left unmasked)
    for training (similar to [1]). This is helpful for training the model to be robust and
    capable of error recovery upon a bad assistant message.
    A missing `weight` key defaults to weight 1, to guarantee downward compatibility.
    
    Extend `src/axolotl/prompters.py::_build_result` and
    `src/axolotl/prompt_strategies/sharegpt.py::SimpleShareGPTPromptTokenizingStrategy::get_conversation_thread`
    to return the turns with weights as additional tuple element.
    Do this in axolotl directly instead of modifying `fastchat.conversation`'s `Conversation`.
    
    Extend `src/axolotl/prompt_tokenizers.py::tokenize_prompt` to mask out tokens when weight is set to 0.
    
    Extend `tests/prompt_strategies/test_sharegpt.py` with four test cases that contain messages with `weight` keys.
    Switch names `test_w_train_on_input` and `test_no_train_on_input`.
    
    [1]: https://github.com/mistralai/mistral-finetune
    DavidFarago committed Jun 12, 2024
    Configuration menu
    Copy the full SHA
    14428da View commit details
    Browse the repository at this point in the history