ords and phrases:</p><p id="b593">“我” (wǒ) means “I” or “me.”
“对” (duì) means “toward” or “regarding.”
“能够” (nénggòu) means “to be able to.”
“达成” (dáchéng) means “to reach” or “to achieve.”
“协议” (xiéyì) means “agreement.”
“感到” (gǎndào) means “to feel.”
“乐观” (lèguān) means “optimistic.”</p><p id="73f9">It’s fantastic. Imagine integrating this into Litany directly instead of having to leave the app.</p><h2 id="db22">Integrating ChatGPT Into My App</h2><p id="ff61">OK, first of all, I didn’t actually decide to integrate ChatGPT into my app, I decided to integrate GPT3. There is technically an API for ChatGPT but it’s not official and could break at any time so I decided not to use it.</p><p id="ecff">So I looked at GPT3 instead. And the pricing for it is not bad. There are 4 language models available: Ada, Babbage, Curie, and Davinci, and you pay for one thousand tokens.</p><figure id="247a"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*fzCBa7TJDBAwHCT39tzlDA.png"><figcaption></figcaption></figure><p id="f32d">Each token is a few characters. So look at the pricing: Babbage only costs less than a tenth of a cent for thousands of characters. This is going to be easy.</p>
<figure id="6b50">
<div>
<div>
<img class="ratio" src="http://placehold.it/16x9">
<iframe class="" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FvyTnNTrs3wqQ0UIvwE%2Ftwitter%2Fiframe&display_name=Giphy&url=https%3A%2F%2Fgiphy.com%2Fgifs%2Ftheoffice-the-office-tv-frame-toby-vyTnNTrs3wqQ0UIvwE&image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExcmlsd2ZseDdnaTE2Y2xzcnVraHBxYTdzc3lsM3p6enRoa3VmN21lZSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FvyTnNTrs3wqQ0UIvwE%2Fgiphy.gif&key=a19fcc184b9711e1b4764040d3dc5c07&type=text%2Fhtml&schema=giphy" allowfullscreen="" frameborder="0" height="362" width="435">
</div>
</div>
</figure></iframe></div></div></figure><p id="6cee">So you can actually play around with GPT3 in the playground here:</p><div id="3cd7" class="link-block">
<a href="https://beta.openai.com/playground">
<div>
<div>
<h2>OpenAI API</h2>
<div><h3>An API for accessing new AI models developed by OpenAI</h3></div>
<div><p>beta.openai.com</p></div>
</div>
<div>
<div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/)"></div>
</div>
</div>
</a>
</div><p id="d09d">Note that in using playgrounds you will be using actual API tokens. You don’t have to pay money because you get $18 worth of tokens for free, but they expire after 3 months so you might not want to try it just yet.</p><p id="0434">And very quickly I noticed something: Ada, Babbage, and Curie all suck. Unless you have a very simple query the only model that produces acceptable responses is Davinci. So 2 cents per 1000 tokens. Which isn’t too bad, but it can get pricey. Guess I’ll be heavily limiting how much free users can use this feature then.</p><p id="4def">The next thing I noticed is that GPT3 is just not as chatty as ChatGPT. It still works remarkably similarly to ChatGPT, if you give it the same prompt it’ll give you a similar answer, just shorte
Options
r.</p><p id="5958">There is a way around this. Just add ‘Be verbose’ to the end of your prompt. But I actually like the shorter replies. It means you won’t be chewing through API tokens as fast. It will mean you have to be much more explicit in what you ask it though.</p><p id="1a41">I played around with it and got pretty similar results to ChatGPT. I translated this: ‘Rusland bereidt zich voor om mannen onder de vijfenvijftig jaar te beletten het nationale grondgebied te verlaten, zei de directeur van de Oekraïense militaire inlichtingendienst.’ and it gave me this:</p><p id="495d">Rusland :: Russia
bereidt zich voor :: is preparing
om mannen onder de vijfenvijftig jaar :: to prevent men under fifty years old
het nationale grondgebied te verlaten :: from leaving the national territory
zeg de directeur van de Oekraïense militaire inlichtingendienst :: said the director of the Ukrainian military intelligence service</p><p id="c903">Oh, yeah, that’s another thing. I asked it to format the responses nicely so I can parse them when I eventually put the code in my app.</p><p id="4a8f">But even this can be a bit confusing. Like ‘het nationale grondgebied te verlaten’? That’s a long phrase. Maybe we can ask it to explain this phrase in detail. So I did that:</p><p id="ba0b">English translation: “to leave the national territory”</p><p id="3a3c">Het: The (definite article)
Nationale: National (adjective)
Grondgebied: Territory (noun)
Te: To (infinitive marker)
Verlaten: Leave (verb)</p><p id="d89b">The phrase “het nationale grondgebied te verlaten” literally translates to “the national territory to leave” and it means “to leave the national territory”.</p><p id="99fe">It works great!</p><h2 id="e601">Final Thoughts</h2><p id="0582">So I haven’t actually implemented this in Litany yet. And I’m wondering if I should. Because I already have word-by-word translations. Integrating GPT isn’t that much of an improvement.</p><p id="4744">Plus if I do this I have to put API keys in my app which is always risky.</p><p id="5896">Although I think I will implement it eventually. I like the challenge and there’s already a package to implement GPT in my app.</p><figure id="2d10"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*YTMVV-W-sjMutSy-5ZKC-A.png"><figcaption></figcaption></figure><p id="4d10">I almost thought I’d have to do it myself.</p><p id="1621">And maybe I could even expand on this in the future. Putting what GPT says each phrase can be broken down into in addition or even replacing the word-by-word translations for pro users.</p><p id="2668">So many opportunities. Well, I better get started.</p><p id="bc64">If you liked this article be sure to give it a few claps. It helps out a lot with the algorithm.</p><div id="c504" class="link-block">
<a href="https://andrewzuo.com/membership">
<div>
<div>
<h2>Join Medium with my referral link - Andrew Zuo</h2>
<div><h3>Read every story from Andrew Zuo (and thousands of other writers on Medium). Your membership fee directly supports…</h3></div>
<div><p>andrewzuo.com</p></div>
</div>
<div>
<div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*sjrR-_ySSjdfLZHf)"></div>
</div>
</div>
</a>
</div></article></body>
I wrote an app called Litany. It’s a language learning app similar to Anki. In fact the basic idea of the app came from my frustrations with Anki. One of my frustrations is that Anki doesn’t tell you what each word means in the translation. Or at least it doesn’t do this by default.
So in Litany we both get the phrase translation and the word-by-word translations
But this isn’t perfect. One of the major problems with this approach is that words can have multiple meanings. And very often you’ll see expressions that if translated directly make very little sense.
So like ‘sin embargo’ which when I first saw it I thought it meant ‘no embargo’. It doesn’t, it means ‘however’. And there’s ‘por supuesto’ which means ‘of course’. Hey, come to think of it, ‘of course’ doesn’t make much sense either.
And there’s also all kinds of other nonsense with conjugating words. And sometimes I might accidentally have an incorrect translation. It’s confusing.
So yesterday I had a phrase I didn’t really get. The phrase was ‘Súper bien, no duele nada, a toda la población joven que se vengan a vacunar, la posibilidad de hacerlo está en nuestras manos y cuidar nuestras vidas.’ And I didn’t really understand this phrase that well. So I put it in ChatGPT. And this is what it gave me:
Sure! The phrase “Súper bien, no duele nada, a toda la población joven que se vengan a vacunar, la posibilidad de hacerlo está en nuestras manos y cuidar nuestras vidas” can be translated as “Super well, it doesn’t hurt at all. To all the young population that comes to get vaccinated, the possibility of doing so is in our hands and taking care of our lives.” Here is a breakdown of the individual words and phrases:
“Súper bien” (super well) means “very good.”
“no duele nada” (it doesn’t hurt at all) means “it doesn’t hurt at all.”
“a toda la población joven” (to all the young population) refers to all young people.
“que se vengan a vacunar” (that come to get vaccinated) means “that come to get vaccinated.”
“la posibilidad de hacerlo está en nuestras manos” (the possibility of doing so is in our hands) means “the possibility of doing so is in our hands.”
“y cuidar nuestras vidas” (and taking care of our lives) means “and taking care of our lives.”
Which is really good. I instantly knew what my problem was, I had missed the ‘que’ in ‘que se vengan a vacunar’, that’s why the phrase wasn’t making sense. So thanks to ChatGPT I now understood this phrase better.
And it doesn’t just work with Spanish. I tried some other languages too. This is Mandarin Chinese:
The phrase “我对能够达成协议感到乐观” can be translated as “I am optimistic about being able to reach an agreement.” Here is a breakdown of the individual words and phrases:
“我” (wǒ) means “I” or “me.”
“对” (duì) means “toward” or “regarding.”
“能够” (nénggòu) means “to be able to.”
“达成” (dáchéng) means “to reach” or “to achieve.”
“协议” (xiéyì) means “agreement.”
“感到” (gǎndào) means “to feel.”
“乐观” (lèguān) means “optimistic.”
It’s fantastic. Imagine integrating this into Litany directly instead of having to leave the app.
Integrating ChatGPT Into My App
OK, first of all, I didn’t actually decide to integrate ChatGPT into my app, I decided to integrate GPT3. There is technically an API for ChatGPT but it’s not official and could break at any time so I decided not to use it.
So I looked at GPT3 instead. And the pricing for it is not bad. There are 4 language models available: Ada, Babbage, Curie, and Davinci, and you pay for one thousand tokens.
Each token is a few characters. So look at the pricing: Babbage only costs less than a tenth of a cent for thousands of characters. This is going to be easy.
So you can actually play around with GPT3 in the playground here:
Note that in using playgrounds you will be using actual API tokens. You don’t have to pay money because you get $18 worth of tokens for free, but they expire after 3 months so you might not want to try it just yet.
And very quickly I noticed something: Ada, Babbage, and Curie all suck. Unless you have a very simple query the only model that produces acceptable responses is Davinci. So 2 cents per 1000 tokens. Which isn’t too bad, but it can get pricey. Guess I’ll be heavily limiting how much free users can use this feature then.
The next thing I noticed is that GPT3 is just not as chatty as ChatGPT. It still works remarkably similarly to ChatGPT, if you give it the same prompt it’ll give you a similar answer, just shorter.
There is a way around this. Just add ‘Be verbose’ to the end of your prompt. But I actually like the shorter replies. It means you won’t be chewing through API tokens as fast. It will mean you have to be much more explicit in what you ask it though.
I played around with it and got pretty similar results to ChatGPT. I translated this: ‘Rusland bereidt zich voor om mannen onder de vijfenvijftig jaar te beletten het nationale grondgebied te verlaten, zei de directeur van de Oekraïense militaire inlichtingendienst.’ and it gave me this:
Rusland :: Russia
bereidt zich voor :: is preparing
om mannen onder de vijfenvijftig jaar :: to prevent men under fifty years old
het nationale grondgebied te verlaten :: from leaving the national territory
zeg de directeur van de Oekraïense militaire inlichtingendienst :: said the director of the Ukrainian military intelligence service
Oh, yeah, that’s another thing. I asked it to format the responses nicely so I can parse them when I eventually put the code in my app.
But even this can be a bit confusing. Like ‘het nationale grondgebied te verlaten’? That’s a long phrase. Maybe we can ask it to explain this phrase in detail. So I did that:
English translation: “to leave the national territory”
Het: The (definite article)
Nationale: National (adjective)
Grondgebied: Territory (noun)
Te: To (infinitive marker)
Verlaten: Leave (verb)
The phrase “het nationale grondgebied te verlaten” literally translates to “the national territory to leave” and it means “to leave the national territory”.
It works great!
Final Thoughts
So I haven’t actually implemented this in Litany yet. And I’m wondering if I should. Because I already have word-by-word translations. Integrating GPT isn’t that much of an improvement.
Plus if I do this I have to put API keys in my app which is always risky.
Although I think I will implement it eventually. I like the challenge and there’s already a package to implement GPT in my app.
I almost thought I’d have to do it myself.
And maybe I could even expand on this in the future. Putting what GPT says each phrase can be broken down into in addition or even replacing the word-by-word translations for pro users.
So many opportunities. Well, I better get started.
If you liked this article be sure to give it a few claps. It helps out a lot with the algorithm.