<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>模板 &amp;mdash; 安娜提戈涅</title>
    <link>https://writee.org/anartigone/tag:模板</link>
    <description>「绝望之为虚妄，正与希望相同。」</description>
    <pubDate>Thu, 04 Jun 2026 00:34:49 +0000</pubDate>
    <item>
      <title>汉化电子书经验谈</title>
      <link>https://writee.org/anartigone/ebook-talk</link>
      <description>&lt;![CDATA[过去一年里制作了三本汉化电子书，就体量来说加一起都比不上前年的那本《少于无》，不过就麻烦程度来说，《与我女儿谈经济》那散碎的章节量实在是很头痛。&#xA;&#xA;多亏在参与《剩余享乐》翻译制作的过程中得到了拉黑字幕组前辈的经验分享，得知可以用Python脚本来自动化这部分工序，于是最近抽空把这个脚本 做出来了。&#xA;&#xA;现在有了AI辅助以后，开发小型项目就变得非常方便省力。在编程方面我尝试过许多模型，目前最满意的是Llama-3.1-70B，比Qwen2.5-coder、Deepseek-coder-v2以及GPT-4o都要强很多。&#xA;&#xA;脚本项目从代码到文档都是羊驼完成的，我只需要构思好程序逻辑和样例就能一个提示词得到可用代码，随后再微调几次来优化交互体验就完工了：&#xA;write a code of converting an epub file into a honkit project, using ebooklib&#xA;&#xA;find h1 and h2 for each .html file.&#xA;create individual folders for each chapter with h1 content as its chapter name.&#xA;under each chapter folder, create .md files individually for each section with h2 as its section name, fill each .md file with all p contents belong to this section (until next h2). if there is no section under a chapter, create the .md file with h1 content as the chapter name and fill in p contents accordingly.&#xA;&#xA; let me show you an example epub file&#xA;&#xA;这个脚本对于下一本要制作的电子书非常重要，是Rockhill翻译的Losurdo的《西方马克思主义》，章节也是非常多所以如果是手工的话工作量会非常巨大。&#xA;&#xA;除了增加了自动化脚本以外，翻译流程的其他部分也有所优化。&#xA;&#xA;目前Calibre电子书翻译器的部分是：DeepL初翻+Qwen2.5修复+人工校对+Qwen2.5润色&#xA;&#xA;DeepL相比Google在翻译结果上更精准贴切，比Qwen更稳定可靠。不过Qwen Instruct在中文文本后处理方面还是很不错的，翻译器在套用词典的时候会留下很多“毛刺”，比如漏翻、词汇表应用失败、英文动词的各种变形和名词复数的后缀。&#xA;&#xA;另外DeepL在书名号方面总会丢失配对、随机产生繁体字、排版和标点也会产生些毛病，把这些常见问题总结出来写成系统提示词，然后还是用电子书翻译器，不带词典并调用Qwen进行中文-中文的校对就可以修复这些“毛刺”了。&#xA;对于词汇表应用失败的问题，还是需要人工校对来确保关键的专有名词能正确地出现在结果里。然后再人工通读一遍以进行全篇的粗校，这之后再交给Qwen润色。&#xA;由于初翻是逐句翻译的，而DeepL并没有记忆功能，所以会在语法或上下文用词一致性方面有所欠缺。所以最后再开启合并翻译功能，让Qwen进行大段文本块的总体润色，可以进一步提升阅读流畅感。&#xA;&#xA;目前的Qwen模板大致是这样的：&#xA;         &#34;system&#34;: &#34;You are a professional book editor who is specialized at reviewing and revising books. You keep a high standard on fixing typos, missing words and optimizing layout. You never answer any question nor explain/summary anything. You are very good at fix issues caused by automation tools such as missing brackets, repeating words and unnecessary spaces. You don&#39;t rephrase or rewrite any sentence, but only fix issues. You change traditional Chinese character into simplified. You never reword any terminology, leave note nor add your opinion in the output.&#34;,&#xA;         &#34;prompt&#34;: &#34;Fix issues caused by automation tools. Don&#39;t rephrase, rewrite nor add any sentence. Do not state nor explain what you did or removed in the output:text&#34;,&#xA;         &#34;stream&#34;: false,&#xA;         &#34;mirostat&#34;: 1,&#xA;         &#34;mirostateta&#34;: 1,&#xA;         &#34;mirostattau&#34;: 1.0,&#xA;         &#34;numpredict&#34;: 256,&#xA;         &#34;temperature&#34;: 0.0,&#xA;         &#34;repeatpenalty&#34;: 0.0,&#xA;         &#34;repeatlastn&#34;: 0,&#xA;         &#34;topk&#34;: 1,&#xA;         &#34;topp&#34;: 0.1&#xA;top-k, top-p和temperature对本身就很不稳定的Qwen来说需要降低到很小，而mirostat的学习功能可以很好的弥补Qwen这一短板。每次用的时候都会微调这个模板里的提示词，不过参数方面还是比较固定的。&#xA;&#xA;在得到准备发布的EPUB文件后，需要用HonKit了。&#xA;&#xA;新建一个目录，然后将一些文件从以前的项目里复制进来，比如README.md和gitbook的目录结构之类的，这样可以免去npx honkit init的步骤。&#xA;&#xA;接下来再用epubtohonkit.py把书打散成md文件，把所有chapter文件夹移动到gitbook/markdown/zh/并把SUMMARY.md放在项目根目录。&#xA;&#xA;现在就可以用npx honkit serve来本地预览网页版了，调整好SUMMARY.md和README.md就可以npx honkit build构建html文件并发布了：&#xA;cp -R book/* .&#xA;git clean -fx book&#xA;git add .&#xA;git commit -a -m &#34;Update docs&#34;&#xA;git branch -M main&#xA;git push -u origin main&#xA;&#xA;最后再将排版好的网页版转换成离线电子书，上传到release和zlib：&#xA;npx honkit epub ./ ./&#34;new-zhcn-ebook.epub&#34;&#xA;&#xA;不过PDF文件的目录跳转问题并没能在更新HonKit之后解决，我目前也暂时没有精力给上游修bug。所以，目前还不能用HonKit来生成PDF，暂时还是得用Calibre转换EPUB到PDF才行。&#xA;&#xA;#Python脚本 #语言模型 #LLM #自定义引擎 #Ollama #Llama-3.1 #Qwen2.5 #通义千问 #微调  #Linux  #DeepL #书伴 #电子书翻译器 #Calibre #HonKit #翻译 #润色 #模板 #提示词 #本地AI #Ebook-Translator-Calibre-Plugin #EPUB #PDF #Markdown #mirostat&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>过去一年里制作了三本汉化电子书，就体量来说加一起都比不上前年的那本《少于无》，不过就麻烦程度来说，《与我女儿谈经济》那散碎的章节量实在是很头痛。</p>

<p>多亏在参与《剩余享乐》翻译制作的过程中得到了拉黑字幕组前辈的经验分享，得知可以用Python脚本来自动化这部分工序，于是最近抽空把<a href="https://github.com/anartigone/epub2honkit" rel="nofollow">这个脚本</a> 做出来了。</p>

<p>现在有了AI辅助以后，开发小型项目就变得非常方便省力。在编程方面我尝试过许多模型，目前最满意的是Llama-3.1-70B，比Qwen2.5-coder、Deepseek-coder-v2以及GPT-4o都要强很多。</p>

<p>脚本项目从代码到文档都是羊驼完成的，我只需要构思好程序逻辑和样例就能一个提示词得到可用代码，随后再微调几次来优化交互体验就完工了：</p>

<pre><code>write a code of converting an epub file into a honkit project, using ebooklib

1. find &lt;h1&gt; and &lt;h2&gt; for each .html file.
2. create individual folders for each chapter with &lt;h1&gt; content as its chapter name.
3. under each chapter folder, create .md files individually for each section with &lt;h2&gt; as its section name, fill each .md file with all &lt;p&gt; contents belong to this section (until next &lt;h2&gt;). if there is no section under a chapter, create the .md file with &lt;h1&gt; content as the chapter name and fill in &lt;p&gt; contents accordingly.

 let me show you an example epub file
</code></pre>

<p>这个脚本对于下一本要制作的电子书非常重要，是Rockhill翻译的Losurdo的《西方马克思主义》，章节也是非常多所以如果是手工的话工作量会非常巨大。</p>

<p>除了增加了自动化脚本以外，翻译流程的其他部分也有所优化。</p>

<p>目前Calibre电子书翻译器的部分是：DeepL初翻+Qwen2.5修复+人工校对+Qwen2.5润色</p>

<p>DeepL相比Google在翻译结果上更精准贴切，比Qwen更稳定可靠。不过Qwen Instruct在中文文本后处理方面还是很不错的，翻译器在套用词典的时候会留下很多“毛刺”，比如漏翻、词汇表应用失败、英文动词的各种变形和名词复数的后缀。</p>

<p>另外DeepL在书名号方面总会丢失配对、随机产生繁体字、排版和标点也会产生些毛病，把这些常见问题总结出来写成系统提示词，然后还是用电子书翻译器，不带词典并调用Qwen进行中文-中文的校对就可以修复这些“毛刺”了。
对于词汇表应用失败的问题，还是需要人工校对来确保关键的专有名词能正确地出现在结果里。然后再人工通读一遍以进行全篇的粗校，这之后再交给Qwen润色。
由于初翻是逐句翻译的，而DeepL并没有记忆功能，所以会在语法或上下文用词一致性方面有所欠缺。所以最后再开启合并翻译功能，让Qwen进行大段文本块的总体润色，可以进一步提升阅读流畅感。</p>

<p>目前的Qwen模板大致是这样的：</p>

<pre><code>         &#34;system&#34;: &#34;You are a professional book editor who is specialized at reviewing and revising books. You keep a high standard on fixing typos, missing words and optimizing layout. You never answer any question nor explain/summary anything. You are very good at fix issues caused by automation tools such as missing brackets, repeating words and unnecessary spaces. You don&#39;t rephrase or rewrite any sentence, but only fix issues. You change traditional Chinese character into simplified. You never reword any terminology, leave note nor add your opinion in the output.&#34;,
         &#34;prompt&#34;: &#34;Fix issues caused by automation tools. Don&#39;t rephrase, rewrite nor add any sentence. Do not state nor explain what you did or removed in the output:&lt;text&gt;&#34;,
         &#34;stream&#34;: false,
         &#34;mirostat&#34;: 1,
         &#34;mirostat_eta&#34;: 1,
         &#34;mirostat_tau&#34;: 1.0,
         &#34;num_predict&#34;: 256,
         &#34;temperature&#34;: 0.0,
         &#34;repeat_penalty&#34;: 0.0,
         &#34;repeat_last_n&#34;: 0,
         &#34;top_k&#34;: 1,
         &#34;top_p&#34;: 0.1
</code></pre>

<p>top-k, top-p和temperature对本身就很不稳定的Qwen来说需要降低到很小，而mirostat的学习功能可以很好的弥补Qwen这一短板。每次用的时候都会微调这个模板里的提示词，不过参数方面还是比较固定的。</p>

<p>在得到准备发布的EPUB文件后，需要用HonKit了。</p>

<p>新建一个目录，然后将一些文件从以前的项目里复制进来，比如README.md和gitbook的目录结构之类的，这样可以免去<code>npx honkit init</code>的步骤。</p>

<p>接下来再用<code>epub_to_honkit.py</code>把书打散成md文件，把所有chapter文件夹移动到<code>gitbook/markdown/zh/</code>并把SUMMARY.md放在项目根目录。</p>

<p>现在就可以用<code>npx honkit serve</code>来本地预览网页版了，调整好SUMMARY.md和README.md就可以<code>npx honkit build</code>构建html文件并发布了：</p>

<pre><code>cp -R _book/* .
git clean -fx _book
git add .
git commit -a -m &#34;Update docs&#34;
git branch -M main
git push -u origin main
</code></pre>

<p>最后再将排版好的网页版转换成离线电子书，上传到release和zlib：</p>

<pre><code>npx honkit epub ./ ./&#34;new-zhcn-ebook.epub&#34;
</code></pre>

<p>不过<a href="https://github.com/anartigone/ttmdate-web/issues/1" rel="nofollow">PDF文件的目录跳转问题</a>并没能在更新HonKit之后解决，我目前也暂时没有精力给上游修bug。所以，目前还不能用HonKit来生成PDF，暂时还是得用Calibre转换EPUB到PDF才行。</p>

<p><a href="/anartigone/tag:Python%E8%84%9A%E6%9C%AC" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Python脚本</span></a> <a href="/anartigone/tag:%E8%AF%AD%E8%A8%80%E6%A8%A1%E5%9E%8B" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">语言模型</span></a> <a href="/anartigone/tag:LLM" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">LLM</span></a> <a href="/anartigone/tag:%E8%87%AA%E5%AE%9A%E4%B9%89%E5%BC%95%E6%93%8E" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">自定义引擎</span></a> <a href="/anartigone/tag:Ollama" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Ollama</span></a> <a href="/anartigone/tag:Llama" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Llama</span></a>-3.1 <a href="/anartigone/tag:Qwen2" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Qwen2</span></a>.5 <a href="/anartigone/tag:%E9%80%9A%E4%B9%89%E5%8D%83%E9%97%AE" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">通义千问</span></a> <a href="/anartigone/tag:%E5%BE%AE%E8%B0%83" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">微调</span></a>  <a href="/anartigone/tag:Linux" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Linux</span></a>  <a href="/anartigone/tag:DeepL" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">DeepL</span></a> <a href="/anartigone/tag:%E4%B9%A6%E4%BC%B4" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">书伴</span></a> <a href="/anartigone/tag:%E7%94%B5%E5%AD%90%E4%B9%A6%E7%BF%BB%E8%AF%91%E5%99%A8" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">电子书翻译器</span></a> <a href="/anartigone/tag:Calibre" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Calibre</span></a> <a href="/anartigone/tag:HonKit" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">HonKit</span></a> <a href="/anartigone/tag:%E7%BF%BB%E8%AF%91" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">翻译</span></a> <a href="/anartigone/tag:%E6%B6%A6%E8%89%B2" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">润色</span></a> <a href="/anartigone/tag:%E6%A8%A1%E6%9D%BF" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">模板</span></a> <a href="/anartigone/tag:%E6%8F%90%E7%A4%BA%E8%AF%8D" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">提示词</span></a> <a href="/anartigone/tag:%E6%9C%AC%E5%9C%B0AI" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">本地AI</span></a> <a href="/anartigone/tag:Ebook" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Ebook</span></a>-Translator-Calibre-Plugin <a href="/anartigone/tag:EPUB" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">EPUB</span></a> <a href="/anartigone/tag:PDF" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">PDF</span></a> <a href="/anartigone/tag:Markdown" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Markdown</span></a> <a href="/anartigone/tag:mirostat" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">mirostat</span></a></p>
]]></content:encoded>
      <guid>https://writee.org/anartigone/ebook-talk</guid>
      <pubDate>Mon, 13 Jan 2025 03:07:17 +0000</pubDate>
    </item>
  </channel>
</rss>