Natural language processingOrNLPBeOn hottestThe field of AI today.NLPBeArtificial intelligenceA sub-area dedicated to enabling computers to understand and process human languages ​​and bring computers closer to human understanding of language.

Computers are ideal for handling standardized and structured data such as database tables and financial records. They are able to process this data faster than we humans. But we humans will not communicate in "structured data", nor will we speak binary! We use words to communicate, this is a kindUnstructureddata.

However, our Mac and PC do not yet have an intuitive understanding of natural language. They can't really understand the languagerealmeaning. They don't think of the following like our friend Allen.

Using the NLP algorithm, we can make our machines closer to humans with a deeper understanding of the language. Today, NLP enables us to build things like chat bots, language translators and automation systems to recommend the best Netflix TV shows.

We will quickly introduce the main technical methods of 3 in NLP and how we can use them to build great machines!

Phase 1: Rule-based approach

The rule-based approach is the earliest type of all AI algorithms. In fact, they unified computer science before we considered using machine learning to automate everything. The essence of a rule-based algorithm is simple:

(1) defines a set of rules that describe all the different aspects of a task, in this case the language

(2) specifies a certain order or combination of weights for these rules to make a final decision

(3) applies the formula consisting of this fixed rule to each input in the same way

NLP rule-based approach

Consider the aboveContextual grammarexample. The bottom of the tree shows"Show flights from Boston to San Francisco on Tuesday"Original sentence.

From a human point of view, we can easily define some rules to help the machine understand this sentence:

(1) As long as we see the word "show", we know that we will do some visual. Therefore, we will use the tag SHOW to mark each match of the word "show" and any other words used with it.

(2) The word "flight" is a noun; we mark all nouns with original words.So both "flight" and "flight" will be marked with FLIGHT

(3) "from" naturally refers to something最初 FromWhere, so we tag it with ORIGIN. We use the "to" of the DESTINATION tag and the "on" of the DEPARTDATE tag to be the same idea.

The three rules we just defined allow us to understand this sentence easily!

SHOW = present visual effects

FLIGHTS = what we want to show

ORIGIN, DESTINATION, DEPARTDATE = all the information we want to show

Rule-based algorithms usually have very high accuracy because the rules are user-defined.When human users define rules, we know they are correct.The disadvantage is that this algorithm has a very low recall rate; we cannot defineEvery city in the world! If we forget to put the city of Toronto in our city database, it will not be detected by our algorithm.

Classic machine learning

Another way to teach machines how to understand a language is to build a classic machine learning model. Our idea is to use some user-defined features to represent some "end-to-end" models. Similar to the rule-based approach, this type of functional design can be very natural:

  • Is the word capitalized?
  • Is this word a city?
  • What is the previous and next word?
  • Is it the first in the sentence, and the last one is some intermediate word?

Combining all of this information allows us to understand the actual meaning of a word or phrase.

Since we are training machine learning models, all our data needs to be represented as numbers at some point.Capital and non-capital can be expressed as 1.0 and 0.0; the same can be done for city names-use one-hot coded 1s and 0s in our entire city list.

Words are usually represented as fixed-length vectors based on their relationship to other words-words with similar meaning will have similar vectors, and vice versa. We can represent the position of a word in a sentence as an integer. It can be classified (first, middle, last) or open (number of steps of the first word in the sentence)

Machine learning models can have higher recall rates than rule-based models. But in order to achieve high precision, their functions need to be very well designed and comprehensive.

Deep learning

Classic machine learning algorithms can be highly accurate and relatively easy to implement. But their main drawbacks do hinder them: they require feature engineering.

Design features, just ordinaryhard disk. weNaturallyUnderstand natural language, but we still have a hard time breaking it down into concrete steps. We can't think of all the necessary rules for understanding the language!

Traditional way and deep learning method NLP comparison
Traditional way and deep learning method NLP comparison

Through in-depth study, we don't have to do any complicated functional engineering. The preprocessing is still roughly the same: convert our text into a vector representation, number that the computer can understand.

However, deep learning does not use engineering features to perform calculations, but rather allows neural networks to learn these features themselves. During training, the input is a feature vector of the text, and the output is some high-level semantic information such as emotion, classification, or entity extraction. In the midst of all this, once-designed features are now learned by deep neural networks by finding ways to convert input to output.

Deep learning using NLP almost always achieves higher accuracy. The downside is that it is often much slower than rule-based and classic machine learning methods. They may take a few seconds to run and need someGPUCalculation.

It is always beneficial to have knowledge of all available tools. If your accuracy is reduced by 2-4%, use an easy-to-use rule-based approach. If you really want to squeeze out the last bit of precision and have the money to spend money, go to the heavyweight level of learning!

This article is transferred from medium,Original address(Requires Internet Science)

Easyai public number