File size: 4,255 Bytes
da9c0a0
5da6a2b
da9c0a0
5da6a2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
da9c0a0
 
5da6a2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
da9c0a0
 
 
5da6a2b
 
 
 
da9c0a0
 
 
 
5da6a2b
da9c0a0
 
 
5da6a2b
da9c0a0
 
5da6a2b
 
 
 
 
 
 
 
da9c0a0
 
 
 
 
 
 
5da6a2b
da9c0a0
5da6a2b
 
 
 
 
 
da9c0a0
5da6a2b
 
 
 
 
 
 
 
 
 
 
 
 
da9c0a0
5da6a2b
da9c0a0
5da6a2b
 
 
 
 
da9c0a0
 
5da6a2b
 
da9c0a0
5da6a2b
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import gradio as gr
import pandas as pd

data = [
    ["Category", "Value", "Percentage"],
    ["Total Reviews", 50000, None],
    ["Total Sentences", 621647, None],
    ["Pronouns in Sentences", None, None],
    ["Male Pronouns", 85615, None],
    ["Female Pronouns", 39372, None],
    ["Both Male and Female Pronouns", 7765, None],
    ["Exclusive Usage of Pronouns", None, None],
    ["Only Male Pronouns", 77860, 13.77],
    ["Only Female Pronouns", 31617, 6.33],
    ["Pronouns and Professions in Sentences", None, None],
    ["Male Pronouns with Professions", 5580, 0.9],
    ["Female Pronouns with Professions", 2618, 0.42],
    ["Exclusive Usage of Pronouns with Professions", None, None],
    ["Only Male Pronouns with Professions", 5011, 0.81],
    ["Only Female Pronouns with Professions", 2049, 0.33],
    ["Pronouns and Professions in Combination", None, None],
    ["Male or Female Pronouns with Professions", 7629, 1.23],
    ["Male and Female Pronouns with Professions", 569, 0.09]
]


def display_methodology(methodology):
    title = methodology
    description = ""
    details = ""
    if methodology == "Term Identity Diversity Analysis":
        description = "111"
        details = "222"
    elif methodology == "Textual Gender Label Evaluation":
        description = "333"
        details = "444"
    elif methodology == "GenBit":
        description = "555"
        details = "666"

    return title, description, details


def run_evaluation(dataset, methodology):
    return f"Running evaluation for {dataset} with {methodology}"

    if methodology == "A":
        run_a(dataset)
    elif methodology == "B":
        run_b(dataset)
    elif methodology == "C":
        run_c(dataset)


demo = gr.Blocks(title="BiasAware: Dataset Bias Detection",
                 theme=gr.themes.Soft())

with demo:
    gr.Markdown("# BiasAware: Dataset Bias Detection")
    gr.Markdown(
        "Natural Language Processing (NLP) training datasets often reflect the biases present in the data sources they are compiled from, leading to the **perpetuation of stereotypes, underrepresentation, and skewed perspectives in AI models**. BiasAware is designed to **identify and quantify biases present in text data**, making it an invaluable resource for data scientists, machine learning practitioners, and organizations committed to **mitigating bias in AI systems**."
    )

    with gr.Row():
        with gr.Column(scale=1):
            gr.Markdown("Select a dataset to analyze")

            dataset = gr.Text(label="Dataset")
            gr.Examples(
                examples=["imdb", "amazon_reviews_multi", "tweet_eval"],
                fn=run_evaluation,
                inputs=[dataset],
            )

            methodology = gr.Radio(
                [
                    "Term Identity Diversity Analysis",
                    "Textual Gender Label Evaluation",
                    "GenBit",
                ],
                label="Methodology",
            )

            button = gr.Button("Run Evaluation")

        with gr.Column(scale=4):
            gr.Markdown("### Results")

            with gr.Box():
                methodology_title = gr.Markdown("### Title")
                methodology_description = gr.Markdown("lorem ipsum")

            methodology_details = gr.Markdown("lorem ipsum")
            # outputs = gr.Markdown()
            outputs = gr.DataFrame(pd.DataFrame(data), headers=[
                                   "", "Count", "Percentage"])

            gr.Error("No results to display")

        with gr.Column(scale=1):
            gr.Markdown("### Leaderboard")
            gr.DataFrame(
                headers=["Dataset", "Score"],
                value=[
                    ["imdb", 0.9],
                    ["amazon_reviews_multi", 0.8],
                    ["tweet_eval", 0.7],
                ],
                interactive=False,
            )

    methodology.change(
        fn=display_methodology,
        inputs=[methodology],
        outputs=[
            methodology_title,
            methodology_description,
            methodology_details,
        ],
    )

    button.click(fn=run_evaluation, inputs=[
                 dataset, methodology], outputs=[outputs])

demo.launch()