# How would an AI learn idiomatic phrases in a natural language?

After an AI goes through the process described in How would an AI learn language?, an AI knows the grammar of a language through the process of grammar induction. They can speak the language, but they have learned formal grammar. But most conversations today, even formal ones, use idiomatic phrases. Would it be possible for an AI to be given a set of idioms, for example,

Immer mit der Ruhe

Which, in German, means 'take it easy' but an AI of grammar induction, if told to translate 'take it easy' to German, would not think of this. And if asked to translate this, it would output

Always with the quiet

So, it is possible to teach an AI to use idiomatic phrases to keep up with the culture of humans?

• Do you have access to parallel corpora in source and target language that translates idioms correctly? Neural machine translation should handle this. I don't an AI knows grammar of a language - a translation AI knows patterns but not necessarily grammar in the sense that we learn in school as children. Here's a potential approach that should work give a large enough corpora with examples of idioms - github.com/facebookresearch/MUSE Sep 4, 2019 at 3:11
• Can you make this into an answer? Sep 4, 2019 at 23:42

TL;DR

In the presence of good datasets this can be accomplished with a pipeline.

In reality an idiom is a series of words which is supposed to have a semantic meaning that is not denoted by the literal reading (source). This means that any system that is used must be capable of considering multiple words at a time. Additionally, some idioms are context dependent. Example:

• The fisherman broke the ice with his tool.

Are we to believe that this is a very suave fisherman?

So, it is possible to teach an AI to use idiomatic phrases to keep up with the culture of humans?

Observe that humans do not come linguistically "pre-loaded" with idioms. So we can safely assume that idiom usage is a learning task and that the only way for them to keep up is for them to keep learning. So if we solve the idiom learning task we just need to keep our agent online or periodically retrain it on nascent corpora.

One difficulty is that, in the absence of a label, a metaphor could be easily mistaken for an idiom and vice versa. So semantic outlier (sorry it's not free) approaches may suffer from precision issues. Example:

• She's a thorny wildflower (metaphor - could easily be an idiom)
• She's a diamond in the rough (idiom - could easily be a metaphor)

Though, idioms will most likely be repeated if a dataset is large whereas a "custom metaphor" is less likely to repeat.

Additionally, some idioms (eg bite the bullet or break a leg) do not have readily available "interpretable semantics" that allow us to extract their intended meaning. For example, if one did not know the idiom "cut me some slack" one could think:

"Slack implies loosening or to make less tight/taut. I was being very uptight. They probably want me to loosen up and not be so critical."

Of course the human understanding of it might happen in a flash and not follow such a delineated path. The idea is that some NLP pipeline might be constructible that satisfactorily handles idioms in some specific use cases (example of a pipeline). For example, one module might attempt to process outliers like "diamond in the rough" which have said interpretable semantics. Though, something like "bite the bullet" may have to be labelled with the correct semantics.

I've only scratched the surface of this. Natural language understanding is already a hard problem - and idioms are thus a tough task in a tough task. I hope that this motivates the reading of some more thorough articles. I have gathered some articles that can be used as a springboard into the literature.

Here's a source that uses a dictionary type approach to train the model to recognize idioms. Excerpt:

For identification, we assume data of the form $${(⟨p_i,d_i⟩,y_i) : i = 1...n}$$ where $$p_i$$ is the phrase associated with definition $$d_i$$ and $$y_i ∈ \{literal, idiomatic\}$$.

This source provides pseudo-code for idiom extraction.

This source describes a dataset to help solve the idiom difficulties.

• Natural language processing is already a hard problem, to be more precise, I would say natural language understanding is a hard problem.
– nbro
Sep 6, 2019 at 15:37
• @nbro Indeed. Thanks for the input. I want my answers to be as precise as possible. see edit Sep 6, 2019 at 15:47

Do you have access to parallel corpora in source and target language that translates idioms correctly? Neural machine translation. (NMT) should handle this. NMT uses deep learning to match sequences/pairs of words in one language to another and is now the state of the art method for translation AI.

I don't think an AI knows grammar of a language. A translating AI knows patterns but not necessarily grammar in the sense that we learn in school as children. Here's a potential approach that should work give a large enough corpora with examples of idioms - github.com/facebookresearch/MUSE