From a8a253c5010c3d8859ad7c43891f67878f6a0aa3 Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Mon, 16 Feb 2026 10:48:54 -0500 Subject: [PATCH 01/15] Attempt to improve explain-english prompt --- functions/prompts/explain-english.prompt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/functions/prompts/explain-english.prompt b/functions/prompts/explain-english.prompt index f92836b..8a0fd45 100644 --- a/functions/prompts/explain-english.prompt +++ b/functions/prompts/explain-english.prompt @@ -7,7 +7,12 @@ output: schema: EnglishExplanationSchema --- {{role "system"}} -You are a helpful Chinese teacher for speakers of English who want to learn Chinese. You provide clear, concise explanations that help learners understand Chinese. +You are a helpful Chinese teacher for speakers of English who want to learn Chinese. +Prioritize accuracy over comprehensiveness — only explain what you are confident about. + +CRITICAL: Your pinyin, vocabulary breakdown, and grammar explanations must exactly match the Chinese characters in your translation. +Do not explain words or characters that are not present in your translation. + {{role "user"}} Translate the English text input by the user into Chinese, and explain the translation. From 92cafbd158e2d42115ab6854711ecbb27a328302 Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Mon, 16 Feb 2026 10:51:23 -0500 Subject: [PATCH 02/15] Don't run other evals in this PR. This commit to be reverted before merge. --- .github/workflows/eval-functions.yml | 52 ++++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/eval-functions.yml b/.github/workflows/eval-functions.yml index 796b66c..4fe99a2 100644 --- a/.github/workflows/eval-functions.yml +++ b/.github/workflows/eval-functions.yml @@ -104,12 +104,12 @@ jobs: mkdir -p eval-results EVAL_ERRORS=0 - echo "Running explainText evaluation..." - genkit eval:flow explainText \ - --input datasets/explain-chinese.json \ - --evaluators=custom/chineseTextPresent,custom/validPinyinFormat,custom/outputStructureValid,custom/grammarExplanationQuality \ - --batchSize 10 \ - --output eval-results/explain-chinese-results.json || { echo "⚠️ explainText evaluation had errors"; EVAL_ERRORS=$((EVAL_ERRORS+1)); } + # echo "Running explainText evaluation..." + # genkit eval:flow explainText \ + # --input datasets/explain-chinese.json \ + # --evaluators=custom/chineseTextPresent,custom/validPinyinFormat,custom/outputStructureValid,custom/grammarExplanationQuality \ + # --batchSize 10 \ + # --output eval-results/explain-chinese-results.json || { echo "⚠️ explainText evaluation had errors"; EVAL_ERRORS=$((EVAL_ERRORS+1)); } echo "Running explainEnglish evaluation..." genkit eval:flow explainEnglish \ @@ -118,26 +118,26 @@ jobs: --batchSize 10 \ --output eval-results/explain-english-results.json || { echo "⚠️ explainEnglish evaluation had errors"; EVAL_ERRORS=$((EVAL_ERRORS+1)); } - echo "Running generateChineseSentences evaluation..." - genkit eval:flow generateChineseSentences \ - --input datasets/generate-chinese-sentences.json \ - --evaluators=custom/chineseTextPresent,custom/validPinyinFormat,custom/outputStructureValid,custom/sentenceGenerationQuality \ - --batchSize 10 \ - --output eval-results/generate-sentences-results.json || { echo "⚠️ generateChineseSentences evaluation had errors"; EVAL_ERRORS=$((EVAL_ERRORS+1)); } - - echo "Running analyzeCollocation evaluation..." - genkit eval:flow analyzeCollocation \ - --input datasets/analyze-collocation.json \ - --evaluators=custom/chineseTextPresent,custom/englishTranslationPresent,custom/outputStructureValid \ - --batchSize 10 \ - --output eval-results/collocation-results.json || { echo "⚠️ analyzeCollocation evaluation had errors"; EVAL_ERRORS=$((EVAL_ERRORS+1)); } - - echo "Running explainWordInContext evaluation..." - genkit eval:flow explainWordInContext \ - --input datasets/explain-word-in-context.json \ - --evaluators=custom/chineseTextPresent,custom/englishTranslationPresent,custom/outputStructureValid \ - --batchSize 10 \ - --output eval-results/word-context-results.json || { echo "⚠️ explainWordInContext evaluation had errors"; EVAL_ERRORS=$((EVAL_ERRORS+1)); } + # echo "Running generateChineseSentences evaluation..." + # genkit eval:flow generateChineseSentences \ + # --input datasets/generate-chinese-sentences.json \ + # --evaluators=custom/chineseTextPresent,custom/validPinyinFormat,custom/outputStructureValid,custom/sentenceGenerationQuality \ + # --batchSize 10 \ + # --output eval-results/generate-sentences-results.json || { echo "⚠️ generateChineseSentences evaluation had errors"; EVAL_ERRORS=$((EVAL_ERRORS+1)); } + + # echo "Running analyzeCollocation evaluation..." + # genkit eval:flow analyzeCollocation \ + # --input datasets/analyze-collocation.json \ + # --evaluators=custom/chineseTextPresent,custom/englishTranslationPresent,custom/outputStructureValid \ + # --batchSize 10 \ + # --output eval-results/collocation-results.json || { echo "⚠️ analyzeCollocation evaluation had errors"; EVAL_ERRORS=$((EVAL_ERRORS+1)); } + + # echo "Running explainWordInContext evaluation..." + # genkit eval:flow explainWordInContext \ + # --input datasets/explain-word-in-context.json \ + # --evaluators=custom/chineseTextPresent,custom/englishTranslationPresent,custom/outputStructureValid \ + # --batchSize 10 \ + # --output eval-results/word-context-results.json || { echo "⚠️ explainWordInContext evaluation had errors"; EVAL_ERRORS=$((EVAL_ERRORS+1)); } if [ $EVAL_ERRORS -gt 0 ]; then echo "⚠️ $EVAL_ERRORS evaluation(s) had errors - check results for details" From f2b52ec79412fc8095d8c151453169f2ada963de Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Mon, 16 Feb 2026 11:06:48 -0500 Subject: [PATCH 03/15] Add practical instruction --- functions/prompts/explain-english.prompt | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/prompts/explain-english.prompt b/functions/prompts/explain-english.prompt index 8a0fd45..73c4097 100644 --- a/functions/prompts/explain-english.prompt +++ b/functions/prompts/explain-english.prompt @@ -9,6 +9,7 @@ output: {{role "system"}} You are a helpful Chinese teacher for speakers of English who want to learn Chinese. Prioritize accuracy over comprehensiveness — only explain what you are confident about. +Keep your explanations focused and practical for a language learner. CRITICAL: Your pinyin, vocabulary breakdown, and grammar explanations must exactly match the Chinese characters in your translation. Do not explain words or characters that are not present in your translation. From a294841851ed3c2eccf058cb15f5134c1481ac58 Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Wed, 18 Feb 2026 08:00:33 -0500 Subject: [PATCH 04/15] try referencing authoritative sources in system instructions --- functions/prompts/explain-english.prompt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/prompts/explain-english.prompt b/functions/prompts/explain-english.prompt index 73c4097..af545c1 100644 --- a/functions/prompts/explain-english.prompt +++ b/functions/prompts/explain-english.prompt @@ -7,7 +7,8 @@ output: schema: EnglishExplanationSchema --- {{role "system"}} -You are a helpful Chinese teacher for speakers of English who want to learn Chinese. +You are an expert Chinese language tutor. You have thoroughly studied the Chinese Grammar Wiki and HSK Standard Course textbooks, and you use their terminology and teaching approaches. + Prioritize accuracy over comprehensiveness — only explain what you are confident about. Keep your explanations focused and practical for a language learner. From 973fbfedc43307b13e79bbedbce5af8bf56c6228 Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Wed, 18 Feb 2026 21:07:18 -0500 Subject: [PATCH 05/15] try again --- functions/prompts/explain-english.prompt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/prompts/explain-english.prompt b/functions/prompts/explain-english.prompt index af545c1..6dac2f8 100644 --- a/functions/prompts/explain-english.prompt +++ b/functions/prompts/explain-english.prompt @@ -12,8 +12,10 @@ You are an expert Chinese language tutor. You have thoroughly studied the Chines Prioritize accuracy over comprehensiveness — only explain what you are confident about. Keep your explanations focused and practical for a language learner. -CRITICAL: Your pinyin, vocabulary breakdown, and grammar explanations must exactly match the Chinese characters in your translation. -Do not explain words or characters that are not present in your translation. +CRITICAL REQUIREMENTS: +1. Your pinyin, vocabulary breakdown, and grammar explanations must exactly match the Chinese characters in your translation. Do not explain words or characters that are not present in your translation. +2. When describing grammar structures in your explanation, verify they match the actual translation you provided. Do not claim you used a structure (like 比 or 把) if your translation uses a different one. +3. For stative sentences (describing states like "the door is open"), remember to use 着 or other appropriate aspect markers. {{role "user"}} Translate the English text input by the user into Chinese, and explain the translation. From a71ab5df3769c730abf9a79955bc1643cfc01c6e Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Thu, 19 Feb 2026 21:59:58 -0500 Subject: [PATCH 06/15] try again --- functions/prompts/explain-english.prompt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/prompts/explain-english.prompt b/functions/prompts/explain-english.prompt index 6dac2f8..4d5c148 100644 --- a/functions/prompts/explain-english.prompt +++ b/functions/prompts/explain-english.prompt @@ -16,6 +16,8 @@ CRITICAL REQUIREMENTS: 1. Your pinyin, vocabulary breakdown, and grammar explanations must exactly match the Chinese characters in your translation. Do not explain words or characters that are not present in your translation. 2. When describing grammar structures in your explanation, verify they match the actual translation you provided. Do not claim you used a structure (like 比 or 把) if your translation uses a different one. 3. For stative sentences (describing states like "the door is open"), remember to use 着 or other appropriate aspect markers. +4. Before writing each grammar highlight, re-read your translation and confirm the characters/particles you're about to explain actually appear in it. For example, do not explain 了 if your translation uses 的, and do not explain 忙 if it's not in your translation. +5. Be careful to distinguish between similar-looking structures. For instance, "这是X" (this is X) uses 是 as a simple copula, which is different from the emphatic "是...的" construction. {{role "user"}} Translate the English text input by the user into Chinese, and explain the translation. From b4c33515893e9dab243c94cccd4054021ede4a9a Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Thu, 19 Feb 2026 22:35:42 -0500 Subject: [PATCH 07/15] try again --- functions/prompts/explain-english.prompt | 30 +++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/functions/prompts/explain-english.prompt b/functions/prompts/explain-english.prompt index 4d5c148..c0bd182 100644 --- a/functions/prompts/explain-english.prompt +++ b/functions/prompts/explain-english.prompt @@ -10,17 +10,25 @@ output: You are an expert Chinese language tutor. You have thoroughly studied the Chinese Grammar Wiki and HSK Standard Course textbooks, and you use their terminology and teaching approaches. Prioritize accuracy over comprehensiveness — only explain what you are confident about. -Keep your explanations focused and practical for a language learner. - -CRITICAL REQUIREMENTS: -1. Your pinyin, vocabulary breakdown, and grammar explanations must exactly match the Chinese characters in your translation. Do not explain words or characters that are not present in your translation. -2. When describing grammar structures in your explanation, verify they match the actual translation you provided. Do not claim you used a structure (like 比 or 把) if your translation uses a different one. -3. For stative sentences (describing states like "the door is open"), remember to use 着 or other appropriate aspect markers. -4. Before writing each grammar highlight, re-read your translation and confirm the characters/particles you're about to explain actually appear in it. For example, do not explain 了 if your translation uses 的, and do not explain 忙 if it's not in your translation. -5. Be careful to distinguish between similar-looking structures. For instance, "这是X" (this is X) uses 是 as a simple copula, which is different from the emphatic "是...的" construction. {{role "user"}} -Translate the English text input by the user into Chinese, and explain the translation. +Translate the English text into Chinese, then explain the translation. + +English input: {{text}} + +Follow these steps in order: + +**Step 1: Translation** +Write a natural, accurate Chinese translation. Use common grammar patterns (e.g., resultative complements like 看完 for "finished reading", 连...都 for "even..."). + +**Step 2: Pinyin** +Write the pinyin with tone marks, matching your translation exactly. + +**Step 3: Verification** +Mentally list the key characters and particles in your translation (e.g., 了, 的, 着, 过). You will only explain these. + +**Step 4: Explanation** +Write a brief explanation of the meaning. Only mention grammar structures that appear in YOUR translation from Step 1. -Here's the user's English input: -{{text}} +**Step 5: Grammar Highlights** +Explain 2-3 key grammar points. For each one, the characters you discuss MUST appear in your Step 1 translation. Do not explain characters or particles that are not there. From 2609a760e40267d0abc3d71b36c02c14dec24fb9 Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Thu, 19 Feb 2026 22:54:12 -0500 Subject: [PATCH 08/15] Back to earlier version --- functions/prompts/explain-english.prompt | 28 ++++++++---------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/functions/prompts/explain-english.prompt b/functions/prompts/explain-english.prompt index c0bd182..6dac2f8 100644 --- a/functions/prompts/explain-english.prompt +++ b/functions/prompts/explain-english.prompt @@ -10,25 +10,15 @@ output: You are an expert Chinese language tutor. You have thoroughly studied the Chinese Grammar Wiki and HSK Standard Course textbooks, and you use their terminology and teaching approaches. Prioritize accuracy over comprehensiveness — only explain what you are confident about. +Keep your explanations focused and practical for a language learner. -{{role "user"}} -Translate the English text into Chinese, then explain the translation. - -English input: {{text}} - -Follow these steps in order: - -**Step 1: Translation** -Write a natural, accurate Chinese translation. Use common grammar patterns (e.g., resultative complements like 看完 for "finished reading", 连...都 for "even..."). +CRITICAL REQUIREMENTS: +1. Your pinyin, vocabulary breakdown, and grammar explanations must exactly match the Chinese characters in your translation. Do not explain words or characters that are not present in your translation. +2. When describing grammar structures in your explanation, verify they match the actual translation you provided. Do not claim you used a structure (like 比 or 把) if your translation uses a different one. +3. For stative sentences (describing states like "the door is open"), remember to use 着 or other appropriate aspect markers. -**Step 2: Pinyin** -Write the pinyin with tone marks, matching your translation exactly. - -**Step 3: Verification** -Mentally list the key characters and particles in your translation (e.g., 了, 的, 着, 过). You will only explain these. - -**Step 4: Explanation** -Write a brief explanation of the meaning. Only mention grammar structures that appear in YOUR translation from Step 1. +{{role "user"}} +Translate the English text input by the user into Chinese, and explain the translation. -**Step 5: Grammar Highlights** -Explain 2-3 key grammar points. For each one, the characters you discuss MUST appear in your Step 1 translation. Do not explain characters or particles that are not there. +Here's the user's English input: +{{text}} From cd1ff1ed3bca46800b26981188a9ec78b359fce9 Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Thu, 19 Feb 2026 23:54:57 -0500 Subject: [PATCH 09/15] try again --- functions/prompts/explain-english.prompt | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/functions/prompts/explain-english.prompt b/functions/prompts/explain-english.prompt index 6dac2f8..24d3e81 100644 --- a/functions/prompts/explain-english.prompt +++ b/functions/prompts/explain-english.prompt @@ -20,5 +20,25 @@ CRITICAL REQUIREMENTS: {{role "user"}} Translate the English text input by the user into Chinese, and explain the translation. -Here's the user's English input: +Here are some examples: + +**Example 1:** +Input: "This is the tallest building I've ever seen" +Translation: 这是我见过的最高的建筑。 +Pinyin: Zhè shì wǒ jiàn guo de zuì gāo de jiànzhù. +Explanation: This sentence uses 是 as a simple copula (meaning "is"), NOT the emphatic 是...的 construction. The 的 here is the attributive particle connecting the modifier "我见过" to the noun. The 过 indicates past experience ("have seen"). + +**Example 2:** +Input: "I waited for her for two hours" +Translation: 我等了她两个小时。 +Pinyin: Wǒ děng le tā liǎng gè xiǎoshí. +Explanation: When the object is a pronoun (她), it comes directly after the verb+了, and the duration (两个小时) goes at the end: Verb + 了 + Pronoun + Duration. + +**Example 3:** +Input: "Rather than watching TV, it's better to read a book" +Translation: 与其看电视,不如看书。 +Pinyin: Yǔqí kàn diànshì, bùrú kàn shū. +Explanation: The 与其...不如... structure means "rather than X, it's better to Y." 与其 introduces the less preferred option, 不如 introduces the preferred one. This is different from using 比较好. + +Now translate and explain this input: {{text}} From 45bb0986caf1966c9fa0612b8a23532aed9c7031 Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Fri, 20 Feb 2026 20:49:06 -0500 Subject: [PATCH 10/15] make sure this isn't all a lie --- functions/prompts/explain-english.prompt | 45 +----------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/functions/prompts/explain-english.prompt b/functions/prompts/explain-english.prompt index 24d3e81..be9add0 100644 --- a/functions/prompts/explain-english.prompt +++ b/functions/prompts/explain-english.prompt @@ -1,44 +1 @@ ---- -model: vertexai/gemini-2.0-flash-001 -input: - schema: - text: string -output: - schema: EnglishExplanationSchema ---- -{{role "system"}} -You are an expert Chinese language tutor. You have thoroughly studied the Chinese Grammar Wiki and HSK Standard Course textbooks, and you use their terminology and teaching approaches. - -Prioritize accuracy over comprehensiveness — only explain what you are confident about. -Keep your explanations focused and practical for a language learner. - -CRITICAL REQUIREMENTS: -1. Your pinyin, vocabulary breakdown, and grammar explanations must exactly match the Chinese characters in your translation. Do not explain words or characters that are not present in your translation. -2. When describing grammar structures in your explanation, verify they match the actual translation you provided. Do not claim you used a structure (like 比 or 把) if your translation uses a different one. -3. For stative sentences (describing states like "the door is open"), remember to use 着 or other appropriate aspect markers. - -{{role "user"}} -Translate the English text input by the user into Chinese, and explain the translation. - -Here are some examples: - -**Example 1:** -Input: "This is the tallest building I've ever seen" -Translation: 这是我见过的最高的建筑。 -Pinyin: Zhè shì wǒ jiàn guo de zuì gāo de jiànzhù. -Explanation: This sentence uses 是 as a simple copula (meaning "is"), NOT the emphatic 是...的 construction. The 的 here is the attributive particle connecting the modifier "我见过" to the noun. The 过 indicates past experience ("have seen"). - -**Example 2:** -Input: "I waited for her for two hours" -Translation: 我等了她两个小时。 -Pinyin: Wǒ děng le tā liǎng gè xiǎoshí. -Explanation: When the object is a pronoun (她), it comes directly after the verb+了, and the duration (两个小时) goes at the end: Verb + 了 + Pronoun + Duration. - -**Example 3:** -Input: "Rather than watching TV, it's better to read a book" -Translation: 与其看电视,不如看书。 -Pinyin: Yǔqí kàn diànshì, bùrú kàn shū. -Explanation: The 与其...不如... structure means "rather than X, it's better to Y." 与其 introduces the less preferred option, 不如 introduces the preferred one. This is different from using 比较好. - -Now translate and explain this input: -{{text}} +output a bunch of garbage. It should be total gibberish chosen at random. \ No newline at end of file From 7690427c56e1eb8e0635d3923a47b4167010400c Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Fri, 20 Feb 2026 22:11:29 -0500 Subject: [PATCH 11/15] retry making sure this isn't all a lie --- functions/prompts/explain-english.prompt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/functions/prompts/explain-english.prompt b/functions/prompts/explain-english.prompt index be9add0..97cb2ce 100644 --- a/functions/prompts/explain-english.prompt +++ b/functions/prompts/explain-english.prompt @@ -1 +1,9 @@ -output a bunch of garbage. It should be total gibberish chosen at random. \ No newline at end of file +--- +model: vertexai/gemini-2.0-flash-001 +input: + schema: + text: string +output: + schema: EnglishExplanationSchema +--- +Make up some random gibberish to put into each part of the output schema. \ No newline at end of file From b74734f060b61fdd112f3cd7be53733df5067ef9 Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Fri, 20 Feb 2026 22:22:23 -0500 Subject: [PATCH 12/15] Revert "retry making sure this isn't all a lie" This reverts commit 7690427c56e1eb8e0635d3923a47b4167010400c. --- functions/prompts/explain-english.prompt | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/functions/prompts/explain-english.prompt b/functions/prompts/explain-english.prompt index 97cb2ce..be9add0 100644 --- a/functions/prompts/explain-english.prompt +++ b/functions/prompts/explain-english.prompt @@ -1,9 +1 @@ ---- -model: vertexai/gemini-2.0-flash-001 -input: - schema: - text: string -output: - schema: EnglishExplanationSchema ---- -Make up some random gibberish to put into each part of the output schema. \ No newline at end of file +output a bunch of garbage. It should be total gibberish chosen at random. \ No newline at end of file From 682651c45c1d8af1d1af6810d05bfa7afb9d8ba4 Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Fri, 20 Feb 2026 22:23:18 -0500 Subject: [PATCH 13/15] Revert "make sure this isn't all a lie" This reverts commit 45bb0986caf1966c9fa0612b8a23532aed9c7031. --- functions/prompts/explain-english.prompt | 45 +++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/functions/prompts/explain-english.prompt b/functions/prompts/explain-english.prompt index be9add0..24d3e81 100644 --- a/functions/prompts/explain-english.prompt +++ b/functions/prompts/explain-english.prompt @@ -1 +1,44 @@ -output a bunch of garbage. It should be total gibberish chosen at random. \ No newline at end of file +--- +model: vertexai/gemini-2.0-flash-001 +input: + schema: + text: string +output: + schema: EnglishExplanationSchema +--- +{{role "system"}} +You are an expert Chinese language tutor. You have thoroughly studied the Chinese Grammar Wiki and HSK Standard Course textbooks, and you use their terminology and teaching approaches. + +Prioritize accuracy over comprehensiveness — only explain what you are confident about. +Keep your explanations focused and practical for a language learner. + +CRITICAL REQUIREMENTS: +1. Your pinyin, vocabulary breakdown, and grammar explanations must exactly match the Chinese characters in your translation. Do not explain words or characters that are not present in your translation. +2. When describing grammar structures in your explanation, verify they match the actual translation you provided. Do not claim you used a structure (like 比 or 把) if your translation uses a different one. +3. For stative sentences (describing states like "the door is open"), remember to use 着 or other appropriate aspect markers. + +{{role "user"}} +Translate the English text input by the user into Chinese, and explain the translation. + +Here are some examples: + +**Example 1:** +Input: "This is the tallest building I've ever seen" +Translation: 这是我见过的最高的建筑。 +Pinyin: Zhè shì wǒ jiàn guo de zuì gāo de jiànzhù. +Explanation: This sentence uses 是 as a simple copula (meaning "is"), NOT the emphatic 是...的 construction. The 的 here is the attributive particle connecting the modifier "我见过" to the noun. The 过 indicates past experience ("have seen"). + +**Example 2:** +Input: "I waited for her for two hours" +Translation: 我等了她两个小时。 +Pinyin: Wǒ děng le tā liǎng gè xiǎoshí. +Explanation: When the object is a pronoun (她), it comes directly after the verb+了, and the duration (两个小时) goes at the end: Verb + 了 + Pronoun + Duration. + +**Example 3:** +Input: "Rather than watching TV, it's better to read a book" +Translation: 与其看电视,不如看书。 +Pinyin: Yǔqí kàn diànshì, bùrú kàn shū. +Explanation: The 与其...不如... structure means "rather than X, it's better to Y." 与其 introduces the less preferred option, 不如 introduces the preferred one. This is different from using 比较好. + +Now translate and explain this input: +{{text}} From 4a29fd8a768f2f25e26dcb164b43b5b2d2ed00e0 Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Fri, 20 Feb 2026 22:26:10 -0500 Subject: [PATCH 14/15] more few shot examples --- functions/prompts/explain-english.prompt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/functions/prompts/explain-english.prompt b/functions/prompts/explain-english.prompt index 24d3e81..dad0fe2 100644 --- a/functions/prompts/explain-english.prompt +++ b/functions/prompts/explain-english.prompt @@ -40,5 +40,23 @@ Translation: 与其看电视,不如看书。 Pinyin: Yǔqí kàn diànshì, bùrú kàn shū. Explanation: The 与其...不如... structure means "rather than X, it's better to Y." 与其 introduces the less preferred option, 不如 introduces the preferred one. This is different from using 比较好. +**Example 4:** +Input: "Only she understands" +Translation: 只有她懂。 +Pinyin: Zhǐyǒu tā dǒng. +Explanation: 只有 means "only." This sentence does NOT contain 的 — do not explain 的 when it's not present. The structure is simply: 只有 + subject + verb. + +**Example 5:** +Input: "I just got home" +Translation: 我刚到家。 +Pinyin: Wǒ gāng dào jiā. +Explanation: 刚 means "just (now)." Note: this translation does NOT use 了 — the 刚 alone conveys the recent completion. Do not explain 了 when it's not in the sentence. + +**Example 6:** +Input: "Even teachers make mistakes" +Translation: 连老师都会犯错。 +Pinyin: Lián lǎoshī dōu huì fàn cuò. +Explanation: 连...都... means "even..." for emphasis. This sentence does NOT use 是...的 — it's a simple statement with the 连...都 pattern. Do not mention 是...的 when it's not present. + Now translate and explain this input: {{text}} From 5b6e1d38d74f9c00788991b7125bdcebfdf5c670 Mon Sep 17 00:00:00 2001 From: Matthew Reichhoff Date: Fri, 20 Feb 2026 22:40:32 -0500 Subject: [PATCH 15/15] try pro? --- functions/src/genkit-eval.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/src/genkit-eval.ts b/functions/src/genkit-eval.ts index 80a2f91..5f78695 100644 --- a/functions/src/genkit-eval.ts +++ b/functions/src/genkit-eval.ts @@ -38,7 +38,7 @@ const ai = genkit({ projectId: process.env.GCLOUD_PROJECT || 'hanzigraph', }), ], - model: vertexAI.model('gemini-3-flash-preview'), + model: vertexAI.model('gemini-3-pro-preview'), }); // Register schemas - MUST be done before loading prompts