Spaces:
Running
on
A10G
Running
on
A10G
MekkCyber
commited on
Commit
Β·
ca0db66
1
Parent(s):
80c526e
final
Browse files
app.py
CHANGED
@@ -190,11 +190,52 @@ def save_model(
|
|
190 |
|
191 |
# Format it for display in markdown with proper styling
|
192 |
model_architecture_info = f"""
|
193 |
-
<div class="model-architecture" style="
|
|
|
|
|
194 |
<div style="line-height: 1.2; font-size: 0.75em;">{model_architecture_str_html}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
</div>
|
196 |
"""
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
|
200 |
def quantize_and_save(
|
@@ -508,7 +549,8 @@ with gr.Blocks(theme=gr.themes.Ocean(), css=css) as demo:
|
|
508 |
# π€ BitsAndBytes Quantizer : Create your own BNB Quants ! β¨
|
509 |
|
510 |
|
511 |
-
|
|
|
512 |
"""
|
513 |
)
|
514 |
|
@@ -597,7 +639,7 @@ with gr.Blocks(theme=gr.themes.Ocean(), css=css) as demo:
|
|
597 |
"π Quantize and Push to the Hub", variant="primary"
|
598 |
)
|
599 |
output_link = gr.Markdown(
|
600 |
-
"π Quantized Model", container=True, min_height=
|
601 |
)
|
602 |
|
603 |
quantize_button.click(
|
|
|
190 |
|
191 |
# Format it for display in markdown with proper styling
|
192 |
model_architecture_info = f"""
|
193 |
+
<div class="model-architecture-container" style="margin-top: 20px; margin-bottom: 20px; background-color: #f8f9fa; padding: 15px; border-radius: 8px; border-left: 4px solid #4CAF50;">
|
194 |
+
<h3 style="margin-top: 0; color: #2E7D32;">π Model Architecture</h3>
|
195 |
+
<div class="model-architecture" style="max-height: 500px; overflow-y: auto; overflow-x: auto; background-color: #f5f5f5; padding: 5px; border-radius: 8px; font-family: monospace; white-space: pre-wrap;">
|
196 |
<div style="line-height: 1.2; font-size: 0.75em;">{model_architecture_str_html}</div>
|
197 |
+
</div>
|
198 |
+
</div>
|
199 |
+
"""
|
200 |
+
|
201 |
+
code = f"""
|
202 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
203 |
+
import torch
|
204 |
+
|
205 |
+
model = AutoModelForCausalLM.from_pretrained(
|
206 |
+
"{repo_name}",
|
207 |
+
device_map="auto"
|
208 |
+
)
|
209 |
+
|
210 |
+
tokenizer = AutoTokenizer.from_pretrained("{model_name}")
|
211 |
+
|
212 |
+
inputs = tokenizer("Hello, my name is", return_tensors="pt").to(model.device)
|
213 |
+
outputs = model.generate(inputs.input_ids, max_length=50)
|
214 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
215 |
+
"""
|
216 |
+
# First replace newlines in the code
|
217 |
+
code_html = code.replace("\n", "<br/>")
|
218 |
+
|
219 |
+
usage_example = f"""
|
220 |
+
<div class="usage-example" style="margin-top: 20px; margin-bottom: 20px; background-color: #f8f9fa; padding: 15px; border-radius: 8px; border-left: 4px solid #4CAF50;">
|
221 |
+
<h3 style="margin-top: 0; color: #2E7D32;">π How to use this model</h3>
|
222 |
+
<div class="model-architecture" style="max-height: 500px; overflow-y: auto; overflow-x: auto; background-color: #f5f5f5; padding: 5px; border-radius: 8px; font-family: monospace; font-size: 0.75em; white-space: pre-wrap;">{code_html}</div>
|
223 |
+
</div>
|
224 |
+
"""
|
225 |
+
model_size_info = f"""
|
226 |
+
<div class="model-size-info" style="margin-top: 20px; margin-bottom: 20px; background-color: #f8f9fa; padding: 15px; border-radius: 8px; border-left: 4px solid #4CAF50;">
|
227 |
+
<h3 style="margin-top: 0; color: #2E7D32;">π¦ Model Size</h3>
|
228 |
+
<p>Original (bf16)β {original_size_gb} GB β Quantized β {get_model_size(model)} GB</p>
|
229 |
</div>
|
230 |
"""
|
231 |
+
|
232 |
+
repo_link = f"""
|
233 |
+
<div class="repo-link" style="margin-top: 20px; margin-bottom: 20px; background-color: #f8f9fa; padding: 15px; border-radius: 8px; border-left: 4px solid #4CAF50;">
|
234 |
+
<h3 style="margin-top: 0; color: #2E7D32;">π Repository Link</h3>
|
235 |
+
<p>Find your repo here: <a href="https://huggingface.co/{repo_name}" target="_blank" style="text-decoration:underline">{repo_name}</a></p>
|
236 |
+
</div>
|
237 |
+
"""
|
238 |
+
return f'<h1>π Quantization Completed</h1><br/>{repo_link}{model_architecture_info}{model_size_info}{usage_example}'
|
239 |
|
240 |
|
241 |
def quantize_and_save(
|
|
|
549 |
# π€ BitsAndBytes Quantizer : Create your own BNB Quants ! β¨
|
550 |
|
551 |
|
552 |
+
<br/>
|
553 |
+
<br/>
|
554 |
"""
|
555 |
)
|
556 |
|
|
|
639 |
"π Quantize and Push to the Hub", variant="primary"
|
640 |
)
|
641 |
output_link = gr.Markdown(
|
642 |
+
"π Quantized Model Info", container=True, min_height=200
|
643 |
)
|
644 |
|
645 |
quantize_button.click(
|