File size: 986 Bytes
ee492a6
 
 
 
 
 
 
 
 
 
 
 
19939f6
 
 
ee492a6
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
import torch

model_id = "TheBloke/MythoMax-L2-13B-GPTQ"

tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=True)

model = AutoModelForCausalLM.from_pretrained(
    model_id,
    device_map="auto",
    trust_remote_code=True,
    revision="main",
    torch_dtype=torch.float16,
    low_cpu_mem_usage=True
)

pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)

def chat(prompt):
    output = pipe(prompt, max_new_tokens=400, temperature=0.7, top_p=0.9, repetition_penalty=1.1)
    return output[0]["generated_text"]

gr.Interface(fn=chat,
             inputs=gr.Textbox(label="Prompt", lines=6, placeholder="Tulis kode atau pertanyaan..."),
             outputs=gr.Textbox(label="Respon MythoMax"),
             title="πŸ§™β€β™‚οΈ MythoMax L2 13B Coder",
             description="Model LLM roleplay + coding kelas berat 🀘 oleh King Hammz"
            ).launch()