Skip to main content

Open-source framework for Reinforcement Learning integrated with Large Language Models

Project description

Hugo: RL-LLM Toolkit

Democratizing Reinforcement Learning with Large Language Models

PyPI CI codecov Downloads License: MIT Python 3.10+

🚀 Overview

RL-LLM Toolkit is an open-source framework that integrates Reinforcement Learning with Large Language Models to create intelligent agents accessible to beginners and researchers. By simulating human feedback via LLMs, we reduce RLHF costs by up to 50% while maintaining training quality.

Key Features

  • 🎮 Gymnasium-Compatible Environments: Easy-to-use RL environments for games, finance, and robotics
  • 🤖 LLM-Powered Rewards: Generate dense rewards using local or API-based LLMs
  • 📊 State-of-the-Art Algorithms: PPO, DQN, and more with modular architecture
  • 🔧 Plug-and-Play Design: Swap algorithms, environments, and LLMs effortlessly
  • 📚 Educational Focus: Interactive Jupyter notebooks and comprehensive tutorials
  • 🌐 Hugging Face Integration: Share models and datasets with the community

🎯 Quick Start

# Install the toolkit from PyPI
pip install hugo-rl-llm

# Run the CLI
hugo --help

# Or run a simple example module
python -m rl_llm_toolkit.examples.cartpole

📦 Installation

From PyPI

pip install hugo-rl-llm

From Source

git clone https://github.com/tonipcv/hugo.git
cd hugo
pip install -e .

Optional Dependencies

# For LLM integration
pip install -e ".[llm]"

# For development
pip install -e ".[dev]"

# For all features
pip install -e ".[all]"

💡 Usage Example

from rl_llm_toolkit import RLEnvironment, PPOAgent, LLMRewardShaper
from rl_llm_toolkit.llm import OllamaBackend

# Create environment
env = RLEnvironment("CartPole-v1")

# Set up LLM-based reward shaping
llm = OllamaBackend(model="llama3")
reward_shaper = LLMRewardShaper(llm, prompt_template="custom_template")

# Train agent
agent = PPOAgent(env, reward_shaper=reward_shaper)
agent.train(total_timesteps=100000)

# Evaluate
agent.evaluate(episodes=10, render=True)

🏗️ Architecture

flowchart LR
  subgraph Agents
    A1[PPOAgent]:::node
    A2[DQNAgent]:::node
    A3[CQL/IQL]:::node
    A4[MADDPG]:::node
  end
  subgraph Environments
    E1[Gymnasium IDs]
    E2[CryptoTradingEnv]
    E3[StockTradingEnv]
    E4[SimpleReacherEnv]
    E5[GridWorldEnv]
  end
  subgraph RewardShaping
    R1[LLMRewardShaper]
    R2[Prompt Templates]
    R3[Cache]
  end
  subgraph LLMBackends
    L1[Ollama]
    L2[OpenAI]
  end
  Agents <--> Environments
  Agents --> R1
  R1 --> LLMBackends
  R1 -->|combine with env_reward| Agents
  classDef node fill:#eef,stroke:#66f,stroke-width:1px;

❓ Why Hugo?

  • LLM Rewards Nativos: integração direta com Ollama e OpenAI, com templates prontos e cache.
  • Lean & Research-Oriented: sem bloat; arquitetura clara, fácil de estender.
  • Domínios Diversos: trading (cripto/ações), robótica (reacher) e gridworld prontos.
  • Benchmarks & Métricas: estabilidade, eficiência amostral e performance assintótica.
  • Colaboração: sessões e buffers compartilhados para cenários multiagente/experimentos.
  • CLI Produtiva: descoberta (list-*), quickstart e validação (--dry-run).

Comparativo rápido:

  • Stable-Baselines3: produção madura, porém sem LLM shaping nativo.
  • TorchRL: poderoso e amplo; Hugo é mais direto para RL + LLM.
  • OpenRLHF / RL4LMs: foco em LLMs; Hugo cobre RL clássico + LLM em vários domínios.

🎓 Examples

  • CartPole with LLM Feedback: Train a classic control agent with GPT-4 reward shaping
  • Crypto Trading Bot: Build a trading agent using historical data and LLM market analysis
  • Multi-Agent Game: Coordinate multiple agents in a competitive environment

🤝 Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

📊 Roadmap

Now (0-3 months)

  • ✅ Core RL framework with PPO/DQN
  • ✅ Basic LLM integration (Ollama, OpenAI)
  • 🔄 Interactive examples and tutorials
  • 🔄 Comprehensive documentation

Next (3-6 months)

  • Offline RL support
  • Financial trading environments
  • Hugging Face model hub integration
  • Community leaderboards

Later (6-12 months)

  • Real-time collaboration features
  • Video reasoning integration
  • Advanced multi-agent systems
  • Research partnerships

📄 License

MIT License - see LICENSE for details.

🙏 Acknowledgments

Inspired by projects like PufferLib, Neural MMO, and the broader open-source RL community.

📬 Contact


Star ⭐ this repo if you find it useful!

Star History: https://star-history.com/#tonipcv/hugo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hugo_rl_llm-0.2.1.tar.gz (202.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hugo_rl_llm-0.2.1-py3-none-any.whl (106.0 kB view details)

Uploaded Python 3

File details

Details for the file hugo_rl_llm-0.2.1.tar.gz.

File metadata

  • Download URL: hugo_rl_llm-0.2.1.tar.gz
  • Upload date:
  • Size: 202.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for hugo_rl_llm-0.2.1.tar.gz
Algorithm Hash digest
SHA256 cd8284fee748442839444a7ddba8f9e989a75467a5f44e6da5eb60b12803b816
MD5 313ba5d78d74e66e176d662315feceba
BLAKE2b-256 aeffd73f5a0387f8797cfb55d69a415a5dec50d59d14b1e6a16850b95b6c9b44

See more details on using hashes here.

File details

Details for the file hugo_rl_llm-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: hugo_rl_llm-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 106.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for hugo_rl_llm-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2bc419aeed3681c627d40fc6baca01f8c018b6378291dccd7616554111541ae4
MD5 3d4d207ea4cfb00e6091bc2cc50f3be6
BLAKE2b-256 7cd4d4256a0728e5bdf9d1a807c66597d8e130ef3c0f32282f21b650af97ab67

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page