Natural language processing method, device and equipment
By processing user-input natural language text through multiple large language models, and constructing target database retrieval expressions, this approach solves the problems of high professional threshold, low efficiency, and poor quality in traditional retrieval algorithms, achieving efficient and accurate database retrieval.
Patent Information
- Application Number
- CN202511269548.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-05
- Publication Date
- 2026-02-13
AI Technical Summary
In existing technologies, traditional keyword and search condition combination algorithms suffer from high technical barriers, low search efficiency, and poor search quality in database retrieval. They cannot accurately understand the logical relationships and entity information in the natural language text input by users, resulting in inaccurate search results.
Multiple large language models are used to process the natural language text input by the user. By identifying target elements, constructing initial logical expressions, performing entity recognition and information completion, generating target database retrieval expressions, converting them into standard elements that conform to database specifications, and finally generating retrieval data for database retrieval.
It improves retrieval quality and efficiency, accurately understands the logical relationships and entity information in the natural language text input by users, and generates precise retrieval results.
Smart Images

Figure CN121524318A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of artificial intelligence, and more particularly, to a natural language processing method, device and equipment. BACKGROUND
[0002] With the continuous development of the field of intelligent retrieval, the demand of users for obtaining accurate retrieval results through natural language input is increasing, for example, in professional scenarios such as judicial case retrieval, historical cases related to user input information are retrieved.
[0003] In the prior art, a traditional keyword and retrieval condition combination retrieval algorithm is used for retrieval in a database, but the above method has the problems of high professional threshold, low retrieval efficiency and poor retrieval quality.
[0004] In summary, how to process the natural language input by the user so that the retrieval quality can be improved when the processed natural language is used for retrieval is a problem to be solved at present. SUMMARY
[0005] Therefore, the embodiments of the present application provide a natural language processing method, device and equipment, which can process the natural language input by the user, and can improve the retrieval quality when the generated target database retrieval expression is used for retrieval.
[0006] In a first aspect, the embodiments of the present application provide a natural language processing method, which comprises: obtaining retrieval text information input by a user, wherein the retrieval text information is a natural language text; determining a plurality of target elements according to the retrieval text information; determining an initial logical expression according to the plurality of target elements, wherein the initial logical expression includes a plurality of target elements, a logical relationship of each target element and a logical relationship between a plurality of target elements; performing entity recognition and information completion on the initial logical expression according to a pre-set entity library to generate a target logical expression; generating an initial database retrieval expression according to the target logical expression and a pre-set database, wherein the initial database retrieval expression includes a plurality of target elements and corresponding database fields; converting the plurality of target elements in the initial database retrieval expression into standard elements to generate a target database retrieval expression, wherein the standard elements are elements conforming to the database regulations; and generating retrieval data for database retrieval according to the target database retrieval expression.
[0007] Optionally, the determining a plurality of target elements according to the retrieval text information specifically comprises: inputting the retrieval text information into a first large language model to output a plurality of target elements.
[0008] Optionally, the inputting the search text information into the first large language model to output a plurality of target elements specifically includes: inputting the search text information and a scene prompt word into the first large language model to output a plurality of fixed-class elements and a plurality of reasoning-class elements, wherein the first large language model is used for element extraction and classification; and determining the fixed-class elements as the target elements.
[0009] Optionally, the determining an initial logical expression according to the plurality of target elements specifically includes: inputting the plurality of target elements and the search text information into a second large language model to output the initial logical expression, wherein the second large language model is used for determining a logical relationship of each target element, a logical relationship between a plurality of target elements, and construction of the initial logical expression.
[0010] Optionally, the performing entity recognition and information completion on the initial logical expression according to a pre-set entity library to generate a target logical expression specifically includes: inputting the pre-set entity library and the initial logical expression into a third large language model to output the target logical expression, wherein the third large language model is used for performing entity recognition and information completion on the target elements in the initial logical expression.
[0011] Optionally, the generating an initial database search expression according to the target logical expression and a pre-set database specifically includes: inputting the target logical expression and the pre-set database into a fourth large language model to output the initial database search expression, wherein the fourth large language model is used for determining database fields corresponding to a plurality of target elements in the target logical expression, and the database fields are determined according to a structure of the database.
[0012] Optionally, the converting a plurality of the target elements in the initial database search expression into standard elements to generate a target database search expression specifically includes: inputting the initial database search expression and the database into a fifth large language model to generate the target database search expression, wherein the fifth large language model is used for converting the plurality of the target elements into standard elements that conform to a regulation of the database.
[0013] Optionally, the search data includes: a to-be-searched enhanced generation (RAG) vector, a keyword, and a to-be-reasoned element prompt word, and the to-be-reasoned element prompt word includes a logical judgment expression and a judgment expression.
[0014] In a second aspect, an embodiment of the present application provides a device for natural language processing, the device comprising: an acquisition unit configured to acquire search text information input by a user, wherein the search text information is natural language text; a determination unit configured to determine a plurality of target elements based on the search text information; the determination unit is further configured to determine an initial logical expression based on the plurality of target elements, wherein the initial logical expression comprises the plurality of target elements, a logical relationship of each target element, and a logical relationship between the plurality of target elements; a generation unit configured to perform entity recognition and information completion on the initial logical expression based on a pre-set entity library to generate a target logical expression; the generation unit is further configured to generate an initial database search expression based on the target logical expression and a pre-set database, wherein the initial database search expression comprises the plurality of target elements and corresponding database fields; the generation unit is further configured to convert the plurality of target elements in the initial database search expression into standard elements to generate a target database search expression, wherein the standard elements are elements that meet the regulations of the database; and the generation unit is further configured to generate search data for database search based on the target database search expression.
[0015] Optionally, the determination unit is specifically configured to input the search text information into a first large language model to output the plurality of target elements.
[0016] Optionally, the determination unit is specifically further configured to input the search text information and a scene prompt word into the first large language model to output a plurality of fixed-class elements and a plurality of reasoning-class elements, wherein the first large language model is used for element extraction and classification; and the fixed-class elements are determined as the target elements.
[0017] Optionally, the determination unit is specifically configured to input the plurality of target elements and the search text information into a second large language model to output the initial logical expression, wherein the second large language model is used for determining a logical relationship of each target element, a logical relationship between the plurality of target elements, and construction of the initial logical expression.
[0018] Optionally, the generation unit is specifically configured to input the pre-set entity library and the initial logical expression into a third large language model to output the target logical expression, wherein the third large language model is used for entity recognition and information completion on the target elements in the initial logical expression.
[0019] Optionally, the generating unit is specifically configured to: input the target logical expression and a preset database into a fourth large language model, and output the initial database retrieval expression, wherein the fourth large language model is configured to determine database fields corresponding to the plurality of target elements in the target logical expression, and the database fields are determined according to a structure of the database.
[0020] Optionally, the generating unit is specifically configured to: input the initial database retrieval expression and the database into a fifth large language model, and generate the target database retrieval expression, wherein the fifth large language model is configured to convert the plurality of target elements into standard elements conforming to a regulation of the database.
[0021] Optionally, the retrieval data includes: a to-be-retrieved enhanced generation (RAG) vector, a keyword, and a to-be-reasoned element prompt word, and the to-be-reasoned element prompt word includes a logical judgment expression and a judgment expression.
[0022] In a third aspect, an electronic device is provided, including a memory and a processor, the memory is configured to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method in the first aspect or any one of the possible implementations of the first aspect.
[0023] In a fourth aspect, a computer readable storage medium is provided, which stores computer program instructions, and the computer program instructions implement the method in the first aspect or any one of the possible implementations of the first aspect when executed by a processor.
[0024] In the embodiments of the present application, retrieval text information input by a user is acquired, wherein the retrieval text information is natural language text; a plurality of target elements are determined according to the retrieval text information; an initial logical expression is determined according to the plurality of target elements, wherein the initial logical expression includes a plurality of target elements, a logical relationship of each target element, and a logical relationship between the plurality of target elements; a target logical expression is generated by performing entity recognition and information completion on the initial logical expression according to a preset entity library; an initial database retrieval expression is generated according to the target logical expression and a preset database, wherein the initial database retrieval expression includes a plurality of target elements and corresponding database fields; a target database retrieval expression is generated by converting the plurality of target elements in the initial database retrieval expression into standard elements, wherein the standard elements are elements conforming to a regulation of the database; and retrieval data for database retrieval is generated according to the target database retrieval expression. Through the above method, the natural language input by the user can be processed, and the retrieval quality can be improved when retrieval is performed using the generated target database retrieval expression. BRIEF DESCRIPTION OF DRAWINGS
[0025] The above and other objects, features and advantages of the present application will become more apparent from the following description when taken in conjunction with the accompanying drawings, in which: Figure 1 is a flow chart of a method for natural language processing in an embodiment of the present application; Figure 2 is a flow chart of another method for natural language processing in an embodiment of the present application; Figure 3 is a schematic diagram of a search result in an embodiment of the present application; Figure 4 is a schematic diagram of an apparatus for natural language processing in an embodiment of the present application; Figure 5 is a schematic diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0026] The present application is described hereinafter based on embodiments. However, the present application is not limited to only these embodiments. In the following detailed description of the present application, some specific details are described in detail. The present application can be completely understood without the description of these specific details by those skilled in the art. In order to avoid confusion of the essence of the present application, well-known methods, processes, flows, elements and circuits are not described in detail.
[0027] In addition, those of ordinary skill in the art will understand that the drawings provided herein are for illustrative purposes only and are not necessarily drawn to scale.
[0028] Unless the context clearly requires otherwise, throughout the description, the words "comprise", "comprising", and the like are to be construed in an inclusive sense as opposed to an exclusive or exhaustive sense; that is to say, in the sense of "including, but not limited to".
[0029] In the description of the present application, it should be understood that the terms "first", "second", and the like are used only for the purpose of description and should not be construed as indicating or implying relative importance. In addition, in the description of the present application, unless otherwise specified, the meaning of "a plurality of" is two or more.
[0030] In existing technologies, traditional keyword and search condition combination retrieval algorithms are used to search databases. However, the above methods suffer from high professional thresholds, low retrieval efficiency, and poor retrieval quality. The high professional threshold refers to the high requirements for users, who need to have a lot of professional knowledge and experience. The low retrieval efficiency refers to the need to repeatedly speculate and adjust the combination of keywords and various search conditions. The poor retrieval quality refers to the low probability of finding a reference case in one search, requiring multiple rounds of searching and checking each case one by one. For example, if a user inputs natural language text such as "to search for traffic accidents that occurred in location C between March and May of this year, where the compensation amount for a food delivery worker was less than 500 yuan," using a traditional keyword and search condition combination search method, the first step is to extract keywords. Assuming the extracted keywords are "March," "May," "amount," "500," "accident," "location C," and "compensation," a combined search might be performed. The search results might include cases from March 2020, May 2020, and March 2014, among others. While existing technologies perform searches based on user-input natural language text, they cannot fully and accurately understand the user's input and cannot address issues related to time, amount, scope, or logic. The current technology struggles to understand and process elements such as relationships and entity information. Specifically, it cannot correctly handle the expression of range-related elements, such as "amount less than 500." The user actually means less than 500, but keyword extraction only retrieves "amount" and "500," resulting in a search that completely contradicts the user's intended meaning. Furthermore, it cannot properly handle the logical relationships between multiple elements. For example, in the case of "cases where compensation is less than 500 yuan and occurred in location C, involving traffic accidents during delivery by food delivery personnel," multiple elements have logical relationships. However, current technology can only perform searches based on extracted keywords, failing to understand these relationships, leading to low accuracy and poor search quality. Therefore, how to process user input natural language to improve search quality is a problem that needs to be solved.
[0031] In this embodiment of the invention, to solve the above problems, a natural language processing method is proposed, specifically as follows: Figure 1 As shown, the method includes: Step S101: Obtain the search text information input by the user.
[0032] Specifically, the search text information is a natural language text, and a user can input search text information for different fields. For example, in the field of judicial case search, the natural language text is "network service contract dispute cases in the first quarter of last year", "cases in which a delivery person of X supermarket was injured in a traffic accident during delivery in the third quarter of last year, with a compensation claim of less than 10,000 yuan, and occurred in C city", and "buyer was induced to provide user ID and verification code, resulting in property loss" and the like. This is only an example for illustrative purposes, and the actual use of the user determines the specific situation.
[0033] In step S102, a plurality of target elements are determined according to the search text information.
[0034] In one possible implementation, the plurality of target elements are determined according to the search text information, specifically including: inputting the search text information into a first large language model (LLM) to output a plurality of target elements; wherein the LLM is a large-scale neural network model based on deep learning technology, which is specially used for natural language processing tasks, and can understand, generate and infer natural language through learning of a large amount of text data. The LLM can also be referred to as a large model, an artificial intelligence (AI) model, etc.
[0035] In one possible implementation, the search text information is input into the first large language model to output a plurality of target elements, specifically including: inputting the search text information and a scene prompt word into the first large language model to output a plurality of fixed class elements and a plurality of inference class elements, wherein the first large language model is used for element extraction and classification; and determining the fixed class elements as the target elements; wherein the fixed class elements are elements that can be determined to be yes or no through logical relationships, and are usually unambiguous information and fields, such as time elements, place elements and name elements, etc. The fixed class elements include range class elements; the inference class elements are elements that are relatively flexible in expression, similar to the course of events, descriptions, etc. that have to be determined to be yes or no through LLM inference; in the embodiment of the application, only the fixed class elements are used.
[0036] For example, it is assumed that the scene prompt word is as follows: "Task description: please extract the case number from the user input. The case number rule is as follows: (+ collection year +) + court code + type code + case number + number User input: this year, the buyer was induced to provide user ID and verification code, resulting in property loss Notes: 1. Must output the content in the original text 2. An example of extraction is as follows: The result is: ["Location A, address xxxx, address xxxx, dated the first year of the Republic of China"]. (2024) Pre-trial Mediation Case No. xxxx in B District, the result is: ["(2024) Pre-trial Mediation Case No. xxxx in B District"] The result for "Minchu xxxx" is: ["Minchu xxxx"]. Number xxxx, the result is: ["number xxxx"] 3. Case number, case details number, and case number are three different fields; please do not treat them as the same content. Require: 1. The output must be a JSONARRAY formatted string and must not contain any other formatting information. 2. If no relevant information is available, the output will be an empty JSONARRAY string, containing no other formatting information. 3. Only output the answer content; do not output any additional information. 4. The extracted content must fully comply with the case number rules. Task Description: Please extract the case number from the user input. The case number format is as follows: three fixed characters + seven digits. The three fixed characters include: C5B, C9A, C6B, JTA, JTB, WYA, WYB, ELA, ELB User input: This year, buyers were tricked into providing user IDs and verification codes, resulting in financial losses. Require: 1. The output must be a JSONARRAY formatted string and must not contain any other formatting information. 2. If no relevant information is available, the output will be an empty JSONARRAY string, containing no other formatting information. 3. The content from the original text must be output. 4. Only output the answer content; do not output any additional information. 5. The extracted content must fully comply with the rules for case numbering. Task Description: Please extract the case number from the user input. The case number format is: S + six digits.
[0037] User input: This year, buyers were tricked into providing device IDs and verification codes, resulting in financial losses. Require: 1. The output content must be a JSONARRAY-formatted string, containing no other format information 2. If there is no relevant information, output an empty JSONARRAY-formatted string, containing no other format information 3. The content in the original text must be output 4. The case number rule is as follows: S + six digits 5. Only output the answer content, do not output additional information Task Description: Please extract the name from the user input User input: Buyers were guided to provide user IDs and verification codes this year, resulting in financial losses Requirements: 1. The output content must be a JSONARRAY-formatted string, containing no other format information 2. If there is no relevant information, output an empty JSONARRAY-formatted string, containing no other format information 3. The content in the original text must be output 4. Only output the answer content, do not output additional information Task Description: Please extract the company name from the user input.
[0038] User input: Buyers were guided to provide device IDs and verification codes this year, resulting in financial losses Requirements: 1. The output content must be a JSONARRAY-formatted string, containing no other format information 2. If there is no relevant information, output an empty JSONARRAY-formatted string, containing no other format information 3. The content in the original text must be output 4. The company name may not be directly mentioned in the input, but related platforms may be mentioned, which can also infer the company name, for example: Xbao platform corresponds to Xbao company, please consider this.
[0039] 5. If the extracted content may exist, output that content 6. Only output the answer content, do not output additional information The above scenario prompt words are only exemplary descriptions, each element corresponds to a set of prompt words, and the target elements are extracted from the "buyer was guided to provide user ID and verification code this year, resulting in property loss" according to the above scenario prompt words, and the extraction result is as follows: "case number: none; case number: none; case number: none; name: none; company name: none; court name: none; address: none; BU: none; judgment result: none; order number: none; amount: none; time: this year; nickname: none; litigation type: none; litigation procedure: none; unified social credit code: none; ID number: none; trial procedure: none; case source: none; case type: Internet transaction dispute; case: property right dispute, network fraud".
[0040] Step S103, determining an initial logical expression according to the plurality of target elements.
[0041] Specifically, the initial logical expression includes a plurality of target elements, a logical relationship of each target element, and a logical relationship between the plurality of target elements.
[0042] In a possible implementation, the determining of the initial logical expression according to the plurality of target elements specifically includes: inputting the plurality of target elements and the search text information into a second large language model, and outputting the initial logical expression, wherein the second large language model is used to determine a logical relationship of each target element, a logical relationship between the plurality of target elements, and construction of the initial logical expression.
[0043] In a possible implementation, the prompt words for generating the initial logical expression are input into the second large language model, and the initial logical expression is output, wherein the prompt words for generating the initial logical expression include the plurality of target elements and specific contents corresponding thereto, and the search text information.
[0044] For example, the prompt words for the initial logical expression are as follows: Task description: Please determine the association relationship between the element names in the element list according to the user input and the information in the element list, and give a relationship expression.
[0045] User input: This year, the buyer was guided to provide user ID and verification code, resulting in property loss Element list: {"Case type": ["Internet transaction dispute"], "Case": ["Property right dispute", "Network fraud"]} Notes: 1. The element list is given in Map form, the key is the element name, and the value is a list, and the list is all the element values extracted from the user input under the current element name 2. The element names are connected by AND, OR operators, and the priority is considered, and parentheses can be used to represent the operation priority 3. If there is only one element name, directly output the element name 4. Example: User input: The defendant is a certain treasure company, and the court is C Internet Court or the case with a subject amount greater than 50 yuan Element list: {"company name": ["certain treasure"], "court name": ["C Internet Court"], "amount": ["50 yuan"], "BU": ["certain treasure"]} Output result: ["company name AND BU AND (court name OR amount)"] Requirements: 1. Only judge the logical relationship between the element names in the element list 2. Output the thinking process within 100 characters, and then output the expression 3. The expression is given in JSONARRAY format, and the content is the complete expression.
[0046] In one possible implementation, the second large language model generates the initial logical expression according to the prompt word of the initial logical expression as follows: "case type AND (case or case)" This is only an example, and in actual use, the initial logical expression is replaced with real content; Each element itself has logic, for example, interval logic; There is also a logical relationship between multiple elements.
[0047] Step S104, according to the pre-set entity library, entity recognition and information completion are performed on the initial logical expression to generate a target logical expression.
[0048] In one possible implementation, the pre-set entity library and the initial logical expression are input into a third large language model, and the target logical expression is output, wherein the third large language model is used for entity recognition and information completion of the target element in the initial logical expression.
[0049] Specifically, a pre-set entity database stores standardized person entities, item entities, company entities, order numbers, case numbers, and auxiliary information. If the initial logical expression includes a person's name or reference, it is identified as a person entity; items are identified as item entities; company abbreviations, full names, and aliases are identified as formula entities; and non-standard order numbers and case numbers are identified as correct order numbers or case numbers. Information not present in the user input is also supplemented, and the database is generated based on the actual situation. For example, in a marketing audit scenario, after recognizing a photo of infant formula, the database needs to identify which company and which product it is, and whether it is stage 3 or earlier, because infant formula before stage 3 is not allowed to be advertised.
[0050] Step S105: Generate an initial database retrieval expression based on the target logical expression and the pre-set database.
[0051] Specifically, the initial database retrieval expression includes multiple target elements and their corresponding database fields.
[0052] In one possible implementation, the target logical expression and a pre-set database are input into a fourth language model, and the initial database retrieval expression is output. The fourth language model is used to determine the database fields corresponding to multiple target elements in the target logical expression, and the database fields are determined according to the structure of the database.
[0053] In one possible implementation, the pre-set database structure includes multiple slots. Elements in the target logical expression are explicitly mapped to specific slots to generate the initial database retrieval expression. For example, if a user's expression mentions time, the specific time needs to be determined—is it the material delivery time, registration time, or court hearing time? For instance, the initial database retrieval expression might be: query = (is_deleted:'n') AND (case_type1:\merchandise\) and ((judge_vector2:'0.0057674896,-0.0030537036……' OR one_sentence_vector: '0.0048965767,-0.0070363053……') OR (case_key:\“This year, buyers were guided to provide user IDs and verification codes, resulting in financial losses\” OR case_key:\“buy\” OR case_key:\“guided\” OR case_key:\“provide\” OR case_key: "persuasion"...), this is just an example and should be generated according to the actual situation.
[0054] Step S106, converting the plurality of target elements in the initial database retrieval expression into standard elements to generate a target database retrieval expression.
[0055] Specifically, the standard element is an element conforming to the database specification.
[0056] In a possible implementation, the plurality of target elements in the initial database retrieval expression are converted into standard elements to generate a target database retrieval expression, specifically including: inputting the initial database retrieval expression and the database into a fifth large language model to generate the target database retrieval expression, wherein the fifth large language model is used to convert the plurality of target elements into standard elements conforming to the database specification; for example, mapping to an established enumeration type in the system, etc.; converting into a business node / stage in the system according to the input of the user, etc.
[0057] Step S107, generating retrieval data for database retrieval according to the target database retrieval expression.
[0058] Specifically, the retrieval data includes a retrieval augmented generation (RAG) vector, a keyword, and an inference element prompt word, and the inference element prompt word includes a logical judgment expression and a judgment expression.
[0059] In a possible implementation, the RAG vector is a vectorized statement, for example, a vectorized representation of “Buyer was directed to provide user ID and verification code, resulting in financial loss”; and the inference element prompt word is as follows: “Task description: Please infer the cause from the user input.
[0060] User input: This year, the buyer was directed to provide user ID and verification code, resulting in financial loss Note: 1. If the user input is insufficient to infer a specific cause, it is handled as no cause 2. If there is no direct cause information description, it is handled as no cause Requirements: 1. First output the thinking process, then output the result, and the thinking process is limited to 30 characters 2. The cause is defined by the court, and there is a standard value set. Please give the result from the court-defined cause value set 3. Ensure that the format of the result is in JSONARRAY format and can be normally parsed 4. The inferred cause may not be only one, and all possible causes need to be given”.
[0061] The generated inference elements are "property rights dispute" and "cyber fraud" as an example.
[0062] In a possible implementation, the prompt words of the keywords are as follows: "Task description: Please filter out the part of the user input about the extracted content, and then extract the core keywords of the other content in the user input. Output the answer in JSONARRAY format User input: Buyers were guided to provide user ID and verification code this year, resulting in financial loss Extracted content: {"Case type": ["Internet transaction dispute"], "Time": ["January 1, 2025", "December 31, 2025"], "Cause of action": ["Property rights dispute", "Cyber fraud"]} Task requirements: 1. The core keywords must be the content in the original text, which is usually a phrase or a word.
[0063] 2. Please filter out useless search words and stop words, such as "case" and "case" broad description.
[0064] 3. The keywords must be single words, not combined output 4. The output content must be a JSONARRAY format string, not including other format information 5. The extracted content is a JSONOBJECT, the key is the element value name, and the value is the information extracted from the user input.
[0065] 6. If part of the user input appears in the value of the extracted content, please filter it out. Output format: 1. First output the thinking process, limited to 40 characters, and then output the result 2. Output the result in JSONARRAY format Here is an example, the generated keywords are "guide", "provide", "user ID", and "verification code" In a possible implementation, the step S107 is followed by other steps, specifically as shown in Figure 2 The steps include the following: Step S108, according to the search data, search in the database, generate search results.
[0066] Specifically, assuming that the user performs intelligent retrieval in the case library, a generated retrieval result schematic diagram is as shown in the figure Figure 3 The two cases related to "cases of buyers being guided to provide user ID and verification code this year, resulting in financial loss" are displayed, and the similarity is displayed. This is only an example for illustrative purposes, and the actual retrieval situation is determined.
[0067] Through the above embodiment, the low-cost and general method is used to extract the retrieval text information (also referred to as Query) input by the user, and the basic elements are obtained when constructing the large funnel of the search database; the obtained various search elements are constructed into a primary retrieval expression, and can support various complex, nested logical relationships, and range calculation involving amount, time, date and other elements; the above method can automatically adapt to specific business scenarios, specific user input initial search element processing, and has high generalization ability and maintenance-free ability, improving the retrieval quality and retrieval efficiency.
[0068] In the embodiment of the application, a natural language processing device is provided, as shown in Figure 4 The acquisition unit 401 is configured to acquire retrieval text information input by a user, wherein the retrieval text information is a natural language text. The determination unit 402 is configured to determine a plurality of target elements according to the retrieval text information. The determination unit 402 is further configured to determine an initial logical expression according to the plurality of target elements, wherein the initial logical expression includes a plurality of target elements, a logical relationship of each target element, and a logical relationship between the plurality of target elements. The generation unit 403 is configured to perform entity recognition and information completion on the initial logical expression according to a pre-set entity library, to generate a target logical expression. The generation unit 403 is further configured to generate an initial database retrieval expression according to the target logical expression and a pre-set database, wherein the initial database retrieval expression includes a plurality of target elements and corresponding database fields. The generation unit 403 is further configured to convert the plurality of target elements in the initial database retrieval expression into standard elements, to generate a target database retrieval expression, wherein the standard elements are elements conforming to the database specification. The generation unit 403 is further configured to generate retrieval data for database retrieval according to the target database retrieval expression.
[0069] Further, the determination unit is specifically configured to input the retrieval text information into a first large language model, and output a plurality of target elements.
[0070] Further, the determining unit is specifically configured to: input the search text information and the scene prompt word into the first large language model, output a plurality of fixed class elements and a plurality of reasoning class elements, wherein the first large language model is used for element extraction and classification; and determine the fixed class elements as the target elements.
[0071] Further, the determining unit is specifically configured to: input the plurality of target elements and the search text information into a second large language model, and output the initial logical expression, wherein the second large language model is used to determine the logical relationship of each target element, the logical relationship between the plurality of target elements, and the construction of the initial logical expression.
[0072] Further, the generating unit is specifically configured to: input the pre-set entity library and the initial logical expression into a third large language model, and output the target logical expression, wherein the third large language model is used for entity recognition and information completion on the target elements in the initial logical expression.
[0073] Further, the generating unit is specifically configured to: input the target logical expression and a pre-set database into a fourth large language model, and output the initial database search expression, wherein the fourth large language model is used to determine the database fields corresponding to the plurality of target elements in the target logical expression, and the database fields are determined according to the structure of the database.
[0074] Further, the generating unit is specifically configured to: input the initial database search expression and the database into a fifth large language model, and generate the target database search expression, wherein the fifth large language model is used to convert the plurality of target elements into standard elements conforming to the database.
[0075] Further, the search data includes: a to-be-searched enhanced generation (RAG) vector, a keyword, and a to-be-reasoned element prompt word, and the to-be-reasoned element prompt word includes a logical judgment expression and a judgment expression.
[0076] Figure 5 is a structural schematic diagram of the electronic device in the embodiment of the present application. As shown in Figure 5As shown, it includes a general computer hardware structure, which at least includes a processor 501 and a memory 502. The processor 501 and the memory 502 are connected through a bus 503. The memory 502 is suitable for storing instructions or programs executable by the processor 501. The processor 501 can be a stand-alone microprocessor, or a set of one or more microprocessors. Thus, the processor 501 performs the processing of data and the control of other devices by executing the instructions stored in the memory 502, thereby implementing the method flow of the embodiments of the application as described above. The bus 503 connects the above-mentioned components together, while connecting the above-mentioned components to a display controller 504 and a display device, and an input / output (I / O) device 505. The input / output (I / O) device 505 can be a mouse, a keyboard, a modem, a network interface, a touch input device, a body sense input device, a printer, and other devices known in the art. Typically, the input / output device 505 is connected to the system through an input / output (I / O) controller 506.
[0077] The instructions stored in the memory 502 are executed by the at least one processor 501 to implement: obtaining a user input search text information; determining a plurality of target elements according to the search text information; determining an initial logical expression according to the plurality of target elements; performing entity recognition and information completion on the initial logical expression according to a pre-set entity library to generate a target logical expression; generating an initial database search expression according to the target logical expression and a pre-set database; converting a plurality of target elements in the initial database search expression into standard elements to generate a target database search expression; and generating search data for database search according to the target database search expression.
[0078] In particular, the electronic device includes one or more processors 501 and a memory 502, Figure 5 Taking one processor 501 as an example. The processor 501 and the memory 502 can be connected through a bus or other means, Figure 5 Taking the connection through the bus as an example. The memory 502 is a non-volatile computer readable storage medium, which can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The processor 501 performs various functional applications and data processing of the device by running the non-volatile software programs, instructions and modules stored in the memory 502, that is, implements the above-mentioned method for determining natural language processing.
[0079] The memory 502 can include a program storage area and a data storage area. The program storage area can store an operating system, application programs required by at least one function, and the like. The data storage area can store an option list, and the like. In addition, the memory 502 can include a high-speed random access memory, and can further include a non-volatile memory such as at least one of a magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 502 can optionally include a memory disposed remotely from the processor 501, which can be connected to an external device through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0080] One or more modules are stored in the memory 502, which, when executed by the one or more processors 501, perform the method of natural language processing in any of the method embodiments described above.
[0081] As those skilled in the art will appreciate, the various aspects of the present embodiments can be implemented as a system, method or computer program product. Accordingly, the various aspects of the present embodiments can take the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, microcode, etc.) or an embodiment combining software and hardware aspects that can all generally be referred to herein as a "circuit," "module" or "system." Furthermore, the various aspects of the present embodiments can take the form of a computer program product embodied in one or more computer readable medium(s) having computer readable program code embodied thereon.
[0082] Any combination of one or more computer readable medium(s) can be utilized. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium 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 (a non-exhaustive list) of the computer readable storage medium would include the following: 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 context of the present embodiments, a 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.
[0083] A computer readable signal medium can include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated signal can take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium can be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
[0084] Program code embodied on a computer readable medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0085] Computer program code for carrying out operations for aspects of the present embodiments 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).
[0086] The flow diagrams depicted herein and / or described in connection with the embodiments of the present embodiments are provided simply as a generalized representation and are not necessarily meant as an exhaustive list of steps or procedures for implementing embodiments of the present embodiments. That is, each block of the flow diagrams and / or diagrams in the flow diagrams can represent one or more steps or procedures performed in support of one or more of the steps or procedures described and / or illustrated in the other blocks of such flow diagrams and / or diagrams. As such, each block of the flow diagrams and / or diagrams can represent one or more steps or procedures performed in support of one or more of the steps or procedures described and / or illustrated in the other blocks of such flow diagrams and / or diagrams. Alternatively, some or all of the flow diagrams and / or diagrams can represent a refinement, expansion, or step which can be built as a component of a larger piece of code.
[0087] These computer program instructions can also be stored in a computer readable medium that can direct a computer, other programmable data processing apparatus, or other devices to function in a particular manner, such that the instructions stored in the computer readable medium produce an article of manufacture including instructions which implement the function / act specified in the flowchart and / or block diagram block or blocks.
[0088] The computer program instructions can also be loaded onto a computer, other programmable data processing device, or other device to cause a series of operational steps to be performed on the computer, other programmable device, or other device to generate a computer implemented process so that the instructions executed on the computer or other programmable device provide processes for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0089] The preferred embodiments of the present application are described above with the specific details. The present application is not limited to the above preferred embodiments, and can be modified and changed by those skilled in the art. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0090] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose authorization or refusal. The user refuses to process personal information other than the necessary information required for basic functions, which does not affect the user's use of basic functions.
Claims
1. A method for natural language processing, characterized in that, The method includes: Obtain the search text information input by the user, wherein the search text information is natural language text; Based on the retrieved text information, multiple target elements are identified; An initial logical expression is determined based on the multiple target elements, wherein the initial logical expression includes multiple target elements, the logical relationship between each target element, and the logical relationship between the multiple target elements; Based on a pre-set entity library, the initial logical expression is subjected to entity recognition and information completion to generate a target logical expression; Based on the target logical expression and the pre-set database, an initial database retrieval expression is generated, wherein the initial database retrieval expression includes multiple target elements and corresponding database fields; The target elements in the initial database retrieval expression are converted into standard elements to generate a target database retrieval expression, wherein the standard elements are elements that conform to the database specifications; Retrieval data for database retrieval is generated based on the target database retrieval expression.
2. The method according to claim 1, characterized in that, The step of determining multiple target elements based on the retrieved text information specifically includes: The retrieved text information is input into the first language model, which outputs multiple target elements.
3. The method according to claim 2, characterized in that, The step of inputting the retrieved text information into the first large language model and outputting multiple target elements specifically includes: The retrieved text information and scene prompts are input into the first large language model, which outputs multiple fixed-class elements and multiple inference-class elements. The first large language model is used for element extraction and classification. The fixed-type element is identified as the target element.
4. The method according to claim 1, characterized in that, The step of determining the initial logical expression based on the multiple target elements specifically includes: The multiple target elements and the retrieved text information are input into the second large language model, and the initial logical expression is output. The second large language model is used to determine the logical relationship of each target element, the logical relationship between multiple target elements, and the construction of the initial logical expression.
5. The method according to claim 1, characterized in that, The step of performing entity recognition and information completion on the initial logical expression based on a pre-set entity library to generate a target logical expression specifically includes: The pre-set entity library and the initial logical expression are input into the third language model, and the target logical expression is output. The third language model is used to perform entity recognition and information completion on the target elements in the initial logical expression.
6. The method according to claim 1, characterized in that, The step of generating an initial database retrieval expression based on the target logical expression and a pre-set database specifically includes: The target logical expression and the pre-set database are input into the fourth language model, and the initial database retrieval expression is output. The fourth language model is used to determine the database fields corresponding to multiple target elements in the target logical expression. The database fields are determined according to the structure of the database.
7. The method according to claim 1, characterized in that, The step of converting multiple target elements in the initial database retrieval expression into standard elements to generate a target database retrieval expression specifically includes: The initial database retrieval expression and the database are input into the fifth language model to generate the target database retrieval expression, wherein the fifth language model is used to convert the plurality of target elements into standard elements that conform to the database.
8. The method according to claim 1, characterized in that, The retrieval data includes: the RAG vector to be retrieved, keywords, and prompts for elements to be inferred. The prompts for elements to be inferred include logical judgment expressions and judgment expressions.
9. A natural language processing apparatus, characterized in that, The device includes: The acquisition unit is used to acquire the search text information input by the user, wherein the search text information is natural language text; The determining unit is used to determine multiple target elements based on the retrieved text information; The determining unit is further configured to determine an initial logical expression based on the plurality of target elements, wherein the initial logical expression includes the plurality of target elements, the logical relationship of each target element, and the logical relationship between the plurality of target elements. The generation unit is used to perform entity recognition and information completion on the initial logical expression based on a pre-set entity library, and generate a target logical expression. The generation unit is further configured to generate an initial database retrieval expression based on the target logical expression and a pre-set database, wherein the initial database retrieval expression includes multiple target elements and corresponding database fields; The generation unit is further configured to convert multiple target elements in the initial database retrieval expression into standard elements to generate a target database retrieval expression, wherein the standard elements are elements that conform to database specifications; The generation unit is also configured to generate retrieval data for database retrieval based on the target database retrieval expression.
10. An electronic device comprising a memory and a processor, characterized in that, The memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method as described in any one of claims 1-8.
11. 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 as described in any one of claims 1-8.
Citation Information
Patent Citations
Query request processing method and device
CN115794857A
Data analysis method and system based on natural language, electronic equipment and storage medium
CN118132587A
Natural language intelligent number asking method and device and storage medium
CN119025552A
Information retrieval method and device based on natural language processing and electronic equipment
CN120123459A