CN112287070A - Method and device for determining upper and lower position relation of words, computer equipment and medium - Google Patents

Method and device for determining upper and lower position relation of words, computer equipment and medium Download PDF

Info

Publication number
CN112287070A
CN112287070A CN202011281974.3A CN202011281974A CN112287070A CN 112287070 A CN112287070 A CN 112287070A CN 202011281974 A CN202011281974 A CN 202011281974A CN 112287070 A CN112287070 A CN 112287070A
Authority
CN
China
Prior art keywords
words
word
relationship
determining
terms
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011281974.3A
Other languages
Chinese (zh)
Inventor
禹常隆
张海松
韩家龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202011281974.3A priority Critical patent/CN112287070A/en
Publication of CN112287070A publication Critical patent/CN112287070A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/253Grammatical analysis; Style critique
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking

Abstract

The embodiment of the application discloses a method and a device for determining the superior-inferior relation of words, computer equipment and a medium, and belongs to the technical field of computers. The method comprises the following steps: the method comprises the steps of obtaining two terms, inquiring the two terms from a term database, wherein the term database comprises a plurality of terms and the relation confidence degree between every two terms in the plurality of terms, responding to the fact that at least one term does not exist in the term database, calling a relation determination model obtained based on the training of the term database, processing word vectors of the two terms, and determining the relation confidence degree between the two terms. The accuracy of the trained relation determination model is improved through the words and the relation confidence degrees in the word database, and when the relation confidence degrees of the two words are determined, the relation confidence degrees between the two words can be determined through combining the word database and the relation determination model under any condition, so that the accuracy of the relation confidence degrees is ensured.

Description

