Law consultation semantic analysis and response generation method based on multi-agent cooperation
Patent Information
- Application Number
- CN202611388649.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-08
- Publication Date
- 2026-10-30
AI Technical Summary
因此,各处理任务从累计法律咨询文本中实际使用的语义内容范围可能存在差异
[0013]本申请提供了基于多智能体协同的法律咨询语义解析与响应生成方法,其所实现的有益效果至少包括:
Smart Images

Figure CN123013958A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of semantic processing technology, and more specifically, to a method for semantic parsing and response generation of legal consultation based on multi-agent collaboration. Background Technology
[0002] With the development of natural language processing and artificial intelligence technologies, intelligent legal consultation systems can receive legal consultation texts input by users, perform semantic analysis on the consultation content, and generate consultation responses by combining laws, regulations, judicial interpretations, cases, or other legal knowledge. To separately perform processing tasks such as fact analysis, legal retrieval, and response generation, existing intelligent legal consultation systems can set up multiple dedicated intelligent agents, assigning different processing tasks to corresponding agents, and transmitting and combining the processing results generated by each agent.
[0003] In multi-round legal consultations, a user's description of the same consultation matter may be scattered across multiple interaction rounds. The accumulated legal consultation text may simultaneously contain multiple subjects, actions, times, results, and their interrelationships. Different processing tasks have different purposes for reading the consultation text. The factual analysis task needs to select semantic content from the accumulated legal consultation text to represent the factual process, the legal retrieval task needs to select semantic content to form search criteria, and the response generation task needs to combine corresponding factual analysis results and legal retrieval results. Therefore, the actual scope of semantic content used by each processing task from the accumulated legal consultation text may differ.
[0004] Existing multi-agent processing methods can provide unified consultation text or structured consultation semantic data to different agents, or generate corresponding task input data based on the task type of each agent. When the fact analysis agent and the legal retrieval agent select semantic content from the common consultation semantic data without further coordinating the data boundaries between the different selection results, the resulting fact processing scope and retrieval processing scope may contain some of the same semantic content, while also containing semantic content that does not belong to the other processing scope, thus forming a partially overlapping and mutually exclusive set of task input data.
[0005] In the above scenario, shared semantic content may simultaneously enter multiple task input data sets, while other related semantic content may be assigned to different task input data sets. If the system only transmits and combines processing results according to agent type, task execution order, or result formation order, it is difficult to determine the correspondence between results based on the actual semantic content range of each processing result. This may result in the combination of fact analysis results and legal search results that do not correspond to the input semantic content range. Summary of the Invention
[0006] In view of this, this application provides a method for semantic parsing and response generation of legal consultation based on multi-agent collaboration, including: The system receives multiple rounds of legal consultation texts, performs semantic encoding and relation extraction on the accumulated legal consultation texts, and obtains consultation semantic data composed of multiple semantic contents and the relations between semantic contents.
[0007] By using fact analysis agents and legal retrieval agents, semantic content is selected from consultation semantic data to form the scope of fact processing and the scope of retrieval processing.
[0008] Compare the fact processing scope and the retrieval processing scope to determine the common semantic content and the non-common semantic content in the two processing scopes. When the two processing scopes have common semantic content and do not contain each other, determine the partial overlap between the two processing scopes.
[0009] For two partially overlapping processing scopes, starting from the common semantic content, non-common semantic content connected to the common semantic content is searched along the association relationship. The common semantic content and the found non-common semantic content are merged to form the adjusted processing scope, and the non-common semantic content that is not found is formed into other processing scopes.
[0010] Based on the attribution relationship of each semantic content in the adjusted processing scope and other processing scopes, the adjusted processing scope and other processing scopes are formed into non-overlapping collaborative processing units.
[0011] The fact analysis agent generates fact analysis results based on each collaborative processing unit, and the legal retrieval agent generates retrieval formulas based on each collaborative processing unit and obtains legal retrieval results from the legal text database.
[0012] The response-generating agent combines the fact analysis results and legal search results corresponding to the same collaborative processing unit into unit result groups, and generates legal consultation responses based on each unit result group.
[0013] This application provides a method for semantic parsing and response generation of legal consultation based on multi-agent collaboration, the beneficial effects of which include at least: (1) This application addresses the issue that the processing scopes formed after the fact analysis agent and the legal retrieval agent select semantic content may partially overlap. It processes the common semantic content, non-common semantic content, and their relationships in the fact processing scope and the retrieval processing scope, transforming the originally overlapping task input data sets into non-overlapping collaborative processing units. As a result, each semantic content can be assigned to a specific collaborative processing unit, and the fact analysis results and legal retrieval results can also establish a clear data correspondence according to the corresponding collaborative processing units. This enables the response generation agent to combine only the processing results that correspond to each other in the input semantic scope, reducing the possibility of intermediate results with only partially corresponding input scopes being cross-combined.
[0014] (2) When adjusting the overlapping processing scope, this application starts with the common semantic content in the two processing scopes and searches for non-common semantic content layer by layer along the relationship between semantic content. Non-common semantic content that can be reached by any common semantic content along the relationship is included in the adjusted processing scope, and non-common semantic content that is not found is formed into other processing scopes according to the relationship between them. Thus, while eliminating the overlap between the fact processing scope and the retrieval processing scope, it avoids the non-common semantic content that belongs to the same related content chain as the common semantic content being directly split into different processing scopes, and forms non-overlapping unit input data for subsequent intelligent agents.
[0015] (3) When the addition of a new round of legal consultation text causes changes in the consultation semantic data, this application locates the collaborative processing unit to be updated based on the relationship between the new semantic content and the existing semantic content. Only the processing scope of the new semantic content and the collaborative processing unit to be updated is redefined and the collaborative processing units are divided, while the unaffected collaborative processing units and their processing results are retained. By setting a collaborative processing unit identifier and unit version for each collaborative processing unit, and verifying the collaborative processing unit identifier and unit version carried by the processing results before forming the unit result group and outputting the legal consultation response, the possibility of fact analysis results and legal search results belonging to different collaborative processing units being cross-combined and the intermediate processing results before the update being continued to be transmitted or output can be reduced. At the same time, it is not necessary to re-execute the fact analysis and legal search tasks corresponding to all collaborative processing units due to changes in local semantic content, thereby reducing the repeated reading, repeated retrieval and repeated processing of input data for unchanged tasks. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 The flowchart of the legal consultation semantic parsing and response generation method based on multi-agent collaboration provided in this application is shown. Figure 2 The cumulative distribution of the number of characters in the sample text of the legal consultation questions, legal provision search queries, and case search queries used in this application is shown. Figure 3 This paper illustrates the distribution of the number of text units in a single round of real consultation text and the number of interaction rounds in a multi-round legal consultation session used in this application. Figure 4 This application demonstrates the consistency ratio of collaborative processing unit division under different combinations of fact task association thresholds and retrieval task association thresholds; Figure 5 The precision, recall, retention rate of candidate legal text fragments, and F1 score of this application are shown at different candidate text retention thresholds. Figure 6 The processing time distribution for reconstructing all valid response fragments after receiving new rounds of legal consultation texts is shown. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with the accompanying drawings. It should be understood that the accompanying drawings are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale.
[0019] The following embodiment is a specific implementation of the technical solution of this application. Each intelligent agent can be executed by different program processes in the same computing device, or by different computing devices capable of data communication. The specific deployment method does not change the data transmission relationship between the intelligent agents.
[0020] In one embodiment, the computing device includes a legal consultation terminal and a processing server communicatively connected to the legal consultation terminal. The legal consultation terminal includes a main control module, a touch display module, a voice acquisition module, a network communication module, and a printing module. The processing server runs a semantic parsing agent, a fact analysis agent, a legal retrieval agent, and a response generation agent, and is connected to a legal text database.
[0021] The main control module of the legal consultation terminal reads the legal consultation text input by the user and sends it to the processing server via the network communication module. The processing server writes the legal consultation text, semantic content, and related relationships into the shared session data storage area, and performs semantic encoding, related relationship extraction, processing scope determination, collaborative processing unit division, fact analysis, legal retrieval, and response generation. The fact processing scope, retrieval processing scope, and collaborative processing units store corresponding semantic content identifiers, without repeatedly storing the original text content and semantic representation within the semantic content. Each agent reads the corresponding unit input data from the shared session data storage area based on the collaborative processing unit identifier, causing its processing result to carry the corresponding collaborative processing unit identifier. The processing server sends the generated legal consultation response to the legal consultation terminal, where it is displayed by the touch display module.
[0022] like Figure 1 The diagram shows a flowchart of a method for semantic parsing and response generation of legal consultation based on multi-agent collaboration. The method includes: receiving multiple rounds of legal consultation text to obtain consultation semantic data; using a fact analysis agent and a legal retrieval agent to form a fact processing scope and a retrieval processing scope; for two partially overlapping processing scopes, forming an adjusted processing scope and other processing scopes; dividing the process into non-overlapping collaborative processing units; using a fact analysis agent to form fact analysis results; using a legal retrieval agent to obtain legal retrieval results; forming a unit result group; and generating a legal consultation response.
[0023] Example 1: This embodiment provides a method for semantic parsing and response generation in legal consultation based on multi-agent collaboration. The semantic parsing agent, fact analysis agent, legal retrieval agent, and response generation agent operate as computer processing components capable of reading, processing, and writing data.
[0024] After logging into the user account, the legal consultation terminal reads the user account identifier returned by the processing server. When the legal consultation terminal receives a new consultation instruction, it generates a new consultation session identifier, associates and saves the user account identifier with the consultation session identifier, and creates an empty cumulative legal consultation text. When it receives a continue historical consultation instruction, it queries the corresponding historical consultation record based on the user account identifier and the selected consultation session identifier, reads the historical round legal consultation text in the corresponding consultation session according to the interaction round, and uses the read historical round legal consultation text as the cumulative legal consultation text of the current consultation session.
[0025] For each round of legal consultation, first save the consultation session identifier, interaction round, input time, and original text content. Then, append the newly received legal consultation text to the corresponding cumulative legal consultation text according to the interaction round. Determine the starting position of the original text of this round of legal consultation text based on the character length of the cumulative legal consultation text before appending, and determine the ending position of the original text based on the character length of the original text of this round of legal consultation text. Write the starting and ending positions of the original text into the legal consultation record for this round. Legal consultation texts belonging to different consultation sessions are not merged, nor are they written into the same consultation semantic data.
[0026] The system associates and saves accumulated legal consultation texts, consultation semantic data, fact analysis results, legal search results, and legal consultation responses with their corresponding user account identifiers and consultation session identifiers. When a request to retrieve historical consultations is received, the system compares the user account identifier carried in the request with the user account identifier associated with the consultation session identifier, and returns the corresponding historical consultation data only if they match.
[0027] When the legal consultation terminal receives an instruction to log out of the current user account or the current consultation session ends, it deletes the accumulated legal consultation text, consultation semantic data, and legal consultation responses from the local cache of the legal consultation terminal. It does not delete the data stored on the processing server associated with the user account identifier and consultation session identifier. When resuming historical consultations, the processing server rereads the corresponding historical consultation data and sends it to the legal consultation terminal.
[0028] The legal consultation terminal provides both text and voice input interfaces. When character data is received through the text input interface, the character data from the start to the end of the input is determined as the current round of legal consultation text. When voice data is received through the voice input interface, the voice data is sent to the voice recognition component, which outputs the corresponding character data and determines it as the current round of legal consultation text.
[0029] Perform a null character check on the current round of legal consultation text. If the current round of legal consultation text only contains spaces, line breaks, or punctuation marks, it will not be written into the cumulative legal consultation text, and a re-entry prompt will be output through the legal consultation terminal; if the current round of legal consultation text contains valid text, it will be assigned an interaction round, and the cumulative legal consultation text update and semantic encoding will continue.
[0030] Receive the legal consultation text input by the user in the current round, append the legal consultation text of the current round to the legal consultation text of the previous round according to the interaction order, form a cumulative legal consultation text, and record the original start position and original end position of the legal consultation text of the current round in the cumulative legal consultation text.
[0031] The legal consultation texts for each round are divided according to the positions of periods, semicolons, question marks, and line breaks. When there is valid text between two adjacent separators, the corresponding text is defined as a text unit; when there are only spaces or punctuation marks between two adjacent separators, no text unit is formed.
[0032] Semantic content is established for each text unit. The semantic content includes semantic content identifier, the interaction round to which it belongs, the start position of the original text, the end position of the original text, the original text content, and semantic representation.
[0033] Each text unit undergoes word segmentation, resulting in terms arranged according to their position in the text. The subject name dictionary, action word dictionary, time word dictionary, quantity word dictionary, negation word dictionary, and result word dictionary are configuration data written to the processing server before deployment. Each dictionary record includes a term and its dictionary category. Dictionary records are extracted from legal text in the legal text database and anonymized historical legal consultation text, and are labeled according to six categories: subject name, action, time, quantity, negation, and result before being written. The processing server sequentially queries whether each term exists in at least one dictionary and whether it exists in the stop word list. Punctuation marks are removed; terms existing in the stop word list but not in any dictionary are removed; terms existing in any dictionary, and other terms not in the stop word list, are retained. Each dictionary and stop word list remains unchanged during the same round of semantic encoding.
[0034] The benchmark corpus is composed of the text content of each legal text record in the legal text database and anonymized historical legal consultation texts. Each legal text record or each historical legal consultation text unit is treated as a document within the benchmark corpus. All documents in the benchmark corpus are segmented, and a benchmark term table is established in ascending order of term character encoding. Fixed term positions are assigned to each benchmark term. Let the total number of documents in the benchmark corpus be N, and the number of documents containing the k-th benchmark term be Dk. The inverse document frequency (IVF) of the k-th benchmark term is determined. The ratio of the number of times the k-th benchmark term appears in the current text unit to the total number of terms in the current text unit is calculated to obtain the corresponding term frequency. The product of the term frequency and the corresponding IVF is written into the fixed term position corresponding to the k-th benchmark term. Zero values are written into the positions corresponding to benchmark terms that do not appear in the current text unit. The semantic representation of the corresponding text unit is composed of the values of all fixed term positions.
[0035] In a specific implementation process, legal consultation questions from the Legal QA dataset, legal retrieval queries from the STARD dataset, and case retrieval queries from the LeCaRDv2 dataset are selected as mutually independent validation samples. The number of characters contained in each sample text is counted, and a cumulative distribution is formed based on the proportion of samples in each validation sample set whose number of characters is not greater than the corresponding horizontal axis value.
[0036] like Figure 2 As shown, this diagram illustrates the cumulative distribution of the number of characters in the sample text for legal consultation questions, legal provision retrieval queries, and case retrieval queries used in this application. The horizontal axis represents the number of characters in the sample text on a logarithmic scale, and the vertical axis represents the cumulative distribution. The solid line represents the LeCaRDv2 case retrieval query, the dashed line represents the STARD legal provision retrieval query, and the dotted line represents the LegalQA legal consultation question. These three curves reflect the actual distribution of legal consultation questions, legal provision retrieval queries, and case retrieval queries in terms of sample text length and text length range, verifying that the legal consultation text received by the processing server and the retrieval content processed by the legal retrieval agent have different text length ranges.
[0037] In the anonymized real legal consultation text, the processing server divides the text into units according to the positions of periods, semicolons, question marks and line breaks, and counts the number of text units formed in each round of real consultation text; for legal consultation sessions containing more than two rounds of interaction, the number of rounds of interaction contained in each legal consultation session is further counted.
[0038] like Figure 3 As shown, the distribution of the number of text units in a single round of real consultation text and the number of interaction rounds in a multi-round legal consultation session are illustrated in this application. The black outline represents the distribution of the number of text units in a single round of real consultation text, and the gray fill represents the distribution of the number of interaction rounds in a multi-round legal consultation session. The vertical axis probability density represents the normalized statistical value of the sample occurrence frequency within the corresponding quantity interval. Figure 3 The quantities shown on the horizontal axis are a common abbreviation for discrete count values: for black outlines, the horizontal axis value specifically represents the number of text units obtained according to the aforementioned text unit division method; for gray fills, the horizontal axis value specifically represents the number of interaction rounds contained in a legal consultation session. The number of text units and the number of interaction rounds are two different statistical parameters, which are not equivalent to each other and are not converted into numerical values. They are used to reflect the single-round content composition and multi-round interaction scale of real legal consultation texts.
[0039] Select two different semantic contents in turn, and calculate the vector similarity between the two semantic representations according to the following formula: , in, and These represent the weights corresponding to the k-th term in the two semantic representations, respectively. Here, n represents the dimension of the semantic representation, and S(A,B) represents the vector similarity between two semantic representations. When the weights corresponding to all terms in any semantic representation are zero, the vector similarity between the two semantic representations is set to zero, and no division operation is performed.
[0040] When the vector similarity reaches the association establishment threshold, an association is established with the corresponding two semantic content identifiers as endpoints; when the vector similarity is below the association establishment threshold, no corresponding association is established. The association record includes the semantic content identifier of the first endpoint, the semantic content identifier of the second endpoint, and the vector similarity between the two endpoints.
[0041] The association establishment threshold is determined based on the semantic content obtained before deployment for the labeled samples. Each labeled sample includes two semantic contents and a label indicating whether they are related or unrelated. The vector similarity between the two semantic contents in each labeled sample is calculated, and the different similarity values are sequentially used as candidate thresholds. For each candidate threshold, labeled samples with a vector similarity reaching the threshold are considered related, while those with a vector similarity below the threshold are considered unrelated. The determination results are compared with the corresponding labeling results, and the number of samples with the same determination result is counted. The candidate threshold with the highest number of consistent samples is determined as the association establishment threshold; if multiple candidate thresholds have the same number of consistent samples, the candidate threshold with the higher value is selected.
[0042] Semantic content and relationships are recorded in the consultation semantic data. Relationships are used to record the calculated association between two semantic contents, and the order of occurrence of the corresponding facts is not determined by the order in which the two semantic contents appear in the cumulative legal consultation text.
[0043] Read the fact task description text corresponding to the fact analysis agent and the retrieval task description text corresponding to the legal retrieval agent. Obtain historical legal consultation text units and their task attribution annotation results in advance. For each historical legal consultation text unit, save the sample identifier, the starting position of the original text within the sample, and the task attribution annotation result. The task attribution annotation result is used to indicate whether the corresponding historical legal consultation text unit enters the fact analysis task, the legal retrieval task, or both tasks simultaneously. Historical legal consultation text units marked as entering the fact analysis task are identified as fact task annotation samples, and those marked as not entering the fact analysis task are identified as fact task reverse annotation samples; historical legal consultation text units marked as entering the legal retrieval task are identified as retrieval task annotation samples, and those marked as not entering the legal retrieval task are identified as retrieval task reverse annotation samples. Extract the original text content from the fact task annotation samples, remove duplicates of the same original text content, and concatenate them sequentially according to the sample identifier and the starting position of the original text within the sample to form the fact task description text; process the retrieval task annotation samples in the same way to form the retrieval task description text. The fact task description text and the retrieval task description text are saved as task configuration data for the fact analysis agent and the legal retrieval agent, respectively, and remain unchanged during the determination of the processing scope corresponding to the same cumulative legal consultation text.
[0044] Using the same word segmentation, term weight calculation, and term arrangement methods as text units, the fact task description text and the retrieval task description text are converted into fact task semantic representation and retrieval task semantic representation, respectively.
[0045] The fact analysis agent sequentially calculates the vector similarity between the semantic representation of the fact task and the semantic representation of each semantic content, and adds the semantic content identifiers whose vector similarity reaches the fact task association threshold to the fact processing scope. The legal retrieval agent sequentially calculates the vector similarity between the semantic representation of the retrieval task and the semantic representation of each semantic content, and adds the semantic content identifiers whose vector similarity reaches the retrieval task association threshold to the retrieval processing scope.
[0046] The fact task association threshold is determined based on the fact task labeled samples and fact task reverse labeled samples. The vector similarity between the semantic representation of the fact task and the semantic representation of each fact task labeled sample and fact task reverse labeled sample is calculated. The fact task labeled samples are considered as relevant samples, and the fact task reverse labeled samples are considered as irrelevant samples. The fact task association threshold is determined by the aforementioned candidate threshold comparison method.
[0047] The retrieval task association threshold is determined based on the retrieval task labeled samples and the retrieval task reverse labeled samples. The vector similarity between the semantic representation of the retrieval task and the semantic representation of each retrieval task labeled sample and the retrieval task reverse labeled sample is calculated. The retrieval task labeled samples are considered as relevant samples, and the retrieval task reverse labeled samples are considered as irrelevant samples. The aforementioned candidate threshold comparison method is then used to determine the retrieval task association threshold.
[0048] To verify the impact of the fact-task association threshold and the retrieval task association threshold within a certain range on the collaborative processing unit partitioning results, the threshold combination formed by the fact-task association threshold and the retrieval task association threshold determined according to the aforementioned candidate threshold comparison method is used as the threshold combination adopted in this embodiment, and the collaborative processing unit partitioning result obtained using this threshold combination is used as the benchmark partitioning result. Multiple threshold combinations to be verified are formed within the adjacent value ranges of the fact-task association threshold and the retrieval task association threshold. For each threshold combination to be verified, the determination of the fact processing range, the determination of the retrieval processing range, the adjustment of the partial cross-processing range, and the partitioning of collaborative processing units are re-executed.
[0049] The partitioning result of the collaborative processing unit corresponding to each combination of thresholds to be verified is compared with the baseline partitioning result. For a semantic content identifier, when the set of semantic content identifiers contained in its collaborative processing unit is consistent with the corresponding set in the baseline partitioning result, the semantic content identifier is determined to be partitioned consistent; the ratio of the number of partitioned consistent semantic content identifiers to the total number of semantic content identifiers participating in the comparison is determined as the partitioning consistency ratio of the collaborative processing unit.
[0050] like Figure 4 As shown, this figure illustrates the consistency ratio of collaborative processing unit partitioning under different combinations of fact-task association thresholds and retrieval task association thresholds. The horizontal axis represents the retrieval task association threshold, and the vertical axis represents the fact-task association threshold. The grayscale value represents the consistency ratio of collaborative processing unit partitioning under the corresponding threshold combination; the darker the grayscale, the higher the consistency ratio. The contour lines marked with stability of 0.80 and 0.90 represent the boundaries of threshold combination boundaries with consistency ratios of 0.80 and 0.90, respectively, where stability specifically represents the consistency ratio of collaborative processing unit partitioning. The cross-shaped markers indicate the combination of fact-task association thresholds and retrieval task association thresholds used in this embodiment. The statistical results shown in this figure are used to verify the stability of collaborative processing unit partitioning near the adopted threshold combination without changing the aforementioned determination method of the fact-task association threshold and retrieval task association threshold.
[0051] If both the fact processing scope and the retrieval processing scope are empty, the current round of fact analysis and legal retrieval will cease, and a prompt will be generated to request the user to provide additional information. If neither the fact processing scope nor the retrieval processing scope is empty, the comparison between the two processing scopes will continue.
[0052] When generating a prompt to request additional consultation content from the user, the word segmentation results corresponding to the current round of legal consultation text are read, and the subject name dictionary, behavior word dictionary, time word dictionary, quantifier dictionary, negation word dictionary, and result word dictionary are queried respectively. If no term matching the subject name dictionary exists in the current round of legal consultation text, the subject content is added to the supplementary content set; if no term matching the behavior word dictionary exists, the behavior content is added to the supplementary content set; if no term matching the time word dictionary exists, the time content is added to the supplementary content set; if no term matching the result word dictionary exists, the result content is added to the supplementary content set.
[0053] The content in the set of content to be supplemented is arranged in the order of main content, behavioral content, time content, and result content. The arranged content is then written into a pre-saved supplementary consultation prompt template to generate a prompt for the user to supplement the consultation content. When the set of content to be supplemented is empty, but both the fact processing scope and the retrieval processing scope are empty, a prompt is generated to request the user to redescribe the consultation object, the behavior that occurred, and the consultation request.
[0054] When one of the fact processing scope and the retrieval processing scope is empty and the other is not empty, the process of comparing processing scopes and dividing collaborative processing units is not initiated. The task type corresponding to the empty processing scope is written into the supplementary content record: when the fact processing scope is empty, a prompt is generated to request the user to supplement the factual description; when the retrieval processing scope is empty, a prompt is generated to request the user to supplement the consultation request or re-describe the consultation content. The non-empty processing scope is retained as an intermediate result of this round, but it is not provided to the response generating agent; after receiving the supplementary text, the fact processing scope and the retrieval processing scope are redefined.
[0055] Sequentially read the semantic content identifiers within the fact processing scope and query whether the same semantic content identifier exists within the retrieval processing scope. Semantic content that exists simultaneously in both the fact processing and retrieval processing scopes is identified as common semantic content; semantic content that exists only in the fact processing scope is identified as non-common semantic content on the fact side; and semantic content that exists only in the retrieval processing scope is identified as non-common semantic content on the retrieval side.
[0056] When all semantic content contained in the fact processing scope and the retrieval processing scope is the same, the two processing scopes are determined to be the same processing scope; when the two processing scopes do not have common semantic content, the two processing scopes are determined to be separate; when all semantic content in one processing scope exists in another processing scope and the other processing scope also contains other semantic content, the two processing scopes are determined to be strictly inclusive; when the common semantic content, the fact-side non-common semantic content, and the retrieval-side non-common semantic content are all not empty, the two processing scopes are determined to be partially overlapping.
[0057] For partially overlapping fact processing and retrieval processing scopes, a search set and a read set are established, and common semantic content is added to the search set. Semantic content is read sequentially from the search set, and the association relationships with the currently read semantic content as any endpoint are queried.
[0058] When the semantic content corresponding to the other end of the association belongs to non-common semantic content on the fact side or non-common semantic content on the retrieval side, and has not yet entered the search set or the read set, the semantic content corresponding to the other end is added to the search set. The currently read semantic content is written to the read set, and other semantic content in the search set is read again until there is no unread semantic content in the search set.
[0059] The common semantic content read during the search process, as well as the non-common semantic content connected to the common semantic content, form the adjusted processing scope.
[0060] Sequentially select one semantic content from the non-common semantic content that has never entered the adjusted processing scope as the new starting content, establish a new search set, and search for other non-common semantic content connected to the starting content according to the same association query method. Then, form another processing scope with each found semantic content until all non-common semantic content is included in the corresponding processing scope.
[0061] Write the aforementioned adjusted processing scope and all other processing scopes into the set of processing scopes to be divided, and write all semantic content identifiers contained in the fact processing scope and the retrieval processing scope into the set of unassigned semantic content identifiers.
[0062] The system sequentially reads each processing range in the set of processing ranges to be divided, and selects semantic content identifiers that still exist in the set of unassigned semantic content identifiers from the currently read processing range. When the currently read processing range contains at least one unassigned semantic content identifier, a collaborative processing unit identifier is generated for it. The selected semantic content identifier is written into the corresponding collaborative processing unit, and the association relationship in which both endpoints belong to the collaborative processing unit is selected as the internal association relationship of the corresponding collaborative processing unit.
[0063] Each time a collaborative processing unit is formed, the semantic content identifiers already written into that collaborative processing unit are deleted from the set of unassigned semantic content identifiers before continuing to read the next processing range. If the currently read processing range no longer contains unassigned semantic content identifiers, a collaborative processing unit is not formed again based on that processing range.
[0064] When the set of unassigned semantic content identifiers is empty, the division of collaborative processing units is stopped, an attribution mapping between each semantic content identifier and its corresponding collaborative processing unit identifier is established, and the set of collaborative processing units is published. Since a semantic content identifier is deleted from the set of unassigned semantic content identifiers after being written into a collaborative processing unit, the same semantic content identifier is assigned to only one collaborative processing unit.
[0065] For each collaborative processing unit, the semantic content belonging to that collaborative processing unit is read, and the association relationship where both endpoints are located within that collaborative processing unit is selected to form the corresponding unit input data.
[0066] The fact analysis agent reads the semantic content identifiers and relationships in the input data of the reading unit, and sequentially selects the semantic content that has not yet been assigned to the fact content group as the starting semantic content. It searches for other semantic content that is directly or indirectly connected to the starting semantic content along the relationship that is located in the current collaborative processing unit at both ends. Each set of semantic content found forms a fact content group until all semantic content in the current collaborative processing unit is assigned to the corresponding fact content group.
[0067] For each fact content group, the semantic content is arranged in ascending order according to the interaction rounds it belongs to, and in ascending order of the original text's starting position within the same interaction round. The original text content, interaction round, original text's starting position, original text's ending position, and the relationships within the fact content group are written into the fact analysis results. Relationships whose endpoints are located in other collaborative processing units are not written into the current fact analysis results.
[0068] The fact analysis results save the corresponding collaborative processing unit identifier, each fact content group, the semantic content arrangement order within the fact content group, and the internal relationships. When not all fact content groups have been formed, the result formation status is set to "not formed"; when all semantic content has been assigned to the corresponding fact content group and saved, the result formation status is updated to "formed".
[0069] The legal retrieval agent reads the semantic content of each element in the current collaborative processing unit, and retrieves the corresponding original text content from the accumulated legal consultation texts based on the original start and end positions of the semantic content.
[0070] Each original text content is segmented into words, and words from the stop word list are removed. The remaining words are deduplicated to obtain a group of search terms corresponding to each semantic content. Semantic content not yet included in the search criteria is selected sequentially, and other semantic content directly or indirectly connected to it is searched along the relationships within the current collaborative processing unit. The search terms corresponding to each found semantic content are combined and deduplicated to form a search condition, until all semantic content is included in the corresponding search condition.
[0071] Within each search condition, use logical AND to connect the corresponding search terms; when there are multiple search conditions, use logical OR to connect the different search conditions, and arrange the search conditions according to the starting position of the smallest original text containing the semantic content of each search condition to form a search expression.
[0072] The legal text database stores multiple legal text records. Each record includes a legal text identifier, text type, text title, text content, and text source. Text types include legal regulations, judicial interpretations, and judicial cases. The maximum length of a single search record is set based on the maximum number of characters allowed in the inverted index field of the legal text database. When the legal text content does not exceed the maximum length, the complete legal text content is saved as a single legal text fragment. When it exceeds the maximum length, the legal text content is divided sequentially according to the boundaries of articles, clauses, items, and paragraphs. If any division result still exceeds the maximum length, it is further divided according to a continuous range of characters not exceeding the maximum length. The corresponding legal text identifier, fragment start position, and fragment end position are saved for each legal text fragment.
[0073] Each legal text fragment in the legal text database is segmented into words, and terms from the stop word list are removed while the remaining terms are retained. For each retained term, an inverted index is created pointing to the legal text identifier containing that term and the corresponding fragment location. When querying the legal text database using a search query, the corresponding inverted index is read according to the search terms in the search query, and the legal text identifiers and fragment locations that meet the search criteria are identified as candidate legal text fragments.
[0074] Candidate legal text fragments are obtained by using a retrieval query to access the inverted index of the legal text database. Each candidate legal text fragment undergoes the same semantic encoding process as the text unit to obtain its semantic representation.
[0075] Calculate the vector similarity between the semantic representation of each candidate legal text fragment and the semantic representation of each semantic content within the current collaborative processing unit. Use the highest vector similarity as the candidate fragment matching score for that fragment. Include candidate legal text fragments with matching scores reaching the candidate text retention threshold in the legal retrieval results, and exclude those with matching scores below the threshold.
[0076] The candidate text retention threshold is determined based on the candidate legal text annotation samples. Each candidate legal text annotation sample includes a collaborative processing unit sample, a candidate legal text, and annotation results indicating whether the two are related or unrelated. The matching degree between the candidate legal text and the candidate fragments of the collaborative processing unit sample in each candidate legal text annotation sample is calculated. Samples annotated as related are considered as related samples, and samples annotated as unrelated are considered as unrelated samples. The candidate text retention threshold is determined using the aforementioned candidate threshold comparison method.
[0077] To verify the effectiveness of the candidate text retention threshold on the labeled candidate legal text samples, different candidate segment matching scores were sequentially used as candidate text retention thresholds to be verified, and candidate legal text segments whose matching scores reached the corresponding thresholds were identified as retained segments. For each threshold to be verified, the ratio of the number of retained segments labeled as relevant to the total number of retained segments was determined as precision, and the ratio of the number of retained segments labeled as relevant to the total number of candidate legal text segments labeled as relevant was determined as recall. Calculate the F1 score, where P represents precision and R represents recall. The F1 score is set to zero when the sum of precision and recall is zero. The ratio of the number of retained candidate legal text fragments to the total number of candidate legal text fragments participating in the validation is determined as the candidate legal text fragment retention ratio.
[0078] like Figure 5 As shown, it illustrates the precision, recall, retention rate of candidate legal text fragments, and F1 score of this application at different candidate text retention thresholds. Specifically, as shown... Figure 5 As shown in Figure a, the horizontal axis represents recall, and the vertical axis represents precision. The numerical labels next to each data point indicate the candidate text retention threshold used to generate that data point. Figure 5 As shown in b, the horizontal axis represents the candidate text retention threshold, the curve formed by square data points represents the retention ratio of candidate legal text fragments, and the curve formed by circular data points represents F1.
[0079] In this embodiment, the candidate text retention threshold determined according to the aforementioned candidate threshold comparison method is 0.57. Figure 5 The vertical dashed line in b represents the threshold. Figure 5 The precision, recall, candidate legal text fragment retention rate, and F1 score shown are used to reflect the screening status of the candidate text retention threshold on the labeled candidate legal text samples. It should be noted that F1 is not used as a substitute for the aforementioned candidate threshold comparison method to determine the threshold.
[0080] The legal search results save the corresponding collaborative processing unit identifier, the retained legal text identifier, the fragment start position, the fragment end position, and the corresponding candidate fragment matching degree. When not all candidate legal text fragments have been screened, the result formation status is set to "not formed"; when all candidate legal text fragments have been screened and the screening results are saved, the result formation status is updated to "formed". When no candidate legal text fragments reach the candidate text retention threshold, an empty set of legal text fragments is saved, and the result formation status is updated to "formed".
[0081] The response generation agent queries the corresponding fact analysis results and legal search results according to the collaborative processing unit identifier. When both the fact analysis results and legal search results corresponding to the same collaborative processing unit are in a formed state, the two processing results are read and combined into a unit result group; when either processing result has not yet been formed, the generation of the response fragment corresponding to that collaborative processing unit is stopped, and the already formed processing results are retained, until both processing results corresponding to the same collaborative processing unit are in a formed state.
[0082] The response generation agent reads each fact content group in the result group of the response generation unit, reads the corresponding original text content according to the semantic content arrangement order stored in the fact content group, and writes the read original text content into the fact information part in sequence. The response generation agent reads the legal text identifier, fragment start position, fragment end position, and candidate fragment matching degree from the legal retrieval results, and arranges the retained legal text fragments according to the candidate fragment matching degree from high to low; if the candidate fragment matching degree is the same, they are arranged according to the legal text identifier and fragment start position. According to the arrangement result, the agent reads the text title and fragment content from the legal text database, and writes the legal text identifier, text title, fragment start position, fragment end position, and fragment content into the relevant legal text part in sequence. The fact information part and the relevant legal text part together form the response fragment corresponding to the current collaborative processing unit.
[0083] A response record is established for legal consultation responses. This record includes the consultation session identifier, result formation status, response segments, and the identifier of the corresponding collaborative processing unit for each segment. When not all response segments have been formed, the result formation status is set to "Not Formed." Once all collaborative processing units have formed their corresponding response segments, the response segments are arranged in order of the smallest original text starting position within each collaborative processing unit, and the result formation status is updated to "Formed," thus obtaining the legal consultation response. Fact analysis results and legal search results corresponding to different collaborative processing units are not cross-combined.
[0084] After the response-generating agent forms a legal consultation response, it sends the response to the legal consultation terminal. The legal consultation terminal reads each response fragment from the response, writes the factual information and relevant legal text into the display data according to the order of the response fragments, and outputs the display data through the touch display module.
[0085] When the legal consultation terminal receives a print command, it queries the most recently received legal consultation response based on the current consultation session identifier and reads its result formation status. If the result formation status is "formed," the legal consultation response is converted into print data and sent to the printing module; if no legal consultation response is found or the result formation status is "not formed," no print data is sent. In the update scenario corresponding to Embodiment 2, the processing server only sends the legal consultation response to the legal consultation terminal after the legal consultation response passes the unit version verification.
[0086] Example 2: Based on Example 1, this example updates the collaborative processing units affected by the newly added round of legal consultation text when the fact analysis agent, legal retrieval agent, or response generation agent receives the text during processing.
[0087] When each collaborative processing unit is formed, its identifier and version are saved. The version of the newly formed collaborative processing unit is set to one. When a one-to-one correspondence exists between collaborative processing units before and after the update, the original identifier is retained, and the original version is incremented by one to become the updated version. If the update process results in an original collaborative processing unit being split into multiple collaborative processing units, or multiple original collaborative processing units being merged into one, a new identifier is generated for the resulting collaborative processing unit, and its version is set to one. When the fact analysis agent and the legal retrieval agent read a collaborative processing unit, they also read the current version of that collaborative processing unit.
[0088] The fact analysis results and legal search results respectively save their corresponding collaborative processing unit identifiers and the unit version read at the start of processing. When the response generation agent generates a legal consultation response, it writes the actual collaborative processing unit identifier and corresponding unit version into the legal consultation response.
[0089] Upon receiving a new round of legal consultation text, the text is checked for valid characters according to the empty character check and text unit division method in Implementation Example 1. If no text unit containing valid characters is formed, the new round of legal consultation text is not added to the current accumulated legal consultation text, the collaborative processing unit is not updated, and a prompt for re-entry is output; if at least one text unit containing valid characters is formed, the new round of legal consultation text is added to the current accumulated legal consultation text in the order of interaction, its original start position and original end position are recorded, and the formed text unit is semantically encoded to obtain at least one new semantic content.
[0090] Two different newly added semantic content items are selected sequentially, and the vector similarity between their semantic representations is calculated. Simultaneously, the vector similarity between the semantic representation of each newly added semantic content item and the semantic representation of each existing semantic content item is calculated. When the vector similarity reaches the association establishment threshold, an association is established with the corresponding two semantic content identifiers as endpoints; when the vector similarity is below the association establishment threshold, no corresponding association is established. The newly added semantic content records and the newly formed association records are written into the consultation semantic data corresponding to the current consultation session.
[0091] Based on the existing semantic content identifier, query the collaborative processing unit to which it belongs, and determine the collaborative processing unit that contains existing semantic content that is related to the new semantic content as the collaborative processing unit to be updated.
[0092] When there is no existing semantic content associated with the newly added semantic content, the collaborative processing unit to be updated is not determined. The newly added semantic content is treated as a new processing object, and the fact processing scope, retrieval processing scope and collaborative processing unit corresponding to the newly added semantic content are determined in accordance with the processing scope determination, partial cross-processing scope adjustment and collaborative processing unit formation method of Embodiment 1.
[0093] When there are collaborative processing units to be updated, the existing semantic content in the collaborative processing units to be updated is read, and the existing semantic content and the newly added semantic content are used as update inputs to redetermine the scope of fact processing and retrieval processing. The partial cross-processing scope adjustment and collaborative processing unit division are re-executed to form the updated collaborative processing units.
[0094] The semantic content identifier set and internal relation set contained in the pre-update and post-update collaborative processing units are read separately. For a set of pre-update and post-update collaborative processing units that have the same semantic content identifier set and internal relation set, they are identified as the same unchanged collaborative processing unit, and the original collaborative processing unit identifier, original unit version, fact analysis results, and legal search results are retained.
[0095] For updated collaborative processing units not identified as unchanged, the intersection of their semantic content identifier sets with the semantic content identifier sets of each pre-update collaborative processing unit is calculated. When the intersection of an updated collaborative processing unit with the semantic content identifier sets of all pre-update collaborative processing units is empty, it is identified as a new collaborative processing unit, a new collaborative processing unit identifier is generated for it, the unit version is set to one, and it is written into the updated current collaborative processing unit set. When an updated collaborative processing unit has a non-empty intersection with only one pre-update collaborative processing unit, and the pre-update collaborative processing unit also has a non-empty intersection with only the updated collaborative processing unit, a one-to-one update relationship is established between them, the original collaborative processing unit identifier is maintained, and the original unit version is incremented by one as the updated unit version. When an updated collaborative processing unit has a non-empty intersection with multiple pre-update collaborative processing units, or a pre-update collaborative processing unit has a non-empty intersection with multiple updated collaborative processing units, the corresponding update is identified as a merge update or a split update, a new collaborative processing unit identifier is generated for each collaborative processing unit formed after merging or splitting, and the unit version is set to one. For collaborative processing units whose unit versions have changed or whose collaborative processing unit identifiers have been newly generated, the fact analysis task and legal retrieval task are re-established based on the updated unit input data.
[0096] For pre-update collaborative processing units that were not identified as unchanged collaborative processing units or one-to-one update collaborative processing units, as well as pre-update collaborative processing units that participated in split updates or merge updates, they will not be written into the updated current collaborative processing unit set, and their corresponding fact analysis results and legal search results will no longer be provided to the response generating agent. Other collaborative processing units that were not identified as collaborative processing units to be updated will retain their original collaborative processing unit identifier and original unit version, and will retain their corresponding fact analysis results and legal search results.
[0097] Before providing the fact analysis results and legal search results to the response generation agent, the collaborative processing unit identifier and unit version saved in the two processing results are read respectively, and the current collaborative processing unit set is queried based on the collaborative processing unit identifier.
[0098] First, compare the collaborative processing unit identifiers saved in the fact analysis results and legal search results. If the two collaborative processing unit identifiers are the same, and the current collaborative processing unit can be queried based on this identifier, and the unit versions saved in both the fact analysis results and legal search results are consistent with the queried current unit version, then the two processing results are combined into a unit result group and provided to the response generating agent. If the collaborative processing unit identifiers saved in the two processing results are different, they are not combined into a unit result group.
[0099] If the collaborative processing unit identifier cannot be found, the corresponding processing result will be identified as invalid and its use will be stopped. If the collaborative processing unit identifier can be found, but the unit version saved in the fact analysis result is inconsistent with the current unit version, the fact analysis result will be stopped, and the fact analysis task will be re-executed based on the current collaborative processing unit. If the unit version saved in the legal search result is inconsistent with the current unit version, the legal search result will be stopped, and the search expression and legal search result will be regenerated based on the current collaborative processing unit.
[0100] If any processing result fails or the unit version is inconsistent, the other processing result will not be provided to the response generating agent separately until the fact analysis result and legal search result corresponding to the same current collaborative processing unit have been formed and are consistent with the current unit version.
[0101] After the response-generating agent generates a legal consultation response, it reads all the collaborative processing unit identifiers and unit versions saved in the legal consultation response. It then sequentially queries the current collaborative processing unit set using the collaborative processing unit identifiers. If a corresponding collaborative processing unit can be found, the unit version saved in the legal consultation response is compared with the currently found unit version. If no corresponding collaborative processing unit can be found, the response fragment corresponding to that collaborative processing unit identifier is identified as an invalid response fragment.
[0102] If all collaborative processing unit identifiers can be found and all unit versions are consistent, a legal consultation response will be output. If there is an invalid response segment or any unit version is inconsistent, the output of the legal consultation response will be stopped, and the invalid response segment and the response segment with inconsistent unit version will be deleted.
[0103] The system queries the current set of collaborative processing units that have not yet generated a valid response fragment. It then reads the fact analysis and legal search results consistent with the current unit version and regenerates the corresponding response fragment. Response fragments from collaborative processing units whose unit versions have not changed are retained. Once all current collaborative processing units have generated response fragments that have passed unit version verification, the response fragments are rearranged according to the order of the smallest original text starting position in each collaborative processing unit, forming and outputting the updated legal consultation response.
[0104] In the implementation of this embodiment, 481 update events were recorded, each triggered by a new round of legal consultation text containing valid text and ultimately resulting in an update. For each update event, the moment the processing server receives the new round of legal consultation text is defined as the timing start point, and the moment when all current collaborative processing units generate response fragments that pass unit version verification and are able to generate updated legal consultation responses is defined as the timing end point. The time difference between the timing end point and the timing start point is defined as the processing duration of the update event. For collaborative processing units that have not undergone unit version changes, their existing response fragments are retained in the aforementioned manner; for collaborative processing units whose unit versions have changed or have been re-formed, the newly generated response fragments that pass the current unit version verification are used for statistical analysis.
[0105] like Figure 6 As shown, this application displays the processing time distribution for re-forming all valid response fragments after receiving new rounds of legal consultation text. The horizontal axis represents the processing time after receiving new rounds of legal consultation text, in seconds; the vertical axis represents the proportion of update events for which all valid response fragments have not yet been formed. For any horizontal axis duration, the proportion is the ratio of the number of update events for which all current collaborative processing units have not yet formed response fragments that have passed unit version verification to the total number of 481 update events. The solid line represents the processing time distribution corresponding to the 481 update events, and the vertical dashed line indicates that the median re-formation time is 0.76 seconds, meaning that half of the 481 update events formed all valid response fragments within 0.76 seconds after receiving new rounds of legal consultation text. Figure 6 This is used to reflect the actual operation of the partial update and response fragment reconstruction process in Example 2.
Claims
1. A method for semantic parsing and response generation in legal consultation based on multi-agent collaboration, characterized in that, include: The system receives multiple rounds of legal consultation texts, performs semantic encoding and relation extraction on the accumulated legal consultation texts, and obtains consultation semantic data composed of multiple semantic contents and the relations between semantic contents. The fact analysis agent and the legal retrieval agent are used to select semantic content from the consultation semantic data to form the fact processing scope and the retrieval processing scope, respectively; Compare the fact processing scope and the retrieval processing scope to determine the common semantic content and the non-common semantic content in the two processing scopes, and determine the partial overlap between the two processing scopes when the two processing scopes have common semantic content and do not contain each other. For two partially overlapping processing ranges, starting from the common semantic content, non-common semantic content connected to the common semantic content is searched along the association relationship. The common semantic content and the found non-common semantic content are merged to form the adjusted processing range, and the non-common semantic content that is not found is formed into other processing ranges respectively. Based on the attribution relationship of each semantic content in the adjusted processing scope and the other processing scopes, the adjusted processing scope and the other processing scopes are formed into non-overlapping collaborative processing units; The fact analysis agent generates fact analysis results based on each collaborative processing unit, and the legal retrieval agent generates retrieval formulas based on each collaborative processing unit and obtains legal retrieval results from the legal text database. The response-generating agent combines the fact analysis results and legal search results corresponding to the same collaborative processing unit into unit result groups, and generates legal consultation responses based on each unit result group.
2. The method for semantic parsing and response generation of legal consultation based on multi-agent collaboration according to claim 1, characterized in that, Semantic encoding and relation extraction are performed on the accumulated legal consultation texts, including: The cumulative legal consultation text is divided into multiple text units according to the interaction rounds and the original text position. Semantic encoding is performed on each text unit to obtain the semantic content corresponding to each text unit. The semantic content includes the semantic representation and the original text position of the corresponding text unit. Calculate the vector similarity between the semantic representations of different semantic content, and use the vector similarity as the semantic content association degree between the corresponding semantic content; When the semantic content relevance reaches the relevance establishment threshold, a relevance relationship is established with the corresponding two semantic contents as endpoints, and the semantic content and the relevance relationship are written into the consultation semantic data.
3. The method for semantic parsing and response generation of legal consultation based on multi-agent collaboration according to claim 2, characterized in that, The fact analysis agent and the legal retrieval agent respectively select semantic content from the consultation semantic data to form the fact processing scope and the retrieval processing scope, including: Read the fact task description text corresponding to the fact analysis task and the retrieval task description text corresponding to the legal retrieval task respectively, and perform semantic encoding on the fact task description text and the retrieval task description text to obtain the fact task semantic representation and the retrieval task semantic representation; Calculate the vector similarity between the semantic representation of the fact task and the semantic representation of the retrieval task and the semantic representation of each semantic content, respectively; The semantic content whose vector similarity with the semantic representation of the fact task reaches the fact task association threshold is included in the fact processing range, and the semantic content whose vector similarity with the semantic representation of the retrieval task reaches the retrieval task association threshold is included in the retrieval processing range.
4. The method for semantic parsing and response generation of legal consultation based on multi-agent collaboration according to claim 1, characterized in that, The two processing ranges partially overlap, including: By comparing the attribution of semantic content in the fact processing scope and the retrieval processing scope, semantic content that belongs to both processing scopes is identified as common semantic content, and semantic content that belongs to only one processing scope is identified as non-common semantic content in the corresponding processing scope. When both the common semantic content and the non-common semantic content of each of the two processing ranges are not empty, the two processing ranges are partially intersected.
5. The method for semantic parsing and response generation of legal consultation based on multi-agent collaboration according to claim 4, characterized in that, Adjustments were made to the two overlapping processing ranges, including: Add common semantic content to the search set, and read the semantic content in the search set in sequence; The query uses the currently read semantic content as the associated endpoint to determine the association relationship, and adds non-common semantic content that is connected to the currently read semantic content but has not yet been read to the search set; Repeat the query until there is no unread semantic content in the search set, and form an adjusted processing range by combining the common and non-common semantic content read during the search process; Sequentially select semantic content that has not yet been included in the processing scope from the remaining non-common semantic content as new starting content, and search for the remaining non-common semantic content connected to it according to the same association query method. Then, form another processing scope with each semantic content found, until all remaining non-common semantic content has been included in the corresponding processing scope.
6. The method for semantic parsing and response generation of legal consultation based on multi-agent collaboration according to claim 5, characterized in that, The formation of non-overlapping collaborative processing units includes: Write all semantic content identifiers included in the fact processing scope and retrieval processing scope into the unassigned semantic content identifier set; The adjusted processing range and the other processing ranges are read sequentially. Semantic content identifiers that still exist in the set of unassigned semantic content identifiers are selected from the currently read processing ranges to form corresponding collaborative processing units. Semantic content identifiers that have been assigned to the collaborative processing units are deleted from the set of unassigned semantic content identifiers. The association relationship between two endpoints belonging to the same collaborative processing unit is selected as the internal association relationship of the corresponding collaborative processing unit; When the set of unassigned semantic content identifiers is empty, the collaborative processing unit division is completed, so that the same semantic content identifier is assigned to only one collaborative processing unit.
7. The method for semantic parsing and response generation of legal consultation based on multi-agent collaboration according to claim 6, characterized in that, Provide collaborative processing units to fact-analysis agents and legal retrieval agents, including: For each collaborative processing unit, the semantic content belonging to that collaborative processing unit is read, and the association relationship where both endpoints are located within that collaborative processing unit is selected to form the corresponding unit input data; Based on the input data from the same unit, fact analysis tasks and legal retrieval tasks are established separately, and the processing results of the two tasks are associated with and saved with the corresponding collaborative processing units; When the fact analysis results and legal search results corresponding to the same collaborative processing unit have been formed, the two processing results are combined into a unit result group and provided to the response generating agent; If no processing result has been formed, the already formed processing result is retained and not provided to the response generating agent.
8. The method for semantic parsing and response generation of legal consultation based on multi-agent collaboration according to claim 2, characterized in that, Obtaining the legal search results includes: Based on the original text position of each semantic content within the collaborative processing unit, the corresponding original text content is read from the accumulated legal consultation text, and each original text content is segmented into words to obtain the search term group corresponding to each semantic content. Sequentially select semantic content that has not yet been included in the search conditions as the starting semantic content, search for other semantic content that is directly or indirectly connected to the starting semantic content along the association relationship, combine the search terms corresponding to each semantic content to the same search condition, and repeat the search until each semantic content is included in the corresponding search condition. A search query is generated based on each search condition, and the search query is used to query the legal text database to obtain candidate legal text fragments. Semantic encoding is performed on each candidate legal text fragment. The vector similarity between the semantic representation of the candidate legal text fragment and the semantic representation of each semantic content in the corresponding collaborative processing unit is calculated. The highest vector similarity is taken as the candidate fragment matching degree of the corresponding candidate legal text fragment. The candidate legal text fragments whose candidate fragment matching degree reaches the candidate text retention threshold are determined as the legal retrieval results of the corresponding collaborative processing unit.
9. The method for semantic parsing and response generation of legal consultation based on multi-agent collaboration according to claim 2, characterized in that, Upon receiving legal consultation documents for a new round of consultations: The newly added legal consultation texts are appended to the cumulative legal consultation texts, and the newly added legal consultation texts are semantically encoded to obtain at least one new semantic content; Calculate the vector similarity between the semantic representations of different newly added semantic content, and the vector similarity between the semantic representation of each newly added semantic content and the semantic representation of existing semantic content. When the vector similarity reaches the association establishment threshold, establish the association relationship between the corresponding semantic content. The collaborative processing unit containing existing semantic content that is related to the newly added semantic content is identified as the collaborative processing unit to be updated; Based on the newly added semantic content and the existing semantic content in the collaborative processing units to be updated, the fact processing scope and retrieval processing scope are re-formed, and the corresponding collaborative processing units are re-divided. The original collaborative processing units that were not identified as collaborative processing units to be updated and their processing results are retained.
10. The method for semantic parsing and response generation of legal consultation based on multi-agent collaboration according to claim 9, characterized in that, Set a corresponding unit version for each collaborative processing unit; When a collaborative processing unit is updated, a new unit version is generated for the updated collaborative processing unit, while the unit version of the unupdated collaborative processing unit remains unchanged, so that the fact analysis results and legal search results carry the corresponding collaborative processing unit identifier and unit version respectively. When the intersection of the semantic content identifier set of an updated collaborative processing unit and all the original collaborative processing units is empty, the updated collaborative processing unit is determined as a new collaborative processing unit, a new collaborative processing unit identifier is generated for the new collaborative processing unit, its unit version is set to one, and the new collaborative processing unit is written into the updated current collaborative processing unit set. Before forming a group of unit results, compare the collaborative processing unit identifiers carried by the fact analysis results and the legal search results, and compare the unit versions carried by the two processing results with the unit version of the current corresponding collaborative processing unit. When two processing results carry the same collaborative processing unit identifier, and the unit version carried by both processing results is consistent with the unit version of the current corresponding collaborative processing unit, the two processing results are combined into a unit result group and provided to the response generating agent. When the collaborative processing unit identifiers carried by two processing results are different, the two processing results are not grouped into a unit result group; when the unit version carried by any processing result is inconsistent with the unit version of the current corresponding collaborative processing unit, the processing result with inconsistent version is stopped, and the corresponding fact analysis agent or legal retrieval agent is used to regenerate the corresponding fact analysis result or legal retrieval result based on the current collaborative processing unit. The legal consultation response carries the collaborative processing unit identifier and unit version of each collaborative processing unit it uses. Before outputting the legal consultation response, the carried unit version is compared with the unit version of the corresponding current collaborative processing unit. If they are all consistent, the legal consultation response is output. If there is any inconsistency, the output is stopped, and the legal consultation response is regenerated according to the unit result group corresponding to the current unit version.
