DEV Community

Cover image for Understanding Reinforcement Learning with Human Feedback Part 1: Pre-Training Large Language Models
Rijul Rajesh
Rijul Rajesh

Posted on

Understanding Reinforcement Learning with Human Feedback Part 1: Pre-Training Large Language Models

In this article, we will explore Reinforcement Learning with Human Feedback (RLHF).

RLHF is one of the techniques used to help train large language models like ChatGPT.

Starting with an Untrained Model

Suppose we want to build a model like ChatGPT from scratch so that we can ask it questions.

To do this, we first need to understand how to train an untrained decoder-only transformer model.

By untrained, we mean that all the weights and biases in the model are initialized with random values.

At this stage, the model does not understand language or meaning.


The First Step: Pre-Training

The first step in training a large language model is to teach it to predict the next token using a very large body of text, such as Wikipedia articles.

We take segments of text and use the earlier words as input tokens. The model then learns to predict the next token in the sequence.

For example, if the input is:

“The cat sat on the…”

The model learns to predict the next likely word.

By repeating this process across a massive amount of text, the model gradually learns:

  • grammar
  • sentence structure
  • facts and patterns in language

This training stage is called pre-training.

Over time, this process produces a pretrained model.


Why Pre-Training Is Not Enough

At this point, the model becomes good at predicting the next token in text.

However, simply predicting the next token is not enough to solve the problem of answering questions like a chatbot.

For example, being good at continuing Wikipedia text does not automatically mean the model will give helpful, safe, or conversational responses.

To make the model useful for chat, we need to align it with human expectations.

We will explore this in the next article.


Looking for an easier way to install tools, libraries, or entire repositories?
Try Installerpedia: a community-driven, structured installation platform that lets you install almost anything with minimal hassle and clear, reliable guidance.

Just run:

ipm install repo-name
Enter fullscreen mode Exit fullscreen mode

… and you’re done! 🚀

Installerpedia Screenshot

🔗 Explore Installerpedia here

Top comments (0)