[Docs] Fix doc warnings, focus on feature and multimodal sections
State: closed | Pull request: yes
Labels: name: ASR

name: NLP

name: Multi Modal

name: Run CICD

# What does this PR do ?

Fix doc feature section warnings

**Collection**: [Note which collection this PR will affect]

# Changelog 
- Add specific line by line info of high level changes in this PR.

# Usage
* You can potentially add a usage example below

```python
# Add a code snippet demonstrating how to use this 
```

# GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

# Before your PR is "Ready for review"
**Pre checks**:
- [ ] Make sure you read and followed [Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md)
- [ ] Did you write any new necessary tests?
- [ ] Did you add or update any necessary documentation?
- [ ] Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
  - [ ] Reviewer: Does the PR have correct import guards for all optional libraries?
  
**PR Type**:
- [ ] New Feature
- [ ] Bugfix
- [ ] Documentation

If you haven't finished some of the above items you can still open "Draft" PR.


## Who can review?

Anyone in the community is free to review the PR once the checks have passed. 
[Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md) contains specific people who can review PRs to various areas.

# Additional Information
* Related to # (issue)


Copyedits for docs/source/features/optimizations/activation_recomputation.rst.

Lines 4-6. fix punctuation and revise.

The input activations of network layers are stored in device memory and are used to compute gradients during back-propagation. When training a LLM with a long sequence length or a large micro-batch size, these input activations can quickly saturate device memory. Checkpointing a few activations and recomputing the rest is a common technique to reduce device memory usage.

Lines 11 -13. fix capitalization, fix punctutation, and revise.

NeMo supports transformer layer recomputation, which checkpoints the input of each transformer layer and recomputes the activations for the remaining layers. This technique significantly reduces activation memory usage. However, it increases the per-transformer layer computation cost by 30% due to re-executing the entire layer’s forward computation. 

Lines 14-15. verify this sentence the sentence; it appears to be missing text. suggested revision.

NeMo also supports partial transformer layer recomputation, which is beneficial when recomputing a few transformer layers to fit the training workload on GPU memory. This approach avoids the need to recompute the rest of the layers.

Lines 18 fix capitalization and use a second-person pronoun.

You can set the number of transformer layers to recompute  using ``activations_checkpoint_num_layers`` along with ``activations_checkpoint_method=block``.

Line 19 fix capitalization, fix punctuation, use a second-person pronoun.

If you set ``activations_checkpoint_num_layers`` as the total number of layers, the inputs of all transformer layers are checkpointed and recomputed.

Line 21. revise.

When using virtual pipelining, activations_checkpoint_num_layers specifies the number of layers per virtual pipeline stage.

Lines 23-25. fix capitalization, fix punctuation, and revise.

NeMo also supports checkpointing the input to a block of multiple consecutive transformer layers, meaning that a block of transformer layers becomes the recomputation granularity. This approach can save activation memory but increases the recomputation buffer memory. Thus, it is only beneficial for memory savings when the model has many transformer layers or when the intermediate layers of a transformer layer hold relatively small activation stores.

Line 26. fix capitalization and revise.

This recomputation mode can be enabled by setting ``activations_checkpoint_method=uniform``, with the number of transformer layers per recomputation block set using ``activations_checkpoint_num_layers``.

Line 32. fix punctuation and revise.

This cost-efficient method achieves high memory savings with minimal recomputation cost.

Line 33. revise.

The intermediate layers of the self-attention block accounts for the majority of the activation memory.

Line 38. use second-person pronoun.

Also, you can use the self-attention recomputation without FlashAttention by setting ``activations_checkpoint_granularity=selective``.



Copyedits for asr_language_modeling_and_customization.rst.

Lines 22 -23. revise.

The beam search decoders and KenLM library are not installed by default in NeMo. You need to install them to be able to use beam search decoding and N-gram LM.

Lines 37 - 40. revise.

The parameter 'beam_alpha' determines the weight given to the N-gram language model, while 'beam_beta' is a penalty term that accounts for sequence length in the scores. A larger 'beam_alpha' places more emphasis on the language model and less on the acoustic model. Negative values for 'beam_beta' penalize longer sequences, encouraging the decoder to prefer shorter predictions. Conversely, positive values for 'beam_beta' favor longer candidates.

