File size: 3,861 Bytes
9329646
 
 
 
 
 
 
 
 
 
 
 
 
ecb17e3
9329646
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ecb17e3
9329646
ecb17e3
9329646
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ecb17e3
9329646
 
 
d3c0fe5
9329646
 
 
 
 
 
 
 
 
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
from huggingface_hub import HfApi, HfFileSystem
import re
from tqdm import tqdm
import concurrent.futures
import gradio as gr
import datetime
import pandas as pd

api = HfApi()
fs = HfFileSystem()


text = f"""
🎯 The Leaderboard aims to track TheBloke's quantized models.

## πŸ“š Type Of Models

- GPTQ

- GGUF

- AWQ

- GGML

## πŸ› οΈ Backend

The leaderboard's backend mainly runs on the [Hugging Face Hub API](https://huggingface.co/docs/huggingface_hub/v0.5.1/en/package_reference/hf_api).

## πŸ” Searching

You can search for author or a spesific model using the search bar.

## βŒ› Last Update

This space is last updated in **{str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M"))}**.

## πŸ“’ Important Note

This space potentially includes incorrectly quantized models for a model.

If you find any incorrectly quantized model, please report it to me.
"""

quant_models = [i.__dict__['id'] for i in api.list_models(author="TheBloke") if "GPTQ" in i.__dict__['id'] or "GGUF" in i.__dict__['id'] or "AWQ" in i.__dict__['id'] or "GGML" in i.__dict__['id']]


pattern = r'\(https://huggingface\.co/([^/]+)/([^/]+)\)'
liste = {}

def process_model(i, pattern, liste):
    text = fs.read_text(i + "/README.md")
    matches = re.search(pattern, text)

    if matches:
        author = matches.group(1)
        model_name = matches.group(2)
        full_id = (author + "/" + model_name).split(")")[0]

        try:
            liste[full_id].append(i)
        except KeyError:
            liste[full_id] = [i]


num_threads = 64

with concurrent.futures.ThreadPoolExecutor(max_workers=num_threads) as executor:
    futures = []
    for i in quant_models:
        future = executor.submit(process_model, i, pattern, liste)
        futures.append(future)

    concurrent.futures.wait(futures)


authors, models, gptq, gguf, awq, ggml = [], [], [], [], [], []


for model, values in liste.items():
    models.append(model)

    gptq_value, gguf_value, awq_value, ggml_value = None, None, None, None

    for value in values:
        if "-GPTQ" in value:
            gptq_value = value
        elif "-GGUF" in value:
            gguf_value = value
        elif "-AWQ" in value:
            awq_value = value
        elif "-GGML" in value:
            ggml_value = value

    authors.append(model.split('/')[0])
    gptq.append(gptq_value)
    gguf.append(gguf_value)
    awq.append(awq_value)
    ggml.append(ggml_value)


df = pd.DataFrame({'πŸ‘€ Author Name': authors, 'πŸ€– Model Name': models, 'πŸ‘ GPTQ': gptq, 'πŸ“₯ GGUF': gguf, 'πŸ€·β€β™‚οΈ AWQ': awq, '😭 GGML': ggml})


def search(search_text):
  if not search_text:
    return df

  if len(search_text.split('/'))>1:
    return df[df['πŸ€– Model Name'] == clickable(search_text)]
  else:
    return df[df['πŸ‘€ Author Name'] == clickable(search_text)]


def clickable(x):
  return None if not x else f'<a target="_blank" href="https://huggingface.co/{x}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{x}</a>'


def to_clickable(df):
    for column in list(df.columns):
          df[column] = df[column].apply(lambda x: clickable(x))
    return df


with gr.Blocks() as demo:
    gr.Markdown("""<center><img src = "https://cdn-uploads.huggingface.co/production/uploads/6426d3f3a7723d62b53c259b/tvPikpAzKTKGN5wrpadOJ.jpeg" width=200 height=200></center>""")
    gr.Markdown("""<h1 align="center" id="space-title">The Bloke Quantized Models</h1>""")
    gr.Markdown(text)

    with gr.Column(min_width=320):
        search_bar = gr.Textbox(placeholder="πŸ” Search for a author or a specific model", show_label=False)

    
    df_clickable = to_clickable(df)
    gr_df = gr.Dataframe(df_clickable, interactive=False, datatype=["markdown"]*len(df.columns))

    search_bar.submit(fn=search, inputs=search_bar, outputs=gr_df)


demo.launch()