HammXG commited on
Commit
ee492a6
Β·
verified Β·
1 Parent(s): 1453e15

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
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()