Line 47. fix punctuation.

The script to train an N-gram language model with KenLM can be found at:

Lines 50 - 52. revise.

This script trains an N-gram language model with the KenLM library which can then be used with the beam search decoders on top of the ASR models. This script also supports both character-level and BPE-level encodings and models which are detected automatically from the model type.

Line 55. revise.

You can train the N-gram model using the following:

Line 68. fix capitalization, fix punctuation, and revise.

For the JSON manifests, the file must contain JSON-formatted samples per each line like this:

Line 74 - 75. revise.

This code extracts the `text` field from each line to create the training text file. After the N-gram model is trained, it is stored at the path specified by `kenlm_model_file`.

Line 101. revise note in rst format.

..note:: 
    It is recommended that you use 6 as the order of the N-gram model for BPE-based models. Higher orders may require re-compiling KenLM to support them.

Line 110. fix punctuation.

This script has a large number of possible argument overrides; therefore, it is recommended that you use ``python eval_beamsearch_ngram.py --help`` to see the full list of arguments.

Line 112. revise.

You can evaluate an ASR model using the following:

Line 127. revise.

It can evaluate a model in the following three modes by setting the argument `--decoding_mode`:

Line 129. fix punctuation.

greedy: Just greedy decoding is done and no beam search decoding is performed.

Line 130. fix punctuation and revise.

beamsearch: The beam search decoding is done, but without using the N-gram language model. Final results are equivalent to setting the weight of LM (beam_beta) to zero.

Lines 133 - 136. revise.

In `beamsearch` mode, the evaluation is performed using beam search decoding without any language model. The performance is reported in terms of Word Error Rate (WER) and Character Error Rate (CER). Moreover, when the best candidate is selected among the candidates, it is also reported as the best WER/CER. This can serve as an indicator of the quality of the predicted candidates.

Line 138 - 144. revise.

The script initially loads the ASR model and predicts the outputs of the model's encoder as log probabilities. This part is computed in batches on a device specified by --device, which can be either a CPU (--device=cpu) or a single GPU (--device=cuda:0). 

The batch size for this part is specified by --acoustic_batch_size. Using the largest feasible batch size can speed up the calculation of log probabilities. Additionally, you can use --use_amp to accelerate the calculation and allow for larger --acoustic_batch_size values.

Currently, multi-GPU support is not available for calculating log probabilities. However, using --probs_cache_file can help. This option stores the log probabilities produced by the model’s encoder in a pickle file, allowing you to skip the first step in future runs.

Line 194. revise.

The width of the beam search (--beam_width) specifies the number of top candidates or predictions the beam search decoder will consider. Larger beam widths result in more accurate but slower predictions.

Lines 198 - 201. Fix note formatting. Delete line 198. The text should appear on the next line after ..note::

.. note::
    The ``eval_beamsearch_ngram.py`` script contains the entire subconfig used for CTC Beam Decoding.
    Therefore it is possible to forward arguments for various beam search libraries such as ``flashlight``
    and ``pyctcdecode`` via the ``decoding`` subconfig.

Lines 203 - 204 revise and fix punctuation.

To learn more about evaluating the ASR models with N-gram LM, refer to the tutorial here: Offline ASR Inference with Beam Search and External Language Model Rescoring <https://colab.research.google.com/github/NVIDIA/NeMo/blob/stable/tutorials/asr/Offline_ASR.ipynb>`_.

Line 209. fix punctuation.

NeMo ASR CTC supports multiple beam search engines for decoding. The default engine is beam, which is the OpenSeq2Seq decoding library.

Line 215. revise.

OpenSeq2Seq is a CPU-based beam search engine that is quite efficient and supports char and subword models. It requires a character/subword KenLM model to be provided.

Line 223. fix punctuation.

Flashlight is a C++ library for ASR decoding provided at `https://github.com/flashlight/flashlight <https://github.com/flashlight/flashlight>`_. It is a CPU- and CUDA-based beam search engine that is quite efficient and supports char and subword models. It requires an ARPA KenLM file.

Line 226. fix punctuation.

It supports several advanced features, such as lexicon-based decoding, lexicon-free decoding, beam pruning threshold, and more.

Line 257. fix capitalization.

