A method, apparatus and device for natural language processing
The method enhances natural language processing by using multiple large language models to extract and process user-input elements and logical relationships, addressing high professional thresholds and poor retrieval quality in existing technologies.
Patent Information
- Authority / Receiving Office
- HK · HK
- Patent Type
- Applications
- Current Assignee / Owner
- ALIBABA (CHINA) CO LTD
- Filing Date
- 2026-04-15
- Publication Date
- 2026-07-10
AI Technical Summary
Existing natural language processing technologies face high professional thresholds, low retrieval efficiency, and poor retrieval quality due to the inability to accurately understand and process user-input natural language, particularly in complex logical relationships and entity information.
A method involving multiple large language models to extract and classify target elements, determine logical relationships, perform entity recognition, and convert elements into database-compatible formats to enhance retrieval quality.
Improves retrieval quality by accurately processing user-input natural language, enabling efficient extraction of elements and logical relationships, resulting in improved search efficiency and accuracy.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
(19) State Intellectual Property Office (12) Invention Patent Application (10) Application Publication Number (43) Application Publication Date (21) Application Number 202511269548.0 (22) Application Date 2025.09.05 (71) Applicant Alibaba (China) Co., Ltd. Address 310052, Room 508, 5th Floor, Building 4, No. 699, Wangshang Road, Changhe Street, Binjiang District, Hangzhou City, Zhejiang Province (72) Inventor Li Chenzhong (74) Patent Agency Beijing Ruipai Intellectual Property Agency Co., Ltd. 11597 Patent Attorney Liu Feng Yang Chunxiao (51) Int.Cl. G06F 16 / 334 (2025.01) G06F 16 / 38 (2019.01) G06N 5 / 04 (2023.01) (54) Invention Title A method, apparatus and device for natural language processing (57) Abstract The embodiments of the present invention disclose a method, apparatus and device for natural language processing. In this embodiment of the invention, the following steps are taken: First, user-inputted search text information is acquired. Then, multiple target elements are determined based on the search text information. Next, an initial logical expression is determined based on the multiple target elements. Finally, entity recognition and information completion are performed on the initial logical expression using a pre-set entity database to generate a target logical expression. Based on the target logical expression and a pre-set database, an initial database retrieval expression is generated. Then, multiple target elements in the initial database retrieval expression are converted into standard elements to generate a target database retrieval expression. Finally, retrieval data for database retrieval is generated based on the target database retrieval expression. This method allows for the processing of user-inputted natural language, and when using the generated target database retrieval expression for retrieval, the retrieval quality can be improved. Claims (2 pages), Description (13 pages), Drawings (4 pages), CN 121524318 A 2026.02.13 CN 1 21 52 43 18 A 1. A method for natural language processing, characterized in that the method comprises: acquiring retrieval text information input by a user, wherein the retrieval text information is natural language text; determining multiple target elements based on the retrieval text information; determining an initial logical expression based on the multiple target elements, wherein the initial logical expression includes multiple target elements, logical relationships between each target element, and logical relationships between the multiple target elements; performing entity recognition and information completion on the initial logical expression based on a pre-set entity database to generate a target logical expression; generating 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; converting the multiple target elements in the initial database retrieval expression into standard elements to generate target data.1. A database retrieval expression, wherein the standard element is an element conforming to the database specification; Retrieval data for database retrieval is generated based on the target database retrieval expression. 2. The method according to claim 1, wherein determining multiple target elements based on the retrieval text information specifically includes: inputting the retrieval text information into a first large language model and outputting multiple target elements. 3. The method according to claim 2, wherein inputting the retrieval text information into a first large language model and outputting multiple target elements specifically includes: inputting the retrieval text information and scene prompt words into the first large language model and outputting multiple fixed-class elements and multiple inference-class elements, wherein the first large language model is used for element extraction and classification; The fixed-class elements are determined as the target elements. 4. The method according to claim 1, wherein determining an initial logical expression based on the multiple target elements specifically includes: inputting the multiple target elements and the retrieval text information into a second large language model and outputting 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 multiple target elements, and the construction of the initial logical expression. 5. The method according to claim 1, wherein 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: inputting the pre-set entity library and the initial logical expression into a third language model and outputting the target logical expression, wherein 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, wherein the step of generating an initial database retrieval expression based on the target logical expression and a pre-set database specifically includes: inputting the target logical expression and the pre-set database into a fourth language model and outputting the initial database retrieval expression, wherein 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. 7. The method according to claim 1, characterized in that, the step of converting the plurality of target elements in the initial database retrieval expression into standard elements to generate a target database retrieval expression specifically includes: inputting the initial database retrieval expression and the database into a 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 conforming to the database specified in claim 1 / 2 page 2 CN 121524318 A.8. The method according to claim 1, wherein the retrieval data includes: a RAG vector to be retrieved, keywords, and prompts for elements to be inferred, wherein the prompts for elements to be inferred include logical judgment expressions and judgment expressions. 9. A natural language processing apparatus, characterized in that the apparatus comprises: an acquisition unit, configured to acquire retrieval text information input by a user, wherein the retrieval text information is natural language text; a determination unit, configured to determine multiple target elements based on the retrieval text information; the determination unit is further configured to determine an initial logical expression based on the multiple target elements, wherein the initial logical expression includes multiple target elements, logical relationships between each target element, and logical relationships between the multiple target elements; a generation unit, configured to perform entity recognition and information completion on the initial logical expression based on a pre-set entity database, thereby generating 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 the multiple target elements in the initial database retrieval expression into standard elements, thereby generating a target database retrieval expression, wherein the standard elements are elements conforming to database specifications; the generation unit is further 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, which, when executed by a processor, implements the method as described in any one of claims 1-8. Claims 2 / 2 Page 3 CN 121524318 A Method, Apparatus and Device for Natural Language Processing Technical Field
[0001] This invention relates to the field of artificial intelligence, and more specifically, to a method, apparatus and device for natural language processing. Background Art
[0002] With the continuous development of the field of intelligent retrieval, users' demand for obtaining accurate retrieval results through natural language input is increasing, for example, in professional scenarios such as judicial case retrieval, retrieving historical cases related to user input information, etc.
[0003] In the prior art, traditional keyword and retrieval condition combination retrieval algorithms are used to retrieve data from databases, but the above methods have problems such as high professional threshold, low retrieval efficiency and poor retrieval quality.
[0004] In summary, how to process the natural language input by the user to improve the retrieval quality when using the processed natural language is a problem that needs to be solved.
[0005] In view of this, embodiments of the present invention provide a method, apparatus, and device for natural language processing, which can process the natural language input by the user and improve the retrieval quality when using the generated target database retrieval expression.
[0006] In a first aspect, embodiments of the present invention provide a natural language processing method, the method comprising: acquiring search text information input by a user, wherein the search text information is natural language text; determining multiple target elements based on the search text information; determining an initial logical expression based on the multiple target elements, wherein the initial logical expression includes multiple target elements, logical relationships between each target element, and logical relationships between the multiple target elements; performing entity recognition and information completion on the initial logical expression based on a pre-set entity database to generate a target logical expression; generating 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; converting the 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 conforming to database specifications; and generating retrieval data for database retrieval based on the target database retrieval expression.
[0007] Optionally, determining multiple target elements based on the search text information specifically includes: inputting the search text information into a first large language model and outputting multiple target elements.
[0008] Optionally, the step of inputting the retrieved text information into the first large language model and outputting multiple target elements specifically includes: inputting the retrieved text information and scene prompt words into the first large language model and outputting multiple fixed-class elements and multiple 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.
[0009] Optionally, the step of determining the initial logical expression based on the multiple target elements specifically includes: inputting the multiple target elements and the retrieved text information into the second large language model and outputting 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 multiple target elements, and the construction of the initial logical expression.
[0010] Optionally, 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: inputting the pre-set entity library and the initial logical expression into the second large language model and outputting the target logical expression.The target logical expression is input into a third language model and output. The third language model is used to perform entity recognition and information completion on the target elements in the initial logical expression.
[0011] Optionally, generating an initial database retrieval expression based on the target logical expression and a pre-set database specifically includes: inputting the target logical expression and the pre-set database into a fourth language model and outputting the initial database retrieval expression. 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.
[0012] Optionally, converting multiple target elements in the initial database retrieval expression into standard elements to generate a target database retrieval expression specifically includes: inputting the initial database retrieval expression and the database into a fifth language model to generate the target database retrieval expression. The fifth language model is used to convert the multiple target elements into standard elements conforming to the database specifications.
[0013] Optionally, the retrieval data includes: the RAG vector to be retrieved, keywords, and prompt words for the elements to be inferred, wherein the prompt words for the elements to be inferred include logical judgment expressions and judgment expressions.
[0014] In a second aspect, embodiments of the present invention provide a natural language processing apparatus, the apparatus comprising: an acquisition unit, configured to acquire retrieval text information input by a user, wherein the retrieval text information is natural language text; a determination unit, configured to determine multiple target elements based on the retrieval text information; the determination unit is further configured to determine an initial logical expression based on the multiple target elements, wherein the initial logical expression includes multiple target elements, logical relationships between each target element, and logical relationships between the multiple target elements; a generation unit, configured to perform entity recognition and information completion on the initial logical expression based on a pre-set entity database, thereby generating 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 the multiple target elements in the initial database retrieval expression into standard elements, thereby generating a target database retrieval expression, wherein the standard elements are elements conforming to database specifications; and the generation unit is further configured to generate retrieval data for database retrieval based on the target database retrieval expression.
[0015] Optionally, the determining unit is specifically used to: input the retrieved text information into the first large language model and output multiple target elements.
[0016] Optionally, the determining unit is further used to: input the retrieved text information and scene prompt words into the first large language model and output multiple target elements.In the first large language model, multiple fixed-class elements and multiple inference-class elements are output, wherein the first large language model is used for element extraction and classification; the fixed-class elements are determined as the target elements.
[0017] Optionally, the determining unit is specifically used to: input the multiple target elements and the retrieved text information into the 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 multiple target elements, and the construction of the initial logical expression.
[0018] Optionally, the generating unit is specifically used to: input the pre-set entity library and the initial logical expression into the third large language model, and output the target logical expression, wherein the third large language model is used to perform entity recognition and information completion on the target elements in the initial logical expression.
[0019] Optionally, the generation unit is further configured to: input the target logical expression and a pre-set database into a fourth language model, and output the initial database retrieval expression, wherein 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.
[0020] Optionally, the generation unit is further configured to: input the initial database retrieval expression and the database into a fifth language model, and generate the target database retrieval expression, wherein the fifth language model is used to convert the multiple target elements into standard elements that conform to the database specifications.
[0021] Optionally, the retrieval data includes: a retrieval enhancement generated RAG vector, keywords, and inference element prompts, wherein the inference element prompts include logical judgment expressions and judgment expressions.
[0022] In a third aspect, embodiments of the present invention provide an electronic device, including a memory and a processor, the memory being 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 the first aspect or any one of the possible methods of the first aspect.
[0023] In a fourth aspect, embodiments of the present invention provide a computer-readable storage medium storing computer program instructions thereon, the computer program instructions being executed by a processor to implement the method as described in the first aspect or any one of the possible methods of the first aspect.
[0024] In embodiments of the present invention, by acquiring retrieval text information input by a user, wherein the retrieval text information is natural language text; determining multiple target elements based on the retrieval text information; determining an initial logical expression based on the multiple target elements, wherein the initial logical expression includes multiple target elements, the logical relationship of each target element, andLogical relationships between multiple target elements; entity recognition and information completion of the initial logical expression based on a pre-set entity database to generate a target logical expression; generating 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; converting 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 regulations; generating retrieval data for database retrieval based on the target database retrieval expression. Through the above method, natural language input by the user can be processed, and the retrieval quality can be improved when using the generated target database retrieval expression for retrieval. Brief Description of the Drawings
[0025] The above and other objects, features, and advantages of the present invention will become clearer from the following description of embodiments of the present invention with reference to the accompanying drawings, in which: Figure 1 is a flowchart of a natural language processing method according to an embodiment of the present invention; Figure 2 is a flowchart of another natural language processing method according to an embodiment of the present invention; Figure 3 is a schematic diagram of a retrieval result according to an embodiment of the present invention; Figure 4 is a schematic diagram of a natural language processing device according to an embodiment of the present invention; Figure 5 is a schematic diagram of an electronic device according to an embodiment of the present invention. Detailed Description of Embodiments
[0026] The present application is described below based on embodiments, but the present application is not limited to these embodiments. In the detailed description of the present application below, some specific details are described in detail. The present application can be fully understood by those skilled in the art without these details. In order to avoid obscuring the substance of the present application, well-known methods, processes, flows, elements and circuits are not described in detail.
[0027] In addition, those skilled in the art should understand that the accompanying drawings provided herein are for illustrative purposes, and the drawings are not necessarily drawn to scale.
[0028] Unless the context explicitly requires it, the words "comprising," "including," and similar terms throughout the application should be interpreted as including rather than exclusive or exhaustive; that is, meaning "including but not limited to."
[0029] In the description of the present application, it should be understood that the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. In addition, in the description of the present application, unless otherwise stated, "a plurality of" means two or more.
[0030] In the prior art, 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 professional thresholds...The high threshold refers to the high requirements for users, requiring them to possess extensive professional knowledge and experience; the low retrieval efficiency refers to the need for repeated speculation and adjustment of keywords and various search condition combinations; the poor retrieval quality refers to the low probability of finding relevant cases in a single search, requiring multiple rounds of searching and item-by-item checking. For example, if a user inputs natural language text such as "search for traffic accident cases occurring in location C between March and May of this year, where the compensation amount for a food delivery worker during delivery was less than 500," using a traditional keyword and search condition combination retrieval 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 return cases from March 2020, May 2020, and March 2014, among others. Although existing technologies perform searches based on user-input natural language text, they cannot fully and accurately understand the user's input natural language text. Furthermore, it cannot understand and process elements such as time, amount, range, logical relationship, and entity information. That is, it cannot correctly handle the expression of range elements. For example, "amount less than 500" means that the user actually wants to express less than 500, but when extracting keywords, only "amount" and "500" can be extracted. When using keywords for matching and retrieval, the content retrieved is completely different from what the user actually wants to express. It also cannot properly handle the logical relationship between multiple elements. For example, "cases where the compensation amount is less than 500 yuan and occurs in location C, and a traffic collision occurs during the delivery by a food delivery worker" means that there is a logical relationship between multiple elements. However, the existing technology can only perform combined retrieval based on the extracted keywords and cannot understand the logical relationship between multiple elements, resulting in low accuracy and poor retrieval quality. Therefore, how to process the natural language input by the user so that the retrieval quality can be improved when using the processed natural language is a problem that needs to be solved.
[0031] In this embodiment of the invention, in order to solve the above problems, a natural language processing method is proposed, as shown in Figure 1. The method includes: Step S101: Obtain the retrieval text information input by the user.
[0032] Specifically, the search text information is natural language text. Users can input search text information for different fields. Taking the field of judicial case search as an example, the natural language text is "a network service contract dispute case in the first quarter of last year", "a case in the third quarter of last year in which a deliveryman from X supermarket was injured by a car during delivery, with a compensation amount of less than 10,000 yuan, which occurred in location C", and "this year, buyers were guided to provide user IDs and verification codes, resulting in property losses", etc. This is only an example illustration, and the specific details are determined according to the user's actual usage.
[0033] Step S102: Determine multiple target elements based on the search text information.
[0034] In one possible implementation, determining multiple target elements based on the retrieved text information specifically includes: inputting the retrieved text information into a first large language model (LLM) and outputting multiple target elements; wherein, the LLM is a large-scale neural network model based on deep learning technology, specifically designed for natural language processing tasks, capable of understanding, generating and reasoning about natural language through learning from massive amounts of text data, and the LLM can also be called a large model, an artificial intelligence (AI) model, etc. Instruction manual, page 4 / 13, CN 121524318 A
[0035] In one possible implementation, the step of inputting the retrieved text information into the first large language model and outputting multiple target elements specifically includes: inputting the retrieved text information and scene prompt words into the first large language model and outputting multiple fixed-class elements and multiple inference-class elements, wherein the first large language model is used for element extraction and classification; determining the fixed-class elements as the target elements; wherein the fixed-class elements are elements that can be judged as yes or no through logical relationships, usually information and fields with unambiguous expression, such as time elements, location elements and name elements, etc., and the fixed-class elements include range elements; the inference-class elements are elements with more flexible expression, such as the course of events, descriptions, etc., which must be judged as yes or no through LLM inference; in this embodiment of the invention, only the fixed-class elements are used.
[0036] For example, suppose the scenario prompt is as follows: "Task description: Please extract the case number from the user input. The case number rules are as follows: (+ Case acceptance year+) + Court code + Type code + Case number + Number User input: This year, the buyer was guided to provide the user ID and verification code, resulting in financial loss. Precautions: 1. The content in the original text must be output. 2. Extraction example is as follows: A place xxxx Civil First Instance No. xxxx, the result is: ["A place xxxx Civil First Instance No. xxxx"] (2024) B place xxxx Civil Prosecution Pre-Mediation No. xxxx, the result is: ["(2024) B place xxxx Civil Prosecution Pre-Mediation No. xxxx"] Civil First Instance No. xxxx, the result is: ["Civil First Instance No. xxxx"], xxxx, the result is: ["xxxx"] 3. Case number and case details number are three different fields. Please do not treat them as the same content. Requirements: 1. The output content must be JSONARRAY 1. Output a string in the formatted JSONARRAY, without any other formatting information. 2. If no relevant information is available, output an empty JSONARRAY string, without any other formatting information. 3. Output only the answer content; do not output any additional information.4. Extracted content must fully conform to the case number rules. Task Description: Please extract the case number from the user input. The case number rules are 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 guided to provide user IDs and verification codes, resulting in financial losses. Requirements: 1. The output content must be a JSONARRAY format string, without other format information. 2. If there is no relevant information, the output should be an empty JSONARRAY format string, without other format information. 3. The original content must be output. 4. Only output the answer content, do not output additional information. Instructions 5 / 13 Page 8 CN 121524318 A 5. Extracted content must fully conform to the case number rules. Task Description: Please extract the case number from the user input. The case number rules are: S + six digits.
[0037] User Input: This year, a buyer was tricked into providing a device ID and verification code, resulting in financial loss. Requirements: 1. The output content must be a JSONARRAY format string, without any other format information. 2. If there is no relevant information, the output should be an empty JSONARRAY format string, without any other format information. 3. The content in the original text must be output. 4. The case numbering rule is as follows: S + six digits. 5. Only output the answer content, do not output any additional information. Task Description: Please extract the company name from the user input. User Input: This year, a buyer was tricked into providing a user ID and verification code, resulting in financial loss. Requirements: 1. The output content must be a JSONARRAY format string, without any other format information. 2. If there is no relevant information, the output should be an empty JSONARRAY format string, without any other format information. 3. The content in the original text must be output. 4. Only output the answer content, do not output any additional information. Task Description: Please extract the company name from the user input.
[0038] User Input: This year, buyers were guided to provide device IDs and verification codes, resulting in financial losses. Requirements: 1. Output content must be a JSONARRAY format string, without other format information. 2. If there is no relevant information, output an empty JSONARRAY format string, without other format information. 3. The original content must be output. 4. The input may not directly mention the company name, but it will mention relevant platforms. These platform names can also be used to infer the company name. For example, the Taobao platform corresponds to the company Taobao. Please take this into account.
[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 prompts are only illustrative examples. Each element corresponds to a set of prompts. Based on the above scenario prompts, target elements are extracted from the statement "This year, buyers were guided to provide user IDs and verification codes, resulting in property losses". The extraction results are as follows: "Case number: None; Case number: None; Case details 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 card number: None; Trial procedure: None; Case source: None; Case type: Internet transaction dispute; Cause of action: Property rights dispute, online fraud".
[0040] Step S103: Determine the initial logical expression based on the multiple target elements.
[0041] Specifically, the initial logical expression includes multiple target elements, the logical relationship of each target element, and the logical relationship between multiple target elements.
[0042] In one possible implementation, determining the initial logical expression based on the plurality of target elements specifically includes: inputting the plurality of target elements and the retrieval text information into a second large language model, and outputting 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.
[0043] In one possible implementation, inputting the prompt words for generating the initial logical expression into the second large language model, and outputting the initial logical expression, wherein the prompt words for the initial logical expression include the plurality of target elements and their corresponding specific content, and the retrieval text information.
[0044] For example, the prompt for the initial logical expression is as follows: "Task Description: Please determine the relationship between the element names in the element list based on the user input and the information in the element list, and give the relationship expression.
[0045] User Input: This year, buyers were guided to provide user IDs and verification codes, resulting in financial losses. Element list: {"Case Type": ["Internet Transaction Dispute"], "Cause of Action": ["Property Rights Dispute", "Online Fraud"]} Notes: 1. The element list is given in Map form, where the key is the element name and the value is a list containing all element values extracted from the user input under the current element name. 2. Element names are connected using AND and OR operators, and priority is considered. Parentheses can be used to indicate the priority of the operation. 3. If there is only one element name, output the element name directly. 4. Example: User Input: The defendant is a certain Taobao company, and the trial authority is the Internet Court of City C or a case with a subject matter greater than 50 yuan.Element list: {"Company Name": ["Taobao"], "Court Name": ["City Internet Court"], "Amount": ["50 Yuan"], "BU": ["Taobao"]} 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 thought process within 100 characters, and then output the expression. 3. The expression is given in JSONARRAY format, and the content is a complete expression}".
[0046] In one possible implementation, the initial logical expression generated by the second language model based on the prompt words of the above initial logical expression is as follows: "Case Type AND (Cause of Action OR Cause of Action)" This is only an example illustration. In actual use, the initial logical expression is replaced with real content; each element itself has logic, for example, the interval logic of CN 121524318 A on page 7 / 13 of the instruction manual; there are also logical relationships between multiple elements.
[0047] Step S104: Perform entity recognition and information completion on the initial logical expression based on the pre-set entity library 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 language model to output the target logical expression, wherein the third language model is used to perform entity recognition and information completion on the target elements 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 person's name, reference, etc., included in the initial logical expression are identified as a person entity, the item is identified as an item entity, the company's abbreviation, full name, alias, etc., are identified as a formula entity, and non-standard order numbers, case numbers, etc., are identified as correct order numbers or case numbers, while supplementing information not present in the user input, etc., the specific generation is based on the actual situation; for example, in the scenario of marketing machine review, after recognizing the photo of milk powder, it is necessary to identify which company's milk powder and which milk powder it is through the product database, whether it is before or after stage 3, 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 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, wherein the fourth language model is used to determine the...The database fields corresponding to multiple target elements in the target logical expression are determined according to the structure of the database.
[0053] In one possible implementation, the pre-set database structure includes multiple slots, and the elements in the target logical expression are explicitly mapped to specific slots to generate the initial database retrieval expression; for example, if the user's expression mentions time, determine the specific time, whether it is the material delivery time, the registration time, or the court hearing time; for example, the initial database retrieval expression is as follows: 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 only an illustrative example, and the specific generation should be based on the actual situation.
[0054] Step S106: Convert the multiple target elements in the initial database retrieval expression into standard elements to generate a target database retrieval expression.
[0055] Specifically, the standard elements are elements that conform to the database specifications.
[0056] In one possible implementation, converting the multiple target elements in the initial database retrieval expression into standard elements to generate a target database retrieval expression specifically includes: inputting the initial database retrieval expression and the database into a fifth language model to generate the target database retrieval expression, wherein the fifth language model is used to convert the multiple target elements into standard elements that conform to the database specifications; for example, mapping to a predetermined enumeration type in the system; converting to a business node / stage in the system according to the user's input.
[0057] Step S107: Generate retrieval data for database retrieval based on the target database retrieval expression. Specification 8 / 13 pages 11 CN 121524318 A
[0058] Specifically, the retrieval data includes: a retrieval-enhanced generation (RAG) vector, keywords, and inference element prompts, wherein the inference element prompts include logical judgment expressions and judgment expressions.
[0059] In one possible implementation, the RAG vector to be generated is a vectorized statement, for example, the vectorized representation of "buyers were guided to provide user ID and verification code, resulting in financial loss"; the inference element prompt is as follows: "Task description: Please infer the cause of action from the user input.
[0060] User input: This year, buyers were guided to provide user ID and verification code, resulting in financial loss. Note: 1. If the user input information is insufficient to infer a definite cause of action, it shall be treated as no cause of action. 2. If there is no direct cause of action information, it shall be treated as no cause of action. Requirements: 1. Output the thought process first, and then output the result. The thought process is limited to 30 characters. 2. The cause of action is a cause of action defined by the court, and there is a standard value set. Please give the result from the set of cause of action values defined by the court. 3. Ensure that the result is given in JSONARRAY format and can be parsed normally. 4. There may be more than one inferred cause of action. All possible causes of action need to be given."
[0061] This is only an illustrative example. The generated inference element is "Cause of action: property rights dispute, online fraud".
[0062] In one possible implementation, the prompt for generating the keyword is as follows: "Task Description: Please remove the part of the user input that relates to the extracted content, and then extract the core keywords of the other content in the user input, and output the answer in JSONARRAY format. User Input: Cases of buyers being guided to provide user IDs and verification codes this year, resulting in financial losses. Extracted Content: {"Case Type": ["Internet Transaction Dispute"], "Time": ["January 1, 2025", "December 31, 2025"], "Cause": ["Property Rights Dispute", "Online Fraud"]} Task Requirements: 1. The core keywords must be content that appears in the original text, and they are generally phrases or words.
[0063] 2. Please filter out useless search terms and stop words, such as: case, case, etc., which are broad descriptions.
[0064] 3. The keywords must be single words, and should not be combined in the output. 4. The output content must be in JSONARRAY format. 5. The extracted content is a JSONOBJECT, where the key is the feature 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 remove it. Output format: 1. First output the thought process, limited to 40 characters, then output the result. 2. The output result is given in JSONARRAY format. This is only an example illustration, and the generated keywords are "guide", "provide", "user ID", and "verification code". In one possible implementation, after step S107, there are other steps, as shown in Figure 2.The instruction manual, page 9 / 13, CN 121524318 A, includes the following: Step S108: Search the database according to the search data and generate search results.
[0066] Specifically, assuming the user performs intelligent search in the case database, the generated search results are shown in Figure 3, which shows two cases related to "this year's buyers were guided to provide user IDs and verification codes, resulting in financial losses" and displays the similarity. This is only an illustrative example, and the specific results will be determined based on the actual search situation.
[0067] Through the above embodiments, a low-cost and universal method is used to extract elements from the user-input search text information (also known as Query), obtaining the basic elements when constructing the first-level funnel of the search database; the obtained search elements are constructed into primary search expressions, which can support various complex and nested logical relationships, as well as range calculations involving elements such as amount, time, and date; the above method can automatically adapt to specific business scenarios and specific user input to automatically process search elements, and has extremely high generalization ability and maintenance-free capability, improving search quality and search efficiency.
[0068] In this embodiment of the invention, a natural language processing apparatus is provided, as shown in FIG4, specifically including: an acquisition unit 401, a determination unit 402, and a generation unit 403; wherein, the acquisition unit 401 is used to acquire retrieval text information input by a user, wherein the retrieval text information is natural language text; the determination unit 402 is used to determine multiple target elements based on the retrieval text information; the determination unit 402 is further used to determine an initial logical expression based on the multiple target elements, wherein the initial logical expression includes multiple target elements, the logical relationship of each target element, and the logical relationship between the multiple target elements; the generation unit 403 is used to generate an initial logical expression based on a pre-set set... The body library performs entity recognition and information completion on the initial logical expression to generate a target logical expression; the generation unit 403 is also used 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 403 is also used 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 regulations; the generation unit 403 is also used to generate retrieval data for database retrieval based on the target database retrieval expression.
[0069] Further, the determining unit is specifically used to: input the retrieval text information into the first large language model and output multiple target elements.
[0070] Further, the determining unit is also specifically used to: input the retrieval text information and scene prompt words intoIn the first large language model, multiple fixed-class elements and multiple inference-class elements are output, wherein the first large language model is used for element extraction and classification; the fixed-class elements are determined as the target elements.
[0071] Further, the determining unit is specifically used to: input the multiple target elements and the retrieval text information into the 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 multiple target elements, and the construction of the initial logical expression.
[0072] Further, the generating unit is specifically used to: input the pre-set entity database and the initial logical expression into the third large language model, and output the target logical expression, wherein the third large language model is used to perform entity recognition and information completion on the target elements in the initial logical expression.
[0073] Further, the generating unit is also specifically used to: input the target logical expression and the pre-set database into the fourth large language model, and output the initial database retrieval expression, wherein the fourth large 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.
[0074] Further, the generation unit is specifically used to: input the initial database retrieval expression and the data specification page 10 / 13 13 CN 121524318 A library into the fifth language model to generate the target database retrieval expression, wherein the fifth language model is used to convert the multiple target elements into standard elements that conform to the database specifications.
[0075] Further, the retrieval data includes: a retrieval enhancement generation RAG vector, keywords, and inference element prompts, wherein the inference element prompts include logical judgment expressions and judgment expressions.
[0076] Figure 5 is a schematic diagram of the structure of the electronic device in the embodiment of the present invention. As shown in Figure 5, it includes a general computer hardware structure, which includes at least a processor 501 and a memory 502. The processor 501 and the memory 502 are connected through a bus 503. The memory 502 is adapted to store instructions or programs executable by the processor 501. The processor 501 can be an independent microprocessor or a collection of one or more microprocessors. Therefore, the processor 501 executes the instructions stored in the memory 502 to perform the method flow of the embodiment of the present invention as described above, thereby realizing data processing and control of other devices. The bus 503 connects the aforementioned components together, and also connects these components to the display controller 504, the display device, and the input / output (I / O) device 505. The input / output (I / O) device 505 may be a mouse, keyboard, modem, etc.Devices, network interfaces, touch input devices, motion-sensing input devices, printers, and other devices known in the art. Typically, input / output device 505 is connected to the system via input / output (I / O) controller 506.
[0077] The instructions stored in memory 502 are executed by at least one processor 501 to: acquire user-inputted search text information; determine multiple target elements based on the search text information; determine an initial logical expression based on the multiple target elements; perform entity recognition and information completion on the initial logical expression based on a pre-set entity library to generate a target logical expression; generate an initial database retrieval expression based on the target logical expression and a pre-set database; convert the multiple target elements in the initial database retrieval expression into standard elements to generate a target database retrieval expression; and generate retrieval data for database retrieval based on the target database retrieval expression.
[0078] Specifically, the electronic device includes: one or more processors 501 and memory 502, as shown in Figure 5 using one processor 501 as an example. The processor 501 and memory 502 can be connected via a bus or other means, as shown in Figure 5 using a bus connection as an example. Memory 502, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Processor 501 executes various functional applications and data processing of the device by running the non-volatile software programs, instructions, and modules stored in memory 502, thereby implementing the aforementioned method for determining natural language processing.
[0079] Memory 502 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and at least one application program required for a function; the data storage area may store an option list, etc. Furthermore, memory 502 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 502 may optionally include memory remotely located relative to processor 501, and these remote memories can be connected to external devices via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0080] One or more modules are stored in memory 502 and, when executed by one or more processors 501, perform the natural language processing method described in any of the above method embodiments.
[0081] As those skilled in the art will recognize, various aspects of the embodiments of the present invention can be implemented as a system, method, or computer program product. Therefore, various aspects of the embodiments of the present invention can take the form of: a completely hardware implementation, a completely software implementation (including firmware, resident software, microcode, etc.), or generally referred to herein as "electronic".The implementation of a "path", "module" or "system" that combines software and hardware aspects. Furthermore, various aspects of the embodiments of the present invention may take the form of a computer program product implemented in one or more computer-readable media having computer-readable program code implemented thereon. Specification 11 / 13 pages 14 CN 121524318 A
[0082] Any combination of one or more computer-readable media can be utilized. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example (but not limited to), an electronic, magnetic, optical, electromagnetic, infrared or semiconductor system, device or apparatus, or any suitable combination thereof. More specific examples (not exhaustive) of computer-readable storage media will include: an electrical connection having one or more wires, a portable computer floppy disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable optical disc read-only memory (CD-ROM), optical storage device, Magnetic storage devices or any suitable combination thereof. In the context of embodiments of the present invention, a computer-readable storage medium can be any tangible medium capable of containing or storing a program used by or in connection with an instruction execution system, device, or apparatus.
[0083] A computer-readable signal medium can include a propagated digital signal having computer-readable program code implemented therein, such as 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: electromagnetic, optical, or any suitable combination thereof. A computer-readable signal medium can be any of the following computer-readable media that is not a computer-readable storage medium and can communicate, propagate, or transmit a program used by or in connection with an instruction execution system, device, or apparatus.
[0084] Any suitable medium, including but not limited to wireless, wired, fiber optic cable, RF, etc., or any suitable combination thereof, can be used to transmit program code implemented on a computer-readable medium.
[0085] Computer program code for performing operations for aspects of embodiments of the present invention can be written in any combination of one or more programming languages, including: object-oriented programming languages such as Java, Smalltalk, etc. C++, etc.; and conventional procedural programming languages such as the "C" programming language or similar programming languages. Program code can be executed as a standalone software package, entirely on the user's computer, partially on the user's computer, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, it is possible to...This allows a remote computer to be connected to a user computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or to be connected to an external computer (e.g., via the Internet provided by an Internet service provider).
[0086] The flowchart illustrations and / or block diagrams of the methods, apparatus (systems), and computer program products according to embodiments of the present invention described above illustrate various aspects of the embodiments of the present invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that the instructions (executed via the processor of the computer or other programmable data processing apparatus) create means for implementing the functions / actions specified in the flowchart and / or block diagram blocks or blocks.
[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 apparatus to operate in a particular manner, such that the instructions stored in the computer-readable medium produce an article of art including instructions that implement the functions / actions specified in the flowchart and / or block diagram blocks or blocks.
[0088] Computer program instructions may also be loaded onto a computer, other programmable data processing equipment, or other apparatus to cause a series of operable steps to be performed on the computer, other programmable equipment, or other apparatus to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable equipment, provide a process for implementing the function / action specified in the flowchart and / or block diagram blocks or blocks.
[0089] The above descriptions are merely preferred embodiments of this application and are not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
[0090] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse. A user's refusal to process personal information other than the necessary information for basic functions will not affect the user's use of basic functions. (Instruction manual 13 / 13 pages 16 CN 121524318 A Figure 1; Instruction manual figure 1 / 4 pages 17 CN 121524318 A Figure 2; Instruction manual figure 2 / 4)Page 18 CN 121524318 A Figure 3 Sheet 3 / 4 of the drawings for the specification Page 19 CN 121524318 A Figure 4 Figure 5 Sheet 4 / 4 of the drawings for the specification Page 20 CN 121524318 A Abstract Embodiments of the present application disclose a natural language processing method, device and equipment. In the embodiments of the present application, search text information input by a user is acquired; a plurality of target elements are determined according to the search text information; an initial logical expression is determined according to the plurality of target elements; entity recognition and information completion are performed on the initial logical expression according to a pre-set entity library to generate a target logical expression; an initial database search expression is generated according to the target logical expression and a pre-set database; a plurality of target elements in the initial database search expression are converted into standard elements to generate a target database search expression; and search data for database search is generatedaccording to the target database search expression. Through the above method, the natural language input by the user can be processed, and the search quality can be improved when search is performed by using the generated target database search expression.
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.