Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 功能建议:求自定义openai翻译的prompt #616

Closed
4 of 5 tasks
ertcds opened this issue Jul 18, 2024 · 3 comments
Closed
4 of 5 tasks

🚀 功能建议:求自定义openai翻译的prompt #616

ertcds opened this issue Jul 18, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@ertcds
Copy link

ertcds commented Jul 18, 2024

请先确认以下事项

  • 已仔细阅读了 README
  • issues 页面搜索过(包括已关闭的 issue),未发现类似功能建议
  • Easydict 已升级到 最新版本
  • 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭

功能描述

发现这个prompt非常好,适合深入学习单词,能不能公布一下,在手机上用,多谢

使用场景

手机

实现方案(可选)

No response

是否愿意提交 PR 实现该功能

  • 我愿意提交 PR
@ertcds ertcds added the enhancement New feature or request label Jul 18, 2024
Copy link

Hello ertcds, Thank you for your first issue contribution 🎉

@tisfeng
Copy link
Owner

tisfeng commented Jul 18, 2024

这些 prompt 其实还挺复杂的,主要由 system, few-shot 和 user prompt 组成,你可以看一下代码 https://github.com/tisfeng/Easydict/blob/dev/Easydict/Swift/Service/OpenAI/Prompt.swift

下面是查单词 battery 的具体 prompt

[
  {
    "content" : "You are a word search assistant skilled in multiple languages and knowledgeable in etymology. You can help search for words, phrases, slang, abbreviations, and other information. Prioritize queries from authoritative dictionary databases, such as the Oxford Dictionary, Cambridge Dictionary, and Wikipedia. If a word or abbreviation has multiple meanings, look up the most commonly used ones.",
    "role" : "system"
  },
  {
    "content" : "Using Simplified-Chinese:\nHere is a English word: \"\"\"album\"\"\",\nLook up its pronunciation, part of speech and meanings, tenses, explanation, etymology, how to remember, cognates, synonyms, antonyms, phrases, example sentences.",
    "role" : "user"
  },
  {
    "content" : "发音:\/ ˈælbəm \/\n\nn. 相册;唱片集;集邮簿\n\n时态:\n复数:albums\n\n解释:{explanation}\n\n词源学:早期 17 世纪:源自拉丁语“albus”(意即“白色”)的中性单词“album”,原意为“白板”。该词是从拉丁语短语“album amicorum”(意即“好友相册”,一种可收集亲笔签名、素描、诗句等内容的空白书籍)中借来的,最初被有意作为拉丁语词汇使用。\n\n记忆方法:{how_to_remember}\n\n同根词:\nn. almanac 年历,历书\nn. anthology 选集,文选\n\n近义词:record, collection, compilation\n反义词:dispersal, disarray, disorder\n\n常用短语:\n1. White Album: 白色相簿\n2. photo album: 写真集;相册;相簿\n3. debut album: 首张专辑\n\n例句:\n1. Their new album is dynamite.\n(他们的*新唱*引起轰动。)\n2. I stuck the photos into an album.\n(我把照片贴到*相册*上。)",
    "role" : "assistant"
  },
  {
    "role" : "user",
    "content" : "raven"
  },
  {
    "content" : "发音:\/ ˈreɪvən \/\n\nn. 掠夺,劫掠;大乌鸦\nadj. 乌黑的\nvt. 掠夺;狼吞虎咽\nvi. 掠夺;狼吞虎咽\n\n时态:\n复数:ravens\n第三人称单数:ravens\n现在分词:ravening\n过去式:ravened\n过去分词:ravened\n\n解释:{explanation}\n\n词源学:{etymology}\n\n记忆方法:{how_to_remember}\n\n同根词:\nn. ravage 蹂躏,破坏\nvi. ravage 毁坏;掠夺\nvt. ravage 毁坏;破坏;掠夺\nadj. ravenous 贪婪的;渴望的;狼吞虎咽的\n\n近义词:seize, blackbird\n反义词:protect, guard, defend\n\n常用短语:\n1. Raven paradox: 乌鸦悖论\n2. raven hair: 乌黑的头发\n3. The Raven: 乌鸦;魔鸟\n\n例句:\n1. She has long raven hair.\n(她有一头*乌黑的*长头发。)\n2. The raven is often associated with death and the supernatural.\n(*乌鸦*常常与死亡和超自然现象联系在一起。)",
    "role" : "assistant"
  },
  {
    "role" : "user",
    "content" : "js"
  },
  {
    "role" : "assistant",
    "content" : "Pronunciation: {Pronunciation}\n\nn. JavaScript 的缩写,一种直译式脚本语言。\n\nExplanation: {Explanation}\n\nEtymology: {Etymology}\n\nSynonym: {Synonym}\n\nPhrases: {Phrases}\n\nExample Sentences: {Example_Sentences}"
  },
  {
    "role" : "user",
    "content" : "Using Simplified-Chinese: \nHere is a English word: \"\"\"battery\"\"\", Look up its pronunciation, use the format: \"发音: \/{pronunciation}\/\" \nLook up all parts of speech and meanings. Use the format: \"{pos}. {meaning}\", with one part of speech and meaning per line.Look up all tenses of the word based on its part of speech. If the word is a noun, provide only its plural form. If the word is a verb, provide its third person singular, present participle, past tense, and past participle forms. Show only one tense per line, use the format: \"时态:\n{tenses}\".Look up its brief explanation in Simplified-Chinese in a clear and understandable way. Use the format: \"解释: {brief_explanation}\"Look up its detailed etymology, including the original origin, changes in meaning, and current common meaning. Use the format: \"词源学: {detailed_etymology}\".Provide some efficient memory techniques and tips to better remember this word, such as association and decomposition, etc. Use the format: \"记忆方法: {how_to_remember}\".Look up main English words with the same root. List no more than 4, excluding phrases. Display all parts of speech and meanings. If there are words with the same root, use the format: \"同根词: {cognates}\", otherwise don't display it.Look up main English synonyms, no more than 3. If there are synonyms, use the format: \"近义词: {synonyms}\".Look up main English antonyms, no more than 3. If there are antonyms, use the format: \"反义词: {antonyms}\".Look up main English phrases, no more than 3. If there are phrases, use the format: \"常用短语: {phrases}\".Look up main English example sentences and their translations, no more than 2. Mark the specific meaning in the translated sentence with *. Use the format: \"例句:\n{example_sentences}\".Ensure the explanation is around 50 words and the etymology is between 100 and 400 words. Word count does not need to be displayed.Do not display additional information or notes."
  }
]
70838

@ertcds
Copy link
Author

ertcds commented Jul 19, 2024

这些 prompt 其实还挺复杂的,主要由 system, few-shot 和 user prompt 组成,你可以看一下代码 https://github.com/tisfeng/Easydict/blob/dev/Easydict/Swift/Service/OpenAI/Prompt.swift

下面是查单词 battery 的具体 prompt

[
  {
    "content" : "You are a word search assistant skilled in multiple languages and knowledgeable in etymology. You can help search for words, phrases, slang, abbreviations, and other information. Prioritize queries from authoritative dictionary databases, such as the Oxford Dictionary, Cambridge Dictionary, and Wikipedia. If a word or abbreviation has multiple meanings, look up the most commonly used ones.",
    "role" : "system"
  },
  {
    "content" : "Using Simplified-Chinese:\nHere is a English word: \"\"\"album\"\"\",\nLook up its pronunciation, part of speech and meanings, tenses, explanation, etymology, how to remember, cognates, synonyms, antonyms, phrases, example sentences.",
    "role" : "user"
  },
  {
    "content" : "发音:\/ ˈælbəm \/\n\nn. 相册;唱片集;集邮簿\n\n时态:\n复数:albums\n\n解释:{explanation}\n\n词源学:早期 17 世纪:源自拉丁语“albus”(意即“白色”)的中性单词“album”,原意为“白板”。该词是从拉丁语短语“album amicorum”(意即“好友相册”,一种可收集亲笔签名、素描、诗句等内容的空白书籍)中借来的,最初被有意作为拉丁语词汇使用。\n\n记忆方法:{how_to_remember}\n\n同根词:\nn. almanac 年历,历书\nn. anthology 选集,文选\n\n近义词:record, collection, compilation\n反义词:dispersal, disarray, disorder\n\n常用短语:\n1. White Album: 白色相簿\n2. photo album: 写真集;相册;相簿\n3. debut album: 首张专辑\n\n例句:\n1. Their new album is dynamite.\n(他们的*新唱*引起轰动。)\n2. I stuck the photos into an album.\n(我把照片贴到*相册*上。)",
    "role" : "assistant"
  },
  {
    "role" : "user",
    "content" : "raven"
  },
  {
    "content" : "发音:\/ ˈreɪvən \/\n\nn. 掠夺,劫掠;大乌鸦\nadj. 乌黑的\nvt. 掠夺;狼吞虎咽\nvi. 掠夺;狼吞虎咽\n\n时态:\n复数:ravens\n第三人称单数:ravens\n现在分词:ravening\n过去式:ravened\n过去分词:ravened\n\n解释:{explanation}\n\n词源学:{etymology}\n\n记忆方法:{how_to_remember}\n\n同根词:\nn. ravage 蹂躏,破坏\nvi. ravage 毁坏;掠夺\nvt. ravage 毁坏;破坏;掠夺\nadj. ravenous 贪婪的;渴望的;狼吞虎咽的\n\n近义词:seize, blackbird\n反义词:protect, guard, defend\n\n常用短语:\n1. Raven paradox: 乌鸦悖论\n2. raven hair: 乌黑的头发\n3. The Raven: 乌鸦;魔鸟\n\n例句:\n1. She has long raven hair.\n(她有一头*乌黑的*长头发。)\n2. The raven is often associated with death and the supernatural.\n(*乌鸦*常常与死亡和超自然现象联系在一起。)",
    "role" : "assistant"
  },
  {
    "role" : "user",
    "content" : "js"
  },
  {
    "role" : "assistant",
    "content" : "Pronunciation: {Pronunciation}\n\nn. JavaScript 的缩写,一种直译式脚本语言。\n\nExplanation: {Explanation}\n\nEtymology: {Etymology}\n\nSynonym: {Synonym}\n\nPhrases: {Phrases}\n\nExample Sentences: {Example_Sentences}"
  },
  {
    "role" : "user",
    "content" : "Using Simplified-Chinese: \nHere is a English word: \"\"\"battery\"\"\", Look up its pronunciation, use the format: \"发音: \/{pronunciation}\/\" \nLook up all parts of speech and meanings. Use the format: \"{pos}. {meaning}\", with one part of speech and meaning per line.Look up all tenses of the word based on its part of speech. If the word is a noun, provide only its plural form. If the word is a verb, provide its third person singular, present participle, past tense, and past participle forms. Show only one tense per line, use the format: \"时态:\n{tenses}\".Look up its brief explanation in Simplified-Chinese in a clear and understandable way. Use the format: \"解释: {brief_explanation}\"Look up its detailed etymology, including the original origin, changes in meaning, and current common meaning. Use the format: \"词源学: {detailed_etymology}\".Provide some efficient memory techniques and tips to better remember this word, such as association and decomposition, etc. Use the format: \"记忆方法: {how_to_remember}\".Look up main English words with the same root. List no more than 4, excluding phrases. Display all parts of speech and meanings. If there are words with the same root, use the format: \"同根词: {cognates}\", otherwise don't display it.Look up main English synonyms, no more than 3. If there are synonyms, use the format: \"近义词: {synonyms}\".Look up main English antonyms, no more than 3. If there are antonyms, use the format: \"反义词: {antonyms}\".Look up main English phrases, no more than 3. If there are phrases, use the format: \"常用短语: {phrases}\".Look up main English example sentences and their translations, no more than 2. Mark the specific meaning in the translated sentence with *. Use the format: \"例句:\n{example_sentences}\".Ensure the explanation is around 50 words and the etymology is between 100 and 400 words. Word count does not need to be displayed.Do not display additional information or notes."
  }
]
70838

非常感谢,我试了好用的很

@tisfeng tisfeng closed this as completed Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants