Spaces:
Sleeping
Sleeping
Aniket Sirsikar commited on
Commit ·
f3ebf4f
1
Parent(s): c13b073
fix: relax LLM length constraints to prevent mid-sentence EOS truncation
Browse files- src/llm.py +9 -17
src/llm.py
CHANGED
|
@@ -51,23 +51,15 @@ def generate_hindi_response(hindi_question: str, english_context: str, history:
|
|
| 51 |
return _FALLBACK_NO_KEY
|
| 52 |
|
| 53 |
prompt = (
|
| 54 |
-
"You are a helpful
|
| 55 |
-
"
|
| 56 |
-
"
|
| 57 |
-
"1. GROUNDING:
|
| 58 |
-
"2.
|
| 59 |
-
"
|
| 60 |
-
"
|
| 61 |
-
"
|
| 62 |
-
"
|
| 63 |
-
"5. DO NOT use complex banking jargon. Use everyday Hindi words.\n"
|
| 64 |
-
"6. CRITICAL: Never stop mid-sentence. You must always finish your thought and guarantee the follow-up question is printed at the very end.\n"
|
| 65 |
-
"7. GROUNDING CONSTRAINT: NEVER invent ages, interest rates, amounts, or specific document names. If the exact number is not in the FAQ text, do not guess it.\n"
|
| 66 |
-
"7. DO NOT add any extra polite fluff. Just give the answer directly.\n"
|
| 67 |
-
"8. ALWAYS end your response with a single follow-up question related to the topic on a new line. "
|
| 68 |
-
"Format it exactly like this: 'क्या आप यह भी जानना चाहेंगे: [your short follow-up question]?'\n"
|
| 69 |
-
"9. CRITICAL: NEVER output your internal thoughts, reasoning, or drafting notes (e.g., '*Drafting the follow-up:*'). "
|
| 70 |
-
"Output ONLY the final, clean Hindi response.\n\n"
|
| 71 |
)
|
| 72 |
|
| 73 |
if history:
|
|
|
|
| 51 |
return _FALLBACK_NO_KEY
|
| 52 |
|
| 53 |
prompt = (
|
| 54 |
+
"You are 'सहायक', a helpful banking assistant for rural Indian farmers.\n"
|
| 55 |
+
"Explain things in simple, direct Hindi (Devanagari script).\n\n"
|
| 56 |
+
"RULES:\n"
|
| 57 |
+
"1. GROUNDING: Base your answer ONLY on the 'FAQ Information' provided below. Do not invent details, ages, numbers, or rules not in the text.\n"
|
| 58 |
+
"2. UNKNOWN: If the FAQ doesn't contain the answer, say EXACTLY: 'माफ़ करें, मेरे पास इसकी जानकारी नहीं है। कृपया बैंक शाखा से संपर्क करें।'\n"
|
| 59 |
+
"3. FORMAT: Give a clear, complete answer. DO NOT cut off mid-sentence. Write as much as needed to finish your thought.\n"
|
| 60 |
+
"4. FOLLOW-UP: ALWAYS end your entire response with ONE relevant follow-up question on a new line, formatted exactly like this:\n"
|
| 61 |
+
"क्या आप यह भी जानना चाहेंगे: [your question here]?\n\n"
|
| 62 |
+
"SAFETY EXCEPTION: If the user asks about fraud, scams, or lost cards, you may advise them to contact the bank or police immediately.\n\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
)
|
| 64 |
|
| 65 |
if history:
|