PyCTCDecode is a Python library for ASR decoding provided at `https://github.com/kensho-technologies/pyctcdecode <https://github.com/kensho-technologies/pyctcdecode>`_. It is a CPU-based beam search engine that is somewhat efficient for a pure Python library, and supports char and subword models. It requires a character/subword KenLM ARPA / BINARY model to be provided.

Line 259. fix punctuation.

It has advanced features, such as word boosting, which can be useful for transcript customization.

Lines 286 - 289. revise.

The accuracy of the model is dependent on the values of these parameters, specifically, beam_alpha and beam_beta. To perform grid search, you can specify a single value or a list of values for each of these parameters. In this case, it would perform the beam search decoding on all combinations of the three hyperparameters.
For example, the following set of parameters would result in 2*1*2=4 beam search decodings:

Line 299. fix capitalization.

Beam Search ngram Decoding for Transducer Models (RNNT and HAT)

Lines 202 - 302. fix punctuation and revise.

You can also find a similar script to evaluate an RNNT/HAT model with beam search decoding and N-gram models at: `scripts/asr_language_modeling/ngram_lm/eval_beamsearch_ngram_transducer.py <https://github.com/NVIDIA/NeMo/blob/stable/scripts/asr_language_modeling/ngram_lm/eval_beamsearch_ngram_transducer.py>`_.

Lines 328 - 331. revise.

When using the neural rescoring approach, a neural network is used to score candidates. A candidate is the text transcript predicted by the ASR model’s decoder. The top K candidates produced by beam search decoding (with a beam width of K) are given to a neural language model for ranking. The language model assigns a score to each candidate, which is usually combined with the scores from beam search decoding to produce the final scores and rankings.

Line 341. revise.

You can also use a pretrained language model from the Hugging Face library, such as Transformer-XL and GPT, instead of training your model.

Line 342. revise.

Models like BERT and RoBERTa are not supported by this script because they are trained as Masked Language Models. As a result, they are not efficient or effective for scoring sentences out of the box.

Line 352. revise.

search decoding or the result of fusion with an N-gram LM. You can generate this file by specifying `--preds_output_folder` for

Line 355. revise.

The neural rescorer would rescore the beams/candidates by using two parameters of `rescorer_alpha` and `rescorer_beta`, as follows:

Lines 361 - 363. revise.

The parameter `rescorer_alpha` specifies the importance placed on the neural rescorer model, while `rescorer_beta` is a penalty term that accounts for sequence length in the scores. These parameters have similar effects to `beam_alpha` and `beam_beta` in the beam search decoder and N-gram language model.

Line 365. revise.

Use the following steps to evaluate a neural LM:

Line 386. fix punctuation.

The candidates, along with their new scores, are stored at the file specified by `--scores_output_file`.

Lines 393 - 394 fix punctuation and name.

The path of the '.nemo' file of an ASR model or the name of a Hugging Face pretrained model, such as  'transfo-xl-wt103' or 'gpt2'.

Line 396. fix punctuation.

Path to the evaluation manifest file (.json manifest file).

Line 397. fix capitalization.

Path to beams file (.tsv) containing the candidates and their scores.

Lines 398, 400, 402, 403, 405, 406, 408, 410, 412, 4414, 416. and 417. Add a period at the end of the sentences in the Description column.

Lines 424 - 429. revise.

The hyperparameter linear search script also supports linear search for parameters `alpha` and `beta`. If any of the two is not
provided, a linear search is performed to find the best value for that parameter. When linear search is used, initially
`beta` is set to zero and the best value for `alpha` is found, then `alpha` is fixed with
that value and another linear search is done to find the best value for `beta`.
If any of the of these two parameters is already specified, then search for that one is skipped. After each search for a
parameter, the plot of WER% for different values of the parameter is also shown.

Lines 438 - 441. fix punctuation and revise.

The Flashlight decoder supports word boosting during CTC decoding using a KenLM binary and corresponding lexicon. Word boosting only works in lexicon-decoding mode and does not function in lexicon-free mode. It allows you to bias the decoder for certain words by manually increasing or decreasing the probability of emitting specific words. This can be very helpful if you have uncommon or industry-specific terms that you want to ensure are transcribed correctly.

Line 443 revise.

For more information, go to `word boosting  <https://docs.nvidia.com/deeplearning/riva/user-guide/docs/asr/asr-customizing.html#word-boosting>`__.

Lines 445 - 446. fix capitalization, fix punctuation, and revise.

To use word boosting in NeMo, create a simple tab-separated text file. Each line should contain a word to be boosted, followed by a tab, and then the boosted score for that word.

Line 463. fix capitalization.

You can then pass this file to your Flashlight config object during decoding:

Lines 479 - 480. revise.

Before combining N-gram LMs, install the required OpenGrm NGram library using `scripts/installers/install_opengrm.sh <https://github.com/NVIDIA/NeMo/blob/stable/scripts/installers/install_opengrm.sh>`__.

Alternatively, you can use the Docker image at: `scripts/installers/Dockerfile.ngramtools <https://github.com/NVIDIA/NeMo/blob/stable/scripts/installers/Dockerfile.ngramtools>`__, which includes all the necessary dependencies.

Line 485. revise.

This script interpolates two ARPA N-gram language models and creates a KenLM binary file that can be used with the beam search decoders on top of ASR models.

Line 487. fix punctuation.

This script supports both character-level and BPE-level encodings and models, which are detected automatically based on the type of the model.

Line 504. revise.

Note that the result of each step during the process is cached in a temporary file in the --out_path to speed up future runs.

Lines 531, 533, 535, 537, and 547. Add a period at the end of the sentences in the Description column.

Line 552. fix capitalization.

Context-biasing (Word Boosting) without External LM

Lines 602 -604. add periods at end of sentence.

*  ``beam_threshold`` - threshold for CTC-WS beam pruning.
*  ``context_score`` - per token weight for context biasing.
*  ``ctc_ali_token_weight`` - per token weight for CTC alignment (prevents false acceptances of context-biasing words).

Line 626. revise.

To use Transducer head of the Hybrid Transducer-CTC model, set ``decoder_type=rnnt``.

copyedits for docs/source/multimodal/text2img/insp2p.rst.

Line 16. revise link.

For instructions on downloading and preparing the custom dataset for training InstructPix2Pix, refer to the official `Instruct-Pix2Pix Repository <https://github.com/timothybrooks/instruct-pix2pix#generated-dataset>`_.

Lines 49 - 52. revise nested bullet formatting for - ``unet_config``. Add a blank line after Line 49 and before Line 50 (where the nest starts).

- ``unet_config``: Configuration parameters for the UNet model within the NeMo collection.

  - ``_target_``: Designates the target module for the UNet model in the NeMo collection.
  - ``from_pretrained``: (Value not provided) Generally indicates the path or identifier of a pretrained model.
  - ``in_channels``: Specifies the number of input channels for the UNet model. Here, the value is set to 8, with the initial 4 channels dedicated to image guidance.
  Additional model configurations align with Stable Diffusion (refer to :doc:`Stable Diffusion <./sd>`).

Line 56. fix capitalization.

Optimization-Related Configurations

copyedits for docs/source/multimodal/text2img/sdxl_quantization.rst.

Line 4. suggested revision.

The example in this section shows how to use ModelOpt to calibrate and quantize the UNet part of the SDXL. The UNet part typically consumes over 95% of the e2e Stable Diffusion latency.

Line 7. revise.

We also provide instructions on deploying and running the E2E SDXL pipeline

Lines 10 - 11. revise link.

To get started, you need a pretrained SDXL checkpoint in NeMo format. Example training configurations are available here: `Stable Diffusion Examples <https://github.com/NVIDIA/NeMo/tree/main/examples/multimodal/text_to_image/stable_diffusion>`_.

Line 15. revise.

The first step is to run the quantization script with the default config. The script will export the quantized unet to the onnx file.

Line 16. revise link.

Here is the default config for `SDXL Quantize Script <https://github.com/NVIDIA/NeMo/blob/main/examples/multimodal/text_to_image/stable_diffusion/sd_xl_quantize.py>`_.

Line 35. revise.

- percentile: Controls the range for collecting quantization scaling factors (amax). This means we will collect the minimum amax over a range of (n_steps * percentile) steps. We recommend 1.0.

Line 36. revise.

- alpha: A parameter in SmoothQuant, used exclusively for linear layers only. We recommend 0.8 for SDXL and 1.0 for SD 1.5.

Line 38. fix punctuation.

calib-size: For SDXL, we recommend 32, 64 or 128, for SD 1.5 and set to 512 or 1024.


Line 51. suggested revision.

When building the TRT engine, you must provide the input shape as follows:

Lines 52 - 53. the bullets don't seem to be rendering properly. Try using the * character for the bullet instead of -. Also, fix the spelling for "dimension".
 
* x: Input image latent shape (B * C * H * W)
* context: Input text conditioning (B * S * hidden_dimension)
* y: Additional embedding (B * adm_in_channels)


Line 59. fix punctuation and revise link.

We provide a script to build an end-to-end TRT inference pipeline with the  NeMo backend here: `SDXL Export Script <https://github.com/NVIDIA/NeMo/blob/main/examples/multimodal/text_to_image/stable_diffusion/sd_xl_export.py>`_.


Lines 76 - 79. fix punctuation. add a period at the end of each item.

- out_path: Directory to save onnx file and TRT engine files.
- width and height: Image resolution of inference output.
- batch_size: Only used for dummy input generation and onnx sanity check.
- {min,max}_batch_size: The input batch size of TRT engine along its dynamic axis.

Line 82. fix capitalization.

Run End-to-End Stable Diffusion XL TRT Pipeline

Line 85. fix link.

The inference script can be found here: `SDXL TRT Inference Script <https://github.com/NVIDIA/NeMo/blob/main/examples/multimodal/text_to_image/stable_diffusion/sd_xl_trt_inference.py>`_.


copyedits for docs/source/multimodal/nerf/dreamfusion.rst.

Line 24. fix capitalization.

Image Guidance

Line 32. fix capitalization.

NeRF (Foreground) Network

Line 34. NERF previously defined. Can remove it here.

The Neural Radiance Fields network is at the heart of DreamFusion's 3D rendering capabilities.

Line 39. fix capitalization.

Background Layer

Line 51. fix capitalization.

Materials Network

Line 53. make plural "material" so it is consistent with title.

The materials network in DreamFusion is responsible for adding realism to the 3D models by accurately simulating the physical properties of different materials.

Line 58 fix capitalization

Renderer Layer

Line 117. revise.

Path to a checkpoint file for initializing the model.

Line 130 fix capitalization.

Image Guidance

Line 145. fix capitalization

NeRF (Foreground) Network

Line 179. fix capitalization.

Background Layer

Line 206. fix capitalization.

Materials Network

Line 238. fix punctuation and spelling.

DMTet fine-tuning disentangles the learning of geometry and appearance models, such that both a fine surface and a rich

Lines 242 - 244. No copyedits here. Just admiring the wizardry of this sentence!

Line 297. fix punctuation and revise.

The rendering module was updated from a volumetric-based approach to a rasterization-based one using nvdiffrast.

Line 299. fix punctuation.

3. DreamFusion-DMTet fine-tunes a pretrained DreamFusion model, the pretrained checkpoint is provided using ``resume_from_checkpoint``.

Line 300. fix spelling.

4. The training shape is increased to 512x512.

copyedits for docs/source/nlp/nemo_megatron/gpt/gpt_training.rst.

Line 1. fix capitalization.

GPT Model Training
------------------------

Line 4. add introductory text for this topic, define acronym on first use, and revise.

The Generative Pre-trained Transformer (GPT) is a decoder-only Transformer model. This section demonstrates how to train a GPT-style model with NeMo.

Lines 7 - 8. Delete "Quick start" and remove heading.

Line 9. Delete this line. We already added it to Line 4.

Line 12. revise this note by icluding a link.

This example is best completed using the latest `NeMo Framework Training container <https://catalog.ngc.nvidia.com/orgs/nvidia/containers/nemo>`__.

Line 14. change this heading to imperative verb, remove the ampersand, and use capitalization.

Download and Pre-process Data

Line 18. remove the "note" format and change the sentence to active voice.

The example below will take approximately 3 hours to download data, pre-process it, and train the tokenizer.

Line 20. replace **Step 1: Download data** with a step number. The recommended style for procedures is to use sequential numbering without the word "Step", avoid bolded text, and write the step as a complete sentence. Like this:

1. Download the data.

Line 22. revise.

The following step will download approximately 20GB of Wikipedia data, which can take several hours to complete.

