DimasMP3 commited on
Commit ·
cc1cfc8
1
Parent(s): 959b2d1
feat: Add model loading status prints and remove `theme` from Gradio examples.
Browse files
app.py
CHANGED
|
@@ -5,7 +5,6 @@ from threading import Thread
|
|
| 5 |
|
| 6 |
MODEL_ID = "DimasMP3/qwen2.5-math-finetuned-7b"
|
| 7 |
|
| 8 |
-
|
| 9 |
bnb_config = BitsAndBytesConfig(
|
| 10 |
load_in_4bit=True,
|
| 11 |
bnb_4bit_use_double_quant=True,
|
|
@@ -13,15 +12,20 @@ bnb_config = BitsAndBytesConfig(
|
|
| 13 |
bnb_4bit_compute_dtype=torch.float16
|
| 14 |
)
|
| 15 |
|
|
|
|
|
|
|
| 16 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
| 17 |
|
|
|
|
| 18 |
model = AutoModelForCausalLM.from_pretrained(
|
| 19 |
MODEL_ID,
|
| 20 |
-
quantization_config=bnb_config,
|
| 21 |
device_map="auto",
|
| 22 |
low_cpu_mem_usage=True
|
| 23 |
)
|
| 24 |
|
|
|
|
|
|
|
| 25 |
def format_prompt(user_query):
|
| 26 |
return f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
| 27 |
|
|
@@ -63,14 +67,13 @@ def predict(message, history):
|
|
| 63 |
|
| 64 |
demo = gr.ChatInterface(
|
| 65 |
fn=predict,
|
| 66 |
-
title="
|
| 67 |
description="Qwen 2.5 (7B Parameters) Fine-Tuned Model for Mathematical Reasoning",
|
| 68 |
examples=[
|
| 69 |
"Solve the equation 3x + 10 = 25",
|
| 70 |
"Calculate the derivative of f(x) = 4x^3 - 2x",
|
| 71 |
"A triangle has a base of 10cm and a height of 5cm, what is its area?"
|
| 72 |
],
|
| 73 |
-
theme="soft",
|
| 74 |
cache_examples=False,
|
| 75 |
)
|
| 76 |
|
|
|
|
| 5 |
|
| 6 |
MODEL_ID = "DimasMP3/qwen2.5-math-finetuned-7b"
|
| 7 |
|
|
|
|
| 8 |
bnb_config = BitsAndBytesConfig(
|
| 9 |
load_in_4bit=True,
|
| 10 |
bnb_4bit_use_double_quant=True,
|
|
|
|
| 12 |
bnb_4bit_compute_dtype=torch.float16
|
| 13 |
)
|
| 14 |
|
| 15 |
+
print(f"System: Loading model {MODEL_ID}...")
|
| 16 |
+
|
| 17 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
| 18 |
|
| 19 |
+
# 2. Load Model dengan Config Baru
|
| 20 |
model = AutoModelForCausalLM.from_pretrained(
|
| 21 |
MODEL_ID,
|
| 22 |
+
quantization_config=bnb_config,
|
| 23 |
device_map="auto",
|
| 24 |
low_cpu_mem_usage=True
|
| 25 |
)
|
| 26 |
|
| 27 |
+
print("System: Model loaded!")
|
| 28 |
+
|
| 29 |
def format_prompt(user_query):
|
| 30 |
return f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
| 31 |
|
|
|
|
| 67 |
|
| 68 |
demo = gr.ChatInterface(
|
| 69 |
fn=predict,
|
| 70 |
+
title="LLM Math AI Solver",
|
| 71 |
description="Qwen 2.5 (7B Parameters) Fine-Tuned Model for Mathematical Reasoning",
|
| 72 |
examples=[
|
| 73 |
"Solve the equation 3x + 10 = 25",
|
| 74 |
"Calculate the derivative of f(x) = 4x^3 - 2x",
|
| 75 |
"A triangle has a base of 10cm and a height of 5cm, what is its area?"
|
| 76 |
],
|
|
|
|
| 77 |
cache_examples=False,
|
| 78 |
)
|
| 79 |
|