Skip to content

Commit

Permalink
feat: Make model uses same language as the prompt
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
  • Loading branch information
marcelklehr committed Jun 12, 2024
1 parent 26c3ab3 commit 16b97c0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/formalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
4 changes: 2 additions & 2 deletions lib/headline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
)

Expand Down
2 changes: 1 addition & 1 deletion lib/simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
)

Expand Down
4 changes: 2 additions & 2 deletions lib/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
)

Expand Down
2 changes: 1 addition & 1 deletion lib/topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
)

Expand Down

0 comments on commit 16b97c0

Please sign in to comment.