Line 28. replace **Step 2: Extract raw data** with a step number.

2. Extract the raw data.

Line 36. fix capitalization and revise.

Now, train_data.jsonl will contain our training data in JSON line format. We are particularly interested in the data within the  "text" field.

Line 39. replace **Step 3: Train tokenizer** with a step number.

3. Train the tokenizer.

Line 41. fix HF name (two words) and revise.

Below, we will consider two options for training data tokenizers: using the pre-built Hugging Face BPE or training and using your own Google Sentencepiece tokenizer.


Line 45. fix HF name and replace gerund ("ing") with imperative verb.

*Option 1:* Use Hugging Face GPT2 tokenizer files.

Line 55. replace gerund with imperative verb

*Option 2:* Use `Google Sentencepiece <https://github.com/google/sentencepiece>`_ tokenizer library. 

Lines 57 - 58. revise.

Google Sentencepiece is included as a dependency with NeMo, so if you have installed NeMo, it should already be installed. Please note that training the tokenizer model will also take some time.

Line 73. revise.

Completing this step can take some time. After it is done, you'll have two files: ``spm_32k_wiki.model`` and ``spm_32k_wiki.vocab`` corresponding to the model and vocabulary.

Line 75. replace **Step 4: Convert training data into memory map format** with a step number.

4. Convert the training data into memory map format.

Line 77. revise.

The memory map format makes training more efficient, especially with many nodes and GPUs. This step will also tokenize data using the tokenizer model from Step 3.

Line 79. fix HF name and use imperative verb.

*Option 1:* Use Hugging Face GPT2 tokenizer files.

Line 95. Use imperative verb.

*Option 2:* Use `Google Sentencepiece <https://github.com/google/sentencepiece>`_ tokenizer library.

Line 109. revise title and use capitalization.

Train a GPT-Style Model

Line 116. fix HF name and use imperative verb.

*Option 1:* Use Hugging Face GPT2 tokenizer files.

Line 169.  Use imperative verb.

*Option 2:* Use `Google Sentencepiece <https://github.com/google/sentencepiece>`_ tokenizer library.

Line 222. revise.

Next, you can launch Tensorboard to monitor training, as follows:

Line 228. use capitalization for heading.

Next Steps

Line 231. revise.

For more information, please refer to:


copyedits for docs/source/nlp/token_classification.rst.

Line 3. suggest topic title revision. This helps SEO searches.

Token Classification Model with Named Entity Recognition (NER)
===============================================================

Line 6. revise.

The token classification model supports NER and other token-level classification tasks, as long as the data follows the format specified below.

Lines 9 - 12 revise.

We're going to use NER task throughout this section. NER, also referred to as entity chunking, identification, or extraction, is the task of detecting and classifying key information (entities) in text. In other words, a NER model takes a piece of text as input and then determines the category for each word within it. For example, in the sentence “Mary lives in Santa Clara and works at NVIDIA,” the model should detect that “Mary” is a person, “Santa Clara” is a location, and “NVIDIA” is a company.

Line 14. Revise heading (delete "Guide") and fix capitalization.

Quick Start
-----------

Line 16 - 28. revise this section and add steps for the Quick Start procedure. For example:

1. To run token-level classification, use the following Python script:

    .. code-block:: python

        from nemo.collections.nlp.models import TokenClassificationModel

        # to get the list of pre-trained models

        TokenClassificationModel.list_available_models()

        # Download and load the pre-trained BERT-based model
    model = TokenClassificationModel.from_pretrained("ner_en_bert")

        # try the model on a few examples
    model.add_predictions(['we bought four shirts from the nvidia gear store in santa clara.', 'NVIDIA is a company.'])


2. Try this model in a Jupyter notebook, which you can run on `Google Colab <https://colab.research.google.com/notebooks/intro.ipynb>`_. 

    You can find this script in the `NeMo tutorial <https://github.com/NVIDIA/NeMo/blob/stable/tutorials/nlp/Token_Classification_Named_Entity_Recognition.ipynb>`_.

3. Connect to an instance with a GPU (**Runtime** -> **Change runtime type** -> select **GPU** for the hardware accelerator).

Lines 30 - 33. Delete all of these lines, including the note.

Lines 37 - 41. revise into bullets and shorten the links. Like this:

