Skip to content

Commit f49a6d9

Browse files
committed
improve docs
1 parent b91da7b commit f49a6d9

55 files changed

Lines changed: 669 additions & 161 deletions

Some content is hidden

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

.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! 🐠

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MIT License
1+
# MIT License
22

33
Copyright (c) 2022 CarperAI
44

README.md

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

26
[![DOI](https://zenodo.org/badge/545104023.svg)](https://zenodo.org/badge/latestdoi/545104023)
37

@@ -39,25 +43,25 @@ For more usage see [examples](./examples). You can also try the colab notebooks
3943

4044
You can train a model using a reward function or a reward-labeled dataset.
4145

42-
#### Using a reward function
46+
### Using a reward function
4347

4448
```python
4549
trainer = trlx.train('gpt2', reward_fn=lambda samples, **kwargs: [sample.count('cats') for sample in samples])
4650
```
4751

48-
#### Using a reward-labeled dataset
52+
### Using a reward-labeled dataset
4953

5054
```python
5155
trainer = trlx.train('EleutherAI/gpt-j-6B', dataset=[('dolphins', 'geese'), (1.0, 100.0)])
5256
```
5357

54-
#### Trainers provide a wrapper over their underlying model
58+
### Trainers provide a wrapper over their underlying model
5559

5660
```python
5761
trainer.generate(**tokenizer('Q: Who rules the world? A:', return_tensors='pt'), do_sample=True)
5862
```
5963

60-
#### Save the resulting model to a Hugging Face pretrained language model. (Ready to upload to the Hub!)
64+
### Save the resulting model to a Hugging Face pretrained language model. (Ready to upload to the Hub!)
6165

6266
```python
6367
trainer.save_pretrained('/path/to/output/folder/')

dictionary.txt

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

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+
```

0 commit comments

Comments
 (0)