Skip to content

Commit 9af30de

Browse files
committed
feature: add new website
1 parent 6427429 commit 9af30de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+718
-629
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')

.pre-commit-config.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
4-
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
55
rev: v4.4.0
66
hooks:
77
- id: check-case-conflict
@@ -18,17 +18,24 @@ repos:
1818
args: [--fix=lf]
1919
- id: requirements-txt-fixer
2020
- id: trailing-whitespace
21-
- repo: https://github.com/psf/black
21+
- repo: https://github.com/psf/black
2222
rev: 23.1.0
2323
hooks:
24-
- id: black
24+
- id: black
2525
files: ^(trlx|examples|tests|setup.py)/
26-
- repo: https://github.com/pycqa/isort
26+
- repo: https://github.com/pycqa/isort
2727
rev: 5.12.0
2828
hooks:
29-
- id: isort
29+
- id: isort
3030
name: isort (python)
31-
- repo: https://github.com/pycqa/flake8
31+
- repo: https://github.com/pycqa/flake8
3232
rev: 6.0.0
3333
hooks:
34-
- id: flake8
34+
- id: flake8
35+
- repo: https://github.com/codespell-project/codespell
36+
rev: v2.2.2
37+
hooks:
38+
- id: codespell
39+
args: [--ignore-words, dictionary.txt]
40+
additional_dependencies:
41+
- tomli

.readthedocs.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
# .readthedocs.yml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
16
version: 2
27

8+
build:
9+
os: "ubuntu-20.04"
10+
tools:
11+
python: "3.8"
12+
13+
# Build documentation in the docs/ directory with Sphinx
314
sphinx:
4-
configuration: docs/source/conf.py
15+
configuration: docs/conf.py
16+
fail_on_warning: false
17+
18+
# Optionally build your docs in additional formats such as PDF and ePub
19+
formats:
20+
- htmlzip
521

22+
# Optionally set the version of Python and requirements required to build your docs
623
python:
7-
version: 3.9
824
install:
9-
- requirements: docs/requirements.txt
25+
- requirements: docs/requirements.txt

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

CONTRIBUTING.md

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
Looking to improve `trlX`? Thanks for considering!
44

