File size: 7,965 Bytes
baaf065
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c38d116
 
baaf065
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c38d116
baaf065
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import ast

import pandas as pd

import streamlit as st

st.set_page_config(layout="wide")
SHORT_CAPTIONS = [
    'ALIGN:align-base:coyo700m', 'OpenCLIP:ViT-B-32:openai', 'OpenCLIP:ViT-B-16:openai',
    'OpenCLIP:ViT-L-14:openai', 'OpenCLIP:ViT-L-14-336:openai',
    'OpenCLIP:ViT-B-32:laion2b_s34b_b79k', 'OpenCLIP:ViT-B-16:laion2b_s34b_b88k',
    'OpenCLIP:ViT-L-14:laion2b_s32b_b82k', 'OpenCLIP:ViT-g-14:laion2b_s34b_b88k',
    'OpenCLIP:ViT-H-14:laion2b_s32b_b79k', 'OpenCLIP:roberta-ViT-B-32:laion2b_s12b_b32k',
    'OpenCLIP:ViT-B-16-SigLIP:webli', 'OpenCLIP:ViT-B-16-SigLIP-384:webli',
    'OpenCLIP:ViT-L-16-SigLIP-256:webli', 'OpenCLIP:ViT-L-16-SigLIP-384:webli',
    'OpenCLIP:ViT-SO400M-14-SigLIP:webli', 'OpenCLIP:coca_ViT-B-32:laion2b_s13b_b90k',
    'OpenCLIP:coca_ViT-L-14:laion2b_s13b_b90k'
]
LONG_CAPTIONS = [
    'DreamLIP:dreamlip-vitb16:cc3m-long', 'DreamLIP:dreamlip-vitb16:cc12m-long',
    'DreamLIP:dreamlip-vitb16:yfcc15m-long', 'DreamLIP:dreamlip-vitb16:cc30m-long',
    "FLAIR:flair-vitb16:cc3m-recap", "FLAIR:flair-vitb16:cc12m-recap",
    "FLAIR:flair-vitb16:yfcc15m-recap", "FLAIR:flair-vitb16:cc30m-recap",
    'CLIPS:CLIPS-Large-14-224:recap-datacomp1b', 'CLIPS:CLIPS-Large-14-336:recap-datacomp1b',
    'CLIPS:CLIPS-Huge-14-224:recap-datacomp1b', 'LoTLIP:LoTLIP-ViT-B-32:lotlip100m',
    'LoTLIP:LoTLIP-ViT-B-16:lotlip100m', 'Recap-CLIP:ViT-L-16-HTxt-Recap-CLIP:recap-datacomp1b',
    'LongCLIP:longclip-vitb32:sharegpt4v-1m', 'LongCLIP:longclip-vitb16:sharegpt4v-1m',
    'LongCLIP:longclip-vitl14:sharegpt4v-1m', 'LongCLIP:longclip-vitl14_336px:sharegpt4v-1m',
    'Jina-CLIP:jina-clip-v1:jinaai', 'Jina-CLIP:jina-clip-v2:jinaai'
]
COMPOSITIONALITY = [
    'OpenCLIP:ViT-B-32:openai', 'StructuredCLIP:NegCLIP-ViT-B-32:coco-ft',
    'StructuredCLIP:CE-CLIP-ViT-B-32:coco-ft', 'StructuredCLIP:DAC-LLM-ViT-B-32:cc3m-ft',
    'StructuredCLIP:DAC-SAM-ViT-B-32:cc3m-ft', 'FSC-CLIP:fsc-clip-ViT-B-32:laioncoco-ft',
    'FSC-CLIP:fsc-clip-ViT-B-16:laioncoco-ft', 'FSC-CLIP:fsc-clip-ViT-L-14:laioncoco-ft'
]

DECODERS = [
    'vqascore:instructblip-flant5-xl:none', 'vqascore:clip-flant5-xl:none',
    'vqascore:llava-v1.5-7b:none', 'vqascore:sharegpt4v-7b:none',
    'visualgptscore:instructblip-flant5-xl:none', 'visualgptscore:clip-flant5-xl:none',
    'visualgptscore:llava-v1.5-7b:none', 'visualgptscore:sharegpt4v-7b:none'
]

MODEL_GROUPS = {
    "short_captions": SHORT_CAPTIONS,
    "long_captions": LONG_CAPTIONS,
    "compositionality": COMPOSITIONALITY
}


