Text Classification
Transformers
Joblib
English
cybersecurity
industrial-control-systems
bert
from-scratch
synthetic-data
Instructions to use ARotting/protocol-guardian with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ARotting/protocol-guardian with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="ARotting/protocol-guardian")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ARotting/protocol-guardian", device_map="auto") - Notebooks
- Google Colab
- Kaggle
| from __future__ import annotations | |
| from transformers import BertConfig, BertForSequenceClassification | |
| def build_model( | |
| vocab_size: int, | |
| pad_token_id: int, | |
| ) -> BertForSequenceClassification: | |
| config = BertConfig( | |
| vocab_size=vocab_size, | |
| hidden_size=64, | |
| num_hidden_layers=2, | |
| num_attention_heads=2, | |
| intermediate_size=160, | |
| hidden_act="gelu", | |
| hidden_dropout_prob=0.08, | |
| attention_probs_dropout_prob=0.05, | |
| max_position_embeddings=96, | |
| type_vocab_size=1, | |
| pad_token_id=pad_token_id, | |
| num_labels=2, | |
| id2label={0: "ROUTINE", 1: "HAZARDOUS"}, | |
| label2id={"ROUTINE": 0, "HAZARDOUS": 1}, | |
| ) | |
| return BertForSequenceClassification(config) | |
| def parameter_count(model) -> int: | |
| return sum(parameter.numel() for parameter in model.parameters()) | |