Skip to content

Commit 88b6fda

Browse files
committed
feature: add new website
1 parent d65cc5f commit 88b6fda

37 files changed

+639
-0
lines changed

.github/workflows/docs.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: docs_pages_workflow
2+
3+
on: [pull_request]
4+
5+
permissions:
6+
pull-requests: write
7+
8+
jobs:
9+
build_docs_job:
10+
runs-on: ubuntu-latest
11+
env:
12+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: 3.8
21+
22+
- name: Get pip cache dir
23+
id: pip-cache
24+
run: |
25+
python -m pip install --upgrade pip
26+
echo "dir={$(pip cache dir)}" >> $GITHUB_OUTPUT
27+
28+
- name: pip cache
29+
uses: actions/cache@v3
30+
with:
31+
path: ${{ steps.pip-cache.outputs.dir }}
32+
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py', '**/requirements.txt', '**/docs/requirements.txt') }}
33+
restore-keys: |
34+
${{ runner.os }}-pip-
35+
36+
- name: Install docs requirements
37+
run: |
38+
python -m pip install -r docs/requirements.txt
39+
40+
- name: make the sphinx docs
41+
run: |
42+
make -C docs clean
43+
make -C docs html
44+
45+
- uses: readthedocs/actions/preview@v1
46+
with:
47+
project-slug: "trlx"
48+
project-language: "en"
49+
# see: https://github.com/readthedocs/actions/tree/main/preview
50+
# message-template (optional): Text message to be injected by the action in the Pull Request description. It supports the following placeholders to be replaced:
51+
# {docs-pr-index-url}: URL to the root of the documentation for the Pull Request preview.
52+
# platform (optional): Read the Docs Community (community) or Read the Docs for Business (business). (default: community)
53+
# single-version (optional): Set this to 'true' if your project is single version, so we can link to the correct URL. (default: 'false')

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Change log
2+
3+
Best viewed on [trlx.readthedocs.io](https://trlx.readthedocs.io/en/latest/changelog.html).
4+
5+
<!--
6+
Remember to align the itemized text with the first line of an item within a list.
7+
-->
8+
9+
## trlx 0.4.0 (2022-12-05)
10+
11+
- python 3.8

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
gendoc:
2+
docker build -t trlxgendocs -f docker/docs/Dockerfile .
3+
run:
4+
docker run --rm -it -v ${PWD}:/build \
5+
--entrypoint /bin/bash \
6+
trlxgendocs

dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rouge

docker/docs/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM python:3.8-slim
2+
3+
# pip install -r docs/requirements.txt
4+
# sphinx-build -b html docs docs/build/html -j auto
5+
# sphinx-build -b html -D nb_execution_mode=off docs docs/build/html -j auto
6+
7+
RUN python -m pip install --upgrade --no-cache-dir pip
8+
ADD docs/requirements.txt /tmp/requirements.txt
9+
RUN python -m pip install --exists-action=w --no-cache-dir -r /tmp/requirements.txt
10+
RUN mkdir /build
11+
WORKDIR /build/docs/
12+
ENTRYPOINT /build/docs/build.sh
13+
# RUN `which sphinx-build` -T -E -b html -d _build/doctrees-readthedocs -D language=en . _build/html

docs/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# How To build the documentation
2+
3+
```bash
4+
make -c docs html
5+
```
3.96 KB
Loading
4.18 KB
Loading
5.3 KB
Loading
5.57 KB
Loading
6.48 KB
Loading
6.84 KB
Loading
1.9 KB
Loading
2.14 KB
Loading
2.43 KB
Loading
2.57 KB
Loading

docs/_static/favicon-128x128.png

4.3 KB
Loading

docs/_static/favicon-16x16.png

534 Bytes
Loading

docs/_static/favicon-196x196.png

7.83 KB
Loading

docs/_static/favicon-32x32.png

1.11 KB
Loading

docs/_static/favicon-96x96.png

3.2 KB
Loading

docs/_static/style.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@import url("theme.css");
2+
3+
:root {
4+
--block-bg-opacity: .5;
5+
}
6+
7+
.wy-side-nav-search {
8+
background-color: #fff;
9+
}
10+
11+
.getting-started {
12+
background-color: rgba(78, 150, 253, var(--block-bg-opacity));
13+
}
14+
15+
.user-guides {
16+
background-color: rgba(0, 169, 154, var(--block-bg-opacity));
17+
}
18+
19+
.developer-docs {
20+
background-color: rgba(171, 0, 182, var(--block-bg-opacity));
21+
}
22+
23+
.key-ideas
24+
{
25+
border: 0px
26+
}

docs/_static/trlx-logo-512x512.png

22.3 KB
Loading

docs/_templates/layout.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{% extends "!layout.html" %}
2+
{% set css_files = css_files + ["_static/style.css"] %}

docs/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
`which sphinx-build` -T -E -b html -d _build/doctrees-readthedocs -D language=en . _build/html

docs/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
```{include} ../CHANGELOG.md
2+
```

docs/conf.py

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
import os
14+
import sys
15+
16+
sys.path.insert(0, os.path.abspath(".."))
17+
18+
19+
# -- Project information -----------------------------------------------------
20+
21+
project = "trlX"
22+
copyright = "2023, CarperAI"
23+
author = "CarperAI"
24+
25+
# -- General configuration ---------------------------------------------------
26+
27+
# Add any Sphinx extension module names here, as strings. They can be
28+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
29+
# ones.
30+
31+
extensions = [
32+
"sphinx.ext.autodoc",
33+
"sphinx.ext.autosummary",
34+
"sphinx.ext.intersphinx",
35+
"sphinx.ext.mathjax",
36+
"sphinx.ext.napoleon",
37+
"sphinx.ext.viewcode",
38+
"matplotlib.sphinxext.plot_directive",
39+
"sphinx_autodoc_typehints",
40+
"myst_nb",
41+
# "myst_parser",
42+
"sphinx_remove_toctrees",
43+
"sphinx_copybutton",
44+
"sphinx_design",
45+
]
46+
47+
intersphinx_mapping = {
48+
"python": ("https://docs.python.org/3/", None),
49+
"numpy": ("https://docs.scipy.org/doc/numpy/", None),
50+
"scipy": ("https://docs.scipy.org/doc/scipy/reference/", None),
51+
"pytorch": ("https://pytorch.readthedocs.io/", None),
52+
}
53+
54+
autodoc_preserve_defaults = True
55+
56+
# Add any paths that contain templates here, relative to this directory.
57+
templates_path = ["_templates"]
58+
59+
# The suffix(es) of source filenames.
60+
# You can specify multiple suffix as a list of string:
61+
#
62+
source_suffix = [".rst", ".md"]
63+
64+
# The master toctree document.
65+
main_doc = "index"
66+
67+
# List of patterns, relative to source directory, that match files and
68+
# directories to ignore when looking for source files.
69+
# This pattern also affects html_static_path and html_extra_path.
70+
exclude_patterns = [
71+
# Sometimes sphinx reads its own outputs as inputs!
72+
"build/html",
73+
]
74+
75+
# The name of the Pygments (syntax highlighting) style to use.
76+
pygments_style = None
77+
78+
autosummary_generate = True
79+
napolean_use_rtype = False
80+
81+
# -- Options for nbsphinx -----------------------------------------------------
82+
83+
# Execute notebooks before conversion: 'always', 'never', 'auto' (default)
84+
# We execute all notebooks, exclude the slow ones using 'exclude_patterns'
85+
nbsphinx_execute = "always"
86+
87+
# Use this kernel instead of the one stored in the notebook metadata:
88+
# nbsphinx_kernel_name = 'python3'
89+
90+
# List of arguments to be passed to the kernel that executes the notebooks:
91+
# nbsphinx_execute_arguments = []
92+
93+
# If True, the build process is continued even if an exception occurs:
94+
# nbsphinx_allow_errors = True
95+
96+
97+
# Controls when a cell will time out (defaults to 30; use -1 for no timeout):
98+
nbsphinx_timeout = 180
99+
100+
# Default Pygments lexer for syntax highlighting in code cells:
101+
# nbsphinx_codecell_lexer = 'ipython3'
102+
103+
# Width of input/output prompts used in CSS:
104+
# nbsphinx_prompt_width = '8ex'
105+
106+
# If window is narrower than this, input/output prompts are on separate lines:
107+
# nbsphinx_responsive_width = '700px'
108+
109+
# This is processed by Jinja2 and inserted before each notebook
110+
nbsphinx_prolog = r""" # noqa: E501
111+
{% set docname = 'docs/' + env.doc2path(env.docname, base=None) %}
112+
.. only:: html
113+
.. role:: raw-html(raw)
114+
:format: html
115+
.. nbinfo::
116+
Interactive online version:
117+
:raw-html:`<a href="https://colab.research.google.com/github/CarperAI/trlx/blob/master/{{ docname }}"><img alt="Open In Colab" src="https://colab.research.google.com/assets/colab-badge.svg" style="vertical-align:text-bottom"></a>`
118+
__ https://github.com/CarperAI/trlx/blob/
119+
{{ env.config.release }}/{{ docname }}
120+
"""
121+
122+
# This is processed by Jinja2 and inserted after each notebook
123+
# nbsphinx_epilog = r"""
124+
# """
125+
126+
# Input prompt for code cells. "%s" is replaced by the execution count.
127+
# nbsphinx_input_prompt = 'In [%s]:'
128+
129+
# Output prompt for code cells. "%s" is replaced by the execution count.
130+
# nbsphinx_output_prompt = 'Out[%s]:'
131+
132+
# Specify conversion functions for custom notebook formats:
133+
# import jupytext
134+
# nbsphinx_custom_formats = {
135+
# '.Rmd': lambda s: jupytext.reads(s, '.Rmd'),
136+
# }
137+
138+
# Link or path to require.js, set to empty string to disable
139+
# nbsphinx_requirejs_path = ''
140+
141+
# Options for loading require.js
142+
# nbsphinx_requirejs_options = {'async': 'async'}
143+
144+
# mathjax_config = {
145+
# 'TeX': {'equationNumbers': {'autoNumber': 'AMS', 'useLabelIds': True}},
146+
# }
147+
148+
# Additional files needed for generating LaTeX/PDF output:
149+
# latex_additional_files = ['references.bib']
150+
151+
152+
# -- Options for HTML output -------------------------------------------------
153+
154+
# The theme to use for HTML and HTML Help pages. See the documentation for
155+
# a list of builtin themes.
156+
#
157+
html_theme = "sphinx_book_theme"
158+
159+
# Add any paths that contain custom static files (such as style sheets) here,
160+
# relative to this directory. They are copied after the builtin static files,
161+
# so a file named "default.css" will overwrite the builtin "default.css".
162+
html_static_path = ["_static"]
163+
164+
# Output file base name for HTML help builder.
165+
htmlhelp_basename = "TRLXdoc"
166+
167+
# -- Extension configuration -------------------------------------------------
168+
169+
# Tell sphinx-autodoc-typehints to generate stub parameter annotations including
170+
# types, even if the parameters aren't explicitly documented.
171+
always_document_param_types = True
172+
173+
# Theme options are theme-specific and customize the look and feel of a theme
174+
# further. For a list of options available for each theme, see the
175+
# documentation.
176+
html_theme_options = {
177+
# "logo_only": True,
178+
"show_toc_level": 2,
179+
"repository_url": "https://github.com/CarperAI/trlx",
180+
"use_repository_button": True, # add a "link to repository" button
181+
}
182+
183+
# The name of an image file (relative to this directory) to place at the top
184+
# of the sidebar.
185+
html_logo = "_static/apple-touch-icon-144x144.png"
186+
187+
html_favicon = "_static/favicon-16x16.png"

docs/configs.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.. _configs:
2+
3+
Configs
4+
************************
5+
6+
Training a model in TRL will require you to set several configs:
7+
ModelConfig, which contains general info on the model being trained. TrainConfig, which contains things like
8+
training hyperparameters. And finally, MethodConfig, which contains hyperparameters or settings for
9+
the specific method being used (i.e. ILQL or PPO)
10+
11+
12+
**General**
13+
14+
.. autoclass:: trlx.data.configs.TRLConfig
15+
:members:
16+
17+
.. autoclass:: trlx.data.configs.ModelConfig
18+
:members:
19+
20+
.. autoclass:: trlx.data.configs.TrainConfig
21+
:members:
22+
23+
.. autoclass:: trlx.data.method_configs.MethodConfig
24+
:members:
25+
26+
**PPO**
27+
28+
.. autoclass:: trlx.trainer.nn.ppo_models.MethodConfig
29+
:members:
30+
31+
**ILQL**
32+
33+
.. autoclass:: trlx.trainer.nn.ilql_models.ILQLConfig
34+
:members:

docs/data.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.. _data:
2+
3+
Data Elements
4+
************************
5+
6+
All of the major Carper projects: trlX, CHEESE, and magiCARP use
7+
dataclasses corresponding to batches of data to communicate data between models and different
8+
components. trlX is no different, though it has many different dataclasses for
9+
different components like training or inference. Currently, we support PPO and ILQL, which
10+
each demand different kinds of data during training.
11+
12+
13+
**Basic Data Elements for Accelerate**
14+
15+
.. autoclass:: trlx.data.accelerate_base_datatypes.PromptElement
16+
:members:
17+
18+
.. autoclass:: trlx.data.accelerate_base_datatypes.PromptBatch
19+
:members:
20+
21+
.. autoclass:: trlx.data.accelerate_base_datatypes.AccelerateRLElement
22+
:members:
23+
24+
.. autoclass:: trlx.data.accelerate_base_datatypes.AccelerateRLBatchElement
25+
:members:
26+
27+
**Data Elements for PPO**
28+
29+
.. autoclass:: trlx.data.ppo_types.PPORLElement
30+
:members:
31+
32+
.. autoclass:: trlx.data.ppo_types.PPORLBatch
33+
:members:
34+
35+
**Data Elements for ILQL**
36+
37+
.. autoclass:: trlx.data.ilql_types.ILQLElement
38+
:members:
39+
40+
.. autoclass:: trlx.data.ilql_types.ILQLBatch
41+
:members:

0 commit comments

Comments
 (0)