Method and device for determining upper and lower position relation of words, computer equipment and medium
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a method and a device for determining the upper and lower relations of words, computer equipment and a medium.
Background
With the development of computer technology, the application of natural language processing is more and more extensive. In natural language processing, words having a superior-inferior relationship in sentences, such as "dog" and "animal", "science fiction movie" and "movie", etc., are generally considered to enhance the understanding of natural language.
In the related art, a relationship confidence level between two words is usually determined according to the co-occurrence frequency of the two words in the word database, that is, the co-occurrence frequency of the two words, and the relationship confidence level is used to indicate the possibility of having a top-bottom relationship between the two words.
In the above method, the relationship confidence is determined only by the co-occurrence frequency of two words in the word database, however, for some words not included in the word database, it cannot be determined whether there is a context relationship, which may cause recognition errors during natural language processing.
Disclosure of Invention
The embodiment of the application provides a method, a device, computer equipment and a medium for determining the upper and lower relations of words, which can improve the accuracy of the relation confidence. The technical scheme is as follows:
in one aspect, a method for determining a context of a word is provided, where the method includes:
acquiring two words;
querying the two terms from a term database, wherein the term database comprises a plurality of terms and the relationship confidence between every two terms in the plurality of terms;
in response to the fact that at least one of the two words does not exist in the word database, calling a relation determination model obtained based on the training of the word database, processing word vectors of the two words, and determining a relation confidence coefficient between the two words;
wherein the relationship confidence is used to represent a likelihood that the two words have a superior-inferior relationship.
In another aspect, an apparatus for determining a context of a word is provided, the apparatus comprising:
the word acquisition module is used for acquiring two words;
the term query module is used for querying the two terms from a term database, and the term database comprises a plurality of terms and the relationship confidence degrees between every two terms in the plurality of terms;
the first confidence coefficient determining module is used for responding to the fact that at least one word in the two words does not exist in the word database, calling a relation determining model obtained based on the training of the word database, processing word vectors of the two words and determining the relation confidence coefficient between the two words;
wherein the relationship confidence is used to represent a likelihood that the two words have a superior-inferior relationship.
In one possible implementation, the term determination module includes:
a word determination unit configured to determine a plurality of words included in the plurality of pairs of words based on the plurality of pairs of words;
a matrix construction unit, configured to construct a co-occurrence frequency matrix based on the multiple words and the co-occurrence frequency corresponding to each pair of words, where each element in the co-occurrence frequency matrix is used to represent the co-occurrence frequency of two corresponding words;
and the matrix decomposition unit is used for decomposing the co-occurrence frequency matrix and determining the co-occurrence frequency corresponding to every two terms in the plurality of terms.
In another possible implementation manner, the apparatus further includes:
the sample determining module is used for taking the words in the word database as sample words and taking the relation confidence coefficient between every two sample words as the corresponding supervision value of every two sample words;
and the model training module is used for performing iterative training on the relation determination model according to the word vectors of every two sample words and the corresponding supervision values.
In another possible implementation manner, the model training module includes:
the confidence determining unit is used for calling the relationship determining model for any iteration turn in a plurality of iteration turns, processing word vectors of any two sample words and determining the confidence of the predicted relationship between any two sample words;
the loss value determining unit is used for determining the loss value of the relation determination model according to the confidence coefficient of the predicted relation and the supervision values corresponding to the any two sample words;
and the parameter adjusting unit is used for adjusting the parameters of the relation determination model according to the loss values.
In another possible implementation, the loss value determination unit is configured to determine a square of a difference between the prediction relationship confidence and the supervision value as the loss value.
In another possible implementation manner, the apparatus further includes:
and the word storage module is used for responding to the relationship confidence coefficient of the two words being larger than the reference confidence coefficient, and correspondingly storing the two words in an upper and lower level relationship database, wherein the upper and lower level relationship database comprises words with upper and lower level relationships.
In another possible implementation manner, the apparatus further includes:
the first receiving module is used for receiving a retrieval request, and the retrieval request carries a target word;
the term query module is further used for querying the target term from the upper-lower relational database;
and the retrieval module is used for responding to the upper terms corresponding to the target terms and retrieving the information related to the target terms based on the target terms and the corresponding upper terms.
In another possible implementation manner, the apparatus further includes:
the second receiving module is used for receiving a classification request, and the classification request carries target text information;
the keyword extraction module is used for extracting keywords from the target text information to obtain keywords in the target text information;
the term query module is also used for querying the keywords from the upper and lower relational databases;
and the label determining module is used for responding to the upper terms corresponding to the keywords and determining corresponding type labels for the target text information according to the upper terms corresponding to the keywords.
In another aspect, a computer device is provided, which includes a processor and a memory, where at least one computer program is stored in the memory, and the at least one computer program is loaded by the processor and executed to implement the operations performed in the above-described method for determining a context of a word.
In another aspect, a computer-readable storage medium is provided, in which at least one computer program is stored, the at least one computer program being loaded and executed by a processor to implement the operations performed in the context determination method for words as described in the above aspect.
In yet another aspect, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer program code, the computer program code being stored in a computer readable storage medium. The processor of the computer device reads the computer program code from the computer-readable storage medium, and the processor executes the computer program code, so that the computer device implements the operations performed in the context determination method of words as described in the above aspect.
The beneficial effects brought by the technical scheme provided by the embodiment of the application at least comprise:
according to the method, the device, the computer equipment and the medium, the accuracy of the trained relation determination model is improved through the words and the relation confidence degrees in the word database, and when the relation confidence degrees of the two words are determined, the relation confidence degrees between the two words can be determined by combining the word database and the relation determination model under any condition, so that the accuracy of the relation confidence degrees is ensured.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic diagram of an implementation environment provided by an embodiment of the present application;
FIG. 2 is a flowchart of a method for determining a context of a word provided in an embodiment of the present application;
FIG. 3 is a flowchart of a method for determining a context of a word provided in an embodiment of the present application;
FIG. 4 is a flow chart for determining the context of a word provided by an embodiment of the present application;
FIG. 5 is a schematic diagram of determining a context of a word provided by an embodiment of the present application;
fig. 6 is a schematic structural diagram of a device for determining a superior-inferior relation of words provided in an embodiment of the present application;
fig. 7 is a schematic structural diagram of a device for determining a superior-inferior relation of words according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a terminal according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a server according to an embodiment of the present application.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present application more clear, the embodiments of the present application will be further described in detail with reference to the accompanying drawings.
As used herein, the terms "at least one," "a plurality," "each," and "any," at least one of which includes one, two, or more than two, and a plurality of which includes two or more than two, each of which refers to each of the corresponding plurality, and any of which refers to any of the plurality. For example, the plurality of words includes 3 words, each of which refers to each of the 3 words, and any of which refers to any one of the 3 words, which may be the first, the second, or the third.
Artificial Intelligence (AI) is a theory, method, technique and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and expand human Intelligence, perceive the environment, acquire knowledge and use the knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technique of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a manner similar to human intelligence. Artificial intelligence is the research of the design principle and the realization method of various intelligent machines, so that the machines have the functions of perception, reasoning and decision making.
The artificial intelligence technology is a comprehensive subject and relates to the field of extensive technology, namely the technology of a hardware level and the technology of a software level. The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
Natural Language Processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that enable efficient communication between humans and computers using natural language. Natural language processing is a science integrating linguistics, computer science and mathematics. Therefore, the research in this field will involve natural language, i.e. the language that people use everyday, so it is closely related to the research of linguistics. Natural language processing techniques typically include text processing, semantic understanding, machine translation, robotic question and answer, knowledge mapping, and the like.
Machine Learning (ML) is a multi-domain cross discipline, and relates to a plurality of disciplines such as probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and the like. The special research on how a computer simulates or realizes the learning behavior of human beings so as to acquire new knowledge or skills and reorganize the existing knowledge structure to continuously improve the performance of the computer. Machine learning is the core of artificial intelligence, is the fundamental approach for computers to have intelligence, and is applied to all fields of artificial intelligence. Machine learning and deep learning generally include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and teaching learning.
The scheme provided by the embodiment of the application can train the relationship determination model based on artificial intelligence natural language processing and machine learning technology, and can determine the superior-inferior relationship between words by using the trained relationship prediction model.
The method for determining the context relationship of the words provided by the embodiment of the application can be used in computer equipment, and optionally, the computer equipment is a terminal or a server. Optionally, the server is an independent physical server, or a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a web service, cloud communication, a middleware service, a domain name service, a security service, a CDN (Content Delivery Network), a big data and artificial intelligence platform, and the like. Optionally, the terminal is a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto.
Fig. 1 is a schematic structural diagram of an implementation environment provided by an embodiment of the present application, and as shown in fig. 1, the system includes a terminal 101 and a server 102, where the terminal 101 and the server 102 can be directly or indirectly connected through wired or wireless communication, and the present application is not limited herein.
The terminal 101 is configured to provide the server with the words of the superior-inferior relationship to be determined, and send the words of the superior-inferior relationship to be determined to the server 102, where the server 102 is configured to determine the superior-inferior relationship between any two words sent by the terminal 101.
The method provided by the embodiment of the application can be used for various scenes.
For example, in a text classification scenario:
by extracting a plurality of words from a corpus and adopting the method provided by the embodiment of the application, the relation confidence coefficient between every two words in the plurality of words is determined, the two words with the relation confidence coefficient larger than the reference confidence coefficient are used as superior and inferior relation words, an superior and inferior relation database is constructed, the upper word corresponding to the keyword is determined by extracting the keyword from any text information and the superior and inferior relation database, and the corresponding type label is distributed to the text information according to the superior word.
For another example, in an information retrieval scenario:
by extracting a plurality of words from a corpus and adopting the method provided by the embodiment of the application, the relation confidence coefficient between every two words in the plurality of words is determined, the two words with the relation confidence coefficient larger than the reference confidence coefficient are used as upper and lower relation words, an upper and lower relation database is established, the upper word corresponding to the target word is determined according to the target word carried by the received retrieval request and the upper and lower relation databases, and the information related to the target word is retrieved through the target word and the corresponding upper word, so that the accuracy of the retrieved information is ensured.
The following embodiments are intended to briefly explain the principles of the present application, and fig. 2 is a flowchart of a method for determining a context of a word provided by an embodiment of the present application, which is applied to a computer device, and as shown in fig. 2, the method includes:
201. the computer device obtains two words.
The two obtained words are to-be-determined upper and lower order words, the upper and lower order relation may exist in the two words, or the upper and lower order relation may not exist in the two words, and the relation confidence of the two words needs to be determined subsequently.
202. The computer device queries the two terms from the term database.
The term database comprises a plurality of terms and relationship confidence degrees between every two terms in the plurality of terms, and the relationship confidence degrees are used for indicating the possibility that the two terms have a superior-inferior relationship. Determining whether the two terms exist in the term database by querying the two terms from the term database.
203. And the computer equipment responds to the fact that at least one of the two words does not exist in the word database, calls a relation determination model obtained based on the training of the word database, processes word vectors of the two words and determines the relation confidence coefficient between the two words.
The relation determining model is obtained by training a plurality of words in the word database and the relation confidence between every two words. Word vectors are used to represent vectors of corresponding words, with word vectors for different words being different.
The method comprises the steps that word vectors of two words of which the superior-inferior relation is to be determined are input into a relation determination model, the relation determination model outputs a relation confidence coefficient between the two words, and whether the superior-inferior relation exists between the two words can be determined subsequently through the relation confidence coefficient between the two words.
According to the method provided by the embodiment of the application, the accuracy of the trained relation determination model is improved through the words and the relation confidence degrees in the word database, and when the relation confidence degrees of the two words are determined, the relation confidence degrees between the two words can be determined by combining the word database and the relation determination model under any condition, so that the accuracy of the relation confidence degrees is ensured.
The following embodiments are described by taking as an example a process of first constructing a term database and then determining a relationship determination model trained based on the term database. Fig. 3 is a flowchart of a method for determining a context of a word according to an embodiment of the present application, which is applied to a computer device, and as shown in fig. 3, the method includes:
301. and the computer equipment extracts words from the text information in the corpus to obtain a plurality of pairs of words and the co-occurrence frequency corresponding to each pair of words.
The corpus is a database for providing corpora, for example, english wiki, Gigaword, and the like. The corpus comprises text information, and the text information is stored in the corpus as a corpus. The co-occurrence frequency is used to indicate the number of times that the corresponding two words appear in the text information at the same time, and optionally, the text information includes a plurality of sentences, and in the plurality of sentences, the number of sentences including two words at the same time is determined as the co-occurrence frequency of the two words. For example, if two words are included in a sentence, it means that the two words co-occur 1 time, and the co-occurrence frequency of the two words can be determined by a plurality of sentences in the text message.
In one possible implementation, this step 301 includes: and determining reference sentences which meet the reference grammar conditions in the text information based on the reference grammar conditions, and extracting words of the obtained multiple reference sentences to obtain multiple pairs of words and the co-occurrence frequency corresponding to each pair of words.
Wherein the reference grammar condition is used for indicating a grammar condition satisfied by a word having a top-bottom relationship. Because the words with the upper and lower relation may exist in the sentences meeting the reference grammar condition, the words are extracted from the sentences meeting the reference grammar condition, and a plurality of pairs of words with the upper and lower relation and the co-occurrence frequency corresponding to each pair of words can be obtained.
For example, if the reference grammar condition indicates that "a includes B" and the text message includes "animal includes dog, rabbit, etc.," the reference sentence in which the "animal includes dog, rabbit, etc" in the text message satisfies the reference grammar condition is extracted, that is, "animal" and "dog", "animal" and "rabbit" are obtained.
Alternatively, the reference syntax condition can be provided in the form of a template. Optionally, the reference grammar condition is a heartt template (a grammar template) which includes a plurality of templates through which sentences in the text information are traversed to determine reference sentences satisfying the heartt template. The heartst template comprises a plurality of templates, as shown in table 1.
TABLE 1
Figure BDA0002781089280000081
Figure BDA0002781089280000091
Optionally, the determining of the co-occurrence frequency includes: for any pair of words, traversing the text information, determining the number of sentences including the pair of words, and taking the number of the first sentences including the pair of words as the co-occurrence frequency of the pair of words.
Optionally, the determining of the co-occurrence frequency includes: the reference grammar condition is a plurality of reference grammar conditions, for any pair of words, the text information is traversed, a plurality of first sentences comprising the pair of words are determined, the number of the reference grammar conditions met by each first sentence is determined, and the sum of the number of the reference grammar conditions met by the plurality of sentences is determined as the co-occurrence frequency of the pair of words.
Optionally, the determining of the co-occurrence frequency includes: the reference grammar condition is a plurality of reference grammar conditions, for any pair of words, the text information is traversed, a plurality of first sentences comprising the pair of words are determined, the number of the reference grammar conditions met by each first sentence is determined, and the sum of the number of the plurality of first sentences and the number of the reference grammar conditions met by each sentence is determined as the co-occurrence frequency of the pair of words.
302. The computer device determines a plurality of words included in the plurality of pairs of words and a co-occurrence frequency corresponding to every two words of the plurality of words based on the plurality of pairs of words and the co-occurrence frequency corresponding to each pair of words.
Since the same word may be included in the plurality of pairs of words, and different words may also be included in the plurality of pairs of words, the plurality of words included in the plurality of pairs of words and the co-occurrence frequency corresponding to every two words can be obtained by counting the plurality of pairs of words.
For example, pairs of words include: "animal" with "dog", "animal" with "cat", "movie" with "science fiction movie", etc., then the resulting plurality of words includes: "animal", "dog", "cat", "movie", "science fiction movie", and the co-occurrence frequency corresponding to each two words.
In one possible implementation, this step 302 includes: determining a plurality of words included in the plurality of pairs of words based on the plurality of pairs of words, constructing a co-occurrence frequency matrix based on the plurality of words and the co-occurrence frequency corresponding to each pair of words, decomposing the co-occurrence frequency matrix, and determining the co-occurrence frequency corresponding to each two words in the plurality of words.
Wherein each element in the co-occurrence frequency matrix is used to represent the co-occurrence frequency of the corresponding two words. Because the co-occurrence frequency matrix is constructed by a plurality of pairs of words and co-occurrence frequencies corresponding to each pair of words, a plurality of words are obtained by the plurality of pairs of words, each element in the co-occurrence frequency matrix is respectively used for indicating the co-occurrence frequency between two words in the plurality of words, but the co-occurrence frequencies between other words in the co-occurrence frequency matrix are unknown except the co-occurrence frequencies corresponding to the determined plurality of pairs of words in the co-occurrence frequency matrix, namely the constructed co-occurrence frequency matrix comprises unknown elements. For example, the obtained co-occurrence frequencies corresponding to a plurality of words are respectively: the co-occurrence frequency corresponding to the word 1 and the word2 is 5, the co-occurrence frequency corresponding to the word 3 and the word 4 is 6, in the constructed co-occurrence frequency matrix, the co-occurrence frequency corresponding to the word 1 and the word 3 is unknown, the co-occurrence frequency corresponding to the word 1 and the word 4 is unknown, the co-occurrence frequency corresponding to the word2 and the word 3 is unknown, and the co-occurrence frequency corresponding to the word2 and the word 4 is unknown, so that the co-occurrence frequency matrix comprises unknown elements. And decomposing the co-occurrence frequency matrix to determine the value of an unknown element in the co-occurrence frequency matrix, thereby determining the co-occurrence frequency corresponding to every two terms in the plurality of terms.
Optionally, when constructing the co-occurrence frequency matrix, the plurality of words are respectively used as row words and column words, and the co-occurrence frequency corresponding to each row word and each column word constitutes the co-occurrence frequency matrix, and an element corresponding to any row word and any column word is the co-occurrence frequency corresponding to the row word and the column word. Optionally, the process of decomposing the co-occurrence frequency matrix includes: and determining the co-occurrence frequency corresponding to every two words in the plurality of words by performing singular value decomposition on the co-occurrence frequency matrix. Wherein the Singular Value Decomposition is SVD (Singular Value Decomposition).
In one possible implementation, this step 302 includes: determining a plurality of words included in the plurality of pairs of words based on the plurality of pairs of words, and determining the co-occurrence frequency corresponding to every two words according to the plurality of words, the co-occurrence frequency corresponding to each pair of words and the context relationship of the plurality of words in the text information.
Optionally, a hyperbolic embedding manner is adopted, and the co-occurrence frequency corresponding to each two words is determined through the context relationship of the words in the text information.
303. The computer device determines a relationship confidence between each two terms based on the co-occurrence frequency corresponding to each two terms.
For any two words, the higher the co-occurrence frequency of the two words, the higher the probability that the two words have the superior-inferior relationship, and the lower the co-occurrence frequency of the two words, the lower the probability that the two words have the superior-inferior relationship. After the co-occurrence frequency corresponding to every two words in the plurality of words is determined, the relation confidence coefficient between every two words is determined according to the co-occurrence frequency corresponding to every two words.
In one possible implementation, this step 303 includes: and for any two words, determining the occurrence frequency of each word in the text information of the corpus, and determining the relation confidence coefficient between the two words according to the co-occurrence frequency of the two words and the occurrence frequency of each word in the two words.
Optionally, for any two words, the frequency of occurrence of each word, the frequency of co-occurrence p (x, y) of the two words, and the relationship confidence Score (x, y) between the two words, satisfy the following relationship:
Figure BDA0002781089280000111
wherein x and y represent words respectively; p (x) represents the frequency of occurrence of the word x in the text information of the corpus; p (y) represents the frequency of occurrence of the word y in the text information of the corpus; p (x, y) represents the co-occurrence frequency of the word x and the word y; score (x, y) represents the confidence of the relationship between the word x and the word y, and the value of the confidence of the relationship Score (x, y) is greater than or equal to 0.
304. The computer device constructs a word database based on the plurality of words and the confidence of the relationship between every two words.
And after the plurality of terms and the relation confidence degrees between every two terms in the plurality of terms are obtained, constructing the term database so as to determine the relation confidence degrees between the two terms in the term database by querying the term database in the following process.
305. The computer device obtains two words.
And the two obtained words are the words of which the superior-inferior relation is to be determined. In the embodiments of the present application, a superior-inferior relationship (hyperym-hyponym) is used to indicate a relationship between words, for example, two words are: the animal is a dog belonging to one of animals, namely, the dog and the animal have an up-down relationship, and the animal comprises the dog. After two words are obtained, the relation confidence degree between the two words is determined based on the word database and the relation determination model.
306. A computer device queries two terms from a term database.
And querying the terms with the upper and lower relations to be determined from the term database to determine whether the two terms exist in the term database.
307. And the computer equipment responds to the fact that at least one of the two words does not exist in the word database, calls a relation determination model obtained based on the training of the word database, processes word vectors of the two words and determines the relation confidence coefficient between the two words.
The relation determining model is obtained by training a plurality of words in the word database and the relation confidence between every two words.
When at least one of the two terms does not exist in the term database, the relationship confidence between the two terms cannot be inquired according to the term database, and therefore the relationship confidence between the two terms is determined by calling a relationship determination model obtained through training.
In one possible implementation, before the step 307, the method includes: and coding the two words to obtain word vectors of the two words. Wherein, the word vector of the word is obtained through distributed Representation (distribution Representation) for representing the corresponding word. When a word is coded, the word vector of the word is obtained by mapping the word into a distributed vector space.
Optionally, a coding model is invoked to code the two words, and a word vector of the two words is obtained. The coding model is BERT (Bidirectional Encoder representation model), RoBERTa (a robust Optimized BERT preceding Approach, a robust Optimized BERT pre-training model), word2vec (word to vector, a word vector model), context2vec (context embedded word vector model), and the like.
In one possible implementation, before the step 307, the method includes: for any target word, text information in a corpus is queried, a plurality of reference sentences containing the target word are determined, the reference sentences are encoded to obtain a sentence vector of each reference sentence, and the sentence vectors of the reference sentences are aggregated to obtain a word vector of the target word.
When a statement is coded into a statement vector, a sequence coding algorithm can be adopted for coding. For example, the sequence coding algorithm is RNN (Recurrent Neural Network), transforms (a coding model).
After a plurality of reference sentences are determined, the process of obtaining the sentence vector of each reference sentence comprises the following three ways:
in the first way, the reference sentence includes a plurality of words: for any reference statement, each word in the reference statement is encoded to obtain initial word vectors of the words, and the ratio of the sum of the initial word vectors of the words to the number of the words is determined as the statement vector of the reference statement.
Optionally, the statement vector of the reference statement satisfies the following relationship:
Figure BDA0002781089280000121
wherein D ishA sentence vector representing a reference sentence D; n represents the number of words included in the reference sentence D, and n is a positive integer not less than 1; j represents the sequence number of the word in the reference sentence D; c. CjAn initial word vector representing the jth word in the reference sentence D.
In a second way, the reference sentence includes a plurality of words: for any reference statement, each word in the reference statement is encoded to obtain initial word vectors of the words, and the initial word vectors of the words are weighted and summed to obtain the statement vector of the reference statement.
Optionally, the statement vector of the reference statement satisfies the following relationship:
Figure BDA0002781089280000131
Figure BDA0002781089280000132
wherein DhA sentence vector representing a reference sentence D; n represents the number of words included in the reference sentence D, and n is a positive integer not less than 1; j represents the sequence number of the word in the reference sentence D; alpha is alphajRepresenting the weight of the jth word in the reference sentence D; c. CjAn initial word vector representing a jth word in the reference sentence D; waFor adjusting the parameters, the adjusting parameter WaIs a constant; t is used to denote the transpose of the matrix.
The third mode is as follows: for any reference sentence, determining a sentence vector of the reference sentence according to the context relationship of the reference sentence in the text information in the corpus.
Optionally, the statement vector of the reference statement satisfies the following relationship:
Figure BDA0002781089280000133
wherein D ishA sentence vector representing a reference sentence D;
Figure BDA0002781089280000134
a vector representing a sentence preceding the reference sentence D in the text information;
Figure BDA0002781089280000135
a vector representing a sentence following the reference sentence D in the text information.
After determining statement vectors of a plurality of reference statements, the process of performing aggregation processing on the statement vectors of the plurality of reference statements includes the following two ways:
the first mode is as follows: and determining the ratio of the sum of the sentence vectors of the plurality of reference sentences to the number of the plurality of reference sentences as the word vector of the target word.
Optionally, the word vector of the target word and the sentence vector of the reference sentence satisfy the following relationship:
Figure BDA0002781089280000136
wherein x ishA word vector representing a target word x; m (x) represents a set of reference sentences that include the target word x; | m (x) | represents the number of reference sentences including the target word x; dhA sentence vector representing a reference sentence D; MLP (D)h) Expression statement vector DhAnd carrying out the converted statement vector.
The second mode is as follows: and carrying out weighted summation on the sentence vectors of the plurality of reference sentences to obtain the word vector of the target word.
Optionally, the statement vector of the reference statement satisfies the following relationship:
Figure BDA0002781089280000137
Figure BDA0002781089280000138
wherein x ishA word vector representing a target word x; m (x) represents a set of reference sentences that include the target word x; i denotes the sequence number of the reference sentence; | m (x) | represents the number of reference sentences including the target word x; beta is aiRepresents the weight of the ith reference sentence;
Figure BDA0002781089280000141
a sentence vector representing an ith reference sentence; wbFor adjusting the parameters, the adjusting parameter WbIs a constant; t is used to denote the transpose of the matrix.
In one possible implementation, after step 306, the method further includes: and acquiring the relation confidence between the two words in the word database in response to the two words in the word database.
Because the word database comprises a plurality of words and the relation confidence between every two words, if the two words exist in the word database, the relation confidence between the two words in the word database can be directly obtained, and the relation confidence between the two words does not need to be determined by calling a relation determination model.
Optionally, the plurality of words in the word database and the relationship confidence between every two words are correspondingly stored in a matrix form. When the word database comprises two words of which the upper-lower relation is to be determined, the relation confidence coefficient between the two words can be determined according to the matrix in the word database.
It should be noted that, in the embodiment of the present application, a process of first constructing a term database and then determining a relationship determination model trained based on the term database is taken as an example for description, and when determining a relationship confidence between two other terms after constructing the term database, it is not necessary to construct the term database again, and a term to be determined in a top-bottom relationship is directly queried from the constructed term database.
In one possible implementation, after step 307, the method further comprises: and responding to the fact that the relation confidence degrees of the two words are larger than the reference confidence degree, and correspondingly storing the two words in a superior-inferior relation database. The reference confidence is an arbitrary value, for example, the reference confidence is 0.7 or 0.9, and the upper and lower relational database includes words having an upper and lower relationship, and in the upper and lower relational database, a plurality of words are stored correspondingly according to the upper and lower relationship. And when the relation confidence of the two words is greater than the reference confidence, the two words are in the upper-lower relation, and the two words are added into the upper-lower relation database.
By the method provided by the embodiment of the application, the upper and lower relational database can be constructed, words with upper and lower relations are added into the upper and lower relational database, and the upper and lower relational database can be applied to various scenes subsequently.
By taking a text information classification scene as an example, based on the upper and lower relational database provided by the embodiment of the application, the text information can be classified. The text information classification process includes the following steps 3711-3714:
3711. the computer device receives a classification request, wherein the classification request carries target text information.
3712. And the computer equipment extracts the keywords from the target text information to obtain the keywords in the target text information.
3713. The computer device queries the keywords from the context relationship database.
3714. And the computer equipment responds to the upper terms corresponding to the searched keywords, and determines corresponding type labels for the target text information according to the upper terms corresponding to the keywords, so that the text information is recommended to the matched users subsequently according to the type labels of the text information.
Taking a text information classification scene as an example, based on the context relationship database provided by the embodiment of the present application, the related information of the words can be retrieved, so as to improve the accuracy of the retrieved related information, and the information retrieval process includes the following steps 3721-3723:
3721. and the computer equipment receives a retrieval request, wherein the retrieval request carries the target words.
Wherein, the target word is the word to be retrieved.
3722. The computer device queries the target term from the context relationship database.
3723. And the computer equipment responds to the upper terms corresponding to the target terms, and retrieves the information related to the target terms based on the target terms and the corresponding upper terms.
For example, if the target term is "dog" and the higher-level term found in the query is "animal", the information related to the target term is searched for using "dog" and "animal" as search conditions.
And the retrieval is carried out according to the target words to be retrieved and the corresponding upper words through the upper and lower relational database, so that the accuracy of the retrieved information is improved.
In addition, before invoking the relationship determination model, the relationship determination model needs to be trained, and the process of training the relationship determination model includes the following steps 308-:
308. and the computer equipment takes the words in the word database as sample words and takes the relation confidence coefficient between every two sample words as the corresponding supervision value of every two sample words.
Because the word database comprises a plurality of words, each word is used as a sample word, and the relationship confidence between any two words is the relationship confidence between two sample words.
309. The computer equipment calls a relation determination model for any iteration turn in the multiple iteration turns, processes word vectors of any two sample words, and determines the confidence coefficient of the prediction relation between any two sample words.
And the predicted relationship confidence coefficient is the relationship confidence coefficient output by the relationship determination model. This step is similar to step 307 described above and will not be described further herein.
310. And the computer equipment determines the loss value of the relation determination model according to the confidence coefficient of the predicted relation and the supervision values corresponding to any two sample words.
The loss value is used for representing the inaccuracy of the relation determination model, the greater the loss value is, the higher the inaccuracy of the relation determination model is represented, and the smaller the loss value is, the lower the inaccuracy of the relation determination model is represented.
Because the predicted relation confidence coefficient is obtained by calling the relation determination model, and the supervision value is the true relation confidence coefficient between two sample words, the loss value of the relation determination model can be determined through the predicted relation confidence coefficient and the supervision value, so that the parameters of the relation determination model can be adjusted according to the loss value in the following process.
In one possible implementation, this step 310 includes: the square of the difference between the prediction relationship confidence and the supervision value is determined as the loss value.
Optionally, a predicted relationship confidence g (x)h,yh(ii) a Phi), the supervision value f (x, y) and the loss value l (x, y; φ) satisfies the following relationship:
l(x,y;φ)=[g(xh,yh;φ)-f(x,y)]2
wherein x and y represent words respectively; phi represents a model parameter of the relationship determination model; x is the number ofhA word vector representing word x; x is the number ofyA word vector representing word y; g (x)h,yh(ii) a Phi) represents the confidence of the predicted relationship between the word x and the word y; f (x, y) represents the supervised values of the word x and the word y.
311. And the computer equipment adjusts the parameters of the relation determination model according to the loss values.
And adjusting parameters of the relation determination model through the loss value so as to reduce the loss value or make the loss value tend to be stable, and improving the accuracy of the relation determination model.
In one possible implementation, in iteratively training the relationship determination model, in response to the loss value being less than the reference threshold, training the relationship determination model is stopped. The reference threshold is an arbitrary value, and is, for example, 0.3 or 0.2. When the loss value of the relation determination model is smaller than the reference threshold value, the accuracy of the current relation determination model is satisfied, and therefore, the relation determination model is stopped from being trained.
In one possible implementation, in the course of iteratively training the relationship determination model, training of the relationship determination model is stopped in response to the number of iteration rounds reaching the reference number. Wherein the reference number is any number, for example, 10 or 20, etc. When the relationship determination model is subjected to iterative training, if the number of iterative rounds of training the relationship determination model reaches the reference number, the accuracy of the current relationship determination model is satisfied, and therefore training of the relationship determination model is stopped.
It should be noted that, as for the training stopping condition of the relationship determination model, the foregoing two modes are only used as examples in the embodiment of the present application, and the present application does not limit the present application.
It should be noted that, in the embodiment of the present application, the relationship determination model is adjusted through the loss value, and in another embodiment, step 309 and step 311 need not be executed, and other manners can be adopted to perform iterative training on the relationship determination model according to the word vectors of every two sample words and the corresponding supervision values.
In addition, by the method provided by the embodiment of the application, after the relationship determination model is obtained through training, the relationship determination model is processed in a model distillation mode to simplify the relationship determination model, so that the simplified relationship determination model not only ensures the accuracy of the output relationship confidence coefficient, but also improves the processing speed. The simplified relation determination model is deployed on line, so that when the relation confidence coefficient between any two words is determined on line, the processing speed is increased, and the throughput capacity of the on-line system is improved.
In the model distillation of the relationship-determining model, TinyBERT (a model distillation mode), Roberta-Tiny (a Robustly Optimized BERT prediction Approach Tiny, a Robustly Optimized BERT pre-training model distillation mode) can be employed.
According to the method provided by the embodiment of the application, the accuracy of the trained relation determination model is improved through the words and the relation confidence degrees in the word database, and when the relation confidence degrees of the two words are determined, the relation confidence degrees between the two words can be determined by combining the word database and the relation determination model under any condition, so that the accuracy of the relation confidence degrees is ensured.
And the relation determination model is trained by taking a plurality of words in the word database and the relation confidence coefficient between every two words as training samples so as to improve the accuracy of the relation determination model.
And in the training process of the relation determination model, parameters of the relation determination model are adjusted according to the loss value of the relation determination model so as to ensure the accuracy of the trained relation determination model.
Based on the above embodiment, a flow chart for determining the context of a word is provided, as shown in fig. 4, the flow chart includes the following steps 401 and 404:
401. extracting a plurality of pairs of words and the co-occurrence frequency corresponding to each pair of words from text information in a corpus based on a reference grammar condition, determining a plurality of words included in the plurality of pairs of words and the relation confidence between every two words in the plurality of words through the co-occurrence frequency corresponding to the plurality of pairs of words and each pair of words, constructing a word database by the plurality of words and the relation confidence between every two words, and forming a word set 1 by the plurality of words.
402. For all words included in the text information in the corpus, a word set 2 is formed, and the word set 2 includes words in the word set 1.
403. And training the distributed semantic model through a plurality of words in the word database and the relation confidence coefficient between every two words. Based on the trained distributed semantic model, the relationship confidence between other words included in the word set 2 except for the words in the word set 1 can be determined.
Wherein, the distributed semantic model is a relation determination model.
404. After any two words are obtained, if the two words belong to the word set 1, the relation confidence coefficient between the two words can be obtained through the word database. If the word set 1 does not include at least one of the two words, the two words are encoded through a context encoder to obtain word vectors of the two words, and a distributed semantic model is called to process the word vectors of the two words to obtain a relation confidence coefficient between the two words.
Based on the method provided by the embodiment of the application, a context relationship determination method based on template and distributed semantic complementation is provided, a term database is built through a Hearst template, the distributed semantic model is trained based on the built term database, the relationship confidence degree between terms in the term database built through the Hearst template is high in accuracy, but the relationship confidence degree between terms in the term database can only be determined through the term database; the relation confidence coefficient between any two words can be obtained through the distributed semantic model, therefore, the Hearst template and the distributed semantic model are combined through the template and distributed semantic complementation-based superior and inferior relation determining method, complementation is formed between the two modes, a complementary frame is formed, the accuracy of the relation confidence coefficient can be guaranteed through the formed complementary frame, the relation confidence coefficient between any two words can be determined, and the application range of the frame is widened.
As shown in fig. 5, a word pair is extracted from text information in a corpus by a hearts template, and the obtained word pair includes: (bird, animal), (mammal, animal), (cat, mammal), (dog mammal, etc.), and constructing a term database. If the relation confidence between two words (dog, animal) is determined, the relation confidence between the words (dog, animal) can be determined through the word database constructed by the Hearst template; if the two words are not included in the word database when determining the confidence of the relationship between the two words (crocodile, animal), the confidence of the relationship between the two words is determined by the relationship determination model.
Fig. 6 is a schematic structural diagram of an apparatus for determining a context of a word according to an embodiment of the present application, where as shown in fig. 6, the apparatus includes:
a word obtaining module 601, configured to obtain two words;
a term query module 602, configured to query two terms from a term database, where the term database includes a plurality of terms and relationship confidence degrees between every two terms in the plurality of terms;
a first confidence determining module 603, configured to, in response to that the term database does not have at least one of the two terms, invoke a relationship determining model obtained based on the term database training, process word vectors of the two terms, and determine a relationship confidence between the two terms;
where relationship confidence is used to indicate the likelihood that two words have a superior-inferior relationship.
In one possible implementation, as shown in fig. 7, the apparatus further includes:
the word extraction module 604 is configured to perform word extraction on the text information in the corpus to obtain multiple pairs of words and co-occurrence frequencies corresponding to each pair of words;
a word determining module 605, configured to determine, based on the multiple pairs of words and the co-occurrence frequency corresponding to each pair of words, multiple words included in the multiple pairs of words and the co-occurrence frequency corresponding to each two words in the multiple words;
a second confidence determining module 606, configured to determine a relationship confidence between every two terms based on the co-occurrence frequency corresponding to every two terms;
the database construction module 607 is configured to construct a term database based on the plurality of terms and the confidence of the relationship between each two terms.
In another possible implementation, as shown in fig. 7, the word extraction module 604 includes:
a sentence determination unit 6401 for determining a reference sentence satisfying a reference grammar condition indicating a grammar condition satisfied by words having an upper-lower relationship in the text information based on the reference grammar condition;
and the word extraction unit 6402 is configured to perform word extraction on the obtained multiple reference sentences to obtain multiple pairs of words and a co-occurrence frequency corresponding to each pair of words.
In another possible implementation, as shown in fig. 7, the word determining module 605 includes:
a word determining unit 6501 for determining a plurality of words included in the plurality of pairs of words based on the plurality of pairs of words;
a matrix construction unit 6502 configured to construct a co-occurrence frequency matrix based on the plurality of words and the co-occurrence frequency corresponding to each pair of words, where each element in the co-occurrence frequency matrix is used to represent the co-occurrence frequency of two corresponding words;
the matrix decomposition unit 6503 is configured to decompose the co-occurrence frequency matrix, and determine the co-occurrence frequency corresponding to each two terms in the plurality of terms.
In another possible implementation manner, as shown in fig. 7, the apparatus further includes:
the sample determination module 608 is configured to use the words in the word database as sample words, and use the relationship confidence between every two sample words as a supervision value corresponding to every two sample words;
and the model training module 609 is used for performing iterative training on the relation determination model according to the word vectors of every two sample words and the corresponding supervision values.
In another possible implementation, as shown in fig. 7, the model training module 609 includes:
the confidence determining unit 6901 is configured to invoke a relationship determination model for any iteration turn of the multiple iteration turns, process word vectors of any two sample words, and determine a confidence of a prediction relationship between any two sample words;
a loss value determining unit 6902, configured to determine a loss value of the relationship determination model according to the confidence of the predicted relationship and the supervision values corresponding to any two sample words;
a parameter adjusting unit 6903, configured to adjust a parameter of the relationship determination model according to the loss value.
In another possible implementation, the loss value determination unit 6902 is configured to determine a square of a difference between the confidence of the prediction relationship and the supervision value as the loss value.
In another possible implementation manner, as shown in fig. 7, the apparatus further includes:
the word storage module 610 is configured to, in response to that the relationship confidence of the two words is greater than the reference confidence, store the two words in a top-bottom relationship database, where the top-bottom relationship database includes words having a top-bottom relationship.
In another possible implementation manner, as shown in fig. 7, the apparatus further includes:
a first receiving module 611, configured to receive a retrieval request, where the retrieval request carries a target word;
the term query module 602 is further configured to query a target term from the upper-lower relational database;
the retrieving module 612, configured to, in response to querying the upper terms corresponding to the target terms, retrieve information related to the target terms based on the target terms and the corresponding upper terms.
In another possible implementation manner, as shown in fig. 7, the apparatus further includes:
a second receiving module 613, configured to receive a classification request, where the classification request carries target text information;
the keyword extraction module 614 is configured to perform keyword extraction on the target text information to obtain a keyword in the target text information;
the term query module 602 is further configured to query keywords from the top-bottom relational database;
and the tag determining module 615 is configured to determine, in response to the query of the upper terms corresponding to the keywords, corresponding type tags for the target text information according to the upper terms corresponding to the keywords.
It should be noted that: the apparatus for determining the context of words provided in the above embodiments is only illustrated by the division of the above functional modules, and in practical applications, the above functions may be distributed by different functional modules according to needs, that is, the internal structure of the computer device is divided into different functional modules to complete all or part of the above described functions. In addition, the apparatus for determining the upper and lower relationships of words and the method for determining the upper and lower relationships of words provided by the above embodiments belong to the same concept, and specific implementation processes thereof are detailed in the method embodiments and are not described herein again.
The embodiment of the present application further provides a computer device, where the computer device includes a processor and a memory, where the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the operations performed in the method for determining the upper and lower bit relationships of the words in the foregoing embodiment.
Optionally, the computer device is provided as a terminal. Fig. 8 shows a block diagram of a terminal 800 according to an exemplary embodiment of the present application. The terminal 800 may be a portable mobile terminal such as: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III, motion video Experts compression standard Audio Layer 3), an MP4 player (Moving Picture Experts Group Audio Layer IV, motion video Experts compression standard Audio Layer 4), a notebook computer, or a desktop computer. The terminal 800 may also be referred to by other names such as user equipment, portable terminal, laptop terminal, desktop terminal, etc.
The terminal 800 includes: a processor 801 and a memory 802.
The processor 801 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and so forth. The processor 801 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 801 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 801 may be integrated with a GPU (Graphics Processing Unit) which is responsible for rendering and drawing the content required to be displayed by the display screen. In some embodiments, the processor 801 may further include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.
Memory 802 may include one or more computer-readable storage media, which may be non-transitory. Memory 802 may also include high speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments, a non-transitory computer readable storage medium in memory 802 is used to store at least one computer program for execution by processor 801 to implement the context determination method of words provided by method embodiments herein.
In some embodiments, the terminal 800 may further include: a peripheral interface 803 and at least one peripheral. The processor 801, memory 802 and peripheral interface 803 may be connected by bus or signal lines. Various peripheral devices may be connected to peripheral interface 803 by a bus, signal line, or circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 804, a display screen 805, a camera assembly 806, an audio circuit 807, a positioning assembly 808, and a power supply 809.
The peripheral interface 803 may be used to connect at least one peripheral related to I/O (Input/Output) to the processor 801 and the memory 802. In some embodiments, the processor 801, memory 802, and peripheral interface 803 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 801, the memory 802, and the peripheral interface 803 may be implemented on separate chips or circuit boards, which are not limited by this embodiment.
The Radio Frequency circuit 804 is used for receiving and transmitting RF (Radio Frequency) signals, also called electromagnetic signals. The radio frequency circuitry 804 communicates with communication networks and other communication devices via electromagnetic signals. The rf circuit 804 converts an electrical signal into an electromagnetic signal to be transmitted, or converts a received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 804 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and so forth. The radio frequency circuit 804 may communicate with other terminals via at least one wireless communication protocol. The wireless communication protocols include, but are not limited to: the world wide web, metropolitan area networks, intranets, generations of mobile communication networks (2G, 3G, 4G, and 5G), Wireless local area networks, and/or WiFi (Wireless Fidelity) networks. In some embodiments, the radio frequency circuit 804 may further include NFC (Near Field Communication) related circuits, which are not limited in this application.
The display screen 805 is used to display a UI (User Interface). The UI may include graphics, text, icons, video, and any combination thereof. When the display 805 is a touch display, the display 805 also has the ability to capture touch signals on or above the surface of the display 805. The touch signal may be input to the processor 801 as a control signal for processing. At this point, the display 805 may also be used to provide virtual buttons and/or a virtual keyboard, also referred to as soft buttons and/or a soft keyboard. In some embodiments, the display 805 may be one, disposed on a front panel of the terminal 800; in other embodiments, the display 805 may be at least two, respectively disposed on different surfaces of the terminal 800 or in a folded design; in other embodiments, the display 805 may be a flexible display disposed on a curved surface or a folded surface of the terminal 800. Even further, the display 805 may be arranged in a non-rectangular irregular pattern, i.e., a shaped screen. The Display 805 can be made of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), and other materials.
The camera assembly 806 is used to capture images or video. Optionally, camera assembly 806 includes a front camera and a rear camera. The front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, the number of the rear cameras is at least two, and each rear camera is any one of a main camera, a depth-of-field camera, a wide-angle camera and a telephoto camera, so that the main camera and the depth-of-field camera are fused to realize a background blurring function, and the main camera and the wide-angle camera are fused to realize panoramic shooting and VR (Virtual Reality) shooting functions or other fusion shooting functions. In some embodiments, camera assembly 806 may also include a flash. The flash lamp can be a monochrome temperature flash lamp or a bicolor temperature flash lamp. The double-color-temperature flash lamp is a combination of a warm-light flash lamp and a cold-light flash lamp, and can be used for light compensation at different color temperatures.
The audio circuit 807 may include a microphone and a speaker. The microphone is used for collecting sound waves of a user and the environment, converting the sound waves into electric signals, and inputting the electric signals to the processor 801 for processing or inputting the electric signals to the radio frequency circuit 804 to realize voice communication. For the purpose of stereo sound collection or noise reduction, a plurality of microphones may be provided at different portions of the terminal 800. The microphone may also be an array microphone or an omni-directional pick-up microphone. The speaker is used to convert electrical signals from the processor 801 or the radio frequency circuit 804 into sound waves. The loudspeaker can be a traditional film loudspeaker or a piezoelectric ceramic loudspeaker. When the speaker is a piezoelectric ceramic speaker, the speaker can be used for purposes such as converting an electric signal into a sound wave audible to a human being, or converting an electric signal into a sound wave inaudible to a human being to measure a distance. In some embodiments, the audio circuitry 807 may also include a headphone jack.
The positioning component 808 is used to locate the current geographic position of the terminal 800 for navigation or LBS (Location Based Service). The Positioning component 808 may be a Positioning component based on the Global Positioning System (GPS) in the united states, the beidou System in china, or the galileo System in russia.
Power supply 809 is used to provide power to various components in terminal 800. The power supply 809 can be ac, dc, disposable or rechargeable. When the power supply 809 includes a rechargeable battery, the rechargeable battery may be a wired rechargeable battery or a wireless rechargeable battery. The wired rechargeable battery is a battery charged through a wired line, and the wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery may also be used to support fast charge technology.
In some embodiments, terminal 800 also includes one or more sensors 810. The one or more sensors 810 include, but are not limited to: acceleration sensor 811, gyro sensor 812, pressure sensor 813, fingerprint sensor 814, optical sensor 815 and proximity sensor 816.
The acceleration sensor 811 may detect the magnitude of acceleration in three coordinate axes of the coordinate system established with the terminal 800. For example, the acceleration sensor 811 may be used to detect the components of the gravitational acceleration in three coordinate axes. The processor 801 may control the display 805 to display the user interface in a landscape view or a portrait view according to the gravitational acceleration signal collected by the acceleration sensor 811. The acceleration sensor 811 may also be used for acquisition of motion data of a game or a user.
The gyro sensor 812 may detect a body direction and a rotation angle of the terminal 800, and the gyro sensor 812 may cooperate with the acceleration sensor 811 to acquire a 3D motion of the user with respect to the terminal 800. From the data collected by the gyro sensor 812, the processor 801 may implement the following functions: motion sensing (such as changing the UI according to a user's tilting operation), image stabilization at the time of photographing, game control, and inertial navigation.
Pressure sensors 813 may be disposed on the side frames of terminal 800 and/or underneath display 805. When the pressure sensor 813 is disposed on the side frame of the terminal 800, the holding signal of the user to the terminal 800 can be detected, and the processor 801 performs left-right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor 813. When the pressure sensor 813 is disposed at a lower layer of the display screen 805, the processor 801 controls the operability control on the UI interface according to the pressure operation of the user on the display screen 805. The operability control comprises at least one of a button control, a scroll bar control, an icon control and a menu control.
The fingerprint sensor 814 is used for collecting a fingerprint of the user, and the processor 801 identifies the identity of the user according to the fingerprint collected by the fingerprint sensor 814, or the fingerprint sensor 814 identifies the identity of the user according to the collected fingerprint. Upon identifying that the user's identity is a trusted identity, the processor 801 authorizes the user to perform relevant sensitive operations including unlocking a screen, viewing encrypted information, downloading software, paying for and changing settings, etc. Fingerprint sensor 814 may be disposed on the front, back, or side of terminal 800. When a physical button or a vendor Logo is provided on the terminal 800, the fingerprint sensor 814 may be integrated with the physical button or the vendor Logo.
The optical sensor 815 is used to collect the ambient light intensity. In one embodiment, processor 801 may control the display brightness of display 805 based on the ambient light intensity collected by optical sensor 815. Specifically, when the ambient light intensity is high, the display brightness of the display screen 805 is increased; when the ambient light intensity is low, the display brightness of the display 805 is reduced. In another embodiment, the processor 801 may also dynamically adjust the shooting parameters of the camera assembly 806 based on the ambient light intensity collected by the optical sensor 815.
A proximity sensor 816, also called a distance sensor, is provided on the front panel of the terminal 800. The proximity sensor 816 is used to collect the distance between the user and the front surface of the terminal 800. In one embodiment, when the proximity sensor 816 detects that the distance between the user and the front surface of the terminal 800 gradually decreases, the processor 801 controls the display 805 to switch from the bright screen state to the dark screen state; when the proximity sensor 816 detects that the distance between the user and the front surface of the terminal 800 becomes gradually larger, the display 805 is controlled by the processor 801 to switch from the breath-screen state to the bright-screen state.
Those skilled in the art will appreciate that the configuration shown in fig. 8 is not intended to be limiting of terminal 800 and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components may be used.
Optionally, the computer device is provided as a server. Fig. 9 is a schematic structural diagram of a server provided in this embodiment of the present application, where the server 900 may generate relatively large differences due to different configurations or performances, and may include one or more processors (CPUs) 901 and one or more memories 902, where the memory 902 stores at least one computer program, and the at least one computer program is loaded and executed by the processors 901 to implement the methods provided by the foregoing method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input/output interface, so as to perform input/output, and the server may also include other components for implementing the functions of the device, which are not described herein again.
The embodiments of the present application also provide a computer-readable storage medium, where at least one computer program is stored, and the at least one computer program is loaded and executed by a processor to implement the operations performed in the method for determining a context of a word in the foregoing embodiments.
Embodiments of the present application also provide a computer program product or a computer program comprising computer program code stored in a computer readable storage medium. The processor of the computer apparatus reads the computer program code from the computer-readable storage medium, and the processor executes the computer program code, so that the computer apparatus realizes the operations performed in the context determination method of the words of the above-described embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only an alternative embodiment of the present application and should not be construed as limiting the present application, and any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (15)

1. A method for determining the context of a word, the method comprising:
acquiring two words;
querying the two terms from a term database, wherein the term database comprises a plurality of terms and the relationship confidence between every two terms in the plurality of terms;
in response to the fact that at least one of the two words does not exist in the word database, calling a relation determination model obtained based on the training of the word database, processing word vectors of the two words, and determining a relation confidence coefficient between the two words;
wherein the relationship confidence is used to represent a likelihood that the two words have a superior-inferior relationship.
2. The method of claim 1, wherein prior to said querying said two terms from a term database, said method further comprises:
extracting words from the text information in the corpus to obtain a plurality of pairs of words and the co-occurrence frequency corresponding to each pair of words;
determining a plurality of words included in the plurality of pairs of words and co-occurrence frequencies corresponding to every two words in the plurality of words based on the plurality of pairs of words and the co-occurrence frequencies corresponding to each pair of words;
determining a relation confidence degree between every two words based on the co-occurrence frequency corresponding to every two words;
and constructing the word database based on the plurality of words and the relationship confidence degrees between every two words.
3. The method of claim 2, wherein extracting words from the text information in the corpus to obtain a plurality of pairs of words and co-occurrence frequencies corresponding to each pair of words comprises:
determining a reference sentence which meets a reference grammar condition in the text information based on the reference grammar condition, wherein the reference grammar condition is used for indicating the grammar condition which is met by the words with the upper-lower relation;
and extracting words from the obtained reference sentences to obtain the pairs of words and the co-occurrence frequency corresponding to each pair of words.
4. The method of claim 2, wherein the determining a plurality of words included in the plurality of pairs of words and a co-occurrence frequency for each two words of the plurality of words based on the co-occurrence frequencies corresponding to the plurality of pairs of words and each pair of words comprises:
determining, based on the plurality of pairs of words, a plurality of words included in the plurality of pairs of words;
constructing a co-occurrence frequency matrix based on the plurality of words and the co-occurrence frequency corresponding to each pair of words, wherein each element in the co-occurrence frequency matrix is used for representing the co-occurrence frequency of two corresponding words;
and decomposing the co-occurrence frequency matrix, and determining the co-occurrence frequency corresponding to every two terms in the plurality of terms.
5. The method of claim 1, wherein in response to the phrase database not having at least one of the two words, invoking a relationship determination model trained based on the phrase database, processing word vectors of the two words, and before determining a confidence of the relationship between the two words, the method further comprises:
taking the words in the word database as sample words, and taking the relation confidence degree between every two sample words as the corresponding supervision value of every two sample words;
and performing iterative training on the relation determination model according to the word vectors of every two sample words and the corresponding supervision values.
6. The method of claim 5, wherein iteratively training the relationship determination model based on the word vectors for each two sample words and corresponding supervised values comprises:
for any iteration turn in a plurality of iteration turns, calling the relationship determination model, processing word vectors of any two sample words, and determining the confidence coefficient of the prediction relationship between any two sample words;
determining a loss value of the relation determination model according to the confidence coefficient of the predicted relation and the supervision values corresponding to the any two sample words;
and adjusting parameters of the relation determination model according to the loss value.
7. The method of claim 6, wherein determining a loss value of the relationship determination model based on the predicted relationship confidence and the supervised values corresponding to the any two sample words comprises:
determining a square of a difference between the predicted relationship confidence and the supervised value as the loss value.
8. The method of claim 1, wherein in response to the word database not having at least one of the two words, invoking a relationship determination model trained based on the word database, processing word vectors of the two words, and after determining a relationship confidence between the two words, the method further comprises:
and responding to the relationship confidence degree of the two words being larger than the reference confidence degree, and correspondingly storing the two words in an upper and lower level relationship database, wherein the upper and lower level relationship database comprises words with upper and lower level relationship.
9. The method of claim 8, further comprising:
receiving a retrieval request, wherein the retrieval request carries a target word;
querying the target term from the upper and lower relational databases;
and responding to the upper terms corresponding to the target terms, and retrieving information related to the target terms based on the target terms and the corresponding upper terms.
10. The method of claim 8, further comprising:
receiving a classification request, wherein the classification request carries target text information;
extracting keywords from the target text information to obtain keywords in the target text information;
querying the keywords from the upper and lower relational databases;
and responding to the upper terms corresponding to the keywords, and determining corresponding type labels for the target text information according to the upper terms corresponding to the keywords.
11. An apparatus for determining a superior-inferior relation of words, the apparatus comprising:
the word acquisition module is used for acquiring two words;
the term query module is used for querying the two terms from a term database, and the term database comprises a plurality of terms and the relationship confidence degrees between every two terms in the plurality of terms;
the first confidence coefficient determining module is used for responding to the fact that at least one word in the two words does not exist in the word database, calling a relation determining model obtained based on the training of the word database, processing word vectors of the two words and determining the relation confidence coefficient between the two words;
wherein the relationship confidence is used to represent a likelihood that the two words have a superior-inferior relationship.
12. The apparatus of claim 11, further comprising:
the word extraction module is used for extracting words from the text information in the corpus to obtain a plurality of pairs of words and the co-occurrence frequency corresponding to each pair of words;
a word determining module, configured to determine, based on the plurality of pairs of words and the co-occurrence frequency corresponding to each pair of words, a plurality of words included in the plurality of pairs of words and the co-occurrence frequency corresponding to each two words in the plurality of words;
the second confidence coefficient determining module is used for determining the relation confidence coefficient between every two terms based on the co-occurrence frequency corresponding to every two terms;
and the database construction module is used for constructing the word database based on the plurality of words and the relationship confidence degrees between every two words.
13. The apparatus of claim 12, wherein the term extraction module comprises:
a sentence determination unit configured to determine a reference sentence in the text information, which satisfies a reference grammar condition indicating a grammar condition satisfied by words having an upper-lower relationship, based on the reference grammar condition;
and the word extraction unit is used for carrying out word extraction on the obtained multiple reference sentences to obtain the multiple pairs of words and the co-occurrence frequency corresponding to each pair of words.
14. A computer device comprising a processor and a memory, wherein at least one computer program is stored in the memory, and wherein the at least one computer program is loaded and executed by the processor to perform the operations performed in the method for determining a context of a word as claimed in any one of claims 1 to 10.
15. A computer-readable storage medium, having at least one computer program stored therein, which is loaded and executed by a processor to perform the operations performed in the method for determining a context of a word according to any one of claims 1 to 10.
CN202011281974.3A 2020-11-16 2020-11-16 Method and device for determining upper and lower position relation of words, computer equipment and medium Pending CN112287070A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011281974.3A CN112287070A (en) 2020-11-16 2020-11-16 Method and device for determining upper and lower position relation of words, computer equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011281974.3A CN112287070A (en) 2020-11-16 2020-11-16 Method and device for determining upper and lower position relation of words, computer equipment and medium

Publications (1)

Publication Number Publication Date
CN112287070A true CN112287070A (en) 2021-01-29

Family

ID=74399126

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011281974.3A Pending CN112287070A (en) 2020-11-16 2020-11-16 Method and device for determining upper and lower position relation of words, computer equipment and medium

Country Status (1)

Country Link
CN (1) CN112287070A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113010740A (en) * 2021-03-09 2021-06-22 腾讯科技(深圳)有限公司 Word weight generation method, device, equipment and medium
CN116306622A (en) * 2023-05-25 2023-06-23 环球数科集团有限公司 AIGC comment system for improving public opinion atmosphere

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113010740A (en) * 2021-03-09 2021-06-22 腾讯科技(深圳)有限公司 Word weight generation method, device, equipment and medium
CN113010740B (en) * 2021-03-09 2023-05-30 腾讯科技(深圳)有限公司 Word weight generation method, device, equipment and medium
CN116306622A (en) * 2023-05-25 2023-06-23 环球数科集团有限公司 AIGC comment system for improving public opinion atmosphere

Similar Documents

Publication Publication Date Title
CN111489378B (en) Video frame feature extraction method and device, computer equipment and storage medium
CN111930964B (en) Content processing method, device, equipment and storage medium
CN110162604B (en) Statement generation method, device, equipment and storage medium
CN112733970B (en) Image classification model processing method, image classification method and device
CN113515942A (en) Text processing method and device, computer equipment and storage medium
CN112749728A (en) Student model training method and device, computer equipment and storage medium
CN111209377B (en) Text processing method, device, equipment and medium based on deep learning
CN111324699A (en) Semantic matching method and device, electronic equipment and storage medium
CN111581958A (en) Conversation state determining method and device, computer equipment and storage medium
CN114281956A (en) Text processing method and device, computer equipment and storage medium
CN110555102A (en) media title recognition method, device and storage medium
CN110942046A (en) Image retrieval method, device, equipment and storage medium
CN111753498A (en) Text processing method, device, equipment and storage medium
CN111507094B (en) Text processing model training method, device and equipment based on deep learning
CN112287070A (en) Method and device for determining upper and lower position relation of words, computer equipment and medium
CN114281936A (en) Classification method and device, computer equipment and storage medium
CN112035671A (en) State detection method and device, computer equipment and storage medium
CN112988984B (en) Feature acquisition method and device, computer equipment and storage medium
CN113486260B (en) Method and device for generating interactive information, computer equipment and storage medium
CN111597823B (en) Method, device, equipment and storage medium for extracting center word
CN114328815A (en) Text mapping model processing method and device, computer equipment and storage medium
CN112070586B (en) Item recommendation method and device based on semantic recognition, computer equipment and medium
CN114281937A (en) Training method of nested entity recognition model, and nested entity recognition method and device
CN113569042A (en) Text information classification method and device, computer equipment and storage medium
CN114925667A (en) Content classification method, device, equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40037362

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination