johan456789 / yaktoa

Yet Another Kindle to Anki
2 stars 3 forks source link

use Chatgpt for WSD #10

Closed johan456789 closed 1 year ago

johan456789 commented 1 year ago

From my preliminary experiments, it seems to do quite well on WSD. I think it's a good idea to try using ChatGPT to generate definitions.

Click to see ChatGPT generated definition ![image](https://user-images.githubusercontent.com/14802181/226275584-2459a1e2-7766-4d96-8b69-43641d76dc97.png) ![image](https://user-images.githubusercontent.com/14802181/226275624-a5156c54-8dad-437f-a732-6bf19bbeed8f.png)
johan456789 commented 1 year ago

a) experiment using dictionary definitions and ChatGPT to select the matching one

Using ChatGPT considerably improves the accuracy

For example,

Simple Lesk got this wrong: image

ChatGPT got this right: image

But there are also words that both Simple Lesk and ChatGPT got wrong: image image

The correct definition is the second in wordnet: image

If we use chatgpt to generate the definition directly, then the definition is correct: image

But this method is susceptible to hallucination.

Problems

Wrong stemming from Kindle

One problem caused by wrong stemming from the Kindle. The correct stem here should be 'don'. Wrong definitions got returned and both got this wrong: image

The definition field is empty here because wn.synset('globe-trotting') returns nothing. What we need is wn.synset('globe-trot'). Interestingly, simple_lesk returns the correct definition here. So maybe we should just we the lemmatizer in pywsd used by simple_lesk. image

Potential solution: use pywsd or nltk's lemmatizer instead of relying on Kindle's.

Incomplete WordNet definitions

Another bigger problem imo is that wordnet definitions are often not good. For example:

"Japan was far from fielding workable guided missiles, but the project gave Morita a glimpse of the future."

None of WordNet's definition match: image

Merrium-Webster Learner's does have this: image

So does OED: image

From this preliminary test, the quality and completeness of the dictionary are in this order: OED >= Merriam-Webster > WordNet. Since Merriam-Webster provides a free API, we should experiment with it first. the completeness of vocabulary OED > WordNet > Merriam-Webster (learner's). Since I think Merriam-Webster's definition is more suitable for language learners, I will use it first and fallback to WordNet if a definition is not found.

johan456789 commented 1 year ago

Here's the log when running manually with chatgpt_wsd and merriam-webster dictionary:

2023-07-26-chatgpt_wsd-mw.rtf.zip (WSD accuracy report is wrong in the file #22)

The end result is WSD accuracy is 31 / 41 = 75.6%. This is a pretty good accuracy. A lot of failures are caused by lemmatization. Two possible solutions: