GithubHelp home page GithubHelp logo

lmgym's Introduction

lmgym

Language Model Gym

This repository records Chai Research's library for training language models which are then deployed to the Chai app. Our current framework is based on Reinforcement Learning from Human Feedback, this repository includes our work on reward modelling and proximal policy optimization (based on a modified version of trlx). Most of our model training been augmented with techniques from DeepSpeed as well as some novel optimizations. We aim to make this repo a centralized and accessible place to gather techniques for large language models that improves convertibility and is aligned with user intentions. Some of the dataset referenced within the repository may not be publicly avaliable.

Initial Setup

Create a Python 3 virtual environment and activate:

virtualenv -p python3 env
source ./env/bin/activate

Install requirements by running:

pip install -r requirements.txt

Then export project to python path:

export PYTHONPATH=$PATH_TO_REPO

To test the scripts, run pytest in the root directory, you may wish to install pytest separately

Reward Modelling

Repository setup

Inside the folder reward_models you may find the following files and folders:

  • config.py contains huggingface authentication token and weights and biases token, you may wish to either add them inside your environment variable or update the file accordingly
  • utils.py contains some general utility functions
  • experiments folder contains all the experiments that have been open sourced, we recommend training using 4xA40 GPUs
  • custom folder contains custom callback functions, custom trainers instantiated from the transformer Trainer class and some helper functions used during training
  • evaluation folder allows users to configure a best-of-N chatbot which they can speak to (by calling the eval_rewards_api.py at the root of the repository

Speaking with trained reward models

After completing training, you may wish to manually evaluate your reward model against existing reward models.

  • First, create an experiment under reward_models/evaluation/experiments, you need to specify a get_base_model() (we use GPTJ) and a dictionary mapping model name to an reward model object
  • Second, run the eval_rewards_api.py by invoking python3 -m IPython -i -- eval_rewards_api.py talk_to_models --experiment_name $NAME_OF_EXPERIMENT_FILE --select_model $ONE_OF_REWARD_MODEL_NAMES
  • This will prompt you to enter model prompt and bot's first message, for each user input, you will see N generated responses and their corresponding reward model scores / ranks.

lmgym's People

Contributors

alekseykorshuk avatar xl402 avatar

Stargazers

Sergey avatar snowden avatar  avatar  avatar ys01 avatar  Deleted user  avatar Dawoon Jung avatar  avatar Mengdi Li avatar LTC avatar Rami Rustom avatar VEEU avatar Tokarev Igor avatar Nguyễn Văn Anh Tuấn avatar Jason Wheeler avatar Yacine Zahidi avatar Nam Pham avatar Alex Nguyen avatar Christian cancedda avatar Dennis Hilgers avatar tr416 avatar

Watchers

Alex Nguyen avatar Shantanu Sharma avatar Robert Irvine avatar ys01 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.