Download source/model.py from ARotting/protocol-guardian-commands: direct link, hf CLI and curl.
- Browser
- Download file 857 Bytes
-
https://huggingface.co/datasets/ARotting/protocol-guardian-commands/resolve/main/source/model.py
- Command line
-
hf download hf://datasets/ARotting/protocol-guardian-commands/source/model.py
-
curl -L -o model.py https://huggingface.co/datasets/ARotting/protocol-guardian-commands/resolve/main/source/model.py
857 Bytes
| 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()) | |