A text vector representation method, device, electronic equipment and storage medium
By acquiring text feature maps and performing hybrid pooling, the problem of inaccurate data retrieval in existing technologies is solved, improving the quality of text vector representation and data retrieval performance.
Patent Information
- Application Number
- CN202510045420.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-13
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2045-01-13
AI Technical Summary
Existing data retrieval methods, especially vector similarity calculations based on keyword matching and cosine similarity, cannot accurately capture user intent, resulting in inaccurate search results.
By acquiring the feature map of the text to be represented, a sliding window is used to determine multiple window feature maps, and a hybrid pooling operation is performed, combining max pooling and soft pooling to improve the quality of vector representation.
It improves the accuracy and information completeness of text vector representation, and enhances the effectiveness of data retrieval.
Smart Images

Figure CN119849441B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computers, and in particular, the present application relates to a text vector representation method, device, electronic equipment and storage medium. BACKGROUND
[0002] Retrieval Augmented Generation is a technology applied in the field of knowledge content retrieval, combining vector databases and large language models, aiming to enhance the generation ability of large models through retrieval technology. The construction process of the vector database is: document preparation-> document segmentation-> slice vectorization-> storage. And the process in the application stage is: user asking-> data retrieval-> injecting prompt words-> large model generating answers. In this technology, the large model will join the prompt words based on the content after data retrieval to answer, so the speed and effect of data retrieval are closely related to the answer results of the large model.
[0003] The data retrieval in the prior art is mainly divided into the strategy of two steps of recall+rearrangement. For recall, currently it is mainly based on keyword matching or simple vector similarity calculation.
[0004] The traditional recall method based on keyword matching realizes data retrieval through simple keyword matching, which is simple and easy to use, but the accuracy is not high, the adaptability is poor, and the user intention cannot be accurately captured, resulting in low accuracy of the retrieval result. The recall method based on vector similarity, the method in the prior art is based on cosine similarity to calculate the vector similarity, which improves the retrieval effect to a certain extent, but the result is still not accurate enough due to the limitation of the quality of vector representation and the accuracy of similarity calculation. SUMMARY
[0005] The technical problem to be solved by the present application is to provide a text vector representation method, device, electronic equipment and storage medium, aiming to solve at least one of the above technical problems.
[0006] In a first aspect, the technical solution of the present application to solve the above technical problems is as follows: a text vector representation method, the method comprising:
[0007] obtaining a text to be represented, and determining a feature map corresponding to the text to be represented;
[0008] determining a plurality of window feature maps corresponding to the sliding of a preset sliding window on the feature map;
[0009] for each window feature map, performing a mixed pooling operation on the window feature map to obtain a target feature corresponding to the window feature map, until target features corresponding to all window feature maps are obtained.
[0010] The present application has the beneficial effects that: in the present application, the mixed pooling operation can integrate the ability of local feature capture and the advantage of retaining information integrity, so that the features of each window feature map can be accurately expressed by target features, and the quality of the vector representation of the text to be represented can be improved.
[0011] Based on the above technical solutions, the present application can be further improved as follows.
[0012] Further, the feature map corresponding to the text to be represented is determined, including:
[0013] A plurality of text segments corresponding to the text to be represented are determined.
[0014] For each text segment, a target vector corresponding to the text segment is determined.
[0015] The target vectors corresponding to all text segments are converted into a multi-dimensional feature map as the feature map corresponding to the text to be represented.
[0016] Further, for each text segment, the determination of the target vector corresponding to the text segment includes:
[0017] For each text segment, the text segment is converted into a fixed-length vector as the target vector corresponding to the text segment.
[0018] Further, for each window feature map, the mixed pooling operation is performed on the window feature map to obtain a target feature corresponding to the window feature map, including:
[0019] For each window feature map, a probability value corresponding to each element in the window feature map is calculated, and for each element, the probability value corresponding to the element represents the possibility that the corresponding element is the target feature corresponding to the window feature map, and each element represents a text feature in the window feature map.
[0020] For each window feature map, the target feature corresponding to the window feature map is determined based on the probability values corresponding to all elements corresponding to the window feature map.
[0021] Further, for each window feature map, the determination of the target feature corresponding to the window feature map based on the probability values corresponding to all elements corresponding to the window feature map includes:
[0022] For each window feature map, a weight corresponding to each element is determined based on the probability values corresponding to all elements corresponding to the window feature map.
[0023] For each window feature map, a target feature corresponding to the window feature map is determined based on probability values corresponding to all elements of the window feature map and weights corresponding to each element.
[0024] In a second aspect, the present application provides a text vector representation device, which comprises:
[0025] An acquisition module is configured to acquire a text to be represented and determine a feature map corresponding to the text to be represented.
[0026] A window feature map determination module is configured to determine a plurality of window feature maps corresponding to a preset sliding window when the sliding window slides on the feature map.
[0027] A target feature determination module is configured to, for each window feature map, perform a mixed pooling operation on the window feature map to obtain a target feature corresponding to the window feature map, until target features corresponding to all window feature maps are obtained.
[0028] In a third aspect, the present application provides an electronic device, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the text vector representation method of the present application when executing the computer program.
[0029] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executable on a processor to implement the text vector representation method of the present application.
[0030] Additional aspects and advantages of the present application will be made apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the description of the embodiments of the present application will be briefly introduced.
[0032] Figure 1 A flowchart of a text vector representation method provided by an embodiment of the present application;
[0033] Figure 2 A structural diagram of a text vector representation device provided by an embodiment of the present application;
[0034] Figure 3 A structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0035] The principles and characteristics of the present application are described below, and the examples are used only to explain the present application and not to limit the scope of the present application.
[0036] The technical solutions of the present application and how the technical solutions solve the above technical problems will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes can not be described again in some embodiments. The embodiments of the present application will be described below with reference to the accompanying drawings.
[0037] The scheme provided by the embodiments of the present application can be applied to any application scenario that requires vector representation of the text to be represented. The scheme provided by the embodiments of the present application can be executed by any electronic device, such as a terminal device of a user, including at least one of the following: a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a smart television, and a smart vehicle device.
[0038] The embodiments of the present application provide a possible implementation manner, as shown in Figure 1 A flowchart of a text vector representation method is provided, which can be executed by any electronic device, for example, a terminal device, or jointly executed by a terminal device and a server. For the sake of description, the method provided by the embodiments of the present application will be described below with the terminal device as an execution subject, as shown in the flowchart in Figure 1 The method can include the following steps:
[0039] S10, obtaining a text to be represented, and determining a feature map corresponding to the text to be represented;
[0040] S20, determining a plurality of window feature maps corresponding to the sliding of a preset sliding window on the feature map;
[0041] S30, for each window feature map, performing a mixed pooling operation on the window feature map to obtain a target feature corresponding to the window feature map, until target features corresponding to all window feature maps are obtained.
[0042] Through the method of the present application, the mixed pooling operation can integrate the local feature capturing capability and the advantage of retaining information integrity, so that the target feature can accurately express the features of each window feature map, and the quality of the vector representation of the text to be represented can be improved.
[0043] The scheme of the present application will be further described below in conjunction with the following specific embodiments. In the embodiments, a text vector representation method can include the following steps:
[0044] S10, obtaining a text to be represented, and determining a feature map corresponding to the text to be represented;
[0045] wherein the feature map is used to represent the text features of the text to be represented.
[0046] Optionally, in the S10, the determining of the feature map corresponding to the text to be represented comprises:
[0047] S101, determining a plurality of text segments corresponding to the text to be represented;
[0048] wherein the text to be represented can be divided into a plurality of text segments.
[0049] S102, for each of the text segments, determining a target vector corresponding to the text segment;
[0050] wherein for a text segment, the target vector corresponding to the text segment represents the text segment in the form of a vector.
[0051] Optionally, one implementation of the S102 comprises:
[0052] for each of the text segments, converting the text segment into a fixed-length vector as the target vector corresponding to the text segment.
[0053] Specifically, for each of the text segments, the text segment can be converted into a fixed-length vector by a pre-trained language model.
[0054] S103, converting the target vectors corresponding to all the text segments into a multi-dimensional feature map as the feature map corresponding to the text to be represented.
[0055] One implementation of the S103 comprises:
[0056] converting the target vectors corresponding to all the text segments into a multi-dimensional feature map by t-SNE dimension reduction technology.
[0057] wherein the multi-dimensional feature map can be represented by a two-dimensional matrix. This conversion not only helps to reduce the computational complexity, but also enhances the association expression between different dimensions, making the subsequent feature extraction more effective.
[0058] As an example, a 1024-dimensional vector can be converted into a 32x32 two-dimensional matrix by t-SNE dimension reduction technology.
[0059] S20, determining a plurality of window feature maps corresponding to the sliding of a preset sliding window on the feature map;
[0060] wherein the size of the sliding window can be preset, for example, 3*3. In the sliding process, the sliding window corresponds to covering a small area on the feature map, and the size of the area is the same as the size of the sliding window.
[0061] The moving step length of the sliding window on the feature map can be pre-set, and can be determined based on the window feature map obtained by the current sliding. After the moving step length is determined, the sliding window can be moved according to the determined moving step length to obtain a plurality of window feature maps.
[0062] Optionally, if the moving step length is determined during the movement, the corresponding moving step length can be the same or different each time. In the present application, the moving step length can be determined based on the following method:
[0063] After the sliding window is moved on the feature map for the first time with a preset first moving step length, a first window feature map is obtained, and the probability value corresponding to each element in the first window feature map is calculated. For each element, the probability value corresponding to the element represents the possibility that the corresponding element is the target feature corresponding to the first window feature map. Each element represents a text feature in the window feature map. If there is an element greater than a set probability value in the first window feature map, the first moving step length is determined as the moving step length corresponding to the next movement. If there is no element greater than the set probability value in the first window feature map, the first moving step length is increased, and the increased moving step length is used as the moving step length corresponding to the next movement. The process of adjusting the first moving step length is repeated until there is an element greater than the set probability value in the window feature map obtained by the second movement based on the increased moving step length. The moving step length corresponding to this time is used as the moving step length of the second movement. Similarly, the moving step length corresponding to each movement is determined in the above manner. That is, the second movement is performed according to the moving step length determined in the above manner to obtain a second window feature map corresponding to the second movement. Similarly, the moving step length corresponding to the third movement is determined in the above manner until the last movement to obtain a plurality of window feature maps.
[0064] Optionally, the probability value corresponding to each element in the first window feature map can be determined by a softmax function, which will be described in detail below.
[0065] S30, for each window feature map, a mixed pooling operation is performed on the window feature map to obtain a target feature corresponding to the window feature map, until target features corresponding to all window feature maps are obtained.
[0066] The mixed pooling operation described above refers to a combination of the maximum pooling operation and soft pooling, which will be described in detail below.
[0067] Optionally, after obtaining the target features corresponding to all window feature maps, the target features corresponding to all window feature maps can be fused, and the fused features can be used as the vector representation of the text to be represented.
[0068] Optionally, in S30 above, for each window feature map, performing a hybrid pooling operation on the window feature map to obtain the target feature corresponding to the window feature map includes:
[0069] S301, for each of the window feature maps, calculate the probability value corresponding to each element in the window feature map. For each element, the probability value corresponding to the element represents the possibility that the corresponding element is the target feature corresponding to the window feature map. Each element represents a text feature in the window feature map.
[0070] The probability value of each element can be determined in the following way:
[0071]
[0072] Where S(x) i ) represents the i-th element x i The corresponding probability value, This represents the i-th element x. i The corresponding exponential function value, It represents the sum of the exponential function values of all elements in a window feature graph, where j represents the total number of all elements in a window feature graph, and i is less than j.
[0073] Optionally, in the process of determining the probability value corresponding to each element, the position of each element in the text to be represented can also be determined, so that after determining the target feature corresponding to each window feature map, the position of the target feature in the text to be represented can be determined, so as to find the text fragment that can represent the text feature of the text to be represented.
[0074] S302, for each window feature map, the target feature corresponding to the window feature map is determined based on the probability values of all elements corresponding to the window feature map.
[0075] Optionally, the first implementation of S302 above is as follows: for each window feature map, the element corresponding to the maximum probability value is determined as the target feature.
[0076] The second implementation of S302 above is as follows:
[0077] S3021, For each window feature map, determine the weight corresponding to each element based on the probability values corresponding to all elements of the window feature map;
[0078] S3022, for each window feature map, based on the probability value corresponding to all elements corresponding to the window feature map and the weight corresponding to each element, determine the target feature corresponding to the window feature map.
[0079] In this scheme, for a window feature map, the target feature determined based on the first implementation manner and the target feature determined based on the second implementation manner can also be fused, and the fused feature is taken as the target feature of the window feature map. The fusion manner can be weighted fusion, so that the locally representative features and the features with a certain degree of influence can be considered.
[0080] Optionally, in the above S3022, one implementation manner of determining the target feature corresponding to the window feature map based on the probability value corresponding to all elements corresponding to the window feature map and the weight corresponding to each element is as follows:
[0081] First, the element with the maximum probability value among all elements corresponding to the window feature map is taken as the target element, and a set first weight value is determined as the weight of the target element. Different weights are assigned to other elements except the target element among all elements corresponding to the window feature map according to the probability value of each element, wherein the first weight value can be represented by a. The target feature corresponding to the window feature map is determined based on each element and the corresponding weight among all elements corresponding to the window feature map. This process can be called soft pooling. In this process, the process of determining the maximum probability value is the maximum pooling operation.
[0082] Wherein, a is a parameter between 0 and 1, which is used to control the weight ratio between the maximum value (maximum probability value) and the remaining value (other probability values).
[0083] Specifically, in the scheme of the present application, for each window feature map, the target feature of the window feature map can be determined based on the size of the first weight value a, specifically as follows:
[0084] When a is close to 1, the maximum value corresponding to the text feature extracted from the corresponding sliding window position is taken as the representative of the region (window feature map), that is, for the window feature map, the element with the maximum probability value among all elements corresponding to the window feature map is taken as the target feature representing the window feature map, which helps to highlight the most important local features.
[0085] When a is close to 0, the information of the entire window is considered, and by converting all elements into a probability distribution form, the element corresponding to a larger probability value obtains a higher weight, and the element corresponding to a smaller probability value also retains a certain degree of influence, that is, the element corresponding to a smaller probability value is assigned a smaller weight. This method can more comprehensively represent the importance of local features and avoid information loss.
[0086] Thus, based on the adjustment of the first weight value, the target feature corresponding to each window feature map can be more accurately represented.
[0087] Specifically, one implementation of S3022 is as follows:
[0088] S-LMP = a-x max +(1-a)·∑1s(x i )·x i
[0089] wherein S-LMP represents a target feature corresponding to a window feature map, x max represents an element with the largest probability value among all elements corresponding to a window feature map, ∑1s(x i )·x i represents a sum of products of other elements except the target element and corresponding probability values among all elements corresponding to a window feature map, S(x i ) represents a probability value of the ith element x i , x i represents the ith element, 1 represents the number of other elements except the target element among all elements corresponding to a window feature map, and 1 is less than j.
[0090] Optionally, in the scheme of the present application, the text to be represented can be segmented to obtain a plurality of text segments by the following method:
[0091] Firstly, the text to be represented is segmented according to paragraphs, and for any paragraph obtained after segmentation, the paragraph is segmented according to periods or semicolons, the length of the sentence obtained after segmentation is determined in real time, and based on the length of the sentence and a pre-set segmentation rule, each sentence is further segmented to obtain a plurality of text segments.
[0092] For each sentence, the length of the sentence and the pre-set segmentation rule are used to segment the sentence to obtain a plurality of text segments, and the specific implementation process is as follows:
[0093] For each sentence, if the sentence length of the sentence is greater than the set length, the corresponding sentence is divided into a first number of first text segments, each first text segment has a first length, and the total length of each first text segment is less than the sentence length. The text segment in the sentence other than all the first text segments is regarded as a second text segment, the sentence length of the second text segment is generally not greater than the first length, the second text segment can be directly taken as a new first text segment, or the second text segment is spliced with the next adjacent sentence of the sentence to obtain a third text segment with the first length, and the third text segment is taken as a new first text segment. All first text segments (including the new first text segment) are taken as the plurality of text segments corresponding to the sentence.
[0094] Then, for the next adjacent sentence of the sentence, if the adjacent sentence has been occupied by a part of the third text segment of the sentence, the part of the sentence other than the part can be taken as a new sentence, and the above-mentioned method is used for division.
[0095] Secondly, according to the paragraph, the text to be represented is divided into paragraphs, a fixed division length is determined, and any paragraph is divided into at least two cutouts according to the fixed division length. It needs to be further explained that, in the process of division according to the fixed division length, if there is a comma or a colon in the cutout obtained by division, the division needs to be re-performed, that is, the division is performed according to the comma or the colon, and after the division, the first letter content after the comma or the colon is taken as the starting point to re-perform the division according to the fixed division length. According to the slicing method in the first method, the text segment corresponding to each sentence is obtained by slicing processing.
[0096] Through the scheme of the application, by mixing the pooling extracted features, the calculation complexity can be reduced, and by combining the local maximum pooling and the soft pooling, the advantages of local feature capturing and information integrity retention are integrated, the vector core features are better extracted, and the quality of the vector representation is improved, so that the subsequent process can be better carried out.
[0097] Based on the same principle as shown in the method in Figure 1 The embodiment of the application also provides a text vector representation device 20, as shown in Figure 2 The text vector representation device 20 can include an acquisition module 210, a window feature map determination module 220 and a target feature determination module 230, wherein:
[0098] The acquisition module 210 is configured to acquire the text to be represented and determine a feature map corresponding to the text to be represented.
[0099] The window feature map determination module 220 is configured to determine a plurality of window feature maps corresponding to the feature map when the preset sliding window slides on the feature map.
[0100] The target feature determination module 230 is configured to, for each window feature map, perform a mixed pooling operation on the window feature map to obtain a target feature corresponding to the window feature map, until target features corresponding to all window feature maps are obtained.
[0101] Optionally, the obtaining module 210, when determining the feature map corresponding to the text to be represented, is specifically configured to:
[0102] determine a plurality of text segments corresponding to the text to be represented.
[0103] for each text segment, determine a target vector corresponding to the text segment.
[0104] convert the target vectors corresponding to all text segments into a multi-dimensional feature map as the feature map corresponding to the text to be represented.
[0105] Optionally, for each text segment, the obtaining module 210, when determining the target vector corresponding to the text segment, is specifically configured to:
[0106] convert the text segment into a fixed-length vector as the target vector corresponding to the text segment.
[0107] Optionally, for each window feature map, the target feature determination module 230, when performing the mixed pooling operation on the window feature map to obtain the target feature corresponding to the window feature map, is specifically configured to:
[0108] for each window feature map, calculate a probability value corresponding to each element in the window feature map, and for each element, the probability value corresponding to the element represents a possibility that the corresponding element is the target feature corresponding to the window feature map, and each element represents a text feature in the window feature map.
[0109] for each window feature map, determine the target feature corresponding to the window feature map based on the probability values corresponding to all elements corresponding to the window feature map.
[0110] Optionally, for each window feature map, the target feature determination module 230, when determining the target feature corresponding to the window feature map based on the probability values corresponding to all elements corresponding to the window feature map, is specifically configured to:
[0111] for each window feature map, determine a weight corresponding to each element based on the probability values corresponding to all elements corresponding to the window feature map.
[0112] For each window feature map, based on the probability values corresponding to all elements of the window feature map and the weights corresponding to each element, determine the target feature corresponding to the window feature map.
[0113] The text vector representation apparatus provided in the embodiments of the present application can perform the text vector representation method provided in the embodiments of the present application, and the implementation principles are similar. The actions performed by each module and unit in the text vector representation apparatus in the embodiments of the present application are corresponding to the steps in the text vector representation method in the embodiments of the present application. For the detailed functions of each module of the text vector representation apparatus, refer to the description of the corresponding text vector representation method in the foregoing, which will not be described here.
[0114] The text vector representation apparatus can be a computer program (including program code) running in a computer device, for example, the text vector representation apparatus is an application software. The apparatus can be used to perform the corresponding steps in the method provided in the embodiments of the present application.
[0115] In some embodiments, the text vector representation apparatus provided in the embodiments of the present application can be implemented in a combination of software and hardware. For example, the text vector representation apparatus provided in the embodiments of the present application can be a hardware decoding processor in the form of a processor programmed to perform the text vector representation method provided in the embodiments of the present application. For example, the hardware decoding processor in the form of a processor can use one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field programmable gate arrays (FPGAs), or other electronic elements.
[0116] In some other embodiments, the text vector representation apparatus provided in the embodiments of the present application can be implemented in software, Figure 2 The text vector representation apparatus stored in the memory is shown, which can be software in the form of programs and plug-ins, and includes a series of modules, including an acquisition module 210, a window feature map determination module 220, and a target feature determination module 230, for implementing the text vector representation method provided in the embodiments of the present application.
[0117] The modules described in the embodiments of the present application can be implemented in the form of software or in the form of hardware. In some cases, the names of the modules do not constitute a limitation on the modules themselves.
[0118] Based on the same principles as the method shown in the embodiments of the present application, the embodiments of the present application also provide an electronic device, which can include but is not limited to a processor and a memory; the memory is configured to store a computer program; and the processor is configured to execute the method shown in any of the embodiments of the present application by invoking the computer program.
[0119] In an optional embodiment, an electronic device is provided, as shown in Figure 3 As shown in Figure 3 The electronic device 4000 shown in the embodiment includes a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, through a bus 4002. Optionally, the electronic device 4000 can also include a transceiver 4004, which can be used for data interaction, such as data transmission and / or data reception, between the electronic device and other electronic devices. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present application.
[0120] The processor 4001 can be a CPU (Central Processing Unit, central processing unit), a general-purpose processor, a DSP (Digital Signal Processor, digital signal processor), an ASIC (Application Specific Integrated Circuit, application specific integrated circuit), an FPGA (Field Programmable Gate Array, field programmable gate array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It can implement or execute various exemplary logical blocks, modules and circuits described in combination with the disclosure. The processor 4001 can also be a combination of computing functions, such as one or more microprocessor combinations, combinations of DSP and microprocessor, etc.
[0121] The bus 4002 can include a path for transmitting information between the above-mentioned components. The bus 4002 can be a PCI (Peripheral Component Interconnect, peripheral component interconnect) bus or an EISA (Extended Industry Standard Architecture, extended industry standard architecture) bus, etc. The bus 4002 can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation,Figure 3 Only one bus or type of bus might exist but implementations that have more than one bus or type of bus are possible.
[0122] The memory 4003 can be a ROM (Read Only Memory) or other type of static storage device that can store static information and instructions that are not to be changed by the computer; a RAM (Random Access Memory) or other type of dynamic storage device that can store information and instructions for execution by the processor 4001 and / or the computer; an EEPROM (Electrically Erasable Programmable Read-Only Memory), a CD-ROM (Compact Disc Read-Only Memory) or other optical disk storage; a magnetic disk storage or other magnetic storage devices or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to this.
[0123] The memory 4003 is configured to store application code (computer program) for implementing the solutions of the present application, and the processor 4001 is configured to control the execution of the application code stored in the memory 4003. The processor 4001 is configured to execute the application code stored in the memory 4003 to implement the content shown in the foregoing method embodiments.
[0124] The electronic device can also be a terminal device, Figure 3 The electronic device shown is only an example and should not limit the functions and use range of the embodiments of the present application.
[0125] The embodiments of the present application provide a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program is run on a computer, the computer can execute the corresponding content in the foregoing method embodiments.
[0126] According to another aspect of the present application, a computer program product or computer program is also provided, which includes computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the computer device to perform the method provided in the various implementation manners of the above embodiments.
[0127] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0128] It should be understood that the flowchart and block diagrams in the drawings illustrate the architecture, functionality, and operation of possible implementations of various embodiments of the present application. In this regard, each block in the flowchart and block diagrams can represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks can sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flowchart illustrations, and combinations thereof, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or combinations of hardware and software.
[0129] The computer readable storage medium of the present application can be, for example but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, the computer readable storage medium can be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
[0130] The computer readable storage medium described above bears one or more programs, when the one or more programs are executed by the electronic device, cause the electronic device to execute the method shown in the above embodiment.
[0131] The above description is merely the preferred embodiments of the present application and the explanation of the applied technical principles. It should be understood by those skilled in the art that the disclosed range of the present application is not limited to the technical solutions formed by the specific combinations of the above technical features, and should also cover other technical solutions formed by any combinations of the above technical features or their equivalent features without departing from the disclosed concept. For example, the technical solutions formed by the mutual replacement of the above features and the technical features disclosed in the present application (but not limited to) having similar functions.
Claims
1. A text vector representation method, characterized in that, Includes the following steps: Obtain the text to be represented and determine the feature map corresponding to the text to be represented; Determine multiple window feature maps corresponding to the preset sliding window when it slides on the feature map; For each window feature map, perform a hybrid pooling operation on the window feature map to obtain the target feature corresponding to the window feature map, until the target features corresponding to all window feature maps are obtained; For each of the window feature maps, the step of performing a hybrid pooling operation on the window feature map to obtain the target feature corresponding to the window feature map includes: For each of the window feature maps, the probability value corresponding to each element in the window feature map is calculated. For each element, the probability value corresponding to the element represents the possibility that the corresponding element is the target feature corresponding to the window feature map. Each element represents a text feature in the window feature map. For each window feature map, the weight corresponding to each element is determined based on the probability values of all elements corresponding to that window feature map; For each window feature map, the element with the highest probability value among all elements corresponding to that window feature map is first selected as the target element. A predetermined first weight value is then determined as the weight of the target element. The first weight value is determined through... express; For each of the aforementioned window feature maps, when When the probability value is close to 1, the element with the highest probability value among all elements corresponding to the feature map of that window is taken as the main target feature representing the feature map of that window. When the value is close to 0, all elements are transformed into a probability distribution, so that elements with higher probability values receive higher weights and elements with lower probability values receive lower weights. Based on each element and its corresponding weight in the feature map of this window, the target feature corresponding to this feature map is determined, specifically as follows: in, This represents the target features corresponding to a window feature map. This represents the element with the highest probability value among all elements corresponding to a window feature map. It represents the sum of the products of all elements in a window feature map except the target element and their corresponding probability values. Represents the i-th element The corresponding probability value, This represents the i-th element. This represents the number of elements other than the target element among all elements in a window feature map. Less than j.
2. The method according to claim 1, characterized in that, Determining the feature map corresponding to the text to be represented includes: Identify multiple text segments corresponding to the text to be represented; For each of the text segments, determine the target vector corresponding to that text segment; The target vectors corresponding to all text fragments are converted into multi-dimensional feature maps, which are then used as the feature maps corresponding to the text to be represented.
3. The method according to claim 2, characterized in that, For each of the text segments, determining the target vector corresponding to that text segment includes: For each text segment, the text segment is converted into a vector of fixed length, which serves as the target vector corresponding to that text segment.
4. A text vector representation device, characterized in that, The apparatus employing the text vector representation method according to claim 1 includes: The acquisition module is used to acquire the text to be represented and determine the feature map corresponding to the text to be represented; The window feature map determination module is used to determine multiple window feature maps corresponding to a preset sliding window sliding on the feature map; The target feature determination module is used to perform a hybrid pooling operation on each window feature map to obtain the target feature corresponding to the window feature map, until the target features corresponding to all window feature maps are obtained.
5. The apparatus according to claim 4, characterized in that, When determining the feature map corresponding to the text to be represented, the acquisition module is specifically used for: Identify multiple text segments corresponding to the text to be represented; For each of the text segments, determine the target vector corresponding to that text segment; The target vectors corresponding to all text fragments are converted into multi-dimensional feature maps, which are then used as the feature maps corresponding to the text to be represented.
6. The apparatus according to claim 5, characterized in that, For each text segment, when determining the target vector corresponding to that text segment, the acquisition module specifically performs the following: For each text segment, the text segment is converted into a vector of fixed length, which serves as the target vector corresponding to that text segment.
7. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the method of any one of claims 1-3.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method of any one of claims 1-3.
Citation Information
Patent Citations
Polyphone pronunciation prediction method, device and equipment and storage medium
CN112528648A
Graph neural network text sentiment classification method based on double sliding windows
CN113220884A