Spaces:
Runtime error
Runtime error
new model
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
st.markdown("# Arxiv classifier")
|
4 |
title = st.text_input('*Article title:')
|
@@ -50,14 +51,21 @@ class_label = ClassLabel(names=categories_tags)
|
|
50 |
|
51 |
@st.cache
|
52 |
def get_model():
|
53 |
-
return AutoModelForSequenceClassification.from_pretrained('./
|
54 |
|
55 |
|
56 |
model = get_model()
|
57 |
|
58 |
-
|
|
|
|
|
59 |
name_by_category = get_name_by_category()
|
60 |
input_tensor = tokenizer(title, abstract, padding="max_length", truncation=True, return_tensors='pt')
|
|
|
61 |
for probability, label_index in top95(model(**input_tensor).logits):
|
62 |
category = class_label.int2str(label_index)
|
63 |
st.markdown(f'{round(probability, 2)} – {category} ({name_by_category[category]})')
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import torch
|
3 |
|
4 |
st.markdown("# Arxiv classifier")
|
5 |
title = st.text_input('*Article title:')
|
|
|
51 |
|
52 |
@st.cache
|
53 |
def get_model():
|
54 |
+
return AutoModelForSequenceClassification.from_pretrained('./arxiv_model_2000', num_labels=len(categories_tags))
|
55 |
|
56 |
|
57 |
model = get_model()
|
58 |
|
59 |
+
|
60 |
+
@torch.inference_mode()
|
61 |
+
def print_results():
|
62 |
name_by_category = get_name_by_category()
|
63 |
input_tensor = tokenizer(title, abstract, padding="max_length", truncation=True, return_tensors='pt')
|
64 |
+
st.markdown('## Results:')
|
65 |
for probability, label_index in top95(model(**input_tensor).logits):
|
66 |
category = class_label.int2str(label_index)
|
67 |
st.markdown(f'{round(probability, 2)} – {category} ({name_by_category[category]})')
|
68 |
+
|
69 |
+
|
70 |
+
if title:
|
71 |
+
print_results()
|
arxiv_model_2000/config.json
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "distilbert-base-cased",
|
3 |
+
"activation": "gelu",
|
4 |
+
"architectures": [
|
5 |
+
"DistilBertForSequenceClassification"
|
6 |
+
],
|
7 |
+
"attention_dropout": 0.1,
|
8 |
+
"dim": 768,
|
9 |
+
"dropout": 0.1,
|
10 |
+
"hidden_dim": 3072,
|
11 |
+
"id2label": {
|
12 |
+
"0": "LABEL_0",
|
13 |
+
"1": "LABEL_1",
|
14 |
+
"2": "LABEL_2",
|
15 |
+
"3": "LABEL_3",
|
16 |
+
"4": "LABEL_4"
|
17 |
+
},
|
18 |
+
"initializer_range": 0.02,
|
19 |
+
"label2id": {
|
20 |
+
"LABEL_0": 0,
|
21 |
+
"LABEL_1": 1,
|
22 |
+
"LABEL_2": 2,
|
23 |
+
"LABEL_3": 3,
|
24 |
+
"LABEL_4": 4
|
25 |
+
},
|
26 |
+
"max_position_embeddings": 512,
|
27 |
+
"model_type": "distilbert",
|
28 |
+
"n_heads": 12,
|
29 |
+
"n_layers": 6,
|
30 |
+
"output_past": true,
|
31 |
+
"pad_token_id": 0,
|
32 |
+
"problem_type": "single_label_classification",
|
33 |
+
"qa_dropout": 0.1,
|
34 |
+
"seq_classif_dropout": 0.2,
|
35 |
+
"sinusoidal_pos_embds": false,
|
36 |
+
"tie_weights_": true,
|
37 |
+
"torch_dtype": "float32",
|
38 |
+
"transformers_version": "4.17.0",
|
39 |
+
"vocab_size": 28996
|
40 |
+
}
|
arxiv_model_2000/pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c4ecd4b5d58ed2a4e3dc73692c8b9aa83f934137f79b9db2cc007736024d6655
|
3 |
+
size 263181873
|
arxiv_model_2000/special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
arxiv_model_2000/tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
arxiv_model_2000/tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"do_lower_case": false, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "model_max_length": 512, "special_tokens_map_file": null, "name_or_path": "distilbert-base-cased", "tokenizer_class": "DistilBertTokenizer"}
|
arxiv_model_2000/training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:666e819549f78d5d59e2e9097cdbabe18f637d029d76bee1ae9295914bd8992a
|
3 |
+
size 2991
|
arxiv_model_2000/vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|