You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
f'2. Do not translate formula placeholders, such as "{formula_placeholder}". The system will automatically replace the placeholders with the corresponding formulas.'
917
+
)
918
+
llm_input.append(
919
+
"3. If there is no need to translate (such as proper nouns, codes, etc.), then return the original text."
920
+
)
921
+
llm_input.append(
922
+
f"4. Only output the translation result in {self.translation_config.lang_out} without explanations and annotations."
923
+
)
924
+
893
925
llm_context_hints= []
894
926
895
927
iftitle_paragraph:
@@ -952,41 +984,8 @@ def generate_prompt_for_llm(
952
984
formd_blockinactive_glossary_markdown_blocks:
953
985
llm_input.append(f"\n{md_block}\n")
954
986
955
-
llm_input.append("When translating, please follow the following rules:")
f'2. Do not translate formula placeholders, such as "{formula_placeholder}". The system will automatically replace the placeholders with the corresponding formulas.'
979
-
)
980
-
llm_input.append(
981
-
"3. If there is no need to translate (such as proper nouns, codes, etc.), then return the original text."
982
-
)
983
-
llm_input.append(
984
-
f"4. Only output the translation result in {self.translation_config.lang_out} without explanations and annotations."
985
-
)
986
-
llm_input.append(f"5. Translate text into {self.translation_config.lang_out}.")
987
987
prompt_template=f"""
988
988
Now, please carefully read the following text to be translated and directly output your translation.\n\n{text}
llm_prompt_parts.append("\n## Contextual Hints for Better Translation")
699
-
llm_prompt_parts.extend(contextual_hints_section)
700
-
701
-
ifactive_glossary_markdown_blocks:
702
-
llm_prompt_parts.append(
703
-
f"{hint_idx}. You MUST strictly adhere to the following glossaries. auto_extracted_glossary has a lower priority; please give preference to other glossaries. If a source term from a table appears in the text, use the corresponding target term in your translation:"
704
-
)
705
-
# hint_idx += 1 # No need to increment if tables are part of this point
706
-
formd_blockinactive_glossary_markdown_blocks:
707
-
llm_prompt_parts.append(f"\n{md_block}\n")
708
-
709
646
# 3. ## Strict Rules:
710
647
llm_prompt_parts.append("\n## Strict Rules:")
711
648
llm_prompt_parts.append(
@@ -771,6 +708,69 @@ def translate_paragraph(
771
708
llm_prompt_parts.append("```")
772
709
llm_prompt_parts.append("</example>")
773
710
711
+
# 2. ##Contextual Hints for Better Translation
712
+
contextual_hints_section: list[str] = []
713
+
hint_idx=1
714
+
iftitle_paragraph:
715
+
contextual_hints_section.append(
716
+
f"{hint_idx}. First title in full text: {title_paragraph.unicode}"
llm_prompt_parts.append("\n## Contextual Hints for Better Translation")
764
+
llm_prompt_parts.extend(contextual_hints_section)
765
+
766
+
ifactive_glossary_markdown_blocks:
767
+
llm_prompt_parts.append(
768
+
f"{hint_idx}. You MUST strictly adhere to the following glossaries. please give preference to other glossaries. If a source term from a table appears in the text, use the corresponding target term in your translation:"
769
+
)
770
+
# hint_idx += 1 # No need to increment if tables are part of this point
771
+
formd_blockinactive_glossary_markdown_blocks:
772
+
llm_prompt_parts.append(f"\n{md_block}\n")
773
+
774
774
# 6. ## Here is the input:
775
775
llm_prompt_parts.append("\n## Here is the input:")
0 commit comments