Hieucyber2208 commited on
Commit
61117d5
·
verified ·
1 Parent(s): d155102

Update src/generation/llm.py

Browse files
Files changed (1) hide show
  1. src/generation/llm.py +1 -9
src/generation/llm.py CHANGED
@@ -99,16 +99,8 @@ class LLM:
99
  )
100
  # Decode the generated tokens
101
  response = self.tokenizer.decode(outputs[0], skip_special_tokens=True)
102
- # Remove system/user/assistant metadata and unwanted tokens
103
- for token in ["system", "user", "assistant", "You are", "Bạn là", "Truy vấn", "Danh sách nhà hàng", "Phản hồi"]:
104
- response = response.replace(token, "")
105
- # Remove extra whitespace and clean up
106
- response = " ".join(response.split()).strip()
107
- # Ensure the response starts cleanly (remove any leading colons or brackets)
108
- if response.startswith(":") or response.startswith("["):
109
- response = response[1:].strip()
110
  print("Response generated successfully!")
111
- return response
112
  except Exception as e:
113
  raise RuntimeError(f"Failed to generate response: {str(e)}")
114
 
 
99
  )
100
  # Decode the generated tokens
101
  response = self.tokenizer.decode(outputs[0], skip_special_tokens=True)
 
 
 
 
 
 
 
 
102
  print("Response generated successfully!")
103
+ return response.strip()
104
  except Exception as e:
105
  raise RuntimeError(f"Failed to generate response: {str(e)}")
106