jmcinern commited on
Commit
c4b05c8
·
verified ·
1 Parent(s): bd3c434

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -2,9 +2,12 @@ import gradio as gr
2
  import torch
3
  import re
4
  from transformers import AutoTokenizer, AutoModelForCausalLM
 
 
5
 
6
  # Model configuration
7
- MODEL_NAME = "jmcinern/qomhra-8B-awq-dpo-beta-0.5-checkpoint-checkpoint-100"
 
8
  THINK_TAG_PATTERN = re.compile(r"<think>.*?</think>\s*", flags=re.DOTALL)
9
 
10
 
@@ -25,13 +28,17 @@ class ChatBot:
25
  print("Tokenizer loaded!")
26
 
27
  print("Loading model...")
28
- self.model = AutoModelForCausalLM.from_pretrained(
29
  MODEL_NAME,
30
  trust_remote_code=True,
31
  device_map="auto",
32
  torch_dtype="auto",
33
  low_cpu_mem_usage=True,
34
  )
 
 
 
 
35
  print("Model loaded!")
36
  except Exception as e:
37
  print(f"Error loading model: {e}")
 
2
  import torch
3
  import re
4
  from transformers import AutoTokenizer, AutoModelForCausalLM
5
+ from peft import PeftModel
6
+
7
 
8
  # Model configuration
9
+ MODEL_NAME = "jmcinern/qwen3-8B-cpt-sft-awq"
10
+ DPO_ADAPTER = "jmcinern/qomhra-8B-awq-dpo-beta-0.5-checkpoint-checkpoint-100"
11
  THINK_TAG_PATTERN = re.compile(r"<think>.*?</think>\s*", flags=re.DOTALL)
12
 
13
 
 
28
  print("Tokenizer loaded!")
29
 
30
  print("Loading model...")
31
+ base_model = AutoModelForCausalLM.from_pretrained(
32
  MODEL_NAME,
33
  trust_remote_code=True,
34
  device_map="auto",
35
  torch_dtype="auto",
36
  low_cpu_mem_usage=True,
37
  )
38
+ self.model = PeftModel.from_pretrained(
39
+ base_model,
40
+ DPO_ADAPTER
41
+ )
42
  print("Model loaded!")
43
  except Exception as e:
44
  print(f"Error loading model: {e}")