How Can Leanpub Translate Entire Books with AI?

Translating books with AI is a big challenge for a number of reasons, some of them obvious, some of them maybe not so obvious.

How Can Leanpub Translate Entire Books with AI?

Translating books with AI is a big challenge for a number of reasons, some of them obvious, some of them maybe not so obvious.

The Obvious Challenges with AI Book Translation

The obvious challenges for LLM / generative AI book translation are:

  • Coherence. What happens at the beginning of a book informs everything that comes after it - and vice versa. With a translation app, you can order a coffee, or localize a website menu, or even do battlefield triage, which is still amazing, but you can't use one to translate a book.
  • Maintaining "voice". Most books are written in a consistent and unique "voice". Doing this can be tricky enough for the author of a book themselves, writing in the original language; it's especially tricky when you're translating.
  • Literary meaning. There's no AI that can do anything close to capturing what you might call "literary meaning" in translation. It's something only a very small number of experts can do; to be clear, that even excludes most professional translators, like the kind who translate in real time for diplomats and world leaders at international conferences. That kind of translation is very hard too of course, but it's nothing like literary translation, where it might genuinely take a day to translate a sentence, and centuries-long controversies can surround the translation of a single word in a single text.
  • Colloquialisms. Everyday language is constantly evolving, and a lot of the things we say may not actually have an analogue in another language at all. Is there really, say, a German equivalent of "In your face"? (This is a fundamental challenge for human translation too, of course.)
  • Hallucination. AI can famously hallucinate, just making things up that sound reasonable but are completely untrue.

How We Can Overcome the Challenges with AI Book Translation

At Leanpub, we've been working on our AI book translation service, TranslateAI, for over a year and a half. We've developed prompt engineering and other processes that overcome many of these challenges, using the always-improving OpenAI services, currently GPT-4o.

  • TranslateAI translates each piece of the book with an "understanding" of the whole puzzle. Our code splits a book manuscript into smaller chunks, sends each chunk to GPT-4o (along with some battle-tested prompt engineering on our part), waits for the response from GPT-4o, confirms that the translation worked using custom code (and asks GPT-4o to try again if it detected any issues), and then recombines the translated chunks into the translated manuscript. Think of it as taking a completed puzzle, taking it apart, translating the pieces, and putting it back together. This helps overcome many of the challenges regarding issues like voice, coherence, and hallucination.
  • GPT-4o "knows" Markua, our plain text book formatting syntax. You can upload a PDF or EPUB book file for publication and sale on Leanpub, but at our core we are a book writing platform. Leanpub books are written in Markua, a plain text book formatting syntax that is explicitly set out in detail in our technical specification here, and GPT-4o has "read" that specification. Now, if computers are good at anything, it's reading plain text specifications: that's basically what the code used to run every single program on your computer is. What this means in a sense is that Leanpub's TranslateAI doesn't just translate the text, it gives you a plain text manuscript that can be used to generate a fully-formatted ebook in every language automatically, as well as a print-ready PDF file for creating a print version. (If you're interested in the history of book production and Markua's place in it, you might enjoy this.)
  • Focus initially on translating ordinary non-fiction books. Most Leanpub books are written by experts on technical, scientific, business, and management topics, as well as subjects like personal transformation. These are typically books that are trying to help the reader learn something they need to learn, and they are also what you might call a "direct" form of writing, where things like colloquialisms and indirect references are typically avoided in the first place. (With that said, the main genere we're very excited about moving on to next is genre fiction, where readers have a passionate demand for books that are also "direct", even though they are fiction.)
  • Human feedback combined with the ability to easily update books that have already been published. Leanpub has "lean" in its name partly because it is built around the idea that publishing a book should not be constrained exclusively by the conventional book publishing processes used by the big book publishers. That means you should publish your book serially, as you're writing it, with readers getting all updates to the book for free. It means you should invite feedback from all your readers, so you can improve your book as you go, and that you should be able to easily change your book, including updating previously-published chapters with edits. This is a perfect process for effectively "crowdsourcing" the editing and improvement of a book, and people who love books love doing it. In that sense (plus the amazing collaborative potential of writing books in our Git and GitHub writing mode, which we'll write about elsewhere), Leanpub is perfectly positioned to lead the way with AI book translation.

Publish Early, Publish Often