def render_mi_table(df, level0_cols):
    # HTML 스타일 정의
    table_style = """

    <style>

        table {

            width: 100%;

            border-collapse: collapse;

        }

        th, td {

            border: 1px solid black;

            text-align: center;

            padding: 8px;

        }

        th {

            background-color: #262730;

        }

    </style>

    """

    # 상위 헤더 (레벨 0)
    header_html = "<tr>"
    for col in level0_cols:
        colspan = len(df.xs(col, axis=1, level=0).columns) if col else 1
        header_html += f'<th colspan="{colspan}" style="text-align: center;">{col if col else ""}</th>'
    header_html += "</tr>"

    # 하위 헤더 (레벨 1)
    sub_header_html = "<tr>"
    for col in df.columns:
        sub_header_html += f"<th style='text-align: center;'>{col[1] if len(col) > 1 else col[0]}</th>"
    sub_header_html += "</tr>"

    # 데이터 HTML 생성
    def map_val(value):
        try:
            value = f"{float(value):.1f}"
        except:
            value = value
        return value

    rows_html = ""
    for _, row in df.iterrows():

        rows_html += "<tr>" + "".join(f"<td>{map_val(value)}</td>" for value in row) + "</tr>"

    # 최종 HTML 합치기
    table_html = f"""

    {table_style}

    <table>

        {header_html}

        {sub_header_html}

        {rows_html}

    </table>

    """
    return table_html


def format_df(df):
    cols = []
    for col in df.columns:
        if col in [("Model", "family"), ("Model", "model"), ("Model", "tag")]:
            continue
        cols.append(col)
    formatted_df = df.style.format({col: "{:.1f}" for col in cols})
    return formatted_df


def print_table(df):
    level0_cols = []
    for col in df.columns:
        if col[0] not in level0_cols:
            level0_cols.append(col[0])
    st.markdown(render_mi_table(df, level0_cols), unsafe_allow_html=True)


def get_model_key_from_df(df, model_names):
    columns = [("Model", "family"), ("Model", "model"), ("Model", "tag")]
    named_rows = df[columns].apply(lambda row: ":".join(row), axis=1)
    new_rows = []
    for name in model_names:
        new_rows.append(df[named_rows == name])
    new_rows = pd.concat(new_rows, axis=0)
    new_rows.columns = pd.MultiIndex.from_tuples(new_rows.columns)
    print_table(new_rows)


# Streamlit app
def main():
    st.title("Interface")
    st.markdown("### Summarized Evaluation Results on Sentence Addition Tasks")
    st.markdown("- random chance 50% 반영")
    st.markdown("- decoder-based model 결과 추가")
    st.markdown("- FLAIR model 결과 추가 (context length 77)")

    df = pd.read_csv("data/250117/summary.csv")
    df.columns = [ast.literal_eval(col) for col in df.columns]
    for group, model_names in MODEL_GROUPS.items():
        st.markdown(f"## {group} models")
        if group == "short_captions":
            st.markdown(
                "- **Length group**: 이미 short group부터, 80<(Num_tokens)<120. 중간에 문장 더해졌으면 60-70%정도 맞추고, 끝에 문장 더해졌으면 애초에 added sentence encoding 불가 -> accuracy 는 random chance, 50%."
            )
            st.markdown(
                "- **neg_target**: description의 끝 (=background)에 sentence 더해진 경우 accuracy 50%"
            )
            st.markdown("- **neg_type**: contradictory sentence가 모델 입장에서 맞추기 더 어려움")

        if group == "long_captions":
            st.markdown(
                "- **Length group**: 모델의 context length에 성능 심하게 dependent함. DreamLIP: 77, CLIPS: 80, LoTLIP: 128, Recap-CLIP: 128, LongCLIP: 248, Jina-CLIP: 512"
            )
            st.markdown("- **neg_target**: 여전히 background level에서 sentence 더해진게 전반적으로 어려움")
            st.markdown("- **neg_type**: contradictory sentence가 모델 입장에서 맞추기 더 어려움")
        if group == "compositionality":
            st.markdown("- context length 77의 한계. Hard Negative Caption으로 Fine-tuning 하면 일부 좋아짐")
        get_model_key_from_df(df, model_names)

    df = pd.read_csv("data/250117/decoder_summary.csv")
    df.columns = [ast.literal_eval(col) for col in df.columns]
    st.markdown("## Decoder-based models")
    st.markdown(
        "- InstructBLIP은 text input context length가 128 -> medium length group부터 헷갈리기 시작 (vqascore, visualgptscore 모두.)"
    )
    st.markdown(
        "- 나머지 세 모델은 vision+language 토탈 2048 context length (충분함). VQAScore에서 high performance, VisualGPTScore은 거의 random chance."
    )
    st.markdown(
        "- visualgptscore는 given caption의 매 token 위치마다 auto-regressive cross-entropy loss의 avg으로 계산됨 (like image captioning)"
    )
    st.markdown(
        "- vqascore는 given caption을 question에 넣고, yes/no 형식 question으로 물어봄 -> answer token 위치에서 cross entropy loss으로 계산"
    )
    st.markdown(
        "- 즉 long text generative task는 약한데 qa 능력은 좋아서 visualgptscore는 낮고, vqascore가 더 높게 나온다고 추측가능"
    )
    get_model_key_from_df(df, DECODERS)


if __name__ == "__main__":
    main()