File size: 4,234 Bytes
a85a5e9
5368a96
168e052
a85a5e9
91f4a96
 
 
 
a85a5e9
 
91f4a96
 
 
 
 
 
 
a85a5e9
91f4a96
 
a85a5e9
ab8868f
a85a5e9
 
91f4a96
 
 
 
 
 
 
 
 
 
 
 
 
 
168e052
 
339a5a9
5368a96
441e512
91f4a96
ab8868f
 
339a5a9
ab8868f
 
339a5a9
ab8868f
 
 
 
339a5a9
91f4a96
ab8868f
 
339a5a9
a85a5e9
441e512
91f4a96
 
 
 
 
 
 
 
 
 
 
441e512
91f4a96
ab8868f
 
 
 
 
441e512
 
 
 
 
 
 
 
fc1f916
441e512
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fc1f916
441e512
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
127
128
129
130
import gradio as gr
import pandas as pd
from datasets import load_dataset

# Initialize total counts
total_yes_count = 0
total_count = 0


def calculate_percentage(*answers):
    """
    Calculate the percentage of 'yes' answers.

    :param answers: Iterable containing the answers.
    :returns: Percentage of 'yes' answers.
    """
    global total_yes_count, total_count
    yes_count = sum(answers)
    total_yes_count += yes_count
    total_count += len(answers)
    percentage = yes_count / len(answers) * 100
    return f"{percentage}%"


def calculate_overall_percentage():
    """
    Calculate the overall percentage of 'yes' answers.

    :returns: Overall percentage of 'yes' answers.
    """
    global total_yes_count, total_count
    if total_count != 100:
        return "Make sure you have submitted your answers in all the tabs."
    overall_percentage = total_yes_count
    return f"{overall_percentage}%"


# Load data
dataset = load_dataset("mariagrandury/fmti-indicators")
df = pd.DataFrame(dataset["train"])
grouped = df.groupby(["Domain", "Subdomain"])


# Create an interface per group of indicators
interfaces = []
tab_names = []
for (domain, subdomain), group in grouped:
    questions = group["Definition"].tolist()
    inputs = [gr.Checkbox(label=question) for question in questions]
    output = gr.Textbox(label="Subdomain Percentage")
    iface = gr.Interface(
        fn=calculate_percentage,
        inputs=inputs,
        outputs=output,
        title=f"{domain} - {subdomain}",
        allow_flagging="never",
    )
    interfaces.append(iface)
    tab_names.append(subdomain)


# Add overall percentage button
overall_button = gr.Interface(
    fn=calculate_overall_percentage,
    inputs=[],
    outputs=gr.Textbox(label="Overall Percentage"),
    title="Transparency Score",
    allow_flagging="never",
)
interfaces.append(overall_button)
tab_names.append("Total Transparency Score")


# Create the tabbed interface
tabbed_interface = gr.TabbedInterface(
    interface_list=interfaces,
    tab_names=tab_names,
    title="The Foundation Model Transparency Index",
)


# Combine blocks to create demo
with gr.Blocks(title="FMTI") as demo:
    gr.Markdown(
        """
        # Transparency Self-Assessment (FMTI)

        This tool allows you to self-assess the transparency of your model development based on the Foundation Model Transparency Index published by the Center for Research on Foundation Models.
        """
    )
    with gr.Accordion(label="Instructions", open=True):
        gr.Markdown(
            """
            The FMTI defines 100 indicators that characterize transparency for foundation model developers. They are divided into three broad domains: "Upstream" (model building), "Model" (model properties and function) and "Downstream" (model distribution). In addition to these top-level domains, the indicators are also grouped together into subdomains.

            Each tab below contains yes-or-no questions for each subdomain. Read all questions and check the boxes corresponding to the 'yes' responses. "Submit" your answers before proceeding to the next tab. Upon reaching the final tab, "Total Transparency Score", click on "Generate" to compute your model's overall transparency score.

            More info about the FMTI at https://crfm.stanford.edu/fmti/.

            Please note: this tool is research work and NOT a commercial or legal product.
            """
        )
    gr.TabbedInterface(
        interface_list=interfaces,
        tab_names=tab_names,
        title="",
    )
    gr.Markdown(
        """
        ## Compare your results

        The original study evaluated the developers of 10 top foundation models. How transparent are you compared to the developers in the 2023 study? Check the graphics below!

        Images source: https://crfm.stanford.edu/fmti
        """
    )
    with gr.Row():
        gr.Image(
            "https://crfm.stanford.edu/fmti/fmti-flagship.jpg",
            show_label=False,
            show_download_button=False,
        )
        gr.Image(
            "https://crfm.stanford.edu/fmti/subdomain-scores.png",
            show_label=False,
            show_download_button=False,
        )

demo.launch()