Skip to main content

No project description provided

Project description

TRL-ENV

ENV

TRL is a convenient library to train large language model (LLM) using reinforcement learning (RL). However, it is still too new, the interface is not well-developed yet. rollout_func is a low-level interface to write your own rollout for RL and environment_factory is a high-level interface to train your model with external environemnt, however, how it parse the model output for tool use is uncleared and not documented.

TRL-ENV addresses the middle-level with a very simple environment interface

type Action = str
type Delta = str
type Seed = str

class Env(Protocol):
    reward: float
    alive: bool
    def reset(self, seed: Seed) -> tuple[Env, Delta]: ...
    def step(self, action: Action) -> tuple[Env, Delta]: ...

It is similar to tool call if not the same. Note that, rollout_func is an experimental feature of TRL, this library is subject to break at anytime

It is important to note that, batch_rollout assumes the additivity of tokenizer, that is

tok(a ++ b) = tok(a) ++ tok(b)

where a and b are texts and ++ is concatenation. This is because Env interacts with LLM via text, not sequence of tokens, and as far as my knowledge, this is unavoidable.

PROCESSOR

transformers despite after 8 years of development (as of 2026) is still not stable. For example, not all models has Tokenizer.parse_response which should be a basic function that must be implemented from the beginning. TRL-ENV requires Tokenizer.parse_response to be existed by Processor interface

Language = str

class Processor(Protocol):
    def init_system_input(self, prompt: Language) -> str: ...
    def append_user_input(self, prompt: Language) -> str: ...
    def parse_agent_output(self, completion: Language) -> tuple[str, str]: ...

EXAMPLES

TRL-ENV provides a very simple example for training agentic LLM. See experiment/examples

  • install all dependencies uv sync --all-packages

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

trl_env-0.1.10.tar.gz (116.3 kB view details)

Uploaded Source

Built Distribution

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

trl_env-0.1.10-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file trl_env-0.1.10.tar.gz.

File metadata

  • Download URL: trl_env-0.1.10.tar.gz
  • Upload date:
  • Size: 116.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for trl_env-0.1.10.tar.gz
Algorithm Hash digest
SHA256 e545ae792a50908b8fb26cc011f2c0d2c580000a1c7307b870e9c2e3b5795832
MD5 dbd63ee5646589de0fef29465a4a45db
BLAKE2b-256 2163540bd1b3d44e6a2e449ed5137e54b87248f59b6b9f7e16158eb8cc09fc68

See more details on using hashes here.

File details

Details for the file trl_env-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: trl_env-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for trl_env-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 69bfc590d1b6c42d8d3eb1b311e83d81b7e639c35fc9a27ba6dd1a00f7fc810c
MD5 fca4e777a1507e60be11222e850504f3
BLAKE2b-256 e07695d4c98863ee24807759a773353ef6e7a9dbe0753952c0812da64a1b3644

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