Sentence vector determination method and device, equipment and medium
Through natural language model and pooling processing of generated sentence vectors, the problem of low accuracy in sentence vector extraction in the prior art is solved, and more accurate and robust text representation is achieved, which is suitable for diverse text applications.
Patent Information
- Application Number
- CN202411362647.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-01-03
AI Technical Summary
The existing sentence vector extraction method is difficult to fully consider the grammatical structure, word order information and context of the sentence, resulting in the generated vectors that may lose key semantic information and cannot accurately distinguish subtle semantic differences.
The natural language model is used to convert word segmentation vectors, generate candidate sentence vectors through bidirectional and vertical pooling processing, and calculate dynamic weights using a full connection matrix and normalization function. Combined with the vertical pooling processing of identifying word segmentation, the target sentence vector is generated.
It realizes the information fusion from word level to sentence level, and the generated sentence vectors are more accurate, which can better represent the semantic and contextual relationship of text content, improves the accuracy and robustness of the representation, and is suitable for diverse text applications. Scene.
Smart Images

Figure CN119250062A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method, device, equipment and medium for determining a sentence vector. Background Art
[0002] The sentence vector extraction method of text can transform the complexity and richness of human language into a numerical representation that computers can understand and process. In practical applications, the quality of sentence vectors directly affects the performance of downstream tasks. For example, when building a medical question-answering system, it is necessary to convert the user's questions and the answers in the system into vectors in order to find the most relevant answers by calculating the similarity between vectors. For another example, when analyzing financial texts (such as news reports, company announcements, social media public opinion, etc.), the generation of sentence vectors can help identify risk signals or positive factors in the text.
[0003] Existing sentence vector determination methods often fail to fully consider multiple dimensions of a sentence, such as its grammatical structure, word order information, and context. This results in the generated vectors possibly losing key semantic information and failing to accurately distinguish subtle semantic differences. Therefore, how to extract highly accurate sentence vectors has become a key issue that needs to be solved in sentence vector research. Summary of the invention
[0004] The purpose of the embodiments of the present application is to propose a method, device, equipment and medium for determining a sentence vector to solve the problem of low accuracy in sentence vector extraction of existing texts.
[0005] In order to solve the above technical problems, the embodiment of the present application provides a method for determining a sentence vector, which adopts the following technical solution:
[0006] Acquire multiple word segmentations of a target text, wherein the multiple word segmentations include an identification word segmentation and multiple target word segmentations; use a preset natural language model to perform vector conversion on the identification word segmentation and the multiple target word segmentations, respectively, to obtain multiple identification word vectors corresponding to the identification word segmentation, and to obtain multiple word vectors corresponding to each target word segmentation, wherein the natural language model includes multiple network layers, and each word vector and each identification word vector are outputted by each network layer; perform bidirectional pooling on the multiple word vectors to obtain candidate sentence vectors representing the multiple target word segmentations, and perform longitudinal pooling on the multiple identification word vectors to obtain identification sentence vectors representing the identification word segmentations; use a preset fully connected matrix and a preset normalization function to calculate the target weights of the candidate sentence vectors, and to calculate the identification weights of the identification sentence vectors; obtain the target sentence vector of the target text based on the candidate sentence vectors, the target weights, the identification sentence vectors, and the identification weights.
[0007] Furthermore, the steps of performing bidirectional pooling on multiple word vectors to obtain candidate sentence vectors representing multiple target word segments specifically include:
[0008] Based on multiple network layers and each target word segmentation, multiple word vectors are divided to obtain multiple word vector sets, each of which includes word vectors corresponding to multiple target word segmentations output by the same network layer; the word vectors of each word vector set are pooled horizontally to obtain the initial sentence vector corresponding to each word vector set; the initial sentence vectors are pooled vertically to obtain candidate sentence vectors representing multiple target word segmentations.
[0009] Furthermore, the word vectors of each word vector set are horizontally pooled to obtain the initial sentence vector corresponding to each word vector set, specifically including:
[0010] The numerical values corresponding to the word vectors in each word vector set are sorted to obtain a sorted first word segmentation value set; the weight corresponding to each numerical value in the first word segmentation set is calculated using a fully connected matrix and a normalization function to obtain multiple first weight values; each numerical value in the first word segmentation set is merged with the multiple first weight values to obtain an initial sentence vector corresponding to each word vector set.
[0011] Furthermore, the initial sentence vector is vertically pooled to obtain candidate sentence vectors representing multiple target word segments, specifically including:
[0012] The numerical values corresponding to the initial sentence vectors are sorted to obtain a sorted second word segmentation value set; the weight corresponding to each numerical value in the second word segmentation value set is calculated using a fully connected matrix and a normalization function to obtain multiple second weight values; each numerical value in the second word segmentation value set is fused with the multiple second weight values to obtain a candidate sentence vector representing multiple target word segments.
[0013] Furthermore, the steps of performing vertical pooling on multiple identification word vectors to obtain identification sentence vectors representing identification word segments specifically include:
[0014] The numerical values corresponding to multiple identification word vectors are sorted to obtain a sorted identification word segmentation value set; the weight corresponding to each numerical value in the identification word segmentation value set is calculated using the fully connected matrix and the normalization function to obtain the identification weight value; each numerical value in the identification word segmentation value set is merged with the identification weight value to obtain an identification sentence vector representing the identification word segmentation.
[0015] Further, the steps of respectively calculating the target weights of the candidate sentence vectors and the identification weights of the identification sentence vectors using a preset fully connected matrix and a preset normalization function specifically include:
[0016] The product of the candidate sentence vector and the weight of the preset fully connected matrix is calculated to obtain the first original weight of the candidate sentence vector; the first original weight is normalized by using a preset normalization function to obtain the target weight of the candidate sentence vector; the product of the identification sentence vector and the weight of the preset fully connected matrix is calculated to obtain the second original weight of the identification sentence vector; the second original weight is normalized by using a preset normalization function to obtain the identification weight of the identification sentence vector.
[0017] Further, the step of obtaining the target sentence vector of the target text based on the candidate sentence vector, the target weight, the identification sentence vector and the identification weight specifically includes:
[0018] The candidate sentence vector, target weight, identification sentence vector and identification weight are weighted summed to obtain the target sentence vector of the target text.
[0019] In order to solve the above technical problems, the embodiment of the present application further provides a device for determining a sentence vector, which adopts the following technical solution:
[0020] A word segmentation acquisition module, which acquires multiple word segments of a target text, wherein the multiple word segments include an identification word segmentation and multiple target word segmentations;
[0021] A vector conversion module is used to use a preset natural language model to perform vector conversion on the identification word and multiple target word segments respectively, to obtain multiple identification word vectors corresponding to the identification word segment, and to obtain multiple word vectors corresponding to each target word segment. The natural language model includes multiple network layers, and each word vector and each identification word vector are outputted by each network layer.
[0022] The pooling module is used to perform bidirectional pooling on multiple word vectors to obtain candidate sentence vectors representing multiple target word segments, and to perform vertical pooling on multiple identifier word vectors to obtain identifier sentence vectors representing identifier word segments;
[0023] A weight calculation module, used to calculate the target weight of the candidate sentence vector and the identification weight of the identification sentence vector using a preset fully connected matrix and a preset normalization function;
[0024] The vector obtaining module is used to obtain the target sentence vector of the target text based on the candidate sentence vector, the target weight, the identification sentence vector and the identification weight.
[0025] In order to solve the above technical problems, an embodiment of the present application further provides a computer device, including a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the method for determining the sentence vector as described above are implemented.
[0026] In order to solve the above technical problems, an embodiment of the present application also provides a computer-readable storage medium, which stores computer-readable instructions. The computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the method for determining the sentence vector as described above.
[0027] Compared with the prior art, the embodiment of the present application mainly has the following beneficial effects: by performing bidirectional pooling on multiple word segmentation and its corresponding sentence vector, such as horizontal pooling and vertical pooling, the scheme realizes information fusion from word level to sentence level. This multi-granular information processing method helps to more comprehensively and accurately represent the text content, avoiding the one-sidedness that may be caused by single granular information. By assigning dynamic weights to candidate sentence vectors and identification sentence vectors through a fully connected matrix and a normalization function, the scheme can automatically adjust the contribution of each sentence vector based on the characteristics of the data itself. This dynamic weight allocation mechanism makes the final target sentence vector more focused on the key information in the text, improving the accuracy of the representation. Introducing identification segmentation as part of the text representation, and obtaining its identification sentence vector through specific processing, such as vertical pooling, helps to improve the model's understanding and grasp of the overall structure of the text. This design makes the model more robust when facing different forms of text input, and can better adapt to a variety of application scenarios. Since the scheme can generate highly representative target sentence vectors, it can show superior performance in various tasks based on text representation, such as text classification, sentiment analysis, semantic similarity calculation, etc. These high-performance representation vectors (e.g., target sentence vectors) can serve as important inputs for downstream tasks, further promoting the development and application of related tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0029] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0030] Figure 2 It is a flowchart of a method for determining a sentence vector provided by this application;
[0031] Figure 3 It is a structural schematic diagram of a sentence vector determination device provided by the present application;
[0032] Figure 4 It is a structural schematic diagram of a computer device provided by this application. DETAILED DESCRIPTION
[0033] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0034] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0035] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0036] like Figure 1 As shown, the system architecture 100 may include a terminal device 101, a network 102 and a server 103. The terminal device 101 may be a laptop 1011, a tablet computer 1012 or a mobile phone 1013. The network 102 is used to provide a medium for a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables.
[0037] The user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0038] The terminal device 101 can be any electronic device with a display screen and supporting web browsing. In addition to a laptop computer 1011, a tablet computer 1012 or a mobile phone 1013, the terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV), a laptop computer, a desktop computer, etc.
[0039] The server 103 may be a server that provides various services, such as a background server that provides support for a web page displayed on the terminal device 101 .
[0040] It should be noted that the method for determining the sentence vector provided in the embodiment of the present application is generally executed by a server, and accordingly, the device for determining the sentence vector is generally arranged in the server.
[0041] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0042] Continue to refer Figure 2 , shows a flow chart of an embodiment of a method for determining a sentence vector according to the present application. The method for determining a sentence vector comprises the following steps:
[0043] Step S201, obtaining multiple word segments of a target text, wherein the multiple word segments include an identification word segment and multiple target word segment segments.
[0044] In this embodiment, the method for determining a sentence vector is executed on an electronic device (e.g. Figure 1 The server shown in the figure) can obtain the target text through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.
[0045] Among them, the target text refers to the raw data or content that is input into the preset natural language model for processing and analysis to extract multiple identification sentence vectors and multiple sentence vectors. These texts can be any form of natural language text (such as news reports, social media posts, blog posts, emails, academic papers, etc.), dialogue text (such as chat records, customer service conversations, interview records, etc.), question-and-answer text (such as questions and corresponding answers. When processing a question-and-answer system, questions and answers can be used as text inputs to generate their own representations and further used for matching or reasoning), and texts in professional fields (such as medical literature, legal documents, technical manuals, etc.).
[0046] The target word segmentation refers to the vocabulary unit obtained after the text is processed by the word segmenter. The word segmenter can split the text into a series of vocabulary units according to a predefined vocabulary or rules.
[0047] Among them, the identification word segmentation refers to a special word segmentation, which is usually used in natural language models to indicate the beginning of the entire input sequence or a special marker for a classification task. For example, the label word segmentation can be a label word segmentation (classification, cls). In natural language models such as BERT, cls is a special word element (token) that is located at the first position of the input sequence and is used to represent the summary information of the entire input sequence or the identification of the classification task, which enables the BERT model to clearly know the starting position of the input sequence.
[0048] Step S202, using a preset natural language model, respectively converts the identification word and multiple target word segments into vectors to obtain multiple identification word vectors corresponding to the identification word and multiple word vectors corresponding to each target word segment.
[0049] The natural language model includes multiple network layers, and each word vector and each identification word vector are outputted by each network layer. The natural language module may be a BERT model, and the network layer may be a network layer of a transformer structure.
[0050] Vector conversion refers to the process of converting target text (such as words, phrases or sentences) into numerical vectors. These numerical vectors can be understood and processed by computers and machine learning models to perform various NLP tasks such as text classification, sentiment analysis, named entity recognition, etc.
[0051] In an example, the target text is S, and the natural language model is a BERT model with L layers of transformer structure (the network layer is a transformer structure). Assume that the target text S has a total of N words (S1, S2, ..., S N), input these N words into a BERT model with an L-layer transformer structure. The output of each layer is the sentence vector corresponding to each target word segmentation and the identification vector corresponding to the identification word segmentation. The first word s1 of BERT is a special label [cls], which can also represent the sentence vector of the entire sentence. The word vectors of all layers can be extracted, that is, for the same word, such as s2, there will be L word vectors, each word vector comes from a different L layer.
[0052] Step S203, bidirectionally pooling is performed on multiple word vectors to obtain candidate sentence vectors representing multiple target word segments, and vertically pooling is performed on multiple identification word vectors to obtain identification sentence vectors representing identification word segments.
[0053] Among them, bidirectional pooling includes horizontal adaptive pooling and vertical adaptive pooling.
[0054] In one example, continuing from the previous example, the process of performing horizontal pooling on multiple word vectors may include the following steps: N , 512 is the word vector dimension of each word N) Sort the values of each column, and input each row of the sorted matrix into a fully connected matrix with a normalization function, such as a softmax activation function. This fully connected matrix will output a weight value θ for each value in a row. After obtaining the weight θ of each value, multiply each value with the corresponding θ to obtain a vector u after multiplication with the weight. Because there are N such u, add all u in the column direction to finally obtain a vector Vobj.
[0055] Vertical adaptive pooling for multiple word vectors can include the following steps: after horizontal adaptive pooling, there are L vectors Vobj, that is, an L*512 matrix (L is the number of layers, 512 is the dimension of each layer of vectors). Similarly, the values of each column of the L*512 matrix are sorted, and each row of the sorted matrix is input into a fully connected matrix with a normalization function, such as a softmax activation function. This fully connected matrix will output a weight value for each value in a row, and this weight is multiplied by each value and then added in the column direction to finally obtain a vector Vt for the word.
[0056] The vertical pooling for multiple identifier word vectors may include the following steps: Since each network layer only outputs one identifier word vector, the calculation process is the same as the vertical adaptive pooling described above. There are L identifier word vectors ([cls] vectors), that is, an L*512 matrix (L is the number of layers, 512 is the dimension of each layer of [cls] vectors). Similarly, the values of each column of the L*512 matrix are sorted, and each row of the sorted matrix is input into a fully connected matrix with a softmax activation function. This fully connected matrix will output a weight value for each value in a row, and this weight is multiplied by each value and then added in the column direction, and finally a vector Vc for [cls] is obtained, that is, the identifier sentence vector representing the identifier word segmentation is obtained.
[0057] Step S204, using a preset fully connected matrix and a preset normalization function, respectively calculate the target weight of the candidate sentence vector and calculate the identification weight of the identification sentence vector.
[0058] The target weight refers to the weight obtained after the candidate sentence vector is processed in the fully connected matrix and normalized by a function such as the softmax function. This weight reflects the relative importance and influence of the candidate sentence vector in the current task or context. The softmax function ensures that the sum of all output weights is 1, so the target weight can be interpreted as the relative importance assigned to the target weight among all possible vectors.
[0059] Among them, the identification weight refers to the weight of the identification sentence vector after being processed by the fully connected matrix and passed through the softmax function. This weight also reflects the relative importance or influence of the identification sentence vector in the current task or context. Like the target weight, the identification weight is also obtained after being processed by the softmax function, ensuring that the sum of all output weights is 1.
[0060] In one example, the two sets of vector candidate sentence vectors and identification sentence vectors can be input into a 512*2 fully connected matrix, and then passed through a softmax function to obtain the weight target weight and identification weight for the two vectors, the candidate sentence vector and the identification sentence vector.
[0061] Step S205, obtaining a target sentence vector of the target text based on the candidate sentence vector, the target weight, the identification sentence vector and the identification weight.
[0062] Among them, the target sentence vector refers to a vector that can comprehensively and effectively represent the semantic information and contextual relationship of the entire text.
[0063] In one example, the product between the candidate sentence vector and the target weight, the product between the identification sentence vector and the identification weight can be calculated, and then the two products are added together to obtain the final target sentence vector.
[0064] In one example, when a medical question-and-answer system receives a query text input by a user, for example, when a user inputs the text "I have been coughing recently and have a fever. What disease could it be?", the query text can be segmented using the BERT model's word segmenter to obtain an identification word segmentation and multiple target word segmentations. Then, the identification word segmentation and multiple target word segmentations are vectorized using the BERT model to obtain multiple identification word vectors corresponding to the identification word segmentation, and multiple word vectors corresponding to each target word segmentation. Then, multiple word vectors are horizontally pooled and vertically pooled to obtain candidate sentence vectors representing multiple target word segmentations. Multiple identification word vectors are vertically pooled to obtain identification sentence vectors representing identification word segmentations. Using a preset fully connected matrix and normalization function, the target weight of the candidate sentence vector is calculated, and the identification weight of the identification sentence vector is calculated. Then, the candidate sentence vector, the target weight, the identification sentence vector, and the identification weight are weighted and summed to obtain the target sentence vector of the target text.
[0065] In one example, in the field of financial text analysis, financial-related text data is collected from multiple sources (such as news websites, company announcement boards, social media platforms, etc.). These data may include company performance reports, market trend analysis, policy change interpretations, and investor emotional expressions. The collected financial-related text data can be segmented using the word segmenter of the BERT model to obtain identification segmentations and multiple target segmentations. Then, the identification segmentation and multiple target segmentations are vectorized using the BERT model to obtain multiple identification word vectors corresponding to the identification segmentation, and multiple word vectors corresponding to each target segmentation. Then, multiple word vectors are horizontally pooled and vertically pooled to obtain candidate sentence vectors representing multiple target segmentations. Multiple identification word vectors are vertically pooled to obtain identification sentence vectors representing identification segmentations. Using a preset fully connected matrix and normalization function, the target weight of the candidate sentence vector is calculated, and the identification weight of the identification sentence vector is calculated. Then, the candidate sentence vector, the target weight, the identification sentence vector, and the identification weight are weighted and summed to obtain the target sentence vector of the target text.
[0066] The embodiment of the present application can realize information fusion from word level to sentence level by bidirectional pooling of multiple word segmentation and its corresponding sentence vector, such as horizontal pooling and vertical pooling. This multi-granular information processing method helps to characterize the text content more comprehensively and accurately, avoiding the one-sidedness that may be caused by single granular information. By assigning dynamic weights to candidate sentence vectors and identification sentence vectors through a fully connected matrix and a normalization function, the scheme can automatically adjust the contribution of each sentence vector based on the characteristics of the data itself. This dynamic weight allocation mechanism makes the final target sentence vector more focused on the key information in the text, improving the accuracy of the representation. Introducing identification word segmentation as part of the text representation, and obtaining its identification sentence vector through specific processing, such as vertical pooling, helps to improve the model's understanding and grasp of the overall structure of the text. This design makes the model more robust when facing different forms of text input, and can better adapt to diverse application scenarios. Since the scheme can generate highly representative target sentence vectors, it can show superior performance in various tasks based on text representation, such as text classification, sentiment analysis, semantic similarity calculation, etc. These high-performance representation vectors (e.g., target sentence vectors) can serve as important inputs for downstream tasks, further promoting the development and application of related tasks.
[0067] In some optional implementations of this embodiment, in step 203, bidirectional pooling is performed on multiple word vectors to obtain candidate sentence vectors representing multiple target word segments, which specifically includes the following steps:
[0068] Based on multiple network layers and each target word segmentation, multiple word vectors are divided to obtain multiple word vector sets, each of which includes word vectors corresponding to multiple target word segmentations output by the same network layer; the word vectors of each word vector set are pooled horizontally to obtain the initial sentence vector corresponding to each word vector set; the initial sentence vectors are pooled vertically to obtain candidate sentence vectors representing multiple target word segmentations.
[0069] In this embodiment, the multiple word vectors output by the natural language model can be divided based on the network layer and each target word segmentation to obtain multiple word vector sets. For example, assuming that the target text S has a total of N words (S1, S2, ..., S N ), these N words are input into a BERT model with an L-layer transformer structure, and the output of each layer is the word vector corresponding to each target word segmentation, and the identification vector corresponding to the identification word segmentation. The word vectors output by each layer for the same target word segmentation can be divided into a word vector set. Then horizontal pooling (i.e. horizontal adaptive pooling) and vertical pooling (i.e. vertical adaptive pooling) are performed on it to obtain the candidate sentence vector corresponding to each word vector set. For specific horizontal pooling and vertical pooling, please refer to the description of step S203 in the above embodiment, which will not be repeated here.
[0070] In an embodiment of the present application, a natural language model, such as multiple network layers of a BERT model, can gradually extract semantic information from shallow to deep layers. The word vector set output by each network layer contains the information representation specific to that layer, and this fusion of multi-level information helps to understand the text more comprehensively. By dividing and pooling the word vectors of each network layer, information from different levels can be retained and fused to generate a richer text representation.
[0071] In some optional implementations of this embodiment, the above step of “horizontally pooling the word vectors of each word vector set to obtain the initial sentence vector corresponding to each word vector set” specifically includes the following steps:
[0072] The numerical values corresponding to the word vectors in each word vector set are sorted to obtain a sorted first word segmentation value set; the weight corresponding to each numerical value in the first word segmentation set is calculated using a fully connected matrix and a normalization function to obtain multiple first weight values; each numerical value in the first word segmentation set is merged with the multiple first weight values to obtain an initial sentence vector corresponding to each word vector set.
[0073] In one example, the numerical values corresponding to the word vectors in each word vector set can be sorted, and each row of the sorted matrix can be input into a fully connected matrix with a softmax activation function. This fully connected matrix will output a weight value θ for each value in a row. After obtaining the weight θ of each value, each value is multiplied by the corresponding θ to obtain a vector multiplied by the weight. Because there are multiple such vectors, all the vectors are added in the column direction to finally obtain a vector, that is, the initial sentence vector.
[0074] The embodiment of the present application can further emphasize or suppress the importance of different features by using a preset fully connected matrix and a normalization function to calculate the weight of each value. The weight distribution enables the model to more flexibly adjust the contribution of different features in the final representation. By generating a more discriminative and representative initial sentence vector, the amount of data and computing resources required in subsequent processing can be reduced.
[0075] In some optional implementations of this embodiment, the above step of “vertically pooling the initial sentence vector to obtain candidate sentence vectors representing multiple target word segments” specifically includes the following steps:
[0076] The numerical values corresponding to the initial sentence vectors are sorted to obtain a sorted second word segmentation value set; the weight corresponding to each numerical value in the second word segmentation value set is calculated using a fully connected matrix and a normalization function to obtain multiple second weight values; each numerical value in the second word segmentation value set is fused with the multiple second weight values to obtain a candidate sentence vector representing multiple target word segments.
[0077] In one example, the numerical values corresponding to the initial sentence vectors can be sorted, and each row of the sorted matrix can be input into a fully connected matrix with a softmax activation function. This fully connected matrix will output a weight value for each value in a row, and each value is multiplied by this weight and then added in the column direction to finally obtain a vector for the word, that is, a candidate sentence vector representing multiple target word segments.
[0078] The embodiment of the present application can further emphasize those features that contribute more to the final text representation by sorting the values of the initial sentence vectors, while reducing the influence of other minor features. This secondary sorting operation helps to strengthen and screen features at a more fine-grained level. By fusing the sorted values with the finely adjusted weights, a more accurate and detailed candidate sentence vector can be generated. This vector reduces noise and redundant interference while retaining key information, thereby improving the accuracy of text representation.
[0079] In some optional implementations of this embodiment, in step S203, multiple identification word vectors are vertically pooled to obtain identification sentence vectors representing identification word segments, which specifically includes the following steps:
[0080] The numerical values corresponding to multiple identification word vectors are sorted to obtain a sorted identification word segmentation value set; the weight corresponding to each numerical value in the identification word segmentation value set is calculated using the fully connected matrix and the normalization function to obtain the identification weight value; each numerical value in the identification word segmentation value set is merged with the identification weight value to obtain an identification sentence vector representing the identification word segmentation.
[0081] In one example, the numerical values corresponding to multiple identification word vectors can be sorted, and each row of the sorted matrix can be input into a fully connected matrix with a softmax activation function. This fully connected matrix will output a weight value for each value in a row. After multiplying each value with this weight and then adding them in the column direction, a vector for identification word segmentation is finally obtained, that is, an identification sentence vector representing the identification word segmentation is obtained.
[0082] In the application embodiment, by sorting the values in the identification word vector, more important features can be automatically given a higher priority. This sorting operation helps to pay more attention to those features that contribute more to the identification word segmentation representation in subsequent processing. The importance of key features can be further emphasized by calculating the weight of each value using a preset fully connected matrix and a normalization function. The identification sentence vector obtained by fusing the sorted values and weight values not only retains key information, but also reasonably adjusts and optimizes the information through weight allocation. This optimization process helps to improve the accuracy of the identification sentence vector, so that it can more accurately reflect the semantic features and contextual information of the identification word segmentation.
[0083] In some optional implementations of this embodiment, step S204 uses a preset fully connected matrix and a preset normalization function to respectively calculate the target weight of the candidate sentence vector and the identification weight of the identification sentence vector, specifically including the following steps:
[0084] The product of the candidate sentence vector and the weight of the preset fully connected matrix is calculated to obtain the first original weight of the candidate sentence vector; the first original weight is normalized by using a preset normalization function to obtain the target weight of the candidate sentence vector; the product of the identification sentence vector and the weight of the preset fully connected matrix is calculated to obtain the second original weight of the identification sentence vector; the second original weight is normalized by using a preset normalization function to obtain the identification weight of the identification sentence vector.
[0085] In one example, the two sets of vector candidate sentence vectors and identification sentence vectors can be input into a 512*2 fully connected matrix, and then passed through a softmax function to obtain the weight target weight and identification weight for the two vectors, the candidate sentence vector and the identification sentence vector.
[0086] The embodiment of the present application can assign reasonable weights to each feature in the sentence vector based on the prior knowledge and training data of the model by multiplying the sentence vector (candidate sentence vector, identification sentence vector) with the weight of the fully connected matrix. This weight distribution takes into account the interaction and relationship between the internal features of the sentence vector, so that the weight value is more in line with the actual semantics and context. The application of the normalization function ensures that all weight values are within a comparable range, avoiding deviations caused by excessive or too small weight values. The normalized weight value is more stable, which is helpful for weight fusion and comparison in subsequent processing.
[0087] In some optional implementations of this embodiment, step S205, based on the candidate sentence vector, the target weight, the identification sentence vector and the identification weight, obtains the target sentence vector of the target text, specifically including the following steps:
[0088] The candidate sentence vector, target weight, identification sentence vector and identification weight are weighted summed to obtain the target sentence vector of the target text.
[0089] In one example, the product between the candidate sentence vector and the target weight, the product between the identification sentence vector and the identification weight can be calculated, and then the two products are added together to obtain the final target sentence vector.
[0090] In an embodiment of the present application, the information in the candidate sentence vector and the identification sentence vector is effectively integrated by weighted summation. This integration not only takes into account the content of the sentence vector itself, but also reflects the importance of different sentence vectors in the final representation through weight values. Therefore, the target sentence vector can more comprehensively reflect the semantic features and contextual information of the target text. The introduction of target weights and identification weights allows the contribution of different sentence vectors in the weighted summation process to be reasonably adjusted. This adjustment helps to highlight key information, suppress noise and redundancy, and thus improve the accuracy and effectiveness of the target sentence vector.
[0091] It should be emphasized that in order to further ensure the privacy and security of the above-mentioned target text and target sentence vector, the above-mentioned target text and target sentence vector can also be stored in a node of a blockchain.
[0092] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0093] The embodiment of the present application can acquire and process the target text and each sentence vector of the target text based on the relevant algorithms of natural language processing (NLP) technology under artificial intelligence. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0094] Natural language processing technology is a key branch in the field of artificial intelligence. It focuses on giving computers the ability to understand and process human language, enabling them to parse, understand and generate natural language text like humans. By simulating some core mechanisms of human language processing, NLP technology can deeply process, analyze and interpret text data, extract key information from it, understand semantic content, and perform complex tasks or generate natural language responses based on it. Natural language processing technology can be used to extract multiple sentence vectors for the target text to generate target sentence vectors, etc.
[0095] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0096] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0097] Further references Figure 3 , as a response to the above Figure 2 In order to realize the method shown in the figure, the present application provides an embodiment of a device for determining a sentence vector, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0098] like Figure 3 As shown, the sentence vector determination device 400 of this embodiment includes: a word segmentation acquisition module 401, a vector conversion module 402, a pooling module 403, a weight calculation module 404 and a vector acquisition module 405. Among them:
[0099] A word segmentation acquisition module 401 acquires multiple word segments of a target text, wherein the multiple word segments include an identification word segment and multiple target word segments;
[0100] A vector conversion module 402 is used to use a preset natural language model to perform vector conversion on the identification word and multiple target word segments respectively, to obtain multiple identification word vectors corresponding to the identification word segment, and to obtain multiple word vectors corresponding to each target word segment, wherein the natural language model includes multiple network layers, and each word vector and each identification word vector are outputted by each network layer;
[0101] The pooling module 403 is used to perform bidirectional pooling on multiple word vectors to obtain candidate sentence vectors representing multiple target word segments, and to perform longitudinal pooling on multiple identification word vectors to obtain identification sentence vectors representing identification word segments;
[0102] A weight calculation module 404 is used to calculate the target weight of the candidate sentence vector and the identification weight of the identification sentence vector using a preset full connection matrix and a preset normalization function;
[0103] The vector obtaining module 405 is used to obtain the target sentence vector of the target text based on the candidate sentence vector, the target weight, the identification sentence vector and the identification weight.
[0104] The embodiment of the present application can realize information fusion from word level to sentence level by bidirectional pooling of multiple word segmentation and its corresponding sentence vector, such as horizontal pooling and vertical pooling. This multi-granular information processing method helps to characterize the text content more comprehensively and accurately, avoiding the one-sidedness that may be caused by single granular information. By assigning dynamic weights to candidate sentence vectors and identification sentence vectors through a fully connected matrix and a normalization function, the scheme can automatically adjust the contribution of each sentence vector based on the characteristics of the data itself. This dynamic weight allocation mechanism makes the final target sentence vector more focused on the key information in the text, improving the accuracy of the representation. Introducing identification word segmentation as part of the text representation, and obtaining its identification sentence vector through specific processing, such as vertical pooling, helps to improve the model's understanding and grasp of the overall structure of the text. This design makes the model more robust when facing different forms of text input, and can better adapt to diverse application scenarios. Since the scheme can generate highly representative target sentence vectors, it can show superior performance in various tasks based on text representation, such as text classification, sentiment analysis, semantic similarity calculation, etc. These high-performance representation vectors (e.g., target sentence vectors) can serve as important inputs for downstream tasks, further promoting the development and application of related tasks.
[0105] In one embodiment, the pooling module 403 includes:
[0106] A partitioning submodule is used to partition multiple word vectors based on multiple network layers and each target word segmentation to obtain multiple word vector sets, each of which includes word vectors corresponding to multiple target word segments output by the same network layer;
[0107] The first pooling submodule is used to perform horizontal pooling on the word vectors of each word vector set to obtain the initial sentence vector corresponding to each word vector set;
[0108] The second pooling submodule is used to perform vertical pooling on the initial sentence vector to obtain candidate sentence vectors representing multiple target word segments.
[0109] In an embodiment of the present application, a natural language model, such as multiple network layers of a BERT model, can gradually extract semantic information from shallow to deep layers. The word vector set output by each network layer contains the information representation specific to that layer, and this fusion of multi-level information helps to understand the text more comprehensively. By dividing and pooling the word vectors of each network layer, information from different levels can be retained and fused to generate a richer text representation.
[0110] In one embodiment, the first pooling submodule is also used to sort the numerical values corresponding to the word vectors in each word vector set to obtain a sorted first word segmentation value set; use the fully connected matrix and normalization function to calculate the weight corresponding to each numerical value in the first word segmentation set to obtain multiple first weight values; each numerical value in the first word segmentation set is merged with the multiple first weight values to obtain an initial sentence vector corresponding to each word vector set.
[0111] The embodiment of the present application can further emphasize or suppress the importance of different features by using a preset fully connected matrix and a normalization function to calculate the weight of each value. The weight distribution enables the model to more flexibly adjust the contribution of different features in the final representation. By generating a more discriminative and representative initial sentence vector, the amount of data and computing resources required in subsequent processing can be reduced.
[0112] In one embodiment, the second pooling submodule is also used to sort the numerical values corresponding to the initial sentence vector to obtain a sorted second word segmentation value set; use the fully connected matrix and normalization function to calculate the weight corresponding to each numerical value in the second word segmentation value set to obtain multiple second weight values; each numerical value in the second word segmentation value set is merged with the multiple second weight values to obtain a candidate sentence vector representing multiple target word segmentations.
[0113] The embodiment of the present application can further emphasize those features that contribute more to the final text representation by sorting the values of the initial sentence vectors, while reducing the influence of other minor features. This secondary sorting operation helps to strengthen and screen features at a more fine-grained level. By fusing the sorted values with the finely adjusted weights, a more accurate and detailed candidate sentence vector can be generated. This vector reduces noise and redundant interference while retaining key information, thereby improving the accuracy of text representation.
[0114] In one embodiment, the pooling module 403 includes:
[0115] A sorting submodule is used to sort the values corresponding to multiple identifier word vectors to obtain a sorted identifier word value set;
[0116] The weight calculation submodule is used to calculate the weight corresponding to each value in the identification word value set by using the fully connected matrix and the normalization function to obtain the identification weight value;
[0117] The first fusion submodule is used to fuse each numerical value in the identification word segmentation value set with the identification weight value to obtain an identification sentence vector representing the identification word segmentation.
[0118] In the application embodiment, by sorting the values in the identification word vector, more important features can be automatically given a higher priority. This sorting operation helps to pay more attention to those features that contribute more to the identification word segmentation representation in subsequent processing. The importance of key features can be further emphasized by calculating the weight of each value using a preset fully connected matrix and a normalization function. The identification sentence vector obtained by fusing the sorted values and weight values not only retains key information, but also reasonably adjusts and optimizes the information through weight allocation. This optimization process helps to improve the accuracy of the identification sentence vector, so that it can more accurately reflect the semantic features and contextual information of the identification word segmentation.
[0119] In one embodiment, the weight calculation module 404 includes:
[0120] A first product calculation submodule, used to calculate the product between the candidate sentence vector and the weight of a preset fully connected matrix to obtain a first original weight of the candidate sentence vector;
[0121] A first normalization submodule, used to use a preset normalization function to normalize the first original weight to obtain a target weight of the candidate sentence vector;
[0122] A second product calculation submodule, used to calculate the product between the identification sentence vector and the weight of a preset fully connected matrix to obtain a second original weight of the identification sentence vector;
[0123] The second normalization submodule is used to use a preset normalization function to normalize the second original weight to obtain the identification weight of the identification sentence vector.
[0124] The embodiment of the present application can assign reasonable weights to each feature in the sentence vector based on the prior knowledge and training data of the model by multiplying the sentence vector (candidate sentence vector, identification sentence vector) with the weight of the fully connected matrix. This weight distribution takes into account the interaction and relationship between the internal features of the sentence vector, so that the weight value is more in line with the actual semantics and context. The application of the normalization function ensures that all weight values are within a comparable range, avoiding deviations caused by excessive or too small weight values. The normalized weight value is more stable, which is helpful for weight fusion and comparison in subsequent processing.
[0125] In one embodiment, the vector obtaining module 405 includes:
[0126] The weighted summation submodule is used to perform weighted summation on the candidate sentence vector, the target weight, the identification sentence vector and the identification weight to obtain the target sentence vector of the target text.
[0127] In an embodiment of the present application, the information in the candidate sentence vector and the identification sentence vector is effectively integrated by weighted summation. This integration not only takes into account the content of the sentence vector itself, but also reflects the importance of different sentence vectors in the final representation through weight values. Therefore, the target sentence vector can more comprehensively reflect the semantic features and contextual information of the target text. The introduction of target weights and identification weights allows the contribution of different sentence vectors in the weighted summation process to be reasonably adjusted. This adjustment helps to highlight key information, suppress noise and redundancy, and thus improve the accuracy and effectiveness of the target sentence vector.
[0128] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0129] The computer device 6 includes a memory 61, a processor 62, and a network interface 63 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 6 having a memory 61, a processor 62, and a network interface 63, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASIC), programmable gate arrays (FPGA), digital signal processors (DSP), embedded devices, etc.
[0130] Computer devices can be computing devices such as desktop computers, notebooks, PDAs, and cloud servers. Computer devices can interact with users through keyboards, mice, remote controls, touch pads, or voice control devices.
[0131] The memory 61 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 61 can be an internal storage unit of the computer device 6, such as a hard disk or memory of the computer device 6. In other embodiments, the memory 61 can also be an external storage device of the computer device 6, such as a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device 6. Of course, the memory 61 can also include both the internal storage unit of the computer device 6 and its external storage device. In this embodiment, the memory 61 is generally used to store the operating system and various application software installed on the computer device 6, such as computer-readable instructions of the method for determining the sentence vector, etc. In addition, the memory 61 can also be used to temporarily store various types of data that have been output or are to be output.
[0132] In some embodiments, the processor 62 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 62 is generally used to control the overall operation of the computer device 6. In this embodiment, the processor 62 is used to run computer-readable instructions stored in the memory 61 or process data, such as computer-readable instructions for running a method for determining a sentence vector.
[0133] The network interface 63 may include a wireless network interface or a wired network interface, and the network interface 63 is generally used to establish a communication connection between the computer device 6 and other electronic devices.
[0134] The embodiment of the present application can realize information fusion from word level to sentence level by bidirectional pooling of multiple word segmentation and its corresponding sentence vector, such as horizontal pooling and vertical pooling. This multi-granular information processing method helps to characterize the text content more comprehensively and accurately, avoiding the one-sidedness that may be caused by single granular information. By assigning dynamic weights to candidate sentence vectors and identification sentence vectors through a fully connected matrix and a normalization function, the scheme can automatically adjust the contribution of each sentence vector based on the characteristics of the data itself. This dynamic weight allocation mechanism makes the final target sentence vector more focused on the key information in the text, improving the accuracy of the representation. Introducing identification word segmentation as part of the text representation, and obtaining its identification sentence vector through specific processing, such as vertical pooling, helps to improve the model's understanding and grasp of the overall structure of the text. This design makes the model more robust when facing different forms of text input, and can better adapt to diverse application scenarios. Since the scheme can generate highly representative target sentence vectors, it can show superior performance in various tasks based on text representation, such as text classification, sentiment analysis, semantic similarity calculation, etc. These high-performance representation vectors (e.g., target sentence vectors) can serve as important inputs for downstream tasks, further promoting the development and application of related tasks.
[0135] The present application also provides another implementation, namely, providing a computer-readable storage medium, which stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the sentence vector determination method as described above.
[0136] The embodiment of the present application can realize information fusion from word level to sentence level by bidirectional pooling of multiple word segmentation and its corresponding sentence vector, such as horizontal pooling and vertical pooling. This multi-granular information processing method helps to characterize the text content more comprehensively and accurately, avoiding the one-sidedness that may be caused by single granular information. By assigning dynamic weights to candidate sentence vectors and identification sentence vectors through a fully connected matrix and a normalization function, the scheme can automatically adjust the contribution of each sentence vector based on the characteristics of the data itself. This dynamic weight allocation mechanism makes the final target sentence vector more focused on the key information in the text, improving the accuracy of the representation. Introducing identification word segmentation as part of the text representation, and obtaining its identification sentence vector through specific processing, such as vertical pooling, helps to improve the model's understanding and grasp of the overall structure of the text. This design makes the model more robust when facing different forms of text input, and can better adapt to diverse application scenarios. Since the scheme can generate highly representative target sentence vectors, it can show superior performance in various tasks based on text representation, such as text classification, sentiment analysis, semantic similarity calculation, etc. These high-performance representation vectors (e.g., target sentence vectors) can serve as important inputs for downstream tasks, further promoting the development and application of related tasks.
[0137] The non-Company software tools or components appearing in the embodiments of this application are merely examples and do not represent actual use.
[0138] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods of each embodiment of the present application.
[0139] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A method for determining a sentence vector, characterized in that: The steps include: Acquire multiple word segments of a target text, wherein the multiple word segments include an identification word segment and multiple target word segments; Using a preset natural language model, respectively performing vector conversion on the identification word segmentation and the multiple target word segmentations to obtain multiple identification word vectors corresponding to the identification word segmentation, and multiple word vectors corresponding to each target word segmentation, wherein the natural language model includes multiple network layers, and each word vector and each identification word vector are outputted by each network layer; Performing bidirectional pooling on the multiple word vectors to obtain candidate sentence vectors representing the multiple target word segments, and performing longitudinal pooling on the multiple identification word vectors to obtain identification sentence vectors representing the identification word segment; Using a preset fully connected matrix and a preset normalization function, respectively calculating the target weight of the candidate sentence vector and calculating the identification weight of the identification sentence vector; A target sentence vector of the target text is obtained based on the candidate sentence vector, the target weight, the identification sentence vector and the identification weight.
2. The method according to claim 1, characterized in that The step of performing bidirectional pooling on the multiple word vectors to obtain candidate sentence vectors representing the multiple target word segments specifically includes: Based on the multiple network layers and each target word segmentation, the multiple word vectors are divided to obtain multiple word vector sets, each word vector set includes word vectors corresponding to the multiple target word segments output by the same network layer; Perform horizontal pooling on the word vectors of each word vector set to obtain the initial sentence vector corresponding to each word vector set; The initial sentence vector is vertically pooled to obtain candidate sentence vectors representing the multiple target word segments.
3. The method according to claim 2, characterized in that The step of horizontally pooling the word vectors of each word vector set to obtain the initial sentence vector corresponding to each word vector set specifically includes: Sort the values corresponding to the word vectors in each word vector set to obtain a sorted first word segmentation value set; Using the fully connected matrix and the normalization function, calculate the weight corresponding to each value in the first word segmentation set to obtain multiple first weight values; Each numerical value in the first word segmentation set is merged with the multiple first weight values to obtain an initial sentence vector corresponding to each word vector set.
4. The method according to claim 3, characterized in that The step of performing vertical pooling on the initial sentence vector to obtain candidate sentence vectors representing the multiple target word segments specifically includes: Sorting the values corresponding to the initial sentence vectors to obtain a sorted second word segmentation value set; Using the fully connected matrix and the normalization function, calculate the weight corresponding to each value in the second word segmentation value set to obtain a plurality of second weight values; Each numerical value in the second word segmentation value set is fused with the multiple second weight values to obtain candidate sentence vectors representing the multiple target word segmentations.
5. The method according to claim 1, characterized in that The step of vertically pooling the multiple identification word vectors to obtain the identification sentence vector representing the identification word segment specifically includes: Sorting the numerical values corresponding to the plurality of identification word vectors to obtain a sorted identification word value set; Using the fully connected matrix and the normalization function, the weight corresponding to each value in the identification segmentation value set is calculated to obtain an identification weight value; Each numerical value in the identification word segmentation value set is fused with the identification weight value to obtain an identification sentence vector representing the identification word segmentation.
6. The method according to claim 1, characterized in that The step of using a preset fully connected matrix and a preset normalization function to respectively calculate the target weights of the candidate sentence vectors and the identification weight of the identification sentence vector specifically includes: Calculate the product of the candidate sentence vector and the weight of a preset fully connected matrix to obtain a first original weight of the candidate sentence vector; Using a preset normalization function to normalize the first original weight to obtain a target weight of the candidate sentence vector; Calculating the product of the identification sentence vector and the weight of a preset fully connected matrix to obtain a second original weight of the identification sentence vector; The second original weight is normalized using a preset normalization function to obtain the identification weight of the identification sentence vector.
7. The method according to claim 1, characterized in that The step of obtaining the target sentence vector of the target text based on the candidate sentence vector, the target weight, the identification sentence vector and the identification weight specifically includes: The candidate sentence vector, the target weight, the identification sentence vector and the identification weight are weightedly summed to obtain a target sentence vector of the target text.
8. A device for determining a sentence vector, characterized in that: include: A word segmentation acquisition module, which acquires multiple word segments of a target text, wherein the multiple word segments include an identification word segmentation and multiple target word segmentations; A vector conversion module, used to use a preset natural language model to perform vector conversion on the identification word segmentation and the multiple target word segmentations respectively, to obtain multiple identification word vectors corresponding to the identification word segmentation, and to obtain multiple word vectors corresponding to each target word segmentation, wherein the natural language model includes multiple network layers, and each word vector and each identification word vector are outputted by each network layer; A pooling module, configured to perform bidirectional pooling on the multiple word vectors to obtain candidate sentence vectors representing the multiple target word segments, and to perform longitudinal pooling on the multiple identification word vectors to obtain identification sentence vectors representing the identification word segments; A weight calculation module, used to calculate the target weight of the candidate sentence vector and the identification weight of the identification sentence vector using a preset full connection matrix and a preset normalization function; The vector obtaining module is used to obtain the target sentence vector of the target text based on the candidate sentence vector, the target weight, the identification sentence vector and the identification weight.
9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the method for determining a sentence vector according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the method for determining a sentence vector according to any one of claims 1 to 7 are implemented.
