Song commited on
Commit
2620fa6
·
1 Parent(s): f8bfac3

Fix text repetition loop by increasing temp and adding penalties

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -52,8 +52,9 @@ FALLBACK_MODELS = [
52
 
53
  LLM_MODEL_CONFIG = {
54
  "max_tokens": int(os.getenv("MAX_TOKENS", 4000)),
55
- "temperature": float(os.getenv("TEMPERATURE", 0.3)),
56
- "seed": int(os.getenv("LLM_SEED", 42)),
 
57
  }
58
 
59
  # ---------- 改良後的 System Prompt ----------
@@ -102,6 +103,7 @@ JESUS_PROMPT = """你現在是耶穌基督。請**完全**模仿新約聖經(
102
  **格式要求:**
103
  - 保持純文字,**絕不使用 Markdown 格式**(如粗體、斜體)。
104
  - 使用短段落,留白便於手機閱讀,但語氣要是連貫的教導,不要變成僵硬的條列。
 
105
 
106
  **範例回答(請嚴格模仿此口吻):**
107
  孩子,願你平安。
@@ -219,7 +221,8 @@ class ChatPipeline:
219
  messages=messages,
220
  max_tokens=max_tokens or LLM_MODEL_CONFIG["max_tokens"],
221
  temperature=LLM_MODEL_CONFIG["temperature"],
222
- seed=LLM_MODEL_CONFIG["seed"],
 
223
  timeout=120.0,
224
  )
225
  content = response.choices[0].message.content or ""
 
52
 
53
  LLM_MODEL_CONFIG = {
54
  "max_tokens": int(os.getenv("MAX_TOKENS", 4000)),
55
+ "temperature": float(os.getenv("TEMPERATURE", 0.7)),
56
+ "frequency_penalty": 0.5,
57
+ "presence_penalty": 0.3,
58
  }
59
 
60
  # ---------- 改良後的 System Prompt ----------
 
103
  **格式要求:**
104
  - 保持純文字,**絕不使用 Markdown 格式**(如粗體、斜體)。
105
  - 使用短段落,留白便於手機閱讀,但語氣要是連貫的教導,不要變成僵硬的條列。
106
+ - **避免重複**:請勿在回答中重複相同的句子或段落,每一句話都應帶出新的意涵。
107
 
108
  **範例回答(請嚴格模仿此口吻):**
109
  孩子,願你平安。
 
221
  messages=messages,
222
  max_tokens=max_tokens or LLM_MODEL_CONFIG["max_tokens"],
223
  temperature=LLM_MODEL_CONFIG["temperature"],
224
+ frequency_penalty=LLM_MODEL_CONFIG.get("frequency_penalty", 0.0),
225
+ presence_penalty=LLM_MODEL_CONFIG.get("presence_penalty", 0.0),
226
  timeout=120.0,
227
  )
228
  content = response.choices[0].message.content or ""