Upload folder using huggingface_hub
Browse files- config.json +42 -0
- model.safetensors +3 -0
- predict.py +49 -0
- tokenizer.json +0 -0
- tokenizer_config.json +15 -0
- training_args.bin +3 -0
config.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DistilBertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.1,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"dim": 768,
|
| 9 |
+
"dropout": 0.1,
|
| 10 |
+
"dtype": "float32",
|
| 11 |
+
"eos_token_id": null,
|
| 12 |
+
"hidden_dim": 3072,
|
| 13 |
+
"id2label": {
|
| 14 |
+
"0": "1.3.1 Info and Relationships",
|
| 15 |
+
"1": "2.1.1 Keyboard",
|
| 16 |
+
"2": "2.4.3 Focus Order",
|
| 17 |
+
"3": "2.4.7 Focus Visible",
|
| 18 |
+
"4": "4.1.2 Name, Role, Value"
|
| 19 |
+
},
|
| 20 |
+
"initializer_range": 0.02,
|
| 21 |
+
"label2id": {
|
| 22 |
+
"1.3.1 Info and Relationships": 0,
|
| 23 |
+
"2.1.1 Keyboard": 1,
|
| 24 |
+
"2.4.3 Focus Order": 2,
|
| 25 |
+
"2.4.7 Focus Visible": 3,
|
| 26 |
+
"4.1.2 Name, Role, Value": 4
|
| 27 |
+
},
|
| 28 |
+
"max_position_embeddings": 512,
|
| 29 |
+
"model_type": "distilbert",
|
| 30 |
+
"n_heads": 12,
|
| 31 |
+
"n_layers": 6,
|
| 32 |
+
"pad_token_id": 0,
|
| 33 |
+
"problem_type": "single_label_classification",
|
| 34 |
+
"qa_dropout": 0.1,
|
| 35 |
+
"seq_classif_dropout": 0.2,
|
| 36 |
+
"sinusoidal_pos_embds": false,
|
| 37 |
+
"tie_weights_": true,
|
| 38 |
+
"tie_word_embeddings": true,
|
| 39 |
+
"transformers_version": "5.17.0",
|
| 40 |
+
"use_cache": false,
|
| 41 |
+
"vocab_size": 30522
|
| 42 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e339ce027995e2d50ed682adfaaa0aaad8bf4fb626943da9d288effc1d2b4102
|
| 3 |
+
size 267841796
|
predict.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
from transformers import (
|
| 4 |
+
AutoModelForSequenceClassification,
|
| 5 |
+
AutoTokenizer,
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
MODEL_PATH = "."
|
| 9 |
+
|
| 10 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
|
| 11 |
+
|
| 12 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
| 13 |
+
MODEL_PATH
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def predict(text):
|
| 18 |
+
inputs = tokenizer(
|
| 19 |
+
text,
|
| 20 |
+
return_tensors="pt",
|
| 21 |
+
truncation=True,
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
with torch.no_grad():
|
| 25 |
+
outputs = model(**inputs)
|
| 26 |
+
|
| 27 |
+
probabilities = torch.softmax(
|
| 28 |
+
outputs.logits,
|
| 29 |
+
dim=-1
|
| 30 |
+
)[0]
|
| 31 |
+
|
| 32 |
+
predicted_id = torch.argmax(probabilities).item()
|
| 33 |
+
|
| 34 |
+
predicted_label = model.config.id2label[predicted_id]
|
| 35 |
+
confidence = probabilities[predicted_id].item()
|
| 36 |
+
|
| 37 |
+
return predicted_label, confidence
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
while True:
|
| 41 |
+
text = input("\nDescribe an accessibility issue (or 'quit'): ")
|
| 42 |
+
|
| 43 |
+
if text.lower() == "quit":
|
| 44 |
+
break
|
| 45 |
+
|
| 46 |
+
label, confidence = predict(text)
|
| 47 |
+
|
| 48 |
+
print(f"\nPrediction: {label}")
|
| 49 |
+
print(f"Confidence: {confidence:.1%}")
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": true,
|
| 5 |
+
"is_local": false,
|
| 6 |
+
"local_files_only": false,
|
| 7 |
+
"mask_token": "[MASK]",
|
| 8 |
+
"model_max_length": 512,
|
| 9 |
+
"pad_token": "[PAD]",
|
| 10 |
+
"sep_token": "[SEP]",
|
| 11 |
+
"strip_accents": null,
|
| 12 |
+
"tokenize_chinese_chars": true,
|
| 13 |
+
"tokenizer_class": "BertTokenizer",
|
| 14 |
+
"unk_token": "[UNK]"
|
| 15 |
+
}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2b04d66d7602bacf6fdd33590e9ee07eb0f9a53aa2a53037858a002704e58dd5
|
| 3 |
+
size 5201
|