You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+56-9Lines changed: 56 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,11 @@
2
2
3
3
Looking to improve `trlX`? Thanks for considering!
4
4
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.
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.
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
+
26
43
```bash
27
44
git checkout -b <BRANCH-NAME>
28
45
```
29
-
2. Install the development dependencies in a Python environment.
46
+
47
+
1. Install the development dependencies in a Python environment.
48
+
30
49
```bash
31
50
pip install -e ".[dev]"
32
51
pre-commit install
33
52
```
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
+
36
71
```bash
37
72
pytest
38
73
```
74
+
39
75
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
+
40
77
```bash
41
78
pytest -vv -k "<TEST-FILE-NAME>"
42
79
```
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
+
44
83
```bash
45
84
pre-commit run --all-files
46
85
```
47
86
48
-
6. Push the changes to your fork.
87
+
1. Push the changes to your fork.
49
88
50
89
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.
51
90
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
+
```
53
100
54
101
## Asking questions
55
102
@@ -63,4 +110,4 @@ This project adheres to the [Contributor Covenant Code of Conduct](https://githu
63
110
64
111
By contributing, you agree that your contributions will be licensed under its MIT License.
@@ -12,6 +14,7 @@ You can read more about trlX in our [documentation](https://trlX.readthedocs.io)
12
14
Want to collect human annotations for your RL application? Check out [CHEESE!](https://github.com/carperai/cheese), our library for HiTL data collection.
13
15
14
16
## Installation
17
+
15
18
```bash
16
19
git clone https://github.com/CarperAI/trlx.git
17
20
cd trlx
@@ -20,31 +23,37 @@ pip install -e .
20
23
```
21
24
22
25
## Examples
26
+
23
27
For more usage see [examples](./examples). You can also try the colab notebooks below:
24
28
| Description | Link |
25
29
| ----------- | ----------- |
26
30
| Simulacra Example |[](https://colab.research.google.com/drive/1vrmCLoHNlKvDVqJjMig-8tKDCfIEoym4?usp=sharing)|
27
31
28
32
29
-
30
33
## How to Train
34
+
31
35
You can train a model using a reward function or a reward-labeled dataset.
32
36
33
-
#### Using a reward function
37
+
### Using a reward function
38
+
34
39
```python
35
40
trainer = trlx.train('gpt2', reward_fn=lambdasamples, **kwargs: [sample.count('cats') for sample in samples])
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.
> 💡 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
-
112
86
## Contributing
113
87
114
88
For development check out these [guidelines](./CONTRIBUTING.md)
0 commit comments