Skip to content

Commit 9ff15af

Browse files
authored
Fix Sphinx doc (#5)
1 parent fe72951 commit 9ff15af

File tree

17 files changed

+98
-87
lines changed

17 files changed

+98
-87
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,15 @@ pip install -e .\[dev\]
277277

278278
Code style check:
279279

280-
```markdown
280+
```shell
281281
pre-commit run --all-files
282282
```
283283

284284

285285

286286
Unit tests:
287287

288-
```markdown
288+
```shell
289289
python -m pytest tests
290290
```
291291

docs/sphinx_doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# You can set these variables from the command line, and also
55
# from the environment for the first two.
6-
SPHINXOPTS ?=
6+
SPHINXOPTS ?= -a -E -j auto
77
SPHINXBUILD ?= sphinx-build
88
SOURCEDIR = source
99
BUILDDIR = build

docs/sphinx_doc/_templates/package.rst_t

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,39 @@
1515
{%- endfor %}
1616
{%- endmacro %}
1717

18+
{%- if is_namespace %}
19+
.. py:module:: {{ pkgname }}
20+
{% endif %}
21+
22+
{%- if modulefirst and not is_namespace %}
23+
{{ automodule(pkgname, automodule_options) }}
24+
{% endif %}
25+
26+
{%- if subpackages %}
27+
Subpackages
28+
-----------
29+
30+
{{ toctree(subpackages) }}
31+
{% endif %}
32+
33+
{%- if submodules %}
34+
Submodules
35+
----------
36+
{% if separatemodules %}
37+
{{ toctree(submodules) }}
38+
{% else %}
39+
{%- for submodule in submodules %}
40+
{% if show_headings %}
41+
{{- [submodule, "module"] | join(" ") | e | heading(2) }}
42+
{% endif %}
43+
{{ automodule(submodule, automodule_options) }}
44+
{% endfor %}
45+
{%- endif %}
46+
{%- endif %}
47+
48+
{%- if not modulefirst and not is_namespace %}
49+
Module contents
50+
---------------
51+
1852
{{ automodule(pkgname, automodule_options) }}
53+
{% endif %}

docs/sphinx_doc/build_doc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
sphinx-apidoc -f -o source ../../trinity -t _templates
2+
sphinx-apidoc -f -o source/build_api ../../trinity -t _templates
33
make clean html

docs/sphinx_doc/source/conf.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
# -- Project information -----------------------------------------------------
77
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8-
import sphinx_rtd_theme
9-
108
from trinity import __version__ as version
119

1210
project = "Trinity-RFT"
@@ -36,16 +34,22 @@
3634
autosectionlabel_prefix_document = True
3735
autosummary_generate = True
3836
autosummary_ignore_module_all = False
37+
napoleon_google_docstring = True
3938

4039
autodoc_member_order = "bysource"
4140

4241
templates_path = ["_templates"]
4342
exclude_patterns = ["build"]
43+
autodoc_mock_imports = ["ray"]
44+
45+
autodoc_default_options = {
46+
"members": True,
47+
"special-members": "__init__",
48+
}
4449

4550
# -- Options for HTML output -------------------------------------------------
4651

4752
html_theme = "sphinx_rtd_theme"
48-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
4953

5054
html_theme_options = {
5155
"navigation_depth": 3,
@@ -55,13 +59,3 @@
5559
# relative to this directory. They are copied after the builtin static files,
5660
# so a file named "default.css" will overwrite the builtin "default.css".
5761
html_static_path = ["_static"]
58-
59-
60-
def skip(app, what, name, obj, would_skip, options):
61-
if name == "__init__":
62-
return False
63-
return would_skip
64-
65-
66-
def setup(app):
67-
app.connect("autodoc-skip-member", skip)

docs/sphinx_doc/source/index.rst

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Welcome to Trinity-RFT's documentation!
77
=======================================
88

9-
.. include:: tutorial/main.md
9+
.. include:: main.md
1010
:parser: myst_parser.sphinx_
1111

1212

@@ -25,31 +25,13 @@ Welcome to Trinity-RFT's documentation!
2525
tutorial/trinity_programming_guide.md
2626

2727
.. toctree::
28-
:maxdepth: 2
28+
:maxdepth: 1
2929
:glob:
3030
:caption: API Reference
3131

32-
example.md
33-
34-
trinity.buffer.reader
35-
trinity.buffer
36-
trinity.buffer.schema
37-
trinity.buffer.writer
38-
trinity.common.models
39-
trinity.common.rewards
40-
trinity.common
41-
trinity.common.workflows
42-
trinity.explorer
43-
trinity.manager
44-
trinity
45-
trinity.trainer
46-
trinity.trainer.verl
47-
trinity.utils
48-
49-
50-
Indices and tables
51-
==================
52-
53-
* :ref:`genindex`
54-
* :ref:`modindex`
55-
* :ref:`search`
32+
build_api/trinity.buffer
33+
build_api/trinity.explorer
34+
build_api/trinity.trainer
35+
build_api/trinity.manager
36+
build_api/trinity.common
37+
build_api/trinity.utils
Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1+
# Trinity-RFT
12

3+
![trinity-rft](../assets/trinity-title.png)
24

35

4-
<!-- ![trinity-rft](../../assets/trinity-title.png) -->
5-
6-
<div align="center">
7-
<img src="../../assets/trinity-title.png" alt="Trinity-RFT">
8-
</div>
96

107

118
Trinity-RFT is a general-purpose, flexible and scalable framework designed for reinforcement fine-tuning (RFT) of large language models (LLM).
@@ -46,12 +43,7 @@ These include converting raw datasets to prompt/task sets for RL, cleaning/filte
4643
## The design of Trinity-RFT
4744

4845

49-
<!-- ![design](../../assets/trinity-design.png) -->
50-
51-
<div align="center">
52-
<img src="../../assets/trinity-design.png" alt="Trinity-RFT">
53-
</div>
54-
46+
![design](../assets/trinity-design.png)
5547

5648

5749

@@ -140,7 +132,7 @@ Trinity-RFT supports most datasets and models from Huggingface and ModelScope.
140132

141133
**Prepare the model** in the local directory `$MODEL_PATH/{model_name}`:
142134

143-
```plain
135+
```shell
144136
# Using Huggingface
145137
huggingface-cli download {model_name} --local-dir $MODEL_PATH/{model_name}
146138

@@ -154,7 +146,7 @@ For more details about model downloading, please refer to [Huggingface](https://
154146

155147
**Prepare the dataset** in the local directory `$DATASET_PATH/{dataset_name}`:
156148

157-
```plain
149+
```shell
158150
# Using Huggingface
159151
huggingface-cli download {dataset_name} --repo-type dataset --local-dir $DATASET_PATH/{dataset_name}
160152

@@ -171,7 +163,7 @@ For more details about dataset downloading, please refer to [Huggingface](https:
171163

172164
You may customize the configurations in `scripts/config/{config_name}.yaml`and `scripts/config/{train_config_name}.yaml`. For example, the model and dataset are specified as:
173165

174-
```plain
166+
```yaml
175167
model:
176168
model_path: $MODEL_PATH/{model_name}
177169

@@ -231,11 +223,11 @@ More example config files can be found in `scripts/config`.
231223

232224

233225
For more detailed examples about how to use Trinity-RFT, please refer to the following documents:
234-
+ [A quick example with GSM8k](./example_reasoning_basic.md);
235-
+ [Off-policy / asynchronous modes of RFT](./example_reasoning_advanced.md);
236-
+ [Multi-turn tasks](./example_multi_turn.md);
237-
+ [Data processing pipelines](./example_data_functionalities.md);
238-
+ [Offline learning by DPO](./example_dpo.md).
226+
+ [A quick example with GSM8k](tutorial/example_reasoning_basic.md);
227+
+ [Off-policy / asynchronous modes of RFT](tutorial/example_reasoning_advanced.md);
228+
+ [Multi-turn tasks](tutorial/example_multi_turn.md);
229+
+ [Data processing pipelines](tutorial/example_data_functionalities.md);
230+
+ [Offline learning by DPO](tutorial/example_dpo.md).
239231

240232

241233

@@ -244,7 +236,7 @@ For more detailed examples about how to use Trinity-RFT, please refer to the fol
244236
## Advanced usage and full configurations
245237

246238

247-
Please refer to [this document](./trinity_configs.md).
239+
Please refer to [this document](tutorial/trinity_configs.md).
248240

249241

250242

@@ -253,7 +245,7 @@ Please refer to [this document](./trinity_configs.md).
253245
## Programming guide for developers
254246

255247

256-
Please refer to [this document](./trinity_programming_guide.md).
248+
Please refer to [this document](tutorial/trinity_programming_guide.md).
257249

258250

259251

@@ -277,15 +269,15 @@ pip install -e .\[dev\]
277269

278270
Code style check:
279271

280-
```markdown
272+
```shell
281273
pre-commit run --all-files
282274
```
283275

284276

285277

286278
Unit tests:
287279

288-
```markdown
280+
```shell
289281
python -m pytest tests
290282
```
291283

@@ -309,7 +301,7 @@ This project is built upon many excellent open-source projects, including:
309301

310302

311303
## Citation
312-
```plain
304+
```
313305
@misc{Trinity-RFT,
314306
title={Trinity-RFT},
315307
author={{Trinity-RFT Team}},

docs/sphinx_doc/source/tutorial/example_data_functionalities.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ In this example, you will learn how to apply the data module of Trinity-RFT to p
88
2. how to configure the data module
99
3. what the data module can do
1010

11-
Before getting started, you need to prepare the main environment of Trinity-RFT according to the [installation section of the README file](main.md#getting-started), and you need to install [postgresql](https://www.postgresql.org/docs/current/tutorial-install.html) as well.
11+
Before getting started, you need to prepare the main environment of Trinity-RFT according to the [installation section of the README file](../main.md), and you need to install [postgresql](https://www.postgresql.org/docs/current/tutorial-install.html) as well.
1212

1313
### Data Preparation
1414

@@ -243,7 +243,7 @@ You can set more config items for this OP (e.g. notification when annotation is
243243

244244
When you start running with the RFT config, the data module will start the OP `human_preference_annotation_mapper`, and then you can find a new project on the "Projects" page of the label-studio server.
245245

246-
<img src="../../assets/data-projects.png" width="300">
246+
![]("../../assets/data-projects.png")
247247

248248
You can click and enter into this project, and all the samples that need to be annotated are listed on the page.
249249

docs/sphinx_doc/source/tutorial/example_multi_turn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,5 @@ and include them in the init files in `trinity/common/workflows/__init__.py`
125125

126126
Then you are all set! It should be pretty simple😄, and both environments converge.
127127

128-
<img src="../../assets/alfworld_reward_curve.png" width="300" height="150">
129-
<img src="../../assets/webshop_reward_curve.png" width="300" height="150">
128+
![]("../../assets/alfworld_reward_curve.png")
129+
![]("../../assets/webshop_reward_curve.png")

0 commit comments

Comments
 (0)