Run this model with HF Jobs
Run nvidia/domain-classifier on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/nvidia/domain-classifier. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/nvidia/domain-classifier on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use nvidia/domain-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/domain-classifier with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("nvidia/domain-classifier", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files7 unmodified lines8910111213141516171819202122232413 unmodified lines3839404142434445464748495051522 unmodified lines5556575859606162639 unmodified lines7374757677787942 unmodified lines1221231241251261277 unmodified lines# Model OverviewThis is a text classification model to classify documents into one of 26 domain classes:'Adult', 'Arts_and_Entertainment', 'Autos_and_Vehicles', 'Beauty_and_Fitness', 'Books_and_Literature', 'Business_and_Industrial', 'Computers_and_Electronics', 'Finance', 'Food_and_Drink', 'Games', 'Health', 'Hobbies_and_Leisure', 'Home_and_Garden', 'Internet_and_Telecom', 'Jobs_and_Education', 'Law_and_Government', 'News', 'Online_Communities', 'People_and_Society', 'Pets_and_Animals', 'Real_Estate', 'Science', 'Sensitive_Subjects', 'Shopping', 'Sports', 'Travel_and_Transportation'# Model ArchitectureThe model architecture is Deberta V3 BaseContext length is 512 tokens# Training (details)## Training data:- 1 million Common Crawl samples, labeled using Google Cloud’s Natural Language API: https://cloud.google.com/natural-language/docs/classifying-text- 500k Wikepedia articles, curated using Wikipedia-API: https://pypi.org/project/Wikipedia-API/## Training steps:Model was trained in multiple rounds using Wikipedia and Common Crawl data, labeled by a combination of pseudo labels and Google Cloud API.# How To Use This Model## InputThe model takes one or several paragraphs of text as input.13 unmodified linesFood_and_Drink```# How to use in NeMo CuratorThe inference code is available on [NeMo Curator's GitHub repository](https://github.com/NVIDIA/NeMo-Curator). Download the [model.pth](https://huggingface.co/nvidia/domain-classifier/blob/main/model.pth) file and check out this [example notebook](https://github.com/NVIDIA/NeMo-Curator/blob/main/tutorials/distributed_data_classification/distributed_data_classification.ipynb) to get started.# How to use in transformersTo use the Domain classifier, use the following code:```pythonimport torchfrom torch import nnfrom transformers import AutoModel, AutoTokenizer, AutoConfig2 unmodified linesclass CustomModel(nn.Module, PyTorchModelHubMixin):def __init__(self, config):super(CustomModel, self).__init__()self.model = AutoModel.from_pretrained(config['base_model'])self.dropout = nn.Dropout(config['fc_dropout'])self.fc = nn.Linear(self.model.config.hidden_size, len(config['id2label']))def forward(self, input_ids, attention_mask):features = self.model(input_ids=input_ids, attention_mask=attention_mask).last_hidden_state9 unmodified lines# Prepare and process inputstext_samples = ["Sports is a popular domain", "Politics is a popular domain"]inputs = tokenizer(text_samples, return_tensors="pt", padding="longest", truncation=True)outputs = model(inputs['input_ids'], inputs['attention_mask'])# Predict and display resultspredicted_classes = torch.argmax(outputs, dim=1)42 unmodified lines# References- https://arxiv.org/abs/2111.09543- https://github.com/microsoft/DeBERTa# LicenseLicense to use this model is covered by the Apache 2.0. By downloading the public and release version of the model, you accept the terms and conditions of the Apache License 2.0.This repository contains the code for the domain classifier model.7 unmodified lines89101112131415161718192021222324252627282913 unmodified lines43444546474849505152535455562 unmodified lines5960616263646566679 unmodified lines7778798081828342 unmodified lines1261271281291301311327 unmodified lines# Model OverviewThis is a text classification model to classify documents into one of 26 domain classes:```'Adult', 'Arts_and_Entertainment', 'Autos_and_Vehicles', 'Beauty_and_Fitness', 'Books_and_Literature', 'Business_and_Industrial', 'Computers_and_Electronics', 'Finance', 'Food_and_Drink', 'Games', 'Health', 'Hobbies_and_Leisure', 'Home_and_Garden', 'Internet_and_Telecom', 'Jobs_and_Education', 'Law_and_Government', 'News', 'Online_Communities', 'People_and_Society', 'Pets_and_Animals', 'Real_Estate', 'Science', 'Sensitive_Subjects', 'Shopping', 'Sports', 'Travel_and_Transportation'```# Model Architecture- The model architecture is Deberta V3 Base- Context length is 512 tokens# Training Details## Training data:- 1 million Common Crawl samples, labeled using Google Cloud’s Natural Language API: https://cloud.google.com/natural-language/docs/classifying-text- 500k Wikepedia articles, curated using Wikipedia-API: https://pypi.org/project/Wikipedia-API/## Training steps:Model was trained in multiple rounds using Wikipedia and Common Crawl data, labeled by a combination of pseudo labels and Google Cloud API.# How To Use This Model## InputThe model takes one or several paragraphs of text as input.13 unmodified linesFood_and_Drink```# How to Use in NVIDIA NeMo CuratorThe inference code is available on [NeMo Curator's GitHub repository](https://github.com/NVIDIA/NeMo-Curator). Check out this [example notebook](https://github.com/NVIDIA/NeMo-Curator/blob/main/tutorials/distributed_data_classification/distributed_data_classification.ipynb) to get started.# How to Use in TransformersTo use the domain classifier, use the following code:```pythonimport torchfrom torch import nnfrom transformers import AutoModel, AutoTokenizer, AutoConfig2 unmodified linesclass CustomModel(nn.Module, PyTorchModelHubMixin):def __init__(self, config):super(CustomModel, self).__init__()self.model = AutoModel.from_pretrained(config["base_model"])self.dropout = nn.Dropout(config["fc_dropout"])self.fc = nn.Linear(self.model.config.hidden_size, len(config["id2label"]))def forward(self, input_ids, attention_mask):features = self.model(input_ids=input_ids, attention_mask=attention_mask).last_hidden_state9 unmodified lines# Prepare and process inputstext_samples = ["Sports is a popular domain", "Politics is a popular domain"]inputs = tokenizer(text_samples, return_tensors="pt", padding="longest", truncation=True)outputs = model(inputs["input_ids"], inputs["attention_mask"])# Predict and display resultspredicted_classes = torch.argmax(outputs, dim=1)42 unmodified lines# References- https://arxiv.org/abs/2111.09543- https://github.com/microsoft/DeBERTa# LicenseLicense to use this model is covered by the Apache 2.0. By downloading the public and release version of the model, you accept the terms and conditions of the Apache License 2.0.This repository contains the code for the domain classifier model.
README.md+19-14