Spaces:
Running
Running
mihalykiss
commited on
Commit
·
a2b0083
1
Parent(s):
a08a74d
third ensemble model
Browse files
app.py
CHANGED
@@ -2,32 +2,32 @@ import gradio as gr
|
|
2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
3 |
import torch
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
9 |
|
10 |
tokenizer = AutoTokenizer.from_pretrained("answerdotai/ModernBERT-base")
|
11 |
|
12 |
model_1 = AutoModelForSequenceClassification.from_pretrained("answerdotai/ModernBERT-base", num_labels=41)
|
13 |
-
model_1.load_state_dict(torch.load(
|
14 |
model_1.to(device).eval()
|
15 |
|
16 |
model_2 = AutoModelForSequenceClassification.from_pretrained("answerdotai/ModernBERT-base", num_labels=41)
|
17 |
-
model_2.load_state_dict(torch.hub.load_state_dict_from_url(
|
18 |
model_2.to(device).eval()
|
19 |
|
20 |
model_3 = AutoModelForSequenceClassification.from_pretrained("answerdotai/ModernBERT-base", num_labels=41)
|
21 |
-
model_3.load_state_dict(torch.hub.load_state_dict_from_url(
|
22 |
model_3.to(device).eval()
|
23 |
|
24 |
|
25 |
label_mapping = {
|
26 |
0: '13B', 1: '30B', 2: '65B', 3: '7B', 4: 'GLM130B', 5: 'bloom_7b',
|
27 |
6: 'bloomz', 7: 'cohere', 8: 'davinci', 9: 'dolly', 10: 'dolly-v2-12b',
|
28 |
-
11: 'flan_t5_base', 12: 'flan_t5_large', 13: 'flan_t5_small',
|
29 |
14: 'flan_t5_xl', 15: 'flan_t5_xxl', 16: 'gemma-7b-it', 17: 'gemma2-9b-it',
|
30 |
-
18: 'gpt-3.5-turbo', 19: 'gpt-35', 20: 'gpt4', 21: 'gpt4o',
|
31 |
22: 'gpt_j', 23: 'gpt_neox', 24: 'human', 25: 'llama3-70b', 26: 'llama3-8b',
|
32 |
27: 'mixtral-8x7b', 28: 'opt_1.3b', 29: 'opt_125m', 30: 'opt_13b',
|
33 |
31: 'opt_2.7b', 32: 'opt_30b', 33: 'opt_350m', 34: 'opt_6.7b',
|
|
|
2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
3 |
import torch
|
4 |
|
5 |
+
model1_path = "modernbert.bin"
|
6 |
+
model2_path = "https://huggingface.co/mihalykiss/modernbert_2/resolve/main/Model_groups_3class_seed12"
|
7 |
+
model3_path = "https://huggingface.co/mihalykiss/modernbert_2/resolve/main/Model_groups_3class_seed22"
|
8 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
9 |
|
10 |
tokenizer = AutoTokenizer.from_pretrained("answerdotai/ModernBERT-base")
|
11 |
|
12 |
model_1 = AutoModelForSequenceClassification.from_pretrained("answerdotai/ModernBERT-base", num_labels=41)
|
13 |
+
model_1.load_state_dict(torch.load(model1_path, map_location=device))
|
14 |
model_1.to(device).eval()
|
15 |
|
16 |
model_2 = AutoModelForSequenceClassification.from_pretrained("answerdotai/ModernBERT-base", num_labels=41)
|
17 |
+
model_2.load_state_dict(torch.hub.load_state_dict_from_url(model2_path, map_location=device))
|
18 |
model_2.to(device).eval()
|
19 |
|
20 |
model_3 = AutoModelForSequenceClassification.from_pretrained("answerdotai/ModernBERT-base", num_labels=41)
|
21 |
+
model_3.load_state_dict(torch.hub.load_state_dict_from_url(model3_path, map_location=device))
|
22 |
model_3.to(device).eval()
|
23 |
|
24 |
|
25 |
label_mapping = {
|
26 |
0: '13B', 1: '30B', 2: '65B', 3: '7B', 4: 'GLM130B', 5: 'bloom_7b',
|
27 |
6: 'bloomz', 7: 'cohere', 8: 'davinci', 9: 'dolly', 10: 'dolly-v2-12b',
|
28 |
+
11: 'flan_t5_base', 12: 'flan_t5_large', 13: 'flan_t5_small',
|
29 |
14: 'flan_t5_xl', 15: 'flan_t5_xxl', 16: 'gemma-7b-it', 17: 'gemma2-9b-it',
|
30 |
+
18: 'gpt-3.5-turbo', 19: 'gpt-35', 20: 'gpt4', 21: 'gpt4o',
|
31 |
22: 'gpt_j', 23: 'gpt_neox', 24: 'human', 25: 'llama3-70b', 26: 'llama3-8b',
|
32 |
27: 'mixtral-8x7b', 28: 'opt_1.3b', 29: 'opt_125m', 30: 'opt_13b',
|
33 |
31: 'opt_2.7b', 32: 'opt_30b', 33: 'opt_350m', 34: 'opt_6.7b',
|