hsuwill000 commited on
Commit
4e74e4f
·
verified ·
1 Parent(s): 72bde98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -27,17 +27,20 @@ for model_id in model_ids:
27
 
28
  # 建立推理管線 (Initialize with a default model first)
29
  device = "CPU"
30
- default_model_name = "Qwen3-0.6B-int4-ov" # Choose a default model
 
31
 
32
  def generate_response(prompt, model_name):
33
  global pipe, tokenizer # Access the global variables
34
-
35
- model_path = model_name
36
-
37
- print(f"Switching to model: {model_name}")
38
- pipe = ov_genai.LLMPipeline(model_path, device)
39
- tokenizer = pipe.get_tokenizer()
40
- tokenizer.set_chat_template(tokenizer.chat_template)
 
 
41
 
42
  try:
43
  generated = pipe.generate([prompt], max_length=1024)
 
27
 
28
  # 建立推理管線 (Initialize with a default model first)
29
  device = "CPU"
30
+ InUsed_model_name = "Qwen3-0.6B-int4-ov" # Choose a default model
31
+ pipe = ov_genai.LLMPipeline(InUsed_model_name, device)
32
 
33
  def generate_response(prompt, model_name):
34
  global pipe, tokenizer # Access the global variables
35
+ if(InUsed_model_name==model_name)
36
+ model_path = model_name
37
+ del pipe
38
+ gc.collect()
39
+ print(f"Switching to model: {model_name}")
40
+ pipe = ov_genai.LLMPipeline(model_path, device)
41
+ tokenizer = pipe.get_tokenizer()
42
+ tokenizer.set_chat_template(tokenizer.chat_template)
43
+ InUsed_model_name=model_name
44
 
45
  try:
46
  generated = pipe.generate([prompt], max_length=1024)