Skip to main content

A Python framework for building RL environments with objective and subjective evaluation

Project description

Hyperbolic

A Python framework for building RL environments that generate training-grade trajectories across any domain -- browser tasks, text tasks, coding tasks, and beyond.

Installation

pip install hyperbolic

# With browser support
pip install 'hyperbolic[browser]'

# With HuggingFace datasets
pip install 'hyperbolic[datasets]'

# Everything
pip install 'hyperbolic[all]'

For browser environments, run the one-time setup after install:

htc setup

Quick Start

import hyperbolic as htc

dataset = htc.Dataset.from_list([
    {"question": "What is 2+2?", "answer": "4"},
    {"question": "What is 3*5?", "answer": "15"},
])

def correct_answer(completion, answer):
    response = completion[-1]["content"]
    return 1.0 if answer in response else 0.0

rubric = htc.Rubric(funcs=[correct_answer])
env = htc.SingleTurnEnv(dataset=dataset, rubric=rubric, system_prompt="Answer concisely.")
agent = htc.OpenAIAgent(model="gpt-4o-mini")
trajectories = env.run(agent)

for t in trajectories:
    print(f"Task: {t.task['question']}, Reward: {t.scalar_reward:.1f}")

Browser Environment

import hyperbolic as htc

dataset = htc.Dataset.from_list([{
    "task": "Find the headphones product and add it to the cart.",
    "start_url": "http://localhost:5001",
    "reset_url": "http://localhost:5001/api/reset",
}])

rubric = htc.Rubric()
rubric.add(htc.URLMatch(pattern=r"/cart"), weight=0.5, dimension="reached_cart")

env = htc.BrowserEnv(
    dataset=dataset,
    rubric=rubric,
    max_turns=10,
    browser_config=htc.BrowserConfig(headless=False),
)

agent = htc.OpenAIAgent(model="gpt-4o", tool_choice="required")
trajectories = env.run(agent)

CLI

htc run examples/simple_math.py -m gpt-4o-mini
htc run examples/browser_task.py -m gpt-4o
htc --version

Environment Types

  • TextEnv -- single-turn or multi-turn text interactions with optional tool calling
  • BrowserEnv -- browser automation via Playwright with screenshot observations

Key Features

  • Multi-dimensional evaluation (accuracy, tone, helpfulness as separate scoring axes)
  • Judge panels with disagreement tracking
  • Pluggable model interface (OpenAI, Anthropic, custom)
  • Deterministic browser environment resets
  • Standardized trajectory output format

API Keys

Create a .env file in your project root:

OPENAI_API_KEY=sk-...

Keys are resolved in order: explicit parameter > .env file > system env var.

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

htc_env-0.1.0.tar.gz (234.2 kB view details)

Uploaded Source

Built Distribution

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

htc_env-0.1.0-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

Details for the file htc_env-0.1.0.tar.gz.

File metadata

  • Download URL: htc_env-0.1.0.tar.gz
  • Upload date:
  • Size: 234.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for htc_env-0.1.0.tar.gz
Algorithm Hash digest
SHA256 63f0695bad96de7eec1deebee17c3a3950bab0853436cc65d245d4e944e64da0
MD5 bf2e05608a72465c9f01b3ccc118b270
BLAKE2b-256 88576d17c8da89535930c1f07ab6d0aad49f7572b487dffc056d98d3451f1e40

See more details on using hashes here.

File details

Details for the file htc_env-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: htc_env-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for htc_env-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ca8c517aa32684bf292408be0ef7dbfc0df4355a5519b3816dd23fc2f57d7a4
MD5 76789710d30c7aa36f102408dddf6694
BLAKE2b-256 cbb3a4202329fda6a858e274c123faaf1bb7195bb8ad2a5c06ae5ab4ee0c3141

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