|
| 1 | +## Text Classification |
| 2 | + |
| 3 | +The Python scripts in this directory demonstrate how to run classification on your text data with each of these 4 classifiers: |
| 4 | + |
| 5 | +- Domain Classifier |
| 6 | +- Quality Classifier |
| 7 | +- AEGIS Safety Models |
| 8 | +- FineWeb Educational Content Classifier |
| 9 | + |
| 10 | +For more information about these classifiers, please see NeMo Curator's [Distributed Data Classification documentation](https://docs.nvidia.com/nemo-framework/user-guide/latest/datacuration/distributeddataclassification.html). |
| 11 | + |
| 12 | +### Usage |
| 13 | + |
| 14 | +#### Domain classifier inference |
| 15 | + |
| 16 | +```bash |
| 17 | +# same as `python domain_classifier_inference.py` |
| 18 | +domain_classifier_inference \ |
| 19 | + --input-data-dir /path/to/data/directory \ |
| 20 | + --output-data-dir /path/to/output/directory \ |
| 21 | + --input-file-type "jsonl" \ |
| 22 | + --input-file-extension "jsonl" \ |
| 23 | + --output-file-type "jsonl" \ |
| 24 | + --input-text-field "text" \ |
| 25 | + --batch-size 64 \ |
| 26 | + --autocast \ |
| 27 | + --max-chars 2000 \ |
| 28 | + --device "gpu" |
| 29 | +``` |
| 30 | + |
| 31 | +Additional arguments may be added for customizing a Dask cluster and client. Run `domain_classifier_inference --help` for more information. |
| 32 | + |
| 33 | +#### Quality classifier inference |
| 34 | + |
| 35 | +```bash |
| 36 | +# same as `python quality_classifier_inference.py` |
| 37 | +quality_classifier_inference \ |
| 38 | + --input-data-dir /path/to/data/directory \ |
| 39 | + --output-data-dir /path/to/output/directory \ |
| 40 | + --input-file-type "jsonl" \ |
| 41 | + --input-file-extension "jsonl" \ |
| 42 | + --output-file-type "jsonl" \ |
| 43 | + --input-text-field "text" \ |
| 44 | + --batch-size 64 \ |
| 45 | + --autocast \ |
| 46 | + --max-chars 2000 \ |
| 47 | + --device "gpu" |
| 48 | +``` |
| 49 | + |
| 50 | +Additional arguments may be added for customizing a Dask cluster and client. Run `quality_classifier_inference --help` for more information. |
| 51 | + |
| 52 | +#### AEGIS classifier inference |
| 53 | + |
| 54 | +```bash |
| 55 | +# same as `python aegis_classifier_inference.py` |
| 56 | +aegis_classifier_inference \ |
| 57 | + --input-data-dir /path/to/data/directory \ |
| 58 | + --output-data-dir /path/to/output/directory \ |
| 59 | + --input-file-type "jsonl" \ |
| 60 | + --input-file-extension "jsonl" \ |
| 61 | + --output-file-type "jsonl" \ |
| 62 | + --input-text-field "text" \ |
| 63 | + --batch-size 64 \ |
| 64 | + --max-chars 6000 \ |
| 65 | + --device "gpu" \ |
| 66 | + --aegis-variant "nvidia/Aegis-AI-Content-Safety-LlamaGuard-Defensive-1.0" \ |
| 67 | + --token "hf_1234" |
| 68 | +``` |
| 69 | + |
| 70 | +- `--aegis-variant` can be `nvidia/Aegis-AI-Content-Safety-LlamaGuard-Defensive-1.0`, `nvidia/Aegis-AI-Content-Safety-LlamaGuard-Permissive-1.0`, or a path to your own PEFT of LlamaGuard 2. |
| 71 | +- `--token` is your HuggingFace token, which is used when downloading the base Llama Guard model. |
| 72 | + |
| 73 | +Additional arguments may be added for customizing a Dask cluster and client. Run `aegis_classifier_inference --help` for more information. |
| 74 | + |
| 75 | +#### FineWeb-Edu classifier inference |
| 76 | + |
| 77 | +```bash |
| 78 | +# same as `python fineweb_edu_classifier_inference.py` |
| 79 | +fineweb_edu_classifier_inference \ |
| 80 | + --input-data-dir /path/to/data/directory \ |
| 81 | + --output-data-dir /path/to/output/directory \ |
| 82 | + --input-file-type "jsonl" \ |
| 83 | + --input-file-extension "jsonl" \ |
| 84 | + --output-file-type "jsonl" \ |
| 85 | + --input-text-field "text" \ |
| 86 | + --batch-size 64 \ |
| 87 | + --autocast \ |
| 88 | + --max-chars 2000 \ |
| 89 | + --device "gpu" |
| 90 | +``` |
| 91 | + |
| 92 | +Additional arguments may be added for customizing a Dask cluster and client. Run `fineweb_edu_classifier_inference --help` for more information. |
0 commit comments