Upload folder using huggingface_hub
Browse filesFiles changed (6)
- config.jsonAdded+42
- model.safetensorsAdded+3
- predict.pyAdded+49
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+15
- training_args.binAdded+3
123456789101112131415161718192021222324252627282930313233343536373839404142{
"activation": "gelu",
"architectures": [
"DistilBertForSequenceClassification"
],
"attention_dropout": 0.1,
"bos_token_id": null,
"dim": 768,
"dropout": 0.1,
"dtype": "float32",
"eos_token_id": null,
"hidden_dim": 3072,
"id2label": {
"0": "1.3.1 Info and Relationships",
"1": "2.1.1 Keyboard",
"2": "2.4.3 Focus Order",
"3": "2.4.7 Focus Visible",
"4": "4.1.2 Name, Role, Value"
},
"initializer_range": 0.02,
"label2id": {
"1.3.1 Info and Relationships": 0,
"2.1.1 Keyboard": 1,
"2.4.3 Focus Order": 2,
"2.4.7 Focus Visible": 3,
"4.1.2 Name, Role, Value": 4
},
"max_position_embeddings": 512,
"model_type": "distilbert",
"n_heads": 12,
"n_layers": 6,
"pad_token_id": 0,
"problem_type": "single_label_classification",
"qa_dropout": 0.1,
"seq_classif_dropout": 0.2,
"sinusoidal_pos_embds": false,
"tie_weights_": true,
"tie_word_embeddings": true,
"transformers_version": "5.17.0",
"use_cache": false,
"vocab_size": 30522
}123version https://git-lfs.github.com/spec/v1oid sha256:e339ce027995e2d50ed682adfaaa0aaad8bf4fb626943da9d288effc1d2b4102size 26784179612345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import torch
from transformers import (
AutoModelForSequenceClassification,
AutoTokenizer,
)
MODEL_PATH = "."
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
model = AutoModelForSequenceClassification.from_pretrained(
MODEL_PATH
)
def predict(text):
inputs = tokenizer(
text,
return_tensors="pt",
truncation=True,
)
with torch.no_grad():
outputs = model(**inputs)
probabilities = torch.softmax(
outputs.logits,
dim=-1
)[0]
predicted_id = torch.argmax(probabilities).item()
predicted_label = model.config.id2label[predicted_id]
confidence = probabilities[predicted_id].item()
return predicted_label, confidence
while True:
text = input("\nDescribe an accessibility issue (or 'quit'): ")
if text.lower() == "quit":
break
label, confidence = predict(text)
print(f"\nPrediction: {label}")
print(f"Confidence: {confidence:.1%}")123456789101112131415{
"backend": "tokenizers",
"cls_token": "[CLS]",
"do_lower_case": true,
"is_local": false,
"local_files_only": false,
"mask_token": "[MASK]",
"model_max_length": 512,
"pad_token": "[PAD]",
"sep_token": "[SEP]",
"strip_accents": null,
"tokenize_chinese_chars": true,
"tokenizer_class": "BertTokenizer",
"unk_token": "[UNK]"
}123version https://git-lfs.github.com/spec/v1oid sha256:2b04d66d7602bacf6fdd33590e9ee07eb0f9a53aa2a53037858a002704e58dd5size 5201config.jsonAdded+42
model.safetensorsAdded+3
predict.pyAdded+49
tokenizer.jsonAdded
tokenizer_config.jsonAdded+15
training_args.binAdded+3