Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
model_id = "TheBloke/MythoMax-L2-13B-GPTQ"
|
| 6 |
+
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=True)
|
| 8 |
+
|
| 9 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 10 |
+
model_id,
|
| 11 |
+
device_map="auto",
|
| 12 |
+
torch_dtype=torch.float16,
|
| 13 |
+
trust_remote_code=True,
|
| 14 |
+
revision="main"
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 18 |
+
|
| 19 |
+
def chat(prompt):
|
| 20 |
+
output = pipe(prompt, max_new_tokens=400, temperature=0.7, top_p=0.9, repetition_penalty=1.1)
|
| 21 |
+
return output[0]["generated_text"]
|
| 22 |
+
|
| 23 |
+
gr.Interface(fn=chat,
|
| 24 |
+
inputs=gr.Textbox(label="Prompt", lines=6, placeholder="Tulis kode atau pertanyaan..."),
|
| 25 |
+
outputs=gr.Textbox(label="Respon MythoMax"),
|
| 26 |
+
title="π§ββοΈ MythoMax L2 13B Coder",
|
| 27 |
+
description="Model LLM roleplay + coding kelas berat π€ oleh King Hammz"
|
| 28 |
+
).launch()
|