File size: 3,844 Bytes
1639c46
 
bac027d
014ba5e
 
f39aadc
014ba5e
01af800
1639c46
 
 
7307761
1639c46
014ba5e
 
01af800
623a39b
014ba5e
623a39b
f39aadc
01af800
 
014ba5e
01af800
 
1639c46
01af800
 
 
 
 
 
7be9d95
1639c46
1692b33
1639c46
 
01af800
1639c46
 
 
 
7be9d95
1639c46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7be9d95
 
 
 
 
1639c46
 
4d068a9
7307761
014ba5e
 
 
 
 
 
 
 
 
 
 
 
7be9d95
 
1639c46
 
 
 
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
import gradio
import argparse
import os
import boto3
from datetime import datetime

from utils import generate, send_to_s3
from models import get_tiny_llama, response_tiny_llama
from constants import css, js_code, js_light

MERA_table = None
TINY_LLAMA = None

S3_SESSION = None

def giga_gen(content):
    res = generate(content,'auth_token.json')
    send_to_s3(res, f'giga_{str(datetime.now()).replace(" ", "_")}.json', S3_SESSION)
    return res

def tiny_gen(content):
    res = response_tiny_llama(TINY_LLAMA, content)
    send_to_s3(res, f'tiny_{str(datetime.now()).replace(" ", "_")}.json', S3_SESSION)
    return res

def tab_arena():
    with gradio.Row():
        with gradio.Column():
            gradio.Interface(fn=giga_gen, inputs="text", outputs="text", allow_flagging=False, title='Giga') # arena = 
        with gradio.Column():
            gradio.Interface(fn=tiny_gen, inputs="text", outputs="text", allow_flagging=False, title='TinyLlama') # arena = 
        
    # arena.launch()

with open("test.md", "r") as f:
    TEST_MD = f.read()

available_models = ["GigaChat", ""] # list(model_info.keys()) 

def build_demo():
    # global original_dfs, available_models, gpt4t_dfs, haiku_dfs, llama_dfs

    with gradio.Blocks(theme=gradio.themes.Base(), css=css, js=js_light) as demo:
        # gradio.HTML(BANNER, elem_id="banner")
        # gradio.Markdown(HEADER_MD.replace("{model_num}", str(len(original_dfs["-1"]))), elem_classes="markdown-text")
        
        with gradio.Tabs(elem_classes="tab-buttons") as tabs:
            with gradio.TabItem("🐼 MERA leaderboard", elem_id="od-benchmark-tab-table", id=0):
                gradio.Markdown(TEST_MD, elem_classes="markdown-text-details")
                # _tab_leaderboard()

            with gradio.TabItem("πŸ†š SBS by categories and criteria", elem_id="od-benchmark-tab-table", id=1):
                gradio.Markdown(TEST_MD, elem_classes="markdown-text-details")

            with gradio.TabItem("πŸ₯Š Model arena", elem_id="od-benchmark-tab-table", id=2):
                tab_arena()
                # _tab_explore()

            with gradio.TabItem("πŸ’ͺ About MERA", elem_id="od-benchmark-tab-table", id=3):
                gradio.Markdown(TEST_MD, elem_classes="markdown-text")
        # gr.Markdown(f"Last updated on **{LAST_UPDATED}** | [Link to V1-legacy](https://huggingface.co/spaces/allenai/WildBench-V1-legacy)", elem_classes="markdown-text-small")
        
        # with gr.Row():
        #     with gr.Accordion("πŸ“™ Citation", open=False, elem_classes="accordion-label"):
        #         gr.Textbox(
        #             value=CITATION_TEXT, 
        #             lines=7,
        #             label="Copy the BibTeX snippet to cite this source",
        #             elem_id="citation-button",
        #             show_copy_button=True)
                # ).style(show_copy_button=True)

    return demo

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--share", action="store_true")
    # parser.add_argument("--bench_table", help="Path to MERA table", default="data_dir/MERA_jun2024.jsonl")
    args = parser.parse_args()
    # data_load(args.result_file)    
    # TYPES = ["number", "markdown", "number"]

    TINY_LLAMA =  get_tiny_llama()

    try:
        session = boto3.session.Session()
        S3_SESSION = session.client(
            service_name='s3',
            endpoint_url=os.getenv('S3_ENDPOINT'),
            aws_access_key_id=os.getenv('S3_ENDPOINT'),
            aws_secret_access_key=os.getenv('S3_ENDPOINT'),
        )
    except:
        print('Failed to start s3 session')

    demo = build_demo()
    demo.launch(share=args.share, height=3000, width="110%") # share=args.share

    # demo = gradio.Interface(fn=gen, inputs="text", outputs="text")
    # demo.launch()