---
type: Concept
title: "Reinforcement Learning from Human Feedback (RLHF)"
description: "RLHF (Reinforcement Learning from Human Feedback) is the technique that trains AI models using human evaluations so responses align more closely with what people expect."
resource: https://felipecferreira.com.br/en/library/what-is-rlhf/
generated: { by: process:okf-bridge, at: 2026-11-23T13:38:54Z }
published_at: 2026-11-23T13:37:14Z
modified_at: 2026-11-23T13:37:14Z
author:
  name: "Felipe Carvalho Ferreira"
  url: https://felipecferreira.com.br/sobre/
  "@id": https://felipecferreira.com.br/#/schema/person/44400987115f09994755b76e5fdf9d3a
  sameAs:
    - https://www.youtube.com/@felipecferreiraa
    - https://x.com/FelipeCF_X
    - https://www.instagram.com/felipecferreira.com.br/
    - https://www.linkedin.com/in/felipe-c-ferreira-a76646152/
    - https://www.tiktok.com/@felipecferreiraa
    - https://github.com/felipeferreiragestor
content_sha256: 3e3f9ff1f5cd3da5efc10d392a7d25c43acd7dcff47e438f5292db422795215b
status: stable
sources:
  - id: canonical-html
    resource: https://felipecferreira.com.br/en/library/what-is-rlhf/
    title: "Official HTML page"
    last_modified: 2026-11-23T13:37:14Z
---

# Reinforcement Learning from Human Feedback (RLHF)

## TL;DR

RLHF (Reinforcement Learning from Human Feedback) is the technique that trains AI models using human evaluations so responses align more closely with what people expect. Here we explain its stages, techniques like PPO, practical applications, tools, and the core benefits and challenges.

