Spaces:
Building
on
CPU Upgrade
Building
on
CPU Upgrade
Upload folder using huggingface_hub
Browse files
modules/llm/summarizer/helpers/llm_helper.py
CHANGED
|
@@ -19,15 +19,16 @@ def summarize_scripture_verse(
|
|
| 19 |
"Your job is to derive the verse’s simple and detailed meaning *strictly* from the provided inputs.\n\n"
|
| 20 |
"=== MANDATORY RULES ===\n"
|
| 21 |
"1. Use ONLY the information from: lyrics, translation, and word-by-word meaning.\n"
|
| 22 |
-
"2. Do NOT invent, guess, or infer anything not explicitly given.\n"
|
|
|
|
| 23 |
"3. Do NOT include any English words or transliterations unless they already appear in the input.\n"
|
| 24 |
-
"4. Every part of your output must be written completely in the target language: {target_language}.\n"
|
| 25 |
" - If the target language lacks a direct word, explain it *in that language* (do not leave English placeholders).\n"
|
| 26 |
" - Preserve transliterated proper nouns (e.g., ‘nanjIyar’, ‘rAmAnuja’) exactly as written — case-sensitive.\n"
|
| 27 |
"5. NEVER mix scripts. Do not output Latin letters unless they occur verbatim in the input.\n"
|
| 28 |
"6. If unsure of a word’s meaning, omit it or express uncertainty *in the target language*.\n"
|
| 29 |
"7. Maintain a respectful, neutral tone. No opinions, commentary, or theological judgment.\n"
|
| 30 |
-
"8. Output must follow the
|
| 31 |
"9. Do NOT repeat the input text or provide explanations in any other language.\n"
|
| 32 |
"10. Ensure all formatting is plain text — no quotes, brackets, or markdown around meanings.\n"
|
| 33 |
)
|
|
@@ -37,7 +38,7 @@ def summarize_scripture_verse(
|
|
| 37 |
f"Translation:\n{translation}\n\n"
|
| 38 |
f"Word-by-word meaning:\n{word_by_word_meaning}\n\n"
|
| 39 |
f"Now generate the verse’s meaning entirely in **{target_language}**.\n"
|
| 40 |
-
"Provide both a simple summary and a detailed explanation in
|
| 41 |
"Do not include any English words unless they appear exactly as in the inputs."
|
| 42 |
)
|
| 43 |
|
|
|
|
| 19 |
"Your job is to derive the verse’s simple and detailed meaning *strictly* from the provided inputs.\n\n"
|
| 20 |
"=== MANDATORY RULES ===\n"
|
| 21 |
"1. Use ONLY the information from: lyrics, translation, and word-by-word meaning.\n"
|
| 22 |
+
# "2. Do NOT invent, guess, or infer anything not explicitly given.\n"
|
| 23 |
+
"2. If the word-by-word meaning is not provided, try to derive it from the original lyrics based on the context of the verse and the translation if provided.\n"
|
| 24 |
"3. Do NOT include any English words or transliterations unless they already appear in the input.\n"
|
| 25 |
+
f"4. Every part of your output must be written completely in the target language: {target_language}.\n"
|
| 26 |
" - If the target language lacks a direct word, explain it *in that language* (do not leave English placeholders).\n"
|
| 27 |
" - Preserve transliterated proper nouns (e.g., ‘nanjIyar’, ‘rAmAnuja’) exactly as written — case-sensitive.\n"
|
| 28 |
"5. NEVER mix scripts. Do not output Latin letters unless they occur verbatim in the input.\n"
|
| 29 |
"6. If unsure of a word’s meaning, omit it or express uncertainty *in the target language*.\n"
|
| 30 |
"7. Maintain a respectful, neutral tone. No opinions, commentary, or theological judgment.\n"
|
| 31 |
+
"8. Output must follow the ScriptureVerseSummary schema exactly: only 'simple_meaning', 'detailed_meaning', 'word_by_word_meaning' and 'target_language'.\n"
|
| 32 |
"9. Do NOT repeat the input text or provide explanations in any other language.\n"
|
| 33 |
"10. Ensure all formatting is plain text — no quotes, brackets, or markdown around meanings.\n"
|
| 34 |
)
|
|
|
|
| 38 |
f"Translation:\n{translation}\n\n"
|
| 39 |
f"Word-by-word meaning:\n{word_by_word_meaning}\n\n"
|
| 40 |
f"Now generate the verse’s meaning entirely in **{target_language}**.\n"
|
| 41 |
+
"Provide both a simple summary and a detailed explanation along with word by word meaning translating each word in original script to the target language.\n"
|
| 42 |
"Do not include any English words unless they appear exactly as in the inputs."
|
| 43 |
)
|
| 44 |
|
modules/llm/summarizer/models.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
# --- Define output schema ---
|
| 2 |
-
from typing import Optional
|
| 3 |
from pydantic import BaseModel, Field
|
| 4 |
|
| 5 |
class ScriptureRequest(BaseModel):
|
|
@@ -10,7 +10,12 @@ class ScriptureRequest(BaseModel):
|
|
| 10 |
) # optional, backward compatible
|
| 11 |
target_language: Optional[str] = Field(default="English")
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
class ScriptureVerseSummary(BaseModel):
|
| 14 |
target_language: str
|
| 15 |
simple_meaning: str
|
| 16 |
detailed_meaning: str
|
|
|
|
|
|
| 1 |
# --- Define output schema ---
|
| 2 |
+
from typing import List, Optional
|
| 3 |
from pydantic import BaseModel, Field
|
| 4 |
|
| 5 |
class ScriptureRequest(BaseModel):
|
|
|
|
| 10 |
) # optional, backward compatible
|
| 11 |
target_language: Optional[str] = Field(default="English")
|
| 12 |
|
| 13 |
+
class ScriptureVerseWordByWordMeaning(BaseModel):
|
| 14 |
+
word: str
|
| 15 |
+
meaning: str
|
| 16 |
+
|
| 17 |
class ScriptureVerseSummary(BaseModel):
|
| 18 |
target_language: str
|
| 19 |
simple_meaning: str
|
| 20 |
detailed_meaning: str
|
| 21 |
+
word_by_word_meaning: List[ScriptureVerseWordByWordMeaning]
|