5-
There are many ways to contribute, from writing tutorials in [Colab notebooks](https://colab.research.google.com) to improving the project's [documentation](https://trlx.readthedocs.io), submitting bug reports and feature requests, or even implementing new features themselves. See the outstanding [issues](https://github.com/CarperAI/trlx/issues) for ideas on where to begin.
5+
There are many ways to contribute, from writing tutorials in [Colab notebooks](https://colab.research.google.com) to improving the project's [documentation](https://trlx.readthedocs.io), to submitting bug reports and feature requests, or even implementing new features themselves. See the outstanding [issues](https://github.com/CarperAI/trlx/issues) for ideas on where to begin.
6+
7+
- [Documentation Issues](https://github.com/CarperAI/trlx/issues?q=is%3Aissue+is%3Aopen+label%3Adocumentation)
8+
- [Bug Fixes](https://github.com/CarperAI/trlx/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
9+
- [Feature Requests](https://github.com/CarperAI/trlx/issues?q=is%3Aissue+is%3Aopen+label%3A%22feature+request%22)
610

711
Here are some guidelines to help you get started 🚀.
812

@@ -16,40 +20,83 @@ To submit a bug report or a feature request, please open an [issue](https://gith
1620
1721
Follow these steps to start contributing code:
1822

23+
1. Setup your environment:
24+
25+
```bash
26+
conda create -n trlx python=3.8 torch torch-cuda=11.7 -c pytorch -c nvidia
27+
git clone https://github.com/CarperAI/trlx
28+
cd trlx
29+
pip install -e ".[dev]"
30+
pre-commit install
31+
```
32+
1933
1. Create your own [fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo#forking-a-repository) of the repository and clone it to your local machine.
34+
2035
```bash
2136
git clone https://github.com/<YOUR-USERNAME>/trlx.git
2237
cd trlx
2338
git remote add upstream https://github.com/CarperAI/trlx.git
2439
```
25-
2. Create a new branch for your changes and give it a concise name that reflects your contribution.
40+
41+
1. Create a new branch for your changes and give it a concise name that reflects your contribution.
42+
2643
```bash
2744
git checkout -b <BRANCH-NAME>
2845
```
29-
2. Install the development dependencies in a Python environment.
46+
47+
1. Install the development dependencies in a Python environment.
48+
3049
```bash
3150
pip install -e ".[dev]"
3251
pre-commit install
3352
```
34-
4. Implement your changes. Make small, independent, and well documented commits along the way (check out [these](https://cbea.ms/git-commit/) tips).
35-
5. Add unit tests whenever appropriate and ensure that the tests pass. To run the entire test suite, use the following command from within the project root directory.
53+
54+
install pre-commit
55+
56+
```bash
57+
pip install pre-commit
58+
pre-commit install
59+
```
60+
61+
bonus: force run pre-commit on all the files
62+
63+
```bash
64+
pre-commit run --all-files
65+
```
66+
67+
1. Implement your changes. Make small, independent, and well documented commits along the way (check out [these](https://cbea.ms/git-commit/) tips).
68+
69+
1. Add unit tests whenever appropriate and ensure that the tests pass. To run the entire test suite, use the following command from within the project root directory.
70+
3671
```bash
3772
pytest
3873
```
74+
3975
For changes with minimal project scope (e.g. a simple bug fix), you might want to run the unit tests for just a specific test file instead:
76+
4077
```bash
4178
pytest -vv -k "<TEST-FILE-NAME>"
4279
```
43-
5. Commit your final changes. Our `pre-commit` hooks will automatically run before each commit and will prevent you from committing code that does not pass our style and linter checks. They'll also automatically format your code! To run these manually, use the following command:
80+
81+
1. Commit your final changes. Our `pre-commit` hooks will automatically run before each commit and will prevent you from committing code that does not pass our style and linter checks. They'll also automatically format your code! To run these manually, use the following command:
82+
4483
```bash
4584
pre-commit run --all-files
4685
```
4786
48-
6. Push the changes to your fork.
87+
1. Push the changes to your fork.
4988
5089
Finally ... 🥁 ... Create a [pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request) to the `trlX` repository! Make sure to include a description of your changes and link to any relevant issues.
5190
52-
> __Tip__: If you're looking to introduce an experimental feature, we suggest testing the behavior of your proposed feature on some of the existing [examples](https://github.com/CarperAI/trlx/tree/master/examples), such as [random walks](https://github.com/CarperAI/trlx/blob/master/examples/randomwalks). This will help you get a better sense of how the feature would work in practice and will also help you identify any potential flaws in the implementation.
91+
> **Tip**: If you're looking to introduce an experimental feature, we suggest testing the behavior of your proposed feature on some of the existing [examples](https://github.com/CarperAI/trlx/tree/master/examples), such as [random walks](https://github.com/CarperAI/trlx/blob/master/examples/randomwalks). This will help you get a better sense of how the feature would work in practice and will also help you identify any potential flaws in the implementation.
92+
93+
## Tips & Tricks
94+
95+
Set transformers verbosity level
96+
97+
```bash
98+
TRANSFORMERS_VERBOSITY=error
99+
```
53100

54101
## Asking questions
55102

@@ -63,4 +110,4 @@ This project adheres to the [Contributor Covenant Code of Conduct](https://githu
63110

64111
By contributing, you agree that your contributions will be licensed under its MIT License.
65112

66-
# Thank you for your contribution 🐠!
113+
## Thank you for your contribution! 🐠

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

README.md

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
![TRLX](./docs/_static/apple-touch-icon-114x114.png)
2+
13
[docs-image]: https://readthedocs.org/projects/trlX/badge/?version=latest
24
[docs-url]: https://trlX.readthedocs.io/en/latest/?badge=latest
35

@@ -12,6 +14,7 @@ You can read more about trlX in our [documentation](https://trlX.readthedocs.io)
1214
Want to collect human annotations for your RL application? Check out [CHEESE!](https://github.com/carperai/cheese), our library for HiTL data collection.
1315

1416
## Installation
17+
1518
```bash
1619
git clone https://github.com/CarperAI/trlx.git
1720
cd trlx
@@ -28,23 +31,29 @@ For more usage see [examples](./examples). You can also try the colab notebooks
2831

2932

3033
## How to Train
34+
3135
You can train a model using a reward function or a reward-labeled dataset.
3236

33-
#### Using a reward function
37+
### Using a reward function
38+
3439
```python
3540
trainer = trlx.train('gpt2', reward_fn=lambda samples, **kwargs: [sample.count('cats') for sample in samples])
3641
```
37-
#### Using a reward-labeled dataset
42+
43+
### Using a reward-labeled dataset
44+
3845
```python
3946
trainer = trlx.train('EleutherAI/gpt-j-6B', dataset=[('dolphins', 'geese'), (1.0, 100.0)])
4047
```
4148

42-
#### Trainers provide a wrapper over their underlying model
49+
### Trainers provide a wrapper over their underlying model
50+
4351
```python
4452
trainer.generate(**tokenizer('Q: Who rules the world? A:', return_tensors='pt'), do_sample=True)
4553
```
4654

47-
#### Save the resulting model to a Hugging Face pretrained language model. (Ready to upload to the Hub!)
55+
### Save the resulting model to a Hugging Face pretrained language model. (Ready to upload to the Hub!)
56+
4857
```python
4958
trainer.save_pretrained('/path/to/output/folder/')
5059
```
@@ -69,46 +78,11 @@ python examples/nemo_ilql_sentiments.py
6978
For more usage see the [NeMo README](./trlx/trainer/nemo)
7079

7180
#### Use Ray Tune to launch hyperparameter sweep
81+
7282
```bash
7383
python -m trlx.sweep --config configs/sweeps/ppo_sweep.yml examples/ppo_sentiments.py
7484
```
7585

76-
## Logging
77-
78-
trlX uses the standard Python `logging` library to log training information to the console. The default logger is set to the `INFO` level, which means that `INFO`, `WARNING`, `ERROR`, and `CRITICAL` level messages will be printed to standard output.
79-
80-
To change the log level directly, you can use the verbosity setter. For example, to set the log level to `WARNING` use:
81-
82-
```python
83-
import trlx
84-
85-
trlx.logging.set_verbosity(trlx.logging.WARNING)
86-
```
87-
88-
This will suppress `INFO` level messages, but still print `WARNING`, `ERROR`, and `CRITICAL` level messages.
89-
90-
You can also control logging verbosity by setting the `TRLX_VERBOSITY` environment variable to one of the standard logging [level names](https://docs.python.org/3/library/logging.html#logging-levels):
91-
92-
* `CRITICAL` (`trlx.logging.CRITICAL`)
93-
* `ERROR` (`trlx.logging.ERROR`)
94-
* `WARNING` (`trlx.logging.WARNING`)
95-
* `INFO` (`trlx.logging.INFO`)
96-
* `DEBUG` (`trlx.logging.DEBUG`)
97-
98-
```sh
99-
export TRLX_VERBOSITY=WARNING
100-
```
101-
102-
By default, [`tqdm`](https://tqdm.github.io/docs/tqdm/) progress bars are used to display training progress. You can disable them by calling `trlx.logging.disable_progress_bar()`, otherwise `trlx.logging.enable_progress_bar()` to enable.
103-
104-
Messages can be formatted with greater detail by setting `trlx.logging.enable_explicit_format()`. This will inject call-site information into each log which may be helpful for debugging.
105-
106-
```sh
107-
[2023-01-01 05:00:00,000] [INFO] [ppo_orchestrator.py:63:make_experience] [RANK 0] Message...
108-
```
109-
110-
> 💡 Tip: To reduce the amount of logging output, you might find it helpful to change log levels of third-party libraries used by trlX. For example, try adding `transformers.logging.set_verbosity_error()` to the top of your trlX scripts to silence verbose messages from the `transformers` library (see their [logging docs](https://huggingface.co/docs/transformers/main_classes/logging#logging) for more details).
111-
11286
## Contributing
11387

11488
For development check out these [guidelines](./CONTRIBUTING.md)

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/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# from the environment for the first two.
66
SPHINXOPTS ?=
77
SPHINXBUILD ?= sphinx-build
8-
SOURCEDIR = source
8+
SOURCEDIR = .
99
BUILDDIR = build
1010

1111
# Put it first so that "make" without argument is like "make help".

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

0 commit comments

Comments
 (0)