RLHF, which stands for Reinforcement Learning from Human Feedback, is an innovative approach in artificial intelligence (AI) that combines reinforcement [learning](https://felipecferreira.com.br/en/library/machine-learning/) with human feedback to train AI [models](https://felipecferreira.com.br/en/library/what-are-llms-large-language-models/).

This enables AI systems to learn how to make better decisions and refine their actions based on human evaluations and preferences.

Not sure what Artificial Intelligence is? [Click Here](https://felipecferreira.com.br/en/library/what-is-artificial-intelligence/).

## How Does Reinforcement Learning from Human Feedback Work? {#h-como-funciona-o-aprendizado-por-reforco-com-feedback-humano}

RLHF operates across three main stages:

**Collecting Human Feedback**: Humans evaluate the actions or responses of the AI [agent](https://felipecferreira.com.br/en/library/what-are-ai-agents/), providing positive or negative feedback such as rankings, scores, or detailed annotations.

**Adjusting Reinforcement Policies**: Based on the feedback received, the model adjusts its decision-making policies, aligning them more closely with human expectations and preferences.

**Iteration and Continuous Learning**: The agent repeats actions, receives feedback, updates its policies, and improves continuously, driving the ongoing evolution of AI performance.

### Techniques Used in RLHF {#h-tecnicas-utilizadas-no-rlhf}

**Proximal Policy Optimization (PPO)**: An efficient reinforcement learning technique that updates model policies safely, keeping updates close to previous policies to avoid drastic deviations.

**State Space and Action Space**: The agent explores the action space to discover advantageous actions while receiving human feedback to improve its choices.

**Reward Function and Constraints (Penalties)**: Calibrates the reward function with human feedback to align rewards with human expectations and applies penalties to discourage undesired actions.

**Supervised Fine-Tuning (SFT)**: A preliminary stage where the model is fine-tuned on pre-labeled demonstration data prior to RLHF, providing a solid baseline for subsequent learning with human feedback.

Let us put this puzzle together with an illustrative diagram and a step-by-step walkthrough below!

## How the RLHF Pipeline Works {#h-esquema-de-funcionamento-para-rlhf}

Take a look at a reference diagram we selected from the Amazon Web Services website.

The diagram labels are in English, and I will walk you through each of the three stages in detail below.

*RLHF learning process. Source: [AWS](https://aws.amazon.com/pt/what-is/reinforcement-learning-from-human-feedback/).*

The first stage of RLHF, called Supervised Fine-Tuning (SFT), consists of refining a base language model so it generates responses that are better aligned with human expectations.

To achieve this, human demonstration data is collected, where people provide examples of questions or instructions ([prompts](https://felipecferreira.com.br/en/library/prompt-engineering/)) along with the desired responses.

Using this data, the base language model (Base LLM) is fine-tuned, learning to produce answers similar to those written by humans, resulting in an improved SFT model capable of generating more relevant and helpful outputs.

In the second stage, Training a Reward Model (RM), the goal is to build a reward model that evaluates the quality of the responses generated by the SFT model.

For this step, human preference data is collected, where reviewers compare pairs of responses generated by the SFT model for the same prompt and indicate which one they prefer.

A reward model is then trained on this comparison data, learning to predict which responses human evaluators prefer.

As a result, you get a reward model capable of scoring and providing feedback on the quality of responses produced by the SFT model.

The third stage, Optimize Policy (PPO), aims to optimize the Supervised Fine-Tuning (SFT) model so it generates responses that maximize the reward predicted by the reward model (RM).

This is accomplished through Proximal Policy Optimization (PPO), a reinforcement learning algorithm (mentioned earlier) that updates the SFT model's policy to generate responses that earn higher scores from the reward model.

The process is then repeated iteratively, with the SFT model generating responses, the RM providing feedback scores, and PPO updating the SFT model's policy.

Ultimately, the final result is an optimized SFT model that generates high-quality responses aligned with human preferences.

## Applications of RLHF {#h-aplicacoes-do-rlhf}

Applications of RLHF in Artificial Intelligence include **Chatbots and Virtual Assistants**, improving the accuracy and relevance of answers based on user preferences.

We also have **Recommendation Systems**, refining product, music, or movie suggestions aligned with user tastes (Netflix and other streaming platforms).

**Games and Simulations** also use RLHF, adjusting the behavior of virtual characters or AI agents to create more engaging experiences.

Have you noticed how modern games with non-player characters (NPCs) are using AI to build increasingly realistic and customizable contexts!?

Finally, among these examples, let us mention **Autonomous Vehicles**, where RLHF is applied to improve decision-making across diverse traffic scenarios based on feedback from human drivers.

Tesla, for example, is currently one of the global leaders in this segment.

## Tools for Applying RLHF {#h-algumas-ferramentas-para-aplicacao-do-rlhf}

Here are some open-source tools for RLHF: [Hugging Face Transformers](https://github.com/huggingface/transformers), [Dopamine](https://github.com/google/dopamine) (Google Research), and [OpenAI Baselines](https://github.com/openai/baselines).

## Benefits and Challenges of RLHF {#h-beneficios-e-desafios-do-rlhf}

### Benefits {#h-beneficios}

**Quality Improvement**: Aligning AI actions with human expectations, resulting in stronger performance and higher user satisfaction.

**Flexibility and Adaptability**: Rapid adaptation to new environments and situations based on continuous feedback.

**Human Engagement**: Greater trust and adoption of AI technologies through direct human involvement in AI development.

### Challenges {#h-desafios}

**Data and Feedback Collection**: The logistical challenge of gathering human feedback efficiently at scale (including data privacy compliance such as Brazil's General Personal Data Protection Law, LGPD, the European Union's General Data Protection Regulation, GDPR, and related frameworks).

**Human Variability**: Variations in human evaluations and preferences (subjectivity and mood) can introduce inconsistencies and learning issues.

**Cost and Time**: Collecting feedback and running continuous tuning is time-consuming and potentially expensive, especially at large scale. High-quality, contextualized responses provided by human reviewers often require hiring specialized personnel (particularly when domain expertise is required).

## Conclusions {#h-conclusoes}

RLHF represents a major step forward in how we train and refine artificial intelligence models.

By incorporating human feedback into reinforcement learning, we build AI agents that are better aligned with human needs and expectations, improving the quality and effectiveness of AI interactions while fostering greater trust in intelligent systems.

That alignment happens during training. [Transformer2 (in Portuguese)](https://felipecferreira.com.br/biblioteca/llms-autoadaptaveis-a-revolucao-da-ia-dinamica-com-o-transformer2/) proposes another route: adapting the model to each task at inference time.

OpenAI also published the behavioral rules it expects from its models, the [Model Spec (in Portuguese)](https://felipecferreira.com.br/biblioteca/modelo-spec-da-openai/), and stated that it plans to use that document to guide RLHF training data, as I explain there.

Sign up on our portal to receive the latest updates on artificial intelligence straight to your inbox, for free.

## References {#h-referencias}

[IBM](https://www.ibm.com/br-pt/topics/rlhf), [Amazon](https://aws.amazon.com/pt/what-is/reinforcement-learning-from-human-feedback/) and [OpenAI](https://openai.com/index/learning-from-human-preferences/).

## Related concepts

* [Machine Learning](https://felipecferreira.com.br/okf/en/concepts/machine-learning.md)
* [What Are LLMs (Large Language Models)?](https://felipecferreira.com.br/okf/en/concepts/what-are-llms-large-language-models.md)
* [What Is Artificial Intelligence?](https://felipecferreira.com.br/okf/en/concepts/what-is-artificial-intelligence.md)
* [What Are AI Agents?](https://felipecferreira.com.br/okf/en/concepts/what-are-ai-agents.md)
* [Prompt Engineering: How to Get the Best Results](https://felipecferreira.com.br/okf/en/concepts/prompt-engineering.md)