You can find example scripts and configuration files for the token classification model at the following locations:

* An example script on how to train the model can be found at `NeMo training script <https://github.com/NVIDIA/NeMo/blob/stable/examples/nlp/token_classification/token_classification_train.py>`_.

* An example script on how to run evaluation and inference can be found at `NeMo evaluation script <https://github.com/NVIDIA/NeMo/blob/stable/examples/nlp/token_classification/token_classification_evaluate.py>`_.

* The default configuration file for the model can be found at `NeMo configuration file <https://github.com/NVIDIA/NeMo/blob/stable/examples/nlp/token_classification/conf/token_classification_config.yaml>`_.

Line 43. Please verify this line. it appears to be out of place (?):

.. _dataset_token_classification:

Line 45. revise the heading as imperative verb.

Provide Data Input for the Token Classification Model
-------------------------------------------------------

Line 48. change to active voice.

To pre-train or fine-tune the model, split the data into the following two files:

Line 55. revise.

The following is an example of a ``text.txt`` file:

Line 61. revise.

The following is an example of the corresponding ``labels.txt`` file:

Line 67. revise heading to an imperative verb.

Convert the Dataset
-------------------

Lines 70 - 71 shorten the link and revise.

To convert the `IOB tagging format <https://en.wikipedia.org/wiki/Inside%E2%80%93outside%E2%80%93beginning_(tagging)>`__ (short for inside, outside, beginning) into the format required for training, use the `NeMo import script <https://github.com/NVIDIA/NeMo/blob/stable/examples/nlp/token_classification/data/import_from_iob_format.py>`_.

Line 78, revise heading so it is consistent with the others.

Required Arguments for Dataset Conversion
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Line 83. revise.

After running the previous command, the data directory containing the :code:`--data_file` should include the :code:`text_*.txt` and :code:`labels_*.txt` files.

Line 296 revise heading to imperative verb and fix capitalization.

Train the Token Classification Model
------------------------------------

Line 99. fix capitalization.

In the token classification model, we are jointly training a classifier on top of a pre-trained language model, such as 

Line 102. fix HF name (two words).

from `Hugging Face Transformers <https://github.com/huggingface/transformers>`__.

Line 104. revise and shorten link.

An example of model configuration file for training the model can be found at `NeMo configuration file <https://github.com/NVIDIA/NeMo/blob/stable/examples/nlp/token_classification/conf/token_classification_config.yaml>`_.

Line 112. revise.

You can find more details about the spec file parameters in table below.

Line 142. revise.

Here is an example command for training the model:

Line 155. add lead-in sentence.

The following argument is required for training:

Lines 160 - 164. fix note punctuation (command line) and revise.

While the arguments are defined in the spec file, you can override these parameter definitions and experiment with them using the command line. For example, the sample spec file mentioned above has :code:`validation_ds.batch_size` set to ``64``. However, if GPU utilization can be optimized further by using a larger batch size, you can override it to the desired value by adding the field :code:`validation_ds.batch_size=128` from the command line. You can repeat this process with any of the parameters defined in the sample spec file.

Line 169. shorten the link.

An example script on how to run inference can be found at `NeMo evaluation script <https://github.com/NVIDIA/NeMo/blob/stable/examples/nlp/token_classification/token_classification_evaluate.py>`_.

Line 180.  add lead-in sentence.

The following argument is required for inference:

Line 183. change heading to imperative verb.

Evaluate the Token Classification Model
----------------------------------------

Line 186. shorten the link.

An example script on how to evaluate the pre-trained model can be found at `NeMo evaluation script <https://github.com/NVIDIA/NeMo/blob/stable/examples/nlp/token_classification/token_classification_evaluate.py>`_.


Line 188. revise.

To start the evaluation of the pre-trained mode, run:

Line 200. revise heading so it is consistent with the others.

Required Arguments for Evaluation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Line 202.  add lead-in sentence.

The following arguments are required for evaluation:

Line 212. revise link.

For more information, see `Wikipedia <https://en.wikipedia.org/wiki/Precision_and_recall>`__.


This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

This PR was closed because it has been inactive for 7 days since being marked as stale.

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

Documentation only changes: documentation only changes , doc-string only changes for Python files. We think we can safely skip CI