Skip to content

Commit 75efc06

Browse files
authored
Docs/references in notebooks (#58)
1 parent eb6a3bf commit 75efc06

File tree

6 files changed

+59
-89
lines changed

6 files changed

+59
-89
lines changed

docs/source/concepts.rst

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,30 @@ Key Concepts
22
============
33

44

5-
- **Optimization Search Space**. Автоматический подбор классификатора происходит за счет перебора гиперпараметров в некотором *пространстве поиска*. Говоря на уровне идеи, это пространство поиска является словариком, в котором ключами являются имена гиперпараметров, а значениями --- списки. Гиперпараметры выступают в роли координатных "осей" пространства поиска, а значения в списках --- в роли точек на этой оси.
6-
- **Classification Stages**. Классификацию интента можно разделить на два этапа: скоринг и предсказание. Скоринг --- это предсказание вероятностей наличия каждого интента в данной реплике. Предсказание --- это формирование финального предсказания на основе предоставленных вероятностей.
7-
- **Prediction**. Если мы хотим детектировать out-of-domain примеры, то на этапе предсказания необходимо подобрать порог вероятности, при котором можно утверждать о наличии какого-то известного интента.
8-
- **Nodes and Modules**. Модель скоринга или предсказания вместе с её гиперпараметрами, которые нужно перебрать, мы называем *модулем оптимизации*. Набор модулей, относящихся к одному этапу оптимизации (скорингу или предсказанию), мы называем *узлом оптимизации*.
5+
.. _key-search-space:
6+
7+
Optimization Search Space
8+
-------------------------
9+
10+
Автоматический подбор классификатора происходит за счет перебора гиперпараметров в некотором *пространстве поиска*. Говоря на уровне идеи, это пространство поиска является словариком, в котором ключами являются имена гиперпараметров, а значениями --- списки. Гиперпараметры выступают в роли координатных "осей" пространства поиска, а значения в списках --- в роли точек на этой оси.
11+
12+
.. _key-stages:
13+
14+
Classification Stages
15+
---------------------
16+
17+
Классификацию интента можно разделить на два этапа: скоринг и предсказание. Скоринг --- это предсказание вероятностей наличия каждого интента в данной реплике. Предсказание --- это формирование финального предсказания на основе предоставленных вероятностей.
18+
19+
.. _key-oos:
20+
21+
Out-of-domain utterances
22+
------------------------
23+
24+
Если мы хотим детектировать out-of-domain примеры, то на этапе предсказания необходимо подобрать порог вероятности, при котором можно утверждать о наличии какого-то известного интента.
25+
26+
.. _key-nodes-modules:
27+
28+
Nodes and Modules
29+
-----------------
30+
31+
Модель скоринга или предсказания вместе с её гиперпараметрами, которые нужно перебрать, мы называем *модулем оптимизации*. Набор модулей, относящихся к одному этапу оптимизации (скорингу или предсказанию), мы называем *узлом оптимизации*.

docs/source/docs_utils/apiref.py

Lines changed: 0 additions & 66 deletions
This file was deleted.

docs/source/docs_utils/notebook.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ class DocumentationLink(ReplacePattern):
9898
@staticmethod
9999
def link_to_doc_page(
100100
page_type: Literal["api", "tutorial", "guide"],
101-
page: str,
102-
anchor: str | None = None,
101+
dotpath: str,
102+
obj: str | None = None,
103103
) -> str:
104104
"""
105105
Create a link to a documentation page.
@@ -111,18 +111,18 @@ def link_to_doc_page(
111111
- "tutorial" -- Tutorials
112112
- "guide" -- User guides
113113
114-
:param page:
115-
Name of the page without the common prefix.
114+
:param dotpath:
115+
Path to the index page in unix style.
116116
117-
So, to link to keywords, pass "script.core.keywords" as page (omitting the "chatsky" prefix).
117+
So, to link Dataset, pass "context" as page (omitting the "autointent" prefix).
118118
119119
To link to the basic script tutorial, pass "script.core.1_basics" (without the "tutorials" prefix).
120120
121121
To link to the basic concepts guide, pass "basic_conceptions".
122122
123123
API index pages are also supported.
124124
Passing "index_pipeline" will link to the "apiref/index_pipeline.html" page.
125-
:param anchor:
125+
:param obj:
126126
An anchor on the page. (optional)
127127
128128
For the "api" type, use only the last part of the linked object.
@@ -134,12 +134,14 @@ def link_to_doc_page(
134134
A link to the corresponding documentation part.
135135
"""
136136
if page_type == "api":
137-
prefix = "" if page.startswith("index") else "chatsky."
138-
return f"../apiref/{prefix}{page}.rst" + (f"#{prefix}{page}.{anchor}" if anchor is not None else "")
137+
path = "/".join(dotpath.split("."))
138+
return f"../autoapi/autointent/{path}/index.rst" + (
139+
f"#autointent.{dotpath}.{obj}" if obj is not None else ""
140+
)
139141
if page_type == "tutorial":
140-
return f"../tutorials/tutorials.{page}.py" + (f"#{anchor}" if anchor is not None else "")
142+
return f"../tutorials/tutorials.{dotpath}.py"
141143
if page_type == "guide":
142-
return f"../user_guides/{page}.rst" + (f"#{anchor}" if anchor is not None else "")
144+
return f"../guides/{dotpath}.rst" + (f"#{obj}" if obj is not None else "")
143145
msg = "Unexpected page type"
144146
raise ValueError(msg)
145147

docs/source/learn/optimization.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ In this section, you will learn how hyperparameter optimization works in our lib
66
Pipeline
77
--------
88

9-
The entire process of configuring a classifier in our library is divided into sequential steps:
9+
The entire process of configuring a classifier in our library is divided into sequential steps (:ref:`and that's why <key-stages>`):
1010

1111
1. Selecting an embedder (EmbeddingNode)
1212
2. Selecting a classifier (ScoringNode)

docs/source/quickstart.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Once the data is ready, you can start building the optimal classifier from the c
5555
5656
autointent data.train_path="path/to/your/data.json"
5757
58-
This command will start the hyperparameter search in the default search space.
58+
This command will start the hyperparameter search in the default :ref:`search space <key-search-space>`.
5959

6060
As a result, a ``runs`` folder will be created in the current working directory, which will save the selected classifier ready for inference. More about the run folder and what is saved in it can be found in the guide :doc:`guides/optimization_results`.
6161

@@ -107,6 +107,7 @@ If there is no need to iterate over pipelines and hyperparameters, you can impor
107107
Further Reading
108108
---------------
109109

110+
- Get familiar with :doc:`concepts`.
110111
- Learn more about working with data in AutoIntent in our tutorial :doc:`tutorials/index_data`.
111112
- Learn about how auto-configuration works in our library in the section :doc:`learn/optimization`.
112113
- Learn more about the search space and how to customize it in the guide :doc:`guides/search_space_configuration`.

tutorials/data.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from autointent.context.data_handler import Dataset
1212

1313
# %%
14-
datasets.logging.disable_progress_bar() # disable tqdm outputs
14+
datasets.logging.disable_progress_bar() # disable tqdm outputs
1515

1616
# %% [markdown]
1717
"""
@@ -101,9 +101,9 @@
101101
```
102102
103103
- `name`: A human-readable representation of the intent.
104-
- `tags`: Used in multilabel scenarios to predict the most probable class listed in a specific tag.
105-
- `regexp_partial_match` and `regexp_full_match`: Used by the `RegExp` module to predict intents based on provided patterns.
106-
- `description`: Used by the `DescriptionScorer` to calculate scores based on the similarity between an utterance and intent descriptions.
104+
- `tags`: Used in multilabel scenarios to predict the most probable class listed in a specific %mddoclink(api,context.data_handler,Tag).
105+
- `regexp_partial_match` and `regexp_full_match`: Used by the %mddoclink(api,modules,RegExp) module to predict intents based on provided patterns.
106+
- `description`: Used by the %mddoclink(api,modules.scoring,DescriptionScorer) to calculate scores based on the similarity between an utterance and intent descriptions.
107107
108108
All fields in the `intents` list are optional except for `id`.
109109
"""
@@ -122,6 +122,8 @@
122122
# %% [markdown]
123123
"""
124124
### Creating a dataset from a Python dictionary
125+
126+
One can load data into Python using our %mddoclink(api,context.data_handler,Dataset) object.
125127
"""
126128

127129
# %%
@@ -203,7 +205,7 @@
203205

204206
# %% [markdown]
205207
"""
206-
The `Dataset` class organizes your data as a dictionary of splits (`str: datasets.Dataset`).
208+
The %mddoclink(api,context.data_handler,Dataset) class organizes your data as a dictionary of [datasets.Dataset](https://huggingface.co/docs/datasets/v2.1.0/en/package_reference/main_classes#datasets.Dataset).
207209
For example, after initialization, an `oos` key may be added if OOS samples are provided.
208210
In the case of the `banking77` dataset, only the `train` split is available, which you can access as shown below:
209211
"""
@@ -215,7 +217,7 @@
215217
"""
216218
### Working with dataset splits
217219
218-
Each split in the `Dataset` class is an instance of [datasets.Dataset](https://huggingface.co/docs/datasets/en/package_reference/main_classes#datasets.Dataset),
220+
Each split in the %mddoclink(api,context.data_handler,Dataset) class is an instance of [datasets.Dataset](https://huggingface.co/docs/datasets/en/package_reference/main_classes#datasets.Dataset),
219221
so you can work with them accordingly.
220222
"""
221223

@@ -230,7 +232,7 @@
230232
"""
231233

232234
# %%
233-
dataset.intents[0] # get intent (id=0)
235+
dataset.intents[0] # get intent (id=0)
234236

235237
# %% [markdown]
236238
"""
@@ -242,3 +244,11 @@
242244

243245
# %%
244246
# dataset.push_to_hub("<repo_id>")
247+
248+
# %% [markdown]
249+
"""
250+
## See Also
251+
252+
- Training on your data: %mddoclink(tutorial,pipeline_optimization.demo)
253+
- [Key Concepts](../concepts.html)
254+
"""

0 commit comments

Comments
 (0)