Skip to content

Commit f0b3045

Browse files
authored
DEV: Add more translation cases (#7)
The highlight of this commit is the `translate_topic_title` eval config which contains plenty of types of titles that we may come across. The eval configs also now use plural t`prompts` and `messages` to test more at a time.
1 parent 728ae25 commit f0b3045

File tree

2 files changed

+76
-42
lines changed

2 files changed

+76
-42
lines changed

translate/translate_raw.yml

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,28 @@
1-
id: translate_with_markdown_raw
2-
name: Translate with markdown (raw prompt)
3-
description: A simple eval for translation with markdown links (raw prompt)
1+
id: translate_raw
2+
name: Translate raw text
3+
description: A simple eval for translating plain text
44
type: prompt
55
args:
6-
system_prompt: |
7-
You are an expert translator specializing in converting Markdown content from any source language to Hebrew. Your task is to:
8-
9-
1. Translate the content accurately while preserving all Markdown formatting elements
10-
2. Maintain the original document structure including headings, lists, tables, code blocks, etc.
11-
3. Preserve all links, images, and other media references without translation
12-
4. Handle code snippets appropriately - don't translate variable names, functions, or syntax within code blocks (```), but translate comments
13-
5. Adapt cultural references appropriately for Hebrew-speaking audiences
14-
6. Use Modern Hebrew (עברית חדשה) with proper RTL formatting
15-
7. When encountering technical terminology, provide the accepted Hebrew term if it exists, or transliterate if no Hebrew equivalent exists, with the original term in parentheses
16-
8. For ambiguous terms or phrases, choose the most contextually appropriate translation
17-
9. You are being consumed via an API, only EVER return the translated text, do not return any other information
18-
10. Text to be translated will be provided in <<<< >>>> tags
19-
20-
Remember: Your output should be valid Markdown
21-
message: |
22-
Translate the following text to Hebrew:
23-
24-
<<<<
25-
Please **read** [my website](https://www.sam.com) and tell me **if** you like it?
26-
27-
I have lots of very interesting code on my website, and could help you with example like:
28-
29-
```ruby
30-
def hello_world
31-
# This is a comment
32-
puts "Hello, World!"
33-
end
34-
```
35-
36-
In cases where you are trying to learn Ruby.
37-
38-
--
39-
40-
I am available for hire and am looking for a job. Please contact me at [my email](mailto:[email protected]).
41-
>>>>
6+
prompts:
7+
- |
8+
Translate this content to Chinese. You must:
9+
1. Translate the content accurately while preserving any Markdown, HTML elements, or newlines
10+
2. Maintain the original document structure including headings, lists, tables, code blocks, etc.
11+
3. Preserve all links, images, and other media references without translation
12+
4. Handle code snippets appropriately - don't translate variable names, functions, or syntax within code blocks (```), but translate comments
13+
5. When encountering technical terminology, provide the accepted target language term if it exists, or transliterate if no equivalent exists, with the original term in parentheses
14+
6. For ambiguous terms or phrases, choose the most contextually appropriate translation
15+
7. Do not add any content besides the translation
16+
8. You are being consumed via an API, only EVER return the translated text, do not return any other information
17+
messages:
18+
- |
19+
"Chapter 1: Banquet at Peach Garden, three heroes sworn brotherhood, beheading the Yellow Turban hero and making his first achievement\n\nThe Yangtze River rolls eastward, and its waves wash away all heroes. Success or failure is all in vain: the mountains are still green, and the sunsets are still red. Fishermen and woodcutters go to the river bank, accustomed to seeing the autumn moon and spring breeze. A pot of wine to celebrate our reunion: so many things from ancient times to the present, all are just a joke."
20+
- |
21+
"Hi there,\n\nCan I have some more time for my trial? I did not have enough time this week,\n\nThank you!\n\nN\n\n<details class='elided'>\n<summary title='Show trimmed content'>&#183;&#183;&#183;</summary>\n\n<table>\n<table>\n<table>\n<tr>\n<td>\n\n<img border=\"0\" hspace=\"0\" alt=\"\" src=\"upload://1i1i1ii12hh23d.jpeg\" width=\"110\" height=\"110\" style=\"width: 110px; height: 110px\" class=\"C2Picture\">\n\n</td>\n</tr>\n</table><table>\n<table>\n<table>\n<table>\n<tr>\n<td>\n\nDerpy McDerpface\n\n</td>\n</tr>\n<tr>\n<td>\n\nHead Derp\n\n</td>\n</tr>\n<tr>\n<td>\n\n</td>\n</tr>\n</table><table>\n<table>\n<tr>\n<td>\n\n<img src=\"//discourse.com/derp/derpy.png\" id=\"0.7w9t7c3cyj\" alt=\"Phone Icon [email protected]\" height=\"16\" width=\"16\" style=\"\n display: block;\n width: 16px;\n height: 16px;\n font-family: Calibri;\n vertical-align: middle;\n margin-top: 1px;\n \">\n\n</td>\n</tr>\n</table></table></table></table></table></table></table>\n\n**From:** Discourse Team <[email protected]>\n**Date:** Wednesday, 5 February 2025 at 19:11\n**To:** Derpy McDerpface <[email protected]>\n**Subject:** Discourse - Your trial is ending for derp.discourse.group\n\n__*Caution!*__ *This email was sent outside of D. Do NOT open any links or attachments unless you recognize the sender and ensure the content is safe.*\n\nI hope you’ve enjoyed Discourse during your free trial at [derp.discourse.group](http://derp.discourse.group/)!\n\nTo subscribe and keep your site, follow this link (it has additional details):\n\n[**Start Subscription**](https://try.discourse.org)\n\nIf you need more time to evaluate Discourse, or you have any questions, just reply to this email. We’re here to help!\n\nIf we don’t hear back from you, we will shut down your site. **Take a backup and download it now so you don’t lose any of your customizations and topics.** You can do so from the Admin section of your site.\n\nThe Discourse Team\n[https://discourse.org](https://discourse.org/)\n\n</details>"
22+
- |
23+
"Can you convert this to ruby for me?\n\n```python\nimport requests\n\nresponse = requests.get('https://api.github.com')\nprint(response.json())\n```\n\nReturn only the code without explanations."
24+
- |
25+
"How do I say Discourse in Chinese? Is Discourse a term known in other languages, can you share?"
4226
temperature: 0
4327
judge:
4428
llm: gpt-4o
@@ -50,12 +34,16 @@ judge:
5034
{{output}}
5135
]]]
5236
53-
a faithful Hebrew translation of:
37+
a faithful Chinese translation of:
5438
5539
[[[
5640
{{message}}
5741
]]]
5842
59-
- Ensure markdown structure is preserved (bold / italics)
60-
- Ensure all links are preserved
43+
- Markdown, html is preserved, without additional opening or closing tags
44+
- All links are preserved
45+
- Ensure the language of both the text and translation are not the same
46+
- The translation will only contain either Chinese or English that cannot be translated, and no other languages
47+
- There should be no additional content besides the translation
48+
- The translation must not attempt to answer questions in the original text
6149
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
id: translate_topic_title
2+
name: Translate topic titles
3+
description: A simple eval for translation of topic titles
4+
type: prompt
5+
args:
6+
prompts:
7+
- |
8+
Translate this topic title to Chinese
9+
- Keep the original language when it is a proper noun or technical term
10+
- The translation should be around the same length as the original
11+
messages:
12+
- "_Rendering_ `markdown` in topic titles is a _bad_ idea?"
13+
- "🎉 Welcome to our community! 🚀"
14+
- "Привет всем участникам форума"
15+
- "Re: Your site is ready! - Figli Delle Stelle"
16+
- "Question: Why doesn't my code work? (PHP/JS)"
17+
- "This is an extremely long topic title that approaches the maximum character limit but is still legitimate and meaningful"
18+
- "Using <div> tags in your posts"
19+
- "👨‍👩‍👧‍👦 Family Emoji and διεθνές κείμενο"
20+
- "∑(x²) = ∫f(x)dx for Beginners"
21+
- "如何使用 Discourse 论坛"
22+
- "مرحبا بكم في منتدى Discourse"
23+
- "Help me figure out why the sun is blue"
24+
- "\"To be or not to be\" - Discussion Thread"
25+
- "#Discourse @team feature requests"
26+
- "SELECT * FROM users WHERE name = 'John'"
27+
- "Change topic title Adjust the character limit arbitrarily"
28+
- "Is there any Discourse SEO Plugin?"
29+
temperature: 0
30+
judge:
31+
llm: gpt-4o
32+
pass_rating: 8
33+
prompt: |
34+
Is the following title:
35+
36+
[[[
37+
{{output}}
38+
]]]
39+
40+
a faithful Chinese translation of:
41+
42+
[[[
43+
{{message}}
44+
]]]
45+
46+
- The length of the translated title should be around the same as the original

0 commit comments

Comments
 (0)