GithubHelp home page GithubHelp logo

renee127 / trlx-with-t5 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cg80499/trlx-with-t5

0.0 0.0 0.0 45.62 MB

A repo for distributed training of language models with Reinforcement Learning via Human Feedback (RLHF)

License: MIT License

Python 100.00%

trlx-with-t5's Introduction

Transformer Reinforcement Learning X

trlX allows you to fine-tune ๐Ÿค— Hugging Face supported language models (gpt2, gpt-j, gpt-neo and gpt-neox based) up to 20B parameters using reinforcement learning via either a provided reward function or reward-labeled dataset. Proximal Policy Optimization (PPO) and Implicit Language Q-Learning (ILQL) are implemented.

You can read more about trlX in our documentation.

Installation

git clone https://github.com/CarperAI/trlx.git
cd trlx
pip install torch --extra-index-url https://download.pytorch.org/whl/cu116 # for cuda
pip install -e .

How to Train

You can train a model using a reward function or a reward-labeled dataset.

Using a reward function

model = trlx.train('gpt2', reward_fn=lambda samples: [sample.count('cats') for sample in samples])

Using a reward-labeled dataset

model = trlx.train('EleutherAI/gpt-j-6B', dataset=[('dolphins', 'geese'), (1.0, 100.0)])

Trained model is a wrapper over a given autoregressive model

model.generate(**tokenizer('Q: Who rules the world? A:', return_tensors='pt'), do_sample=True)

Use ๐Ÿค— Accelerate to launch distributed training

accelerate config # choose DeepSpeed option
accelerate launch examples/simulacra.py

Use Ray Tune to launch hyperparameter sweep

python -m trlx.sweep --config configs/sweeps/ppo_sweep.yml examples/ppo_sentiments.py

For more usage see examples

Contributing

For development check out these guidelines and also read our docs

Acknowledgements

Many thanks to Leandro von Werra for contributing with trl, a library that initially inspired this repo.

trlx-with-t5's People

Contributors

shahbuland avatar dahoas avatar jon-tow avatar maxreciprocate avatar lvwerra avatar cg80499 avatar cat-state avatar louiscastricato avatar dependabot[bot] avatar ayulockin avatar leshanbog avatar thedch avatar dongs0104 avatar mrm8488 avatar osanseviero avatar reshinthadithyan avatar simoninithomas avatar vblagoje avatar thomfoster avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.