From 16b97c0fd1c563f979725d61dde722e00ef1cee5 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Wed, 12 Jun 2024 11:24:27 +0200 Subject: [PATCH] feat: Make model uses same language as the prompt Signed-off-by: Marcel Klehr --- lib/formalize.py | 4 ++-- lib/headline.py | 4 ++-- lib/simplify.py | 2 +- lib/summarize.py | 4 ++-- lib/topics.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/formalize.py b/lib/formalize.py index f87d20b..ca7f1b9 100644 --- a/lib/formalize.py +++ b/lib/formalize.py @@ -25,9 +25,9 @@ class FormalizeChain(Chain): " {text} " - Write the above text again, rephrase it to use only formal language and be very polite. + Write the above text again, rephrase it to use only formal words and be very polite. Also, Detect the language of the above text. When rephrasing the text make sure to use the same language as the original text in your rewritten text. Output only the new text, nothing else, no introductory sentence. Also do not output the name of the language you detected. """ - ) + )# Does not work with llama 3 8B :( """Prompt object to use.""" diff --git a/lib/headline.py b/lib/headline.py index bfd64f0..87a7f47 100644 --- a/lib/headline.py +++ b/lib/headline.py @@ -19,11 +19,11 @@ class HeadlineChain(Chain): user_prompt: BasePromptTemplate = PromptTemplate( input_variables=["text"], template=""" - Find a headline for the following text + Give me the headline of the following text in its original language. Output only the headline. " {text} " - Write a single headline for the above text in one sentence + Give me the headline of the above text in its original language. Do not output the language. Output only the headline without any quotes or additional punctuation. """ ) diff --git a/lib/simplify.py b/lib/simplify.py index 9f28dc3..ce588db 100644 --- a/lib/simplify.py +++ b/lib/simplify.py @@ -25,7 +25,7 @@ class SimplifyChain(Chain): " {text} " - Rewrite and rephrase the above text to make it easier to understand, so that a 5-year-old child can understand it. Describe difficult concepts in the text instead of using jargon terms directly. Do not make up anything new that is not in the original text. Only return the new, rewritten text. + Rewrite and rephrase the above text to make it easier to understand, so that a 5-year-old child can understand it. Describe difficult concepts in the text instead of using jargon terms directly. Do not make up anything new that is not in the original text. Make sure to use the same language as the above text. Output only the new, rewritten text in the original language of the original text, nothing else. """ ) diff --git a/lib/summarize.py b/lib/summarize.py index 924203e..45d7297 100644 --- a/lib/summarize.py +++ b/lib/summarize.py @@ -21,11 +21,11 @@ class SummarizeChain(Chain): user_prompt: BasePromptTemplate = PromptTemplate( input_variables=["text"], template=""" - Please write a summary of the following text to make it shorter without losing key information and also don't add anything new: + Summarize the following text. Detect the language of the text. Use the same language as the text. Here is the text: " {text} " - Please write a summary of the above text to make it shorter without losing key information and also don't add anything new: + Output only the summary. Here is your summary in the same language as the text: """ ) diff --git a/lib/topics.py b/lib/topics.py index 74ead2d..3a7101b 100644 --- a/lib/topics.py +++ b/lib/topics.py @@ -24,7 +24,7 @@ class TopicsChain(Chain): " {text} " - List 5 topics of the above text as keywords separated by commas: + List 5 topics of the above text as keywords separated by commas. Output only the topics, nothing else. Use the same language for the topics as the text. """ )