Coder Social home page Coder Social logo

cambioml / pykoi-rlhf-finetuned-transformers Goto Github PK

View Code? Open in Web Editor NEW
399.0 10.0 41.0 55.37 MB

pykoi: Active learning in one unified interface

Home Page: https://www.cambioml.com

License: Apache License 2.0

Python 23.75% HTML 0.03% Svelte 17.31% CSS 1.65% JavaScript 1.74% Jupyter Notebook 55.27% Dockerfile 0.25%
ai chatbot feedback language-model llm machine-learning rlhf

pykoi-rlhf-finetuned-transformers's Introduction

🎏 pykoi: RLHF/RLAIF in one unified interface

License Apache-2.0 pypi_status Commit activity Slack

pykoi is an open-source python library for improving LLMs with RLHF. We provide a unified interface including RLHF/RLAIF data and feedback collection, finetuning with reinforcement learning and reward modeling, and LLM comparisons.

Features

pykoi let you easily get real-time user feedback and continuously improve your models. Here are some common applications:

Sharable UI

Do you want to store your chat history with LLMs from OpenAI, Amazon Bedrock(:woman_technologist: building now :man_technologist:), or Huggingface? With just three lines of code, pykoi lets you to store them locally, ensuring 100% privacy. This includes launching a chatbot UI, automatically saving your chat history in your compute instance (cpu or gpu), and visualizing it on a dashboard. Explore the demos below:

Watch the video

Model comparison

Comparing models is a difficult task. pykoi makes it easy by allowing one to directly compare the performance of multiple models to each other, with just a few lines of code. If you have multiple language models that you’d like to compare to each other on a set of prompts or via an interactive session, you can use pk.Compare. Check out any of the demo below:

Watch the video

RLHF

Reinforcement Learning with Human Feedback (RLHF) is a unique training paradigm that blends reinforcement learning with human-in-the-loop training. The central idea is to use human evaluative feedback to refine a model's decision-making ability and guide the learning process towards desired outcomes. Researchers from Deepmind, OpenAI and Meta Llama2 have all demonstrated that RLHF is a game changer for large language models (LLMs) training.

pykoi allows you to easily fine-tune your model on the datasets you've collected via your pykoi chat or rank databases. Check our blog for detailed instructions on how to use it.

RAG

Implement a Retrieval-Augmented Generation (RAG) Chatbot quickly with pykoi. Upload your own documents to create context-aware responses on top of a pretrained LLM, such as from OpenAI or Huggingface.

Watch the video

Then chat with the RAG Chatbot, where you can select specific sources for the text generation, as well as see which sources the model used to generate the response.

Watch the video

Finally, you can save a modified response to help improve the model. This is a great way to collect data for RLHF.

Watch the video

Installation

To get started with pykoi, you can choose from any of the installation options. The choice should be based on the features you need (e.g., RAG, RLHF or all) and the compute resources you have, such as a CPU (e.g., your laptop) or GPU (e.g., AWS EC2 or SageMaker).

Option 1: RAG (CPU)

This option allows you to run RAG on a CPU using either the OpenAI API or the Anthropic Claude2 API. Installation of RAG (CPU) is simple if you have conda. If not, install conda for your operating system.

First, create a conda environment on your terminal using:

conda create -n pykoi python=3.10 -y
conda activate pykoi  # some OS requires `source activate pykoi`

Then install pykoi and the compatible pytorch based on your os

pip3 install "pykoi[rag]"
pip3 install torch

Option 2: RAG (GPU)

This option allows you to run RAG on a GPU using an open-source LLM from HuggingFace. Here's a quick tutorial on setting up an EC2 GPU instance for the installation below.

On your GPU instance terminal, create a conda environment using:

conda create -n pykoi python=3.10 -y && source activate pykoi

Then install pykoi and pytorch based on your cuda version. You can find your CUDA version via nvcc -V.

pip3 install "pykoi[rag, huggingface]"

pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu121  # cu121 means cuda 12.1

Option 3: RLHF (GPU)

This option allows you to train LLM via RLHF on a GPU. Here's a quick tutorial on setting up an EC2 GPU instance for the installation below.

On your GPU instance terminal, create a conda environment using:

conda create -n pykoi python=3.10 -y && source activate pykoi

Then install pykoi and pytorch based on your cuda version. You can find your CUDA version via nvcc -V.

pip3 install "pykoi[rlhf]"

pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu121  # cu121 means cuda 12.1

Congrats you have finished the installation!

Dev Setup

If you are interested to contribute to us, here are the preliminary development setup.

Backend Dev Setup

conda create -n pykoi python=3.10
conda activate pykoi
cd pykoi
pip3 install poetry

Then, based the feature you need to develop, run one or more installation options below. We recommend install all the options below although it may take ~3 minutes longer.

  • Option 1: RAG (CPU)
    poetry install --no-root --extras rag
    
  • Option 2: RAG (GPU)
    poetry install --no-root --extras "rag huggingface"
    
  • Option 3: RLHF (GPU)
    poetry install --no-root --extras rlhf
    

Finally, if you are on a GPU, install pytorch based on your cuda version. You can find your CUDA version via nvcc -V.

pip3 uninstall -y torch
pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu121  # cu121 means cuda 12.1

Now you are done with installing, try to modify one of the examples and run the below command!

python -m example.retrieval_qa.retrieval_qa_huggingface_demo

Frontend Dev Setup

cd pykoi/pykoi/frontend
npm install
npm run build

EC2 Dev Setup

If you are on EC2, you can launch a GPU instance with the following config:

  • EC2 g5.2xlarge (if you want to run a pretrained LLM with 7B parameters)

  • Deep Learning AMI PyTorch GPU 2.0.1 (Ubuntu 20.04) Alt text

  • EBS: at least 100G

    Alt text

pykoi-rlhf-finetuned-transformers's People

Contributors

goldmermaid avatar jwilber avatar jojortz avatar cambioml avatar alexchen4ai avatar llauraa23 avatar ricki-epsilla avatar hfnhf avatar asaiacai avatar ethanyanjiali avatar garyjyzhang avatar lipingx avatar lucasjwilber avatar zimplex avatar largelanguagemodels avatar sdeavin22 avatar

Stargazers

 avatar Kaiqu Liang avatar Doxie avatar Jongwon Kim avatar Minho Ryang avatar Carlos avatar Keith Hon avatar  avatar Aditya Mandke avatar Always avatar Jing avatar  avatar Vangelis Metsis avatar Matt Kidd avatar  avatar Henry Song avatar Pengyu CHEN avatar  avatar Hugo avatar Karol J. Piczak avatar Marcin avatar Omar Valdez avatar Xin Li avatar Guilherme Euzébio avatar Akaash Patel avatar Adrian Salceanu avatar Ben Wunderlich avatar  avatar  avatar Rob avatar Ibrahim H. avatar Yong Liu avatar  avatar 0x000 avatar Brandon J. Bjelland avatar El Dorado131 avatar Murat avatar Derry Redjeki avatar Srihari Thyagarajan avatar Alex C avatar J. Lee avatar Tyler Etchart avatar Alex Ruco avatar Sushanth Reddy avatar Daoist space avatar Pavel Klymenko avatar Loïc Roux avatar Lara Strachan avatar KC Okolo avatar Christian Ledermann avatar  avatar Tim Yardley avatar Sean DiSanti avatar Boris avatar  avatar kelsy gagnebin avatar Dan avatar Samuel R avatar TonyMoMoney avatar Robert Dempsey avatar uriel avatar Henry Ward avatar Roger Mattos avatar  avatar Alex Chen avatar Harsh Singh avatar  avatar  avatar Thetoolist avatar Wei_Yao avatar Pamela Claridy avatar Kevin Ding avatar Charlie Cheng-Jie Ji avatar LiangxuanZhao avatar Animesh Kumar avatar Hu Xiaolin avatar ddelange avatar harshavardhanpb avatar Eric Richmond avatar  avatar Victor avatar Robb Beal avatar Yuncong Chen avatar Edison Yao avatar Allie Ellis avatar  avatar Zack Li avatar  avatar 레오(김현옥) avatar  avatar  avatar Jamie Lee avatar  avatar Jiayu Liu avatar louis030195 avatar Jarrian Gojar avatar Subham Kumar avatar Lukasz Hanusik avatar Samuel Rincé avatar Taha avatar

Watchers

 avatar  avatar Stella Gao avatar Diyi Hu avatar Lingjie Kong avatar Brent Werness avatar Unprocessable Man avatar 轻茹莉莉酱 avatar  avatar  avatar

pykoi-rlhf-finetuned-transformers's Issues

How to connect to the model endpoint ?

Hi this is my code and I'd like to use my azure openai endpoint but it doesn't work . I really wanna try to use the pykoi app. Could anybody give me a good solution ? Thanks.

image

image

`import pykoi as pk
import openai

openai.api_type = "azure"
openai.api_base = ""
openai.api_version = "2022-12-01"
OPENAI_API_KEY = ""
openai.api_key = OPENAI_API_KEY

model = "endpoint"

add chatbot to model

chatbot = pk.Chatbot(model, feedback='vote')

analyze chatbot usage & feedback

dashboard = pk.Dashboard(chatbot)

Create sharable link to the application

app = pk.Application(share=True, username="test", password="1234")
app.add_component(chatbot)
app.add_component(dashboard)
app.run()
`

frontend app not working

Hi, I like your repo and I'd like to contribute & test pykoi.

I've installed pykoi, conda, and git repo and I've got some problems with running frontend app
I assume it's the matter of the Node.js version and I'd like to know which version is compatible with frontend Node

Thank you
image

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.