使用 ChatGPT 進行電子書高品質翻譯

最近大範圍的研究 ChatGPT 能應用跟結合哪些既有服務,這篇文章是用來紀錄將 ChatGPT 應用在電子書翻譯的狀況。 代碼解析 首先我使用 Bilingual Book Maker 這個專案協助進行與 ChatGPT 的溝通,它這邊就是作兩個主要動作,呼叫 OpenAI API 和處理一些細節文本轉換,具體可以看以下片段代碼: GPT-3.5-turbo model # 調用 openai pkg 的方法 completion = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ { "role": "user", # english prompt here to save tokens # prompt 告訴 OpenAI 請協助文本翻譯到 target language,並且回文內容不要包含原本的文本 "content": f"Please help me to translate,`{text}` to {self.language}, please return only translated content not include the origin text", } ], ) ... 如果是使用 GPT-3 model 則是以下:...

March 10, 2023 · Yish