beyoru commited on
Commit
dd9176b
·
verified ·
1 Parent(s): 892868a

Update client.py

Browse files
Files changed (1) hide show
  1. client.py +5 -3
client.py CHANGED
@@ -7,10 +7,12 @@ from database import execute
7
  # Load the model and tokenizer
8
  model_name = "Qwen/Qwen2.5-3B-Instruct"
9
  tokenizer = AutoTokenizer.from_pretrained(model_name)
10
- model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16)
11
 
 
 
12
  def respond(message, history, system_message, max_tokens, temperature, top_p):
13
- messages = [{"role": "system", "content": SYSTEM_PROMPT}]
14
 
15
  # Process chat history
16
  for val in history:
@@ -23,7 +25,7 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
23
 
24
  # Tokenize input
25
  input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
26
- input_ids = tokenizer.encode(input_text, return_tensors="pt").to(model.device)
27
 
28
  # Generate response
29
  output_ids = model.generate(
 
7
  # Load the model and tokenizer
8
  model_name = "Qwen/Qwen2.5-3B-Instruct"
9
  tokenizer = AutoTokenizer.from_pretrained(model_name)
10
+ model = AutoModelForCausalLM.from_pretrained(model_name)
11
 
12
+
13
+ messages = [{"role": "system", "content": SYSTEM_PROMPT}]
14
  def respond(message, history, system_message, max_tokens, temperature, top_p):
15
+
16
 
17
  # Process chat history
18
  for val in history:
 
25
 
26
  # Tokenize input
27
  input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
28
+ input_ids = tokenizer.encode(input_text, return_tensors="pt")
29
 
30
  # Generate response
31
  output_ids = model.generate(