File size: 3,764 Bytes
40d1f52
 
9bbdcc4
40d1f52
bc51159
4c2e53d
bc51159
40d1f52
 
bc51159
40d1f52
e3a0318
9bbdcc4
 
 
bc51159
9bbdcc4
 
 
 
 
 
efb1390
40d1f52
 
efb1390
 
5a493cf
efb1390
 
 
 
 
26c8ca4
40d1f52
 
 
 
 
 
 
2336086
40d1f52
 
bc51159
 
 
 
4c2e53d
 
 
 
26c8ca4
 
40d1f52
 
 
 
 
 
bc51159
 
 
 
 
 
40d1f52
9bbdcc4
 
 
26c8ca4
40d1f52
26c8ca4
40d1f52
 
 
 
 
 
e3a0318
40d1f52
 
 
 
 
 
 
bc51159
 
 
 
 
 
 
 
 
e3a0318
40d1f52
 
4c2e53d
 
 
 
 
 
 
 
40d1f52
4c2e53d
 
2336086
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import gradio as gr
import os
import pandas as pd

path_to_generation_model = str(os.environ['path_to_generation_model'])
path_to_GNER_model       = str(os.environ['path_to_GNER_model'])

path_to_L_model = str(os.environ['path_to_L_model'])
path_to_S_model = str(os.environ['path_to_S_model'])

read_token      = str(os.environ['read_token'])
read_token_ii   = str(os.environ['read_token_ii'])

languages = pd.read_csv("model_lang.csv", names=["Lang_acr"])


def check_lang(lang_acronym):
    if lang_acronym in languages["Lang_acr"].to_list():
        return "True"
    else: 
        return "False"
    
title = "DReAM: version I"

description_main = """
A set of pre-trained LLMs tuned to perform different tasks over a "very specific" set of textual reports. 
Available tasks include: 

- Sentiment Analysis (SA) (available both Englis-only or multilingual)

- Name Entity Recognition (NER)

Use the current interface to check if a language is included in the multilingual SA model, using language acronyms (e.g. it for Italian).
Click on one of the upper buttons to select and start querying one of the two models.
"""

description_L = """
XLM-R tuned model, EN-tuned, pre-trained with 94 languages available (see original model [card](https://huggingface.co/xlm-roberta-large) to see which are available)
"""

description_S = """
A BERT-base-cased model pre-trained and tuned on English data.
"""

description_G = """
A t5 model tuned to performer text-generation, and predict emotion as well as the character experiencing those emotions.
"""

description_GNER = """
A t5 model tuned to performer text-generation, and predict which characters are present in the report.
"""

example_main = ["en", "it", "pl"]

examples = [
    ["I was followed by the blue monster but was not scared. I was calm and relaxed."],
    ["Ero seguito dal mostro blu, ma non ero spaventato. Ero calmo e rilassato."],
    ["Śledził mnie niebieski potwór, ale się nie bałem. Byłem spokojny i zrelaksowany."],
]

examples_g = [
    ["I'm in an auditorium. Susie S is concerned at her part in this disability awareness spoof we are preparing. I ask, 'Why not do it? Lots of AB's represent us in a patronizing way. Why shouldn't we represent ourselves in a good, funny way?' I watch the video we all made. It is funny. I try to sit on a folding chair. Some guy in front talks to me. Merle is in the audience somewhere. [BL]"],

]


interface_words = gr.Interface(
            fn=check_lang,
            inputs="text", 
            outputs="text",
            title=title,
            description=description_main,
            examples=example_main,
)

interface_model_L = gr.Interface.load(
            name=path_to_L_model,
            description=description_L,
            examples=examples,
            title="DSA Large Multilingual",
            api_key=read_token,
)

interface_model_S = gr.Interface.load(
            name=path_to_S_model,
            description=description_S,
            examples=examples[0],
            title="DSA Base English-Only",
            api_key=read_token_ii,
)

interface_model_G = gr.Interface.load(
            name=path_to_generation_model,
            description=description_G,
            examples=examples_g,
            title="DSA Generation",
            api_key=read_token_ii,
)

interface_model_NER = gr.Interface.load(
            name=path_to_GNER_model,
            description=description_GNER,
            examples=examples_g,
            title="NER Generation",
            api_key=read_token_ii,
)

gr.TabbedInterface(
    [interface_words, interface_model_L, interface_model_S, interface_model_G, interface_model_NER], 
    ["Intro", "SA Large Multilingual", "SA Base En", "SA En Generation", "NER Generation"]
).launch()