Text semantic matching method, system, device and medium based on large language model

CN122964607APending Publication Date: 2026-10-23SHENZHEN QIANHAI HUANRONG LIANYI INFORMATION TECHNOLOGY SERVICES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611265857.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-20
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0008]本申请实施例提供了基于大语言模型的文本语义匹配方法、系统、设备及介质,用以在保持大语言模型对描述粒度不对称文本的语义推理能力的前提下,解决已完成的推理无法为后续请求所取用、每次匹配均须重新调用大语言模型推理服务,从而导致算力消耗大、端到端响应时延长的问题

Benefits of technology

[0015]本申请实施例所提供的上述方案,与现有技术中把两组文本一并交由大语言模型判定的做法相比,其区别在于将一组文本与一批文本元素之间的整体判定降解为一个文本描述与一个文本元素之间的关联关系,并以该原子粒度把大语言模型给出的成立结论写回可按字段条件检索的关联关系存储。由于写回的关联记录构成后续检索的对象,一次已经完成的推理此后即成为对后续请求可见的已知条件;而现有技术中大语言模型所给出的判定结论无从被后续请求取用,相同的输入只能重复推理。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122964607A_ABST
    Figure CN122964607A_ABST
Patent Text Reader

Abstract

The application discloses a text semantic matching method, system, device and medium based on a large language model. The method comprises the following steps: searching an association record storage to obtain a verified subset of elements in a second text element set, the verified subset of elements being elements having corresponding association records in the second text element set, the association records recording text descriptions and text elements that have been verified to establish a preset semantic relationship; separating an unverified subset when the verified subset is inconsistent with the second text element set, determining a cache key and searching the cache according to the unverified subset; generating an input instruction to call the large language model when the cache is not hit, normalizing text output into a structured conclusion; when the conclusion is correct, writing each element in the unverified subset and a first text description as a group of association records into the storage, without setting a time limit for the storage and taking the group of association records as a subsequent search object; otherwise, writing a matching result into the cache with the cache key and limiting the time of the matching result. The application enables completed reasoning to be reused for subsequent requests, gradually reduces the unverified subset, reduces the frequency of model calling and shortens the response time delay.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of natural language processing and computing resource scheduling, and in particular to text semantic matching methods, systems, devices and media based on large language models. Background Technology

[0002] In the field of text processing, it is often necessary to determine whether a pre-defined semantic relationship exists between two sets of text. One set can be a general descriptive text, while the other set can be several specific text fragments, and the two may differ in their descriptive granularity. For example, it is necessary to determine whether a general category description covers the specific items listed one by one.

[0003] In existing technologies, word segmentation and keyword extraction can be performed on two sets of text, and the judgment can be completed through string comparison. However, when there are differences in expression such as synonyms, hyponyms, abbreviations, or industry-standard names between the texts, the accuracy of this type of solution is limited.

[0004] Alternatively, a domain knowledge graph can be pre-built, and semantic relationships can be determined using the hierarchical, synonymous, or equivalence relations in the graph. However, this type of solution has high construction and maintenance costs, may not provide sufficient coverage for newly emerging domains, goods, and services, and its adaptability to cross-domain applications needs improvement.

[0005] In addition, text vectorization models can be used to map two sets of text into vectors, and the similarity of these vectors can be used for judgment. However, for texts with significant differences in descriptive granularity, or semantic relationships that require inference based on common sense, this type of approach still has shortcomings in terms of accuracy and stability.

[0006] In recent years, large language models have also been used for text semantic matching and can handle relatively complex expression differences to a certain extent. However, in large-scale, long-term operation and high-concurrency business scenarios, existing solutions may still have problems such as high computational resource consumption, long response latency, limited concurrent processing capabilities, and insufficient stability of judgment results.

[0007] Therefore, how to reduce the computational resource consumption and response latency in the text semantic matching process while maintaining the ability to determine complex semantic relationships, and improve the processing efficiency and determination stability in large-scale and dynamic business scenarios, is a technical problem that still needs to be solved in this field. Summary of the Invention

[0008] This application provides a text semantic matching method, system, device, and medium based on a large language model, which solves the problems of high computational consumption and prolonged end-to-end response time caused by the inability of completed reasoning to be used for subsequent requests and the need to re-call the large language model reasoning service for each match, while maintaining the semantic reasoning ability of the large language model for asymmetric text description granularity.

[0009] In a first aspect, embodiments of this application provide a text semantic matching method based on a large language model, comprising: obtaining a first text description and a second set of text elements, wherein each element in the second set of text elements is a text fragment to be determined whether it has a preset semantic relationship with the first text description; the overall condition for the preset semantic relationship is that each element in the second set of text elements has the preset semantic relationship with the first text description; retrieving a relational storage using the first text description and the elements in the second set of text elements as query conditions to obtain a verified subset consisting of elements in the second set of text elements that have corresponding relational records, wherein each relational record records a set of text descriptions and text elements that have been verified to have the preset semantic relationship; and configuring the second set of text elements... Elements outside the verified subset constitute an unverified subset; an input instruction containing the preset semantic relationship is generated based on the first text description and the unverified subset, and the input instruction is sent to the large language model inference service. The returned text output is received, and when there is a conclusion value matching the text output in the preset valid conclusion set, the matching conclusion value is used as a structured conclusion; when there is a conclusion value matching the text output in the valid conclusion set, and the structured conclusion represents the preset semantic relationship, the first text description and each element in the unverified subset are written as a group of associated records into the association relationship storage. The written association records are not subject to a duration limit and constitute the retrieval objects of the retrieval association relationship storage.

[0010] In one implementation, after constructing the unverified subset, the method further includes: determining a cache key based on the first text description and the unverified subset, and querying a key-value cache using the cache key; when the key-value cache is hit, outputting the matching result in the key-value cache corresponding to the cache key; when there is a conclusion value in the valid conclusion set that matches the text output, and the structured conclusion does not represent the preset semantic relationship, writing the matching result corresponding to the structured conclusion into the key-value cache using the cache key as the key, and limiting the duration of the matching result to a preset valid duration.

[0011] Secondly, embodiments of this application also provide a text semantic matching system based on a large language model, comprising: a text acquisition module, configured to acquire a first text description and a second set of text elements, and output the first text description and the second set of text elements to an association retrieval module, wherein each element in the second set of text elements is a text fragment to be determined whether it has a preset semantic relationship with the first text description; the overall condition for the preset semantic relationship is that each element in the second set of text elements has the preset semantic relationship with the first text description; an association retrieval module, configured to retrieve association relationship storage using the first text description and the elements in the second set of text elements as query conditions, and obtain a verified subset consisting of elements in the second set of text elements that have corresponding association records, wherein each association record records a set of text descriptions and text elements that have been verified to have the preset semantic relationship; the association retrieval module is further configured to construct an unverified subset of elements in the second set of text elements other than the verified subset, and output the first text description and the unverified subset to a semantic inference module; the semantic inference module; The system is configured to: generate an input instruction containing the preset semantic relationship requirements based on the first text description and the unverified subset; send the input instruction to the large language model inference service; receive the returned text output; and transmit the first text description, the unverified subset, and the text output to the conclusion parsing module. The conclusion parsing module is configured to: take the conclusion values ​​matching the text output from the preset set of valid conclusions as structured conclusions; output the first text description, the unverified subset, the text output, and the structured conclusions to the differential write-back module; and output the structured conclusions to the result output module. The differential write-back module is configured to: when there is a conclusion value matching the text output in the set of valid conclusions, and the structured conclusion indicates that the preset semantic relationship is established, write each element of the first text description and the unverified subset as a group of associated records into the association relationship storage without setting a duration limit for the written associated records; the written associated records constitute the retrieval objects of the association retrieval module. The result output module is configured to: output the matching results corresponding to the structured conclusions.

[0012] In one implementation, the system further includes a cache reuse module; the associated retrieval module is further configured to output the first text description and the unverified subset to the cache reuse module; the cache reuse module is configured to determine a cache key based on the first text description and the unverified subset, query the key-value cache using the cache key, and when the key-value cache is hit, output the matching result corresponding to the cache key in the key-value cache to the result output module and end the current matching, and when the key-value cache is not hit, output the first text description, the cache key, and the unverified subset to the semantic inference module; the differential write-back module is further configured to, when there is a conclusion value in the valid conclusion set that matches the text output and the structured conclusion does not represent the preset semantic relationship, write the matching result corresponding to the structured conclusion to the key-value cache using the cache key as the key, and limit the duration of the matching result to a preset valid duration; the result output module is further configured to output the matching result output by the cache reuse module.

[0013] Thirdly, embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described method.

[0014] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.

[0015] The solution provided in this application differs from the prior art approach of submitting two sets of text to a large language model for judgment. It decomposes the overall judgment between a set of text and a batch of text elements into the association between a text description and a text element, and writes the valid conclusion given by the large language model back to the association storage that can be retrieved by field conditions at this atomic level. Since the written-back association records constitute the objects of subsequent retrievals, a completed reasoning becomes a known condition visible to subsequent requests; whereas in the prior art, the judgment conclusion given by the large language model cannot be used by subsequent requests, and the same input can only be used for repeated reasoning.

[0016] Based on this, since the associated records are linked at the element level, the known relationships can be identified one by one during retrieval. Therefore, the truly unknown part of the current request can be isolated, and only this part is used for cache lookup and model inference. Compared to existing technologies that determine reusability based on the entire input combination, where a change in a single element renders the entire record invalid, this solution ensures that the verified parts are unaffected by changes in the unverified parts, allowing reuse to occur stably at the element level. Simultaneously, the scale of the input entering the model is reduced, and the computational power required for a single inference operation decreases accordingly.

[0017] The most significant effect lies in reducing the frequency of calls to the large language model inference service: each time the model determines a valid conclusion, it is degraded and written back to become the object of the next retrieval, thus gradually reducing the unverified subset until, in a certain retrieval, the verified subset completely matches the set of elements to be determined, at which point the model no longer needs to participate in the matching. The more times it is used, the more complete this convergence becomes, and the lower the call frequency becomes, with the end-to-end response latency of most requests approaching the order of magnitude of index scanning.

[0018] Furthermore, it addresses the handling of invalid conclusions. Valid conclusions can be degraded into atomic associative records and stored long-term, while invalid conclusions cannot be degraded to the granularity of individual elements and are therefore stored as a whole in the key-value cache for a limited time. This way, on the one hand, repeated requests with the same combination within the same business flow do not need to undergo repeated reasoning; on the other hand, it avoids the problem of long-term storage continuing to block potentially valid determinations after updates to the large language model capabilities. Attached Figure Description

[0019] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 A flowchart illustrating a text semantic matching method based on a large language model provided in an embodiment of this application;

[0021] Figure 2 A schematic diagram of the structure of a text semantic matching system based on a large language model provided in an embodiment of this application;

[0022] Figure 3 A timing diagram illustrating the differentiated persistence process provided in an embodiment of this application;

[0023] Figure 4 This is a flowchart illustrating a multi-granularity concurrent matching process provided in an embodiment of this application.

[0024] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0025] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0026] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0027] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0028] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0029] This application provides a text semantic matching method, system, device, and medium based on a large language model.

[0030] The method provided in this application embodiment can be implemented by a semantic matching service deployed on a server. This service operates in conjunction with three types of components: a relational storage system for persistently storing verified relational records and accepting searches initiated based on field conditions; a key-value cache for accessing matching results by key and supporting setting the duration of the written content; and a large language model inference service that receives input commands and returns text output (hereinafter referred to as the model for lack of confusion). The semantic matching service receives matching requests externally, interacts internally with the above three types of components, and returns matching results downstream. The physical deployment of these three types of components does not affect the implementation of this application embodiment.

[0031] Currently, in scenarios where semantic relationships are determined between two sets of texts with asymmetrical descriptive granularity, existing approaches rely on literal comparison, pre-built domain knowledge graphs, or the distance between text vectors. When encountering semantic differences such as synonyms, hyponyms, abbreviations, or industry-standard names, these approaches often fail to yield correct conclusions. While submitting both sets of texts to a large language model can leverage the model's general knowledge to make a determination, it requires a new inference process for each match.

[0032] Further analysis revealed that the root cause of having to re-infer each time lies not in the model itself, but in the fact that the model's judgment result is a piece of natural language. Natural language cannot be retrieved by field conditions, therefore, there is no carrier in the system that can remember the relationship between a pair of texts that has already been judged and what the conclusion was. Since it cannot remember, any completed inference is invisible to subsequent requests, and it must start all over again. On the other hand, if all the inputs of a matching request are combined to calculate a hash value as the basis for reuse, if even one element in the input changes, the hash value changes as a whole, and all the previously accumulated judgment results are rendered invalid.

[0033] Based on this, in one embodiment of this application, the overall matching between a group of texts and a batch of text elements is decomposed into an atomic unit—the association relationship between a text description and a text element—and the validity conclusion given by the model is saved in units of this atomic unit. What is saved are atomic association records that can be retrieved by field conditions. Subsequent requests can then identify which relationships have been determined at the element level; the determined parts no longer enter the reasoning process, and only the parts that have not yet been determined continue to flow downwards. The validity conclusion given by the model for this part is then decomposed into new atomic association records and written back, becoming the object of the next retrieval. As the number of uses accumulates, the part that needs to be handed over to the model gradually decreases, and the matching processing path gradually converges to the retrieval path, thereby overcoming the problem in the prior art that the model reasoning must be restarted for each match and that historical judgment results cannot be reused, and shortening the end-to-end response latency.

[0034] See Figure 1 The text semantic matching method based on a large language model provided in one embodiment of this application includes:

[0035] Step S101: Obtain the first text description and the second text element set.

[0036] This step is initiated by the semantic matching service upon receiving a matching request. The matching request can be proactively pushed by the upstream business system after completing document parsing, triggered in batches by a scheduled task, or initiated manually on the business interface. The triggering method used does not affect the implementation of this embodiment. The semantic matching service extracts two sets of text to be matched from the request: one set is a general descriptive text, serving as the first text description; the other set consists of several specific text fragments, which, after deduplication, constitute the second set of text elements.

[0037] Each element in the second set of text elements is a text fragment that needs to be determined whether a pre-defined semantic relationship exists between it and the first text description. A pre-defined semantic relationship refers to a definite relationship between the two text fragments at the semantic level. For example, it could be an inclusion relationship where the first text description semantically covers a certain element, or a matching relationship where both refer to the same object. Which relationship needs to be determined needs to be clarified in this step—the determination requirements given to the model in subsequent steps, as well as the candidate conclusion range that the model output should fall into, will all be based on this.

[0038] At this point, the two sets of texts targeted for this match are in place, and the composition of the second set of text elements will determine the scope of the subsequent search.

[0039] Step S102: Using the first text description and the elements in the second text element set as query conditions, retrieve the associated relationship storage to obtain the verified subset consisting of elements in the second text element set that have corresponding associated records.

[0040] The relational storage contains several relational records, each recording a set of text descriptions and text elements that have been verified to have a predefined semantic relationship. Here, "set" means that a record carries only one text description and one text element, rather than the overall relationship between a text description and a group of text elements. It is this atomic recording method that allows us to subsequently determine which relationships are known and which are unknown by examining each element individually.

[0041] It should be noted that the terms "text description" and "text element" here refer to the names of two fields in the associated record, used to represent the two sides of a verified relationship. The first text description is the value entered into the text description field in this match, and the elements in the second text element set are the values ​​entered into the text element field. Subsequent input values ​​related to this match will be referred to as the first text description, while those relating to the record's fields themselves will be referred to as the text description; the two terms refer to different things.

[0042] The semantic matching service uses the first text description as the query condition on the text description side and the elements in the second set of text elements as the query condition on the text element side, initiating a retrieval in the relational storage. Each record returned by the retrieval corresponds to an element in the second set of text elements. The semantic matching service gathers these elements together to obtain the verified subset. The elements in the verified subset are those that have been previously determined to be valid; the elements outside the subset are those whose conclusions are not yet known in this matching. Step S103 is precisely to separate this part. The term "verified" here means that the relationship has been previously determined to be valid by this method, and manual confirmation is not necessary.

[0043] The existence of a corresponding associated record means that there exists an associated record in the association storage where the value of its text description field corresponds to the first text description, and the value of its text element field corresponds to that element. This correspondence can mean that both values ​​are the same, or that the record stores an identifier value obtained by hashing, summarizing, or numbering the text, and that this identifier value is calculated from the corresponding text according to the same rule; the storage format used does not affect the implementation of the embodiments of this application.

[0044] Step S103: The elements outside the verified subset in the second set of text elements constitute the unverified subset.

[0045] After the retrieval in step S102 is completed, the elements in the second text element set are divided into two parts: elements falling into the verified subset, whose relationship with the first text description is known; and elements outside the verified subset, whose relationship is not yet known. The semantic matching service extracts the latter separately to form the unverified subset.

[0046] The reason for separating the unverified subset, instead of submitting the entire set of second text elements to the downstream process, is that the verified relationships have already been determined by the model. Sending them again would not yield new conclusions and would also consume input resources and computational power for inference. After separation, each downstream step only deals with the truly unknown portion of the current matching; as associated records accumulate, this portion will become smaller and smaller.

[0047] Step S104: Generate an input instruction containing the preset semantic relationship judgment requirements based on the first text description and the unverified subset, send the input instruction to the large language model inference service, receive the returned text output, and when there is a conclusion value in the preset valid conclusion set that matches the text output, take the matching conclusion value as the structured conclusion.

[0048] After the unverified subset is separated, the relationship between each element and the first text description has not been previously determined. This matching needs to rely on the semantic reasoning ability of the model to make a judgment on this part.

[0049] The semantic matching service assembles the input instructions accordingly. Each input instruction contains at least three parts: a first text description, elements from the unverified subset, and the judgment requirements for the preset semantic relationships. The judgment requirements inform the model which relationship needs to be judged and by what criteria; they can be written as a task description in natural language, structured field constraints, or include examples. After assembly, the instructions are sent to the large language model inference service via an interface. The model makes a judgment based on the general knowledge it has learned during the pre-training phase and returns a text output.

[0050] The text output returned by the model is free text and cannot be directly used for subsequent access operations. It needs to be normalized to a definite value first. Therefore, a set of valid conclusions is pre-defined. The set of valid conclusions, as referred to in this application, is an ordered sequence composed of several conclusion values ​​arranged in a preset order, where the position of each conclusion value in the sequence is uniquely determined; the terms "first" and "first position" below refer to the one at the very beginning of the preset order. The set of valid conclusions lists all the conclusion values ​​that the model should provide in this matching scenario. For example, when determining an inclusion relationship, it can be set to consist of two items: conclusion values ​​that indicate the condition is not met and conclusion values ​​that indicate the condition is met. The semantic matching service compares the text output with each conclusion value in the set of valid conclusions and takes the matching item as the structured conclusion. The comparison method can be to determine whether the text output starts with a certain conclusion value, whether it contains a certain conclusion value, or to parse the corresponding field from it according to a preset format. Any of the above comparison methods can be used, and this application does not limit this.

[0051] After this normalization process, the free text given by the model is transformed into a definite value taken from a limited candidate range. The subsequent step S105 can then decide whether to write back the conclusion of this judgment based on this value.

[0052] Step S105: When there is a conclusion value in the set of valid conclusions that matches the text output, and the structured conclusion represents the establishment of the preset semantic relationship, the first text description and each element in the unverified subset are written into the association relationship storage as a group of association records. The written association records are not subject to a duration limit and constitute the retrieval objects of the retrieval association relationship storage.

[0053] The structured conclusion indicates that the relationship is valid, meaning that a pre-defined semantic relationship exists between each element in the unverified subset and the first text description. Based on this, the semantic matching service breaks down this overall conclusion: each element in the unverified subset is paired with the first text description, and each pair is written as an association record into the association relationship storage.

[0054] This split-writing action is the key to this embodiment. The model provides an overall judgment for a batch of elements. If saved as is, it can only be reused next time if the combination of input elements is exactly the same. After splitting it into pairs of atomic association records, even if only some of the elements are hit next time, those elements can be excluded from the inference scope. In other words, the reuse granularity of the model output is thus reduced from the request level to the element level.

[0055] There is no time limit for the written association records. Whether a semantic relationship such as inclusion or matching exists between two texts is relatively stable knowledge and usually does not change over time. Long-term storage allows the reuse value to increase with cumulative use. Furthermore, these written association records constitute the retrieval objects when searching the association relationship storage in step S102—the relationship determined and written back by the model this time becomes a known relationship that can be retrieved when the next matching request arrives, thereby reducing the unverified subset of the request accordingly. It is this connection between writing back and retrieval that allows the matching processing path to gradually converge towards the retrieval path as the number of uses increases.

[0056] At this point, the previously unknown relationships in this matching process have been determined by the model, and the conclusions representing the establishment of relationships have been written back. The structured conclusions do not represent the handling method when the preset semantic relationships are established, nor the way the structured conclusions are presented externally; please refer to steps S109 and S110 described later.

[0057] As can be seen from the above process, this embodiment does not simply add a cache layer before the model. The reason why prior art requires re-inference for each match is that the natural language output by the model cannot be retrieved, and there is no carrier in the system to carry historical conclusions; this embodiment degrades the model's valid conclusion into atomic association records between text descriptions and text elements and writes them back to searchable storage, which is equivalent to providing such a carrier for historical conclusions. Thus, historical reasoning becomes known conditions visible to subsequent requests for the first time.

[0058] Based on this, since the associated records are linked at the element level, the retrieval process can identify which relationships are known one by one, thus separating the truly unknown parts of the current request. Compared to existing technologies that use the hash value of the entire input combination as the basis for reuse, where a change in a single element renders the entire record invalid, the verified part in this embodiment is unaffected by changes in the unverified part, allowing reuse to occur stably at the element level. After separation, only a small portion of the unknown data enters the model, thus narrowing the input scale for a single inference and correspondingly reducing the required computing power.

[0059] The most significant effect lies in the frequency of invocation itself: each valid conclusion determined by the model is written back and becomes the object of the next retrieval, thus gradually narrowing down the unverified subset until, in a certain retrieval, the verified subset completely matches the second set of text elements, at which point the model no longer needs to participate in the matching. The more times it is used, the more complete this convergence becomes, and the lower the frequency of invocation of the model inference service.

[0060] It should be noted that the content described in the above paragraphs is only one implementation method of this application, and not the only implementation method of this application.

[0061] The specific form of relational storage can take many forms. It can be a data table in a relational database, with a composite index formed by the text description field and the text element field; it can also be a collection in a document database, with indexes created on the same two fields; it can also be a graph storage, where an edge between a text description node and a text element node represents a related record, in which case the retrieval in step S102 degenerates into a one-hop adjacency query; or it can be a key-value store that supports retrieval by composite key, storing each record with a key composed of the text description and text element. Similarly, a key-value cache can be an independently deployed distributed cache instance, a cache running in a local process, or a data table indexed by the key column. Furthermore, relational storage and key-value caching do not need to belong to two separate storage systems. They can be carried by different data tables in the same storage system, or by different key spaces in the same storage system, as long as one place can retrieve by the two fields of text description and text element, and the other place can access by the cache key and apply a duration.

[0062] It should also be noted that the association storage can be empty when the method is first run. At this time, the verified subset of any matching request is empty, and the unverified subset is the second text element set itself. This matching will complete the inference path up to step S104. Only after the valid conclusion is written back in step S105 will there be records available for retrieval in the association storage; thereafter, each valid conclusion determined by the model will further accumulate records, and the verified subset will increase accordingly. Therefore, the situation in step S102 where the verified subset is not empty or even consistent with the second text element set is a state that will only appear after the method has been running for a period of time, and its cause is the write-back in step S105 in the previous matching processes.

[0063] The data structure of the matching results can be set as a binary tuple, where one tuple carries the structured conclusion and the other carries the judgment criteria; it can also be set as a single value containing only the structured conclusion, or as a structure with fields such as timestamps and request identifiers. Furthermore, the length of the first text description may exceed the preset length limit of the corresponding field in the association relationship storage. In this case, it can be truncated to the limit before writing, or a field type that supports long text can be used, or a summary value of the first text description can be stored instead. All of the above settings do not affect the implementation of the embodiments of this application.

[0064] It should also be noted that the associated records written to the association relationship storage consist of text descriptions and text elements themselves, and can be limited to business texts that do not contain natural person identity information, such as the category of the subject matter, the name of the goods, and the name of the project. If it is indeed necessary to write text containing personal information, it can be anonymized before writing or stored as a summary value, and used within the scope of authorization obtained at the time of acquisition. How the above boundaries are defined does not affect the implementation of the embodiments of this application.

[0065] In the above process, whenever two sets of text matching requests are obtained, the subsequent steps are executed sequentially starting from step S102. When the search results of step S102 are sufficient to provide an overall conclusion, there is no need to continue the matching process further. In this regard, some embodiments of this application have made the following adjustments.

[0066] In addition to the methods described above, it also includes:

[0067] Step S106: When the verified subset matches the second set of text elements, output the matching result indicating that the preset semantic relationship is established and end the matching.

[0068] If the search results in step S102 show that the verified subset is completely consistent with the second set of text elements, it means that there is already an association record between each element in the second set of text elements and the first text description, that is, each pair of relationships has been determined to be valid. Since each pair is valid, the whole is naturally valid. Based on this, the semantic matching service directly outputs the matching result representing the validity of the preset semantic relationship. This matching ends here, and step S103 and subsequent steps are not executed.

[0069] This convergence is possible because it relies on the atomic granularity of the associated records: if the record is a text description and a group of elements as a whole, then this judgment can only be made when the current combination of elements is completely consistent with the combination in the record; however, records are paired, and each pair is equivalent to the whole being true, and how the element combination is arranged or how many there are does not affect this judgment.

[0070] The aforementioned early termination addresses situations where the retrieval process has already yielded a conclusion. However, for parts requiring model judgment, when the same first text description and the same unverified subset repeatedly occur within a short period, the conclusion obtained from the previous judgment can be directly used without needing to initiate further reasoning; even when the structured conclusion does not represent the establishment of the preset semantic relationship, this conclusion still has value for retention and reuse. In this regard, some embodiments of this application, based on the aforementioned method, add a cache reuse step after forming the unverified subset and before generating the input instruction, and further handle structured conclusions that do not represent the establishment of the preset semantic relationship, including:

[0071] Step S107: Determine the cache key based on the first text description and the unverified subset, and query the key-value cache using the cache key.

[0072] After separation, the semantic matching service determines the cache key based on the first text description and the unverified subset. The cache key serves as an identifier for this specific input combination, accessible via a key. It can be determined by concatenating the two elements according to a preset rule and taking the hash digest, by directly using the concatenation result as the key, or by assigning a number to the combination and using the same number when the combination reappears. The method used does not affect the implementation of this embodiment. It should be noted that the cache key is determined based on the unverified subset rather than the second set of text elements—this ensures that even if some elements in the second set of text elements change between two requests, as long as the change falls within the verified portion, the unverified subset remains unchanged, the cache key remains the same, and the previously cached results are still available.

[0073] The semantic matching service then queries the key-value cache using that cache key. The query result will determine whether model inference needs to be initiated in step S104.

[0074] Step S108: When the key-value cache is hit, output the matching result in the key-value cache corresponding to the cache key and end the current matching.

[0075] If the query initiated with the cache key in step S107 matches the key-value cache, it means that this input combination has been previously reasoned about and a result has been retained. The semantic matching service retrieves this result and outputs it directly. This matching process ends here, and step S104 and subsequent steps are no longer executed. The result retrieved here may be a conclusion indicating that the relationship is invalid, or it may be a conclusion previously written to the cache for other reasons. Regardless of the value, its meaning is based on the structured conclusion upon which it was written.

[0076] The reason for setting convergence at both the retrieval and caching stages is to prevent matching requests whose conclusions can already be determined from entering the inference path. Each call from the semantic matching service to the large language model inference service incurs the overhead of a network round trip and a computational inference operation. In high-concurrency scenarios, it also has to wait in line for the model service's computational quota. In contrast, retrieving relational storage only requires one index scan, and querying key-value cache only requires one key retrieval; the overhead of these two operations is on a completely different scale. After setting these two convergences, any request whose conclusion can be determined at the retrieval or caching stage will have its processing stopped at that stage.

[0077] Therefore, as the write-back in step S105 accumulates related records, the proportion of steps S106 being triggered gradually increases, and more and more requests can end at the retrieval stage. Consequently, the overall end-to-end response latency of the method approaches the magnitude of index scanning. This effect is the result of the combined effect of the write-back in step S105 and the early termination here—if only the write-back is set without termination, the accumulated related records can indeed reduce the unverified subset, but the entire process of cache query and conclusion parsing still needs to be completed; if only termination is set without write-back, the related relationship storage will always be empty, and the termination condition cannot be met.

[0078] If the key-value cache is not hit, the matching continues to execute step S104 and subsequent steps; at this time, the input instruction generated in step S104 and the write-back method of the associated record in step S105 are the same as described above, while the structured conclusion that does not represent the establishment of the preset semantic relationship is handled in the following manner:

[0079] Step S109: When there is a conclusion value in the set of valid conclusions that matches the text output, and the structured conclusion does not represent the preset semantic relationship, the matching result corresponding to the structured conclusion is written into the key-value cache using the cache key as the key, and the duration of the matching result is limited to a preset valid duration.

[0080] When the structured conclusion does not represent a valid relationship, the handling method differs from step S105. If the valid conclusion set has two values, this situation indicates that the conclusion does not represent a valid relationship; if the valid conclusion set has more than two values, all values ​​except the one representing a valid relationship fall into this step. The following explains the handling of this step using the case of a invalid representation. Here is a difference that is easily overlooked but determines the handling method: a valid relationship between a batch of elements and the first text description is equivalent to a valid relationship between each element and the first text description, thus allowing for pairwise separation; however, a invalid relationship between a batch of elements only indicates that at least one element is invalid, without specifying which one or how many, the overall model judgment does not provide the granularity of individual elements.

[0081] Since the conclusion cannot be separated, it is stored as a whole. The semantic matching service uses the cache key determined in step S107 as the key and writes the matching result corresponding to the structured conclusion into the key-value cache. In this way, when the same input combination arrives again, the result can be directly retrieved in the query of step S107 without initiating reasoning again.

[0082] The duration of matching results written to the key-value cache is limited to a preset validity period. This limitation is added because the validity of invalid conclusions depends on the model's knowledge and judgment ability at the time: after model version upgrades and updates to surrounding knowledge, combinations originally judged as invalid may lead to completely different conclusions. If invalid conclusions were also permanently stored, these combinations would be blocked by the old conclusions for a long time and would never have the opportunity to be re-inferred. After limiting the duration, the result naturally expires after the preset validity period, and subsequent requests for the same combination will re-enter the inference path. Whether this duration is set by the write instruction along with the write action or uniformly applied by the storage system according to the configuration does not affect the implementation of the embodiments of this application.

[0083] It should be noted that, provided that a conclusion value matching the text output exists in the valid conclusion set, steps S105 and S109 are executed selectively based on the value of the structured conclusion; they will not occur simultaneously in the same matching process. Furthermore, the output action in step S110 described later does not necessarily depend on the order of the two writing actions mentioned above; output can precede writing, writing can precede output, or they can be executed in parallel. This embodiment does not limit the execution order of the two actions. The differentiated persistence process of steps S105 and S109 can be found in [reference needed]. Figure 3 .

[0084] The effect of setting up a cache reuse step is to handle invalid conclusions: valid conclusions can be degraded into atomic association records and stored long-term, while invalid conclusions cannot be degraded to the granularity of individual elements. Therefore, they are stored in the key-value cache as a whole for a limited time. On the one hand, this prevents repeated requests for the same combination within the same business flow from being repeatedly reasoned; on the other hand, it avoids blocking potentially valid judgments after model capability updates, unlike permanent storage. In embodiments without this step, after the unverified subset is formed, step S104 is executed directly, without executing steps S107, S108, and S109. At this time, the structured conclusions that do not represent the validity of the preset semantic relationship are only output with the corresponding matching results without being persisted. Subsequent requests for the corresponding combination re-enter the reasoning path of step S104, and the execution of the other steps is unaffected.

[0085] After completing the above steps, the structured conclusion of this matching is determined, but it is not yet specified in what form this conclusion should be presented externally. In this regard, some embodiments of this application, based on the aforementioned method, further include:

[0086] Step S110: Output the matching results corresponding to the structured conclusion.

[0087] The semantic matching service encapsulates the structured conclusion into a matching result and outputs it. The matching result contains at least the structured conclusion itself, and may also include other content from the model output besides the conclusion as a basis for judgment, for reference by downstream rule engines, review interfaces, or manual review processes. Whether the matching result includes judgment criteria or in what form it is output does not affect the implementation of this embodiment. At this point, the text semantic matching is complete.

[0088] There are several ways to implement the retrieval of the associated relationship storage in step S102 above. One of them is described below.

[0089] Regarding the organization of this retrieval, the semantic matching service can incorporate all elements from the second set of text elements into the conditions of a single structured query statement. Using the first text description as the equality condition for the text description field and all elements as the range condition for the text element field, this single statement performs a batch retrieval of the relational storage, returning all matched related records in one go. After retrieving the matched records, the semantic matching service reads the values ​​of the text element fields from each record, intersects these values ​​with the second set of text elements, and the result is the verified subset.

[0090] In this way, the number of accesses to the relational storage is reduced to a single operation. If the query were performed on each element in the second text element set individually, each element would require one access, one statement parsing, and one network round trip. When the second text element set is large, this overhead accumulates and becomes the main source of latency within a single matching request. Batch retrieval consolidates this overhead into a single operation; the increase in the number of elements then only manifests as an increase in the number of records returned by that query, rather than an increase in the number of accesses.

[0091] To enable this batch retrieval to be completed with the aid of an index, the relational storage can establish indexes on the text description field and on the combination of the text description field and the text element field. The former is used to quickly define the range of records related to the current first text description, while the latter is used to directly locate records within that range by element value. Of course, how the index is established, or even whether an index is established at all, does not affect the implementation of this embodiment; it will only result in a difference in the retrieval time.

[0092] As a result, the time taken in this step no longer increases linearly with the size of the second set of text elements, and the latency level that can be achieved by the aforementioned early convergence is thus maintained in scenarios with a large number of elements.

[0093] In the aforementioned retrieval and writing process, once a related record is written, it remains involved in the retrieval process for an extended period. However, the model's judgments are not infallible, and business criteria may adjust over time. If an erroneous related record is not addressed, it will continue to affect subsequent judgments. Furthermore, the relationship between the same pair of text descriptions and text elements may be repeatedly determined to be true in different batches of matching. Without intervention, a large number of records with identical content will accumulate in the relationship storage. Considering these two points, related records can also be implemented in the following way.

[0094] In the related records retrieved in step S102 above, an enable status flag can be further recorded to indicate whether the record is currently participating in the retrieval determination. The enable status flag can have three values: A value indicating enable is the initial value after the model determination is successful and written back; a value indicating disable is entered when manual review reveals an error in the relationship determination, or when business interpretations are adjusted, causing the relationship to no longer be valid; and a value indicating suspension is entered during the period when the relationship has been requested for review but the review conclusion has not yet been reached. The specific number of values ​​set for the enable status flag and the symbol encoding used do not affect the implementation of this application embodiment.

[0095] Based on this, the method for obtaining the verified subset in step S102 is adjusted accordingly: the semantic matching service only includes the elements corresponding to those records whose enable status flag is set to enabled from the retrieved associated records into the verified subset. Records in the disabled or suspended states still exist in the association relationship storage, but their corresponding elements are not included in the verified subset, and therefore fall into the unverified subset and re-enter the subsequent cache query and model inference path. Correspondingly, in step S105, when writing associated records, the enable status flag is set to indicate enabled, and the newly written relationship participates in subsequent retrievals from the moment of this write.

[0096] Introducing an enabled status flag provides a reversible channel for already written association records. Association records are the repository of model judgment results. When the model makes an error, the erroneous conclusion is written back into the association relationship storage and treated as a known valid relationship in every subsequent retrieval, thus avoiding review—the error is thus solidified. With the enabled status flag, manual review only requires setting the record to disabled; the relationship it carries is then removed from the verified subset, and the relevant request re-enters the inference path for re-judgment, without needing to delete the record itself; the previous judgment trajectory of the relationship is preserved. The suspended status is used during the transition period while review is in progress, allowing questionable relationships to be removed from reuse first, avoiding continued judgments based on questionable conclusions during the review period.

[0097] Based on the fact that the associated records have an enabled status indicator, the process of writing each element as an associated record to the association relationship storage in step S105 above can be further subdivided into the following two sub-steps, both of which still belong to... Figure 1 Expanding the internal structure of the process block containing step S105:

[0098] Step S1051: Perform a difference operation on the text elements recorded in the association records that already exist in the association relationship storage and are described by the first text description, to obtain a set of elements to be written.

[0099] The semantic matching service first retrieves all associated records from the relational storage that are described by the first text description. Here, all records are retrieved, regardless of their enabled status flag values. The text elements recorded in these records are read out, and a difference operation is performed with the unverified subset. Elements that already have corresponding records are deducted from the unverified subset, and the remaining elements constitute the set of elements to be written.

[0100] It's important to note that the reason there are deductible elements here is because the verified subset only includes records in the enabled state: if an element's associated record is disabled or suspended, that element will not enter the verified subset but will fall into the unverified subset and enter the inference path, while its record in the association storage will always exist. Furthermore, when multiple matching requests for the same first text description are processed concurrently, it's possible that a record for a certain element might be written by another request after this retrieval but before this write.

[0101] Step S1052: Write the first text description and each element in the set of elements to be written into the association relationship storage as a group of association records in batches.

[0102] The semantic matching service pairs the first text description with each element in the set of elements to be written, assembling them into several related records, which are then submitted to the relationship storage in a single batch write operation. Compared to submitting record by record, batch writing also reduces the number of accesses on the write side to a single operation.

[0103] The difference operation is performed before writing, preventing the same pair of relations from being repeatedly accumulated in the relational storage. Without this processing, every time a relation in a disabled or suspended state is re-evaluated, a new record in the enabled state is added, coexisting with the original disabled record in storage—whether the relation participates in the retrieval depends on which record is found by the retrieval, rendering the manual disabling action ineffective. After the difference operation, elements with existing records are no longer written repeatedly. A pair of text descriptions and text elements retains at most one record in the relational storage, and the current value of its enabled status flag is the authoritative status of the relation.

[0104] After this approach, on the one hand, the amount of records stored in the relational relationship storage increases with the actual number of relationships rather than the number of judgments, and the range of records to be scanned for retrieval will not expand due to repeated judgments; on the other hand, the handling of relational records by manual review can be stably effective, and a closed governance loop is thus formed between model judgment and manual correction. The consistency between the relational records stored in the relational relationship storage and the actual business scope can be continuously maintained during use, rather than accumulating unidirectionally with the number of judgments.

[0105] Based on the aforementioned cache reuse process, in order to further reduce the storage overhead of cache keys and make them unaffected by the order of elements in the unverified subset, some embodiments of this application have also made the following design to the cache key determination process.

[0106] The step S107 above, which determines the cache key based on the first text description and the unverified subset, can be further divided into the following two sub-steps:

[0107] Step S1071: Concatenate the first text description with the elements in the unverified subset into a string according to the preset concatenation rules.

[0108] The semantic matching service concatenates the first text description with each element in the unverified subset into a string according to pre-agreed rules. This string is an intermediate product of the cache key, and it must do two things: different input combinations must produce distinct strings, and the same input combination must produce the same string regardless of how many times it appears. The former prevents cached results from overwriting each other, and the latter ensures that cached results of the same combination can be retrieved again.

[0109] Step S1072: Perform a hash digest operation on the string, and use the result of the hash digest operation as the cache key.

[0110] The semantic matching service performs a hash digest operation on the above string and uses the result as the cache key. The hash digest operation here is not for security, but for length: the first text description may be hundreds of characters long, and the number of elements in the unverified subset is not fixed. Directly using the concatenated result as the key would cause the key length to increase with the input size, occupying cache storage space and slowing down key matching. After the hash digest operation, the length of the resulting cache key is fixed regardless of the input length. The specific algorithm for the hash digest operation can be a message digest algorithm, a secure hash algorithm, or other algorithms that can map inputs of arbitrary length to fixed-length outputs. The choice of algorithm does not affect the implementation of this embodiment.

[0111] When the length of the cache key is not a constraint, the hash digest operation step can be omitted, and the concatenated string can be used directly as the cache key. If the length of the concatenated result exceeds the upper limit of the key length of the caching system, it can be truncated to the upper limit, and a suffix consisting of the original string length or a count value can be appended to the end of the key to reduce the possibility of collisions between different combinations after truncation.

[0112] The splicing in step S1071 above can be further defined according to the following rules:

[0113] Step S10711: Sort the elements in the unverified subset in lexicographical order and then concatenate them sequentially using a preset delimiter to obtain an element string.

[0114] The semantic matching service first sorts the elements in the unverified subset lexicographically, then concatenates the sorted elements into a string using a preset delimiter. This sorting process, seemingly optional, directly determines the cache hit rate: the unverified subset is derived from the difference set of the second set of text elements, and the order of the same batch of elements in two requests can be completely different. Without sorting, the same batch of elements will result in different strings due to different arrangements, leading to different cache keys, and thus the previously cached results will be unavailable. After sorting, the arrangement of elements is normalized, and the resulting string is identical regardless of the order in which the same batch of elements arrives. The delimiter clearly defines the boundaries between elements, preventing two short elements from being misread as a single long element; it can be a semicolon, comma, or other symbols that do not appear in the element content.

[0115] Step S10712: Concatenate the first text description and the element string into the string according to the preset format string.

[0116] The semantic matching service combines the first text description and the aforementioned element string into a final string used for hashing, according to a preset format string. In addition to the two fields to be filled, the format string can also contain a fixed prefix to distinguish the cache keys generated by different matching scenarios—the same pair of first text descriptions and element strings should yield different conclusions when determining inclusion relationships and other semantic relationships; if they share a cache key, the results of the two scenarios will overwrite each other. After adding the scenario prefix, the cache keys for each scenario are independent. Of course, if only a single matching scenario exists in the system, omitting this prefix in the format string is also acceptable.

[0117] Therefore, the length of the cache key does not increase with the size of the input, and the value does not change with the arrangement of elements. As a result, the hit rate of the key-value cache is not weakened by semantically irrelevant factors such as the order of elements.

[0118] The input instructions in step S104 above, the judgment requirements and the range of candidate conclusions are all given according to a single matching scenario in the aforementioned embodiments; as for the requirement that the same method needs to serve multiple matching scenarios at the same time, it can also be organized in the following way.

[0119] The process of generating input instructions in step S104 above can be further divided into the following two sub-steps:

[0120] Step S1041: Based on the scene identifier of the current matching scene, retrieve the model configuration object corresponding to the scene identifier from the configuration storage.

[0121] The semantic matching service first obtains the scene identifier of the scene to which the current match belongs, and then uses this identifier to query the configuration store to retrieve the corresponding model configuration object. The model configuration object contains two items: a prompt word template and a set of valid conclusions. The former specifies how to state the decision task to the model in this scene, and the latter specifies which values ​​the model's output should fall into in this scene. Both items are retrieved along with the scene identifier, thus ensuring that the way the decision task is stated and the candidate range of conclusions remain consistent within the same scene.

[0122] A single system can have multiple scenario identifiers, each corresponding to a model configuration object. For example, to determine whether a general description covers several specific items, whether a general description matches several specific items one by one, or whether a note corresponds to a set of project information, a scenario identifier can be set for each. When adding a new matching scenario, it is only necessary to add a new model configuration object in the configuration storage and assign a scenario identifier; the processing flow of the semantic matching service does not need to be changed.

[0123] Step S1042: Fill the first text description and the unverified subset into the corresponding placeholders in the prompt word template to obtain the input instruction.

[0124] The prompt template contains several placeholders, corresponding to the first text description and the unverified subset, respectively. The semantic matching service substitutes these two items into the template according to the position of the placeholders. The resulting complete text is the input instruction. Placeholders can be marked with symbols plus variable names, or other marking methods that can be recognized by the template engine. The template itself can be written in sections, such as one section explaining the task, one section listing the inputs to be judged, one section specifying the output format, and one section providing analysis guidelines. The level of detail and order of each section can be adjusted according to the scenario.

[0125] The configuration storage can be a dictionary storage in a distributed configuration center, where the scene identifier is the dictionary code in the dictionary storage. The semantic matching service queries the dictionary storage using the dictionary code, retrieves the dictionary value, and then deserializes it into a model configuration object. The dictionary value can be organized in the form of key-value pairs, which respectively record the prompt word template, the set of valid conclusions, and other running parameters. The advantage of this approach is that configuration changes do not require program redeployment: after the dictionary value is modified in the configuration storage, the semantic matching service retrieves the modified dictionary value when it executes step S1041 again, and the deserialized model configuration object is also updated accordingly. Therefore, the optimization of the prompt word template, the addition and deletion of candidate conclusion values, and the deployment of new scenes can all be completed without service interruption.

[0126] In this embodiment, the text output returned by the model is inference output in natural language form. That is, the model not only gives the conclusion but also states the reasons for reaching that conclusion. Correspondingly, the input instruction generated in step S104 also includes an output format constraint, requiring the model to first give a conclusion value from the set of valid conclusions at the beginning of this inference output, and then state the reasons. This convention is made because the order of natural language is inherently unpredictable; the model could very well lay out an analysis first and place the conclusion at the end. By stipulating that the conclusion be placed first, its position in the output is fixed, providing a definite starting point for subsequent comparisons.

[0127] Based on this, step S104 above, where the matching conclusion value is used as a structured conclusion, can be further divided into the following three sub-steps:

[0128] Step S1043: Perform normalization processing on the text output to remove whitespace characters and special punctuation marks.

[0129] The semantic matching service first cleans the text output returned by the model, removing whitespace characters such as spaces, newlines, and tabs, as well as special punctuation marks such as quotation marks and parentheses that may appear before the conclusion value. The output format of the model is not always strictly consistent. If there is an extra space or a pair of symbols before the same conclusion value, subsequent word-by-word comparisons will fail. After cleaning, the conclusion value is located at the beginning of the text.

[0130] Step S1044: Perform prefix matching between the normalized text output and each conclusion value in the set of valid conclusions.

[0131] The semantic matching service sequentially retrieves each conclusion value from the set of valid conclusions and determines whether the normalized text output begins with that conclusion value. Prefix matching is feasible precisely because of the aforementioned output format constraints—since the conclusion has been conventionally placed at the beginning, only the beginning needs to be compared; there is no need to search throughout the entire text, nor is there any concern that homographs appearing accidentally in the reasoning section might be mistaken for conclusions.

[0132] Step S1045: Take the conclusion value of the first successful prefix match as the structured conclusion.

[0133] Once a conclusion value matches the beginning of the text output, the semantic matching service takes that conclusion value as the structured conclusion and stops subsequent comparisons. Taking the first successful match instead of continuing the traversal is to handle situations where there are prefixes between the valid conclusion set: if one conclusion value is a prefix of another, the traversal order determines the matching result. Therefore, the preset order of the valid conclusion set prioritizes the longer of the prefixed conclusion values, thus ensuring that the longer ones are matched first.

[0134] The model's output does not always fall into the set of valid conclusions. Interface timeouts, empty string returns from the model, and the model failing to respond according to the agreed format will all cause the aforementioned prefix matching to fail. Therefore, some implementations of this application include, in addition to the aforementioned process:

[0135] Step S111: When the text output is empty, the length of the text output is less than the minimum length of each conclusion value in the set of valid conclusions, or there is no conclusion value in the set of valid conclusions that successfully matches the prefix of the text output, the first conclusion value in the set of valid conclusions is taken as the structured conclusion, and the structured conclusion and the identifier of unsuccessful characterization parsing are output as the downgraded matching result.

[0136] The three scenarios described above correspond to the model returning no content, the returned content being too short to contain any conclusion value, and the returned content having length but not starting with any conclusion value. Taking the first conclusion value in the valid conclusion set as the structured conclusion ensures the process can continue uninterrupted; simultaneously, a flag indicating unsuccessful parsing is output along with this conclusion, allowing downstream processes to know that this conclusion is not the model's actual judgment. Here, the first conclusion value refers to the conclusion value ranked first in the preset order of the valid conclusion set. When configuring the valid conclusion set, it is advisable to place conclusion values ​​indicating that the preset semantic relationship is invalid at the first position, ensuring that placeholder values ​​in downgraded scenarios fall on the conservative side. Even if the downstream does not read the unsuccessful parsing flag, it will not treat combinations not judged by the model as valid relationships. The minimum length of the conclusion value, rather than the maximum length, is used as the short string criterion because the lengths of the conclusion values ​​in the valid conclusion set may vary. If the maximum length were used as the boundary, a shorter conclusion value that could have been successfully matched would be judged as unsuccessful parsing first.

[0137] The downgraded matching result is neither written to the association relationship storage nor to the key-value cache; that is, steps S105 and S109 are not executed in this case. This is the key point of this implementation: the downgraded conclusion is not a judgment made by the model on the set of texts, but a placeholder value taken by the process to maintain operation. If it were persisted as a real conclusion, the part representing the establishment of the relationship would be written to the association relationship storage. Subsequent retrievals would treat it as a verified relationship and avoid verification. A single interface timeout would leave a long-term erroneous knowledge record in the storage. By excluding it from being written to the two places, the downgraded conclusion only affects the return value of the current request and does not pollute the storage that can be reused later. The downgraded matching result can be handled by the downstream rule engine or manual review process, and the handling method does not affect the implementation of this application embodiment.

[0138] The above step S109 sets the duration of the matching results written to the key-value cache. The appropriate duration needs to be determined by considering two constraints.

[0139] Regarding the lower bound, the preset validity period is longer than the processing cycle of a single business flow. During the review and flow of the same business, the same set of texts is often repeatedly matched due to data correction, node rollback, and multiple rounds of review. If the validity period is shorter than this flow cycle, the previously obtained invalid conclusions become invalid before the flow ends, and the same combination will have to call the model multiple times within a single flow, rendering the cache ineffective. By setting the validity period above the flow cycle, all repeated requests within a single flow can be handled by the cache.

[0140] Regarding the upper bound, the duration of validity should not be too long. The validity of invalid conclusions depends on the model's knowledge and judgment capabilities at that time. After model version updates and surrounding knowledge updates, the same combination may lead to the opposite judgment. The longer the validity period, the longer the blocking period of old conclusions on new judgments. Therefore, this duration should be commensurate with the update rhythm of model capabilities, so that after the model is updated, previously accumulated invalid conclusions can become invalid on their own within an acceptable time.

[0141] Taking into account the above two aspects, the preset effective duration can be set to 5 calendar days. This value is generally longer than the review and processing cycle of a single business transaction, but shorter than the iteration interval of the model version. Of course, this value can be adjusted according to the business processing cycle and the model update rhythm, or it can be set separately according to the matching scenario, or it can be uniformly distributed by the configuration storage without being written to the program, all of which will not affect the implementation of the embodiments of this application.

[0142] There are several ways to implement invalidation after the expiration of the validity period. One method is to apply the write command during the write operation, allowing the storage system to automatically remove the entry when the validity period expires. Another method is to not apply any command, but compare the write time of the entry with the current time on each read operation, treating entries exceeding the preset validity period as misses. A third method is to have a background task periodically scan and batch-clear entries with expired write times. The first method provides the most accurate invalidation timing, while the latter two methods do not depend on whether the storage system itself supports setting the validity period for each entry.

[0143] After the preset validity period expires, if the same first text description and the same unverified subset are obtained again, the query using the cache key to the key-value cache will no longer hit. The semantic matching service will then re-execute the steps for this set of texts when the key-value cache was not hit, namely, regenerating the input instruction, re-calling the model, and re-parse the conclusion. If the model gives a valid judgment due to capability updates, the conclusion will be degraded into associated records in step S105 and written back to the association relationship storage. After that, this set of relationships will be transferred to the retrieval path and no longer require the model's participation.

[0144] The aforementioned implementation methods all take a second set of text elements as the processing object. In practical applications, the same batch of text can often be summarized into multiple sets at different granularities, and in this case, it can be expanded in the following way.

[0145] See Figure 4 In addition to the methods described above, it also includes:

[0146] Step S401: Extract text fragments from the same data source at at least two granularity levels to obtain at least two subsets of text elements.

[0147] The semantic matching service extracts text fragments from the same data source at different granularity levels. The same data source refers to the same batch of original materials used to form the subsets of text elements. Granularity level refers to the degree of coarseness of the generalization of the same batch of objects—coarse-grained level extracts several category names, while fine-grained level extracts specific names under each category. The extraction at the two levels does not affect each other, and each, after deduplication, forms a subset of text elements.

[0148] Step S402: For each subset of text elements, take the subset of text elements as the second set of text elements, independently execute the retrieval of the association relationship storage and the subsequent steps for the association relationship storage, and output the matching result corresponding to the structured conclusion obtained in this execution as the matching result corresponding to the subset of text elements.

[0149] The semantic matching service treats each subset of text elements as a separate second subset of text elements, and performs the aforementioned retrieval, cache query, model inference, and differential write-back process on each subset. The processing of each subset is independent of each other: its validated subset, unvalidated subset, cache key, input instructions, and structured conclusions are all different. The process of one subset ending at the retrieval stage does not prevent another subset from proceeding to the model inference stage.

[0150] The processing of each subset can be executed as a concurrent task. There is no data dependency between the coarse-grained and fine-grained subsets. In serial processing, the later subset must wait for the earlier subset to complete its process before it can start, and the latency of the two subsets is added together. In concurrent processing, the total latency depends on the slowest subset, not the sum of the two. Concurrency can be implemented using thread pool scheduling, coroutines, or asynchronous task frameworks; the specific form does not affect the implementation of the embodiments in this application.

[0151] Step S403: Aggregate the matching results and output a comprehensive matching result.

[0152] The semantic matching service aggregates the matching results from each subset into a single comprehensive matching result for output. This comprehensive matching result can be divided into conclusions and judgment criteria at different granular levels, allowing downstream applications to obtain both coarse-grained and fine-grained judgments in a single request without needing to initiate separate requests.

[0153] Since the processing of each subset is concurrent, aggregation must wait. The semantic matching service aggregates the obtained matching results after all concurrent tasks have been completed or the preset timeout threshold has been reached. This waiting can be implemented using a counting synchronization primitive: each task submission increments the count, each task completion decrements the count, and the waiting ends when the count reaches zero or the waiting time reaches the preset timeout threshold. The timeout threshold is set because the response time of the model inference service fluctuates significantly, and the prolonged suspension of individual tasks should not indefinitely delay the entire comprehensive matching result; after a timeout, only the obtained matching results are aggregated, and the unfinished parts can be marked as "not obtained" in the comprehensive matching result and handed over to downstream processes for further handling. The preset timeout threshold can be set proportionally to the number of subsets or a fixed value.

[0154] As a result, multiple granularity levels of decision-making are completed concurrently within a single request, and the end-to-end latency does not increase exponentially with the number of granularity levels, while the dimensions upon which downstream decisions are based increase from one to multiple.

[0155] In some embodiments of this application, the association record also contains a business dimension identifier to indicate under which business channel the relationship was determined to be established. Accordingly, in step S105 above, when writing the association relationship into the storage, the current business dimension identifier is also recorded in the written association record; while the retrieval in step S102 above does not use the business dimension identifier as a query condition, and association records containing different business dimension identifiers are all included in the retrieval results.

[0156] The intentional arrangement in this implementation is to record information during writing but not during retrieval. The purpose of the business dimension identifier is for tracing: if a relationship is later found to be incorrectly determined, the identifier can be used to determine which channel it originated from, thereby investigating the input quality or configuration settings of that channel. However, whether a semantic relationship of inclusion or matching exists between two texts depends on the meaning of the text itself and is unrelated to which channel the request for determining it came from—if a product name belongs to a certain category, it belongs to channel A and also to channel B. If the retrieval is filtered according to the business dimension identifier, the associated records accumulated by channel A cannot be used by channel B, and each channel must start accumulating from scratch, and the aforementioned convergence process must be repeated in each channel. Without filtering, any relationship determined and written back by any channel is a known and searchable relationship for all subsequent requests from all channels.

[0157] Of course, if certain business channels do require isolation from each other, such as different channels using different interpretations of the same text, business dimension identifiers can be included in the search criteria, or a separate association storage can be established for such channels. In this case, the association records of that channel do not participate in the search of other channels, and its convergence process is carried out independently. The arrangement adopted does not affect the implementation of the embodiments of this application.

[0158] In one embodiment, obtaining the first text description and the second text element set in step S101 above may include:

[0159] Step S1011: Extract text fragments from the optical character recognition results of the document image and the parsing results of the large language model on the document image, respectively. After deduplication of the extracted text fragments, they are concatenated into the first text description according to the preset delimiter.

[0160] The semantic matching service draws data from two sources. One source is the result of optical character recognition (OCR) on the document image, from which corresponding text fragments are extracted based on field positions. The other source is the result of parsing the document image or its recognized text using a large language model, from which semantic fields are extracted. Each source has its strengths and weaknesses: OCR faithfully reflects the layout, providing stable extraction when field positions are fixed, but is prone to omissions when the layout changes or the text is blurred; large language model parsing is not dependent on a fixed layout and can reconstruct the meaning of fields from context, but the description of the same field may slightly differ from the original text. By using both sources, the other can still provide values ​​even if one is missing.

[0161] Inevitably, duplicate content will appear in the extracted text fragments. The semantic matching service first removes duplicates, and then concatenates the remaining fragments sequentially using a preset delimiter to obtain the first text description. In addition to the above two methods, relevant fields can be extracted from the business master data and added to the concatenation, such as the name and number of the document. The more fields added, the more complete the context carried by the first text description, and the more information the model can refer to when making judgments.

[0162] Step S1012: Extract text fragments from the document verification results, deduplicate the extracted text fragments and filter out empty strings and preset symbols to obtain the second set of text elements.

[0163] The semantic matching service extracts the text fragments corresponding to specific items from the document verification results one by one. Items in the verification results often contain symbols unrelated to semantics, such as asterisks, parentheses, and serial numbers, and may also contain empty strings. The semantic matching service filters these out after deduplication. This filtering step does more than just cleanliness: uncleaned symbols will be included in the concatenation of cache keys and the substitution of prompt word templates along with the elements. The former will cause two batches of elements that should be the same to calculate different cache keys, while the latter will introduce unnecessary interference to the model.

[0164] In the asset verification scenario of supply chain finance, the first text description can be a description of the contract's subject matter, and the elements in the second text element set can be the names of the goods on the invoice. In this case, the method determines whether the general category of the subject matter recorded in the contract covers the specific goods listed item by item on the invoice—the contract description is often general while the invoice description is often specific, and the two are not symmetrical in terms of descriptive granularity, which is precisely the situation that the aforementioned method addresses.

[0165] The preset semantic relationship determined in each of the above implementation methods is based on the condition that each element in the second set of text elements establishes the relationship with the first text description.

[0166] In one variation, the storage used for valid and invalid conclusions can be merged. In the aforementioned embodiments, valid conclusions are written to the relational storage, and invalid conclusions are written to the key-value cache; their responsibilities can also be merged into one. Specifically, invalid conclusions can be written back to the relational storage as a record with an expiration time field, instead of being written to the key-value cache. This record records that the relationship between the first text description and the entire unverified subset is invalid, and records its expiration time in the expiration time field. In this case, the retrieval in step S102 retrieves two types of records at once: valid records at the element level are used to delineate the verified subset, while invalid records at the subset level that have not yet reached their expiration time are used to directly give the conclusion. This variation combines two storage accesses into one, at the cost of having records of two granularities coexisting in the relational storage, making the retrieval and writing logic correspondingly more complex; both arrangements have their trade-offs and can be implemented.

[0167] The following example, comparing the subject matter of contracts and invoices in the construction industry, further illustrates the above implementation methods. In this scenario, the aforementioned reserved options are all set as a set of specific values: the preset semantic relationship is an inclusion relationship; the association relationship storage is a data table in a relational database; the key-value cache is an independently deployed distributed cache instance; the cache key is obtained by concatenating the keys in lexicographical order and then performing a hash digest; the valid conclusion set consists of two conclusion values: the representation is true and the representation is false; and the preset valid duration is 5 calendar days.

[0168] The assets corresponding to a certain construction contract enter the review process. In step S101, the semantic matching service extracts the subject matter field from the optical character recognition results and the large language model parsing results of the contract image. After deduplication and splicing, the first text description is obtained, which contains: building materials and decorative materials. The goods name is extracted from the inspection results of the five invoices associated with the asset. After deduplication and filtering, the second text element set is obtained, which contains the following five elements in order: 42.5 ordinary silicate cement, HRB400 rebar, insulating glass, waterproof coating, and cable.

[0169] In step S102, the semantic matching service uses the first text description and the aforementioned five elements as query conditions. It performs a batch retrieval of the relational storage using a structured query statement, retrieving two associated records in an enabled state. The text elements recorded in these two records are "42.5 ordinary silicate cement" and "HRB400 rebar," respectively. These two elements are then combined to obtain the verified subset. These two records originate from previous matching of similar assets: at that time, the model determined that these two goods belonged to the category range specified in the contract. This conclusion was degraded and written back in step S105, and was thus matched in this retrieval, eliminating the need for further model determination.

[0170] The verified subset contains two elements, while the second text element set contains five elements; therefore, the process proceeds to step S103. The semantic matching service constructs an unverified subset from the remaining three elements, which are, in order: insulated glass, waterproof coating, and cable. Subsequently, in step S107, these elements are sorted lexicographically and concatenated into a string using a delimiter. This string is then concatenated with the first text description according to a format string. A hash digest operation is performed on the concatenated result to obtain the cache key. A query for the key-value cache using this cache key fails.

[0171] In step S104, the semantic matching service retrieves the model configuration object from the configuration storage using the scene identifier of this scenario, obtaining the prompt word template and the set of valid conclusions. Substituting the first text description and three elements from the unverified subset into the template placeholder, the resulting input instruction states: This time, it is necessary to determine whether all the goods listed on the invoice can be classified into one or more categories listed in the contract. It is sufficient that the category can broadly cover the goods, and a conclusion must be given first; if the conclusion is invalid, then the unclassifiable goods will be listed. After the instruction is sent to the large language model inference service, the returned inference output begins with a conclusion value indicating that the conclusion is valid, followed by a statement of the reasoning: insulated glass belongs to glass products among decorative materials, waterproof coatings belong to waterproof materials among building materials, and cables belong to building electrical installation materials. The semantic matching service performs normalization processing on this output and performs prefix matching with each item in the set of valid conclusions to obtain the conclusion value indicating that the conclusion is valid as the structured conclusion.

[0172] The structured conclusion indicates that the relationship is established, proceeding to step S105. The semantic matching service first retrieves all associated records in the relationship storage that use the first text description as the text description, and performs a difference operation with the unverified subset. Since none of the three elements have corresponding records, the set of elements to be written remains these three elements. Then, the first text description is paired with each of the three elements to form three associated records, which are then batch-written into the relationship storage. The enable status flag of each record is set to indicate enable. After the writing is completed, the number of associated records in the relationship storage that use the first text description as the text description increases from two to five. Finally, in step S110, the matching result indicating that the relationship is established is output, along with the above-mentioned reasoning, for reference by the downstream rule engine and manual review process.

[0173] Subsequently, if the contract description of another asset is also building materials or decorative materials, and its invoice goods fall within the aforementioned five categories, then the matching will be fully successful in the retrieval in step S102. The verified subset matches the second set of text elements, and the semantic matching service directly outputs the matching result indicating its validity in step S106, ending the matching process without checking the cache or calling the model. In this scenario, as similar assets continue to be added, common goods names under the category of building materials will gradually be written into the association storage. Afterward, the model calls required for similar matching will approach zero, and the time consumed for a single match will decrease from hundreds of milliseconds to seconds for a single model inference to milliseconds for a single index scan.

[0174] In this scenario, the implementing entity of this method is the service provider responsible for asset verification in supply chain finance. Its deployed semantic matching service selectively executes the corresponding actions in steps S101 to S111 based on the appropriate judgment branch. Externally, this service manifests as follows: the first submission of the same combination and invoice results in a slower response and model call records; subsequent submissions show a significantly faster response and no model call records. The number of records in the relational storage increases with the volume of applications, with each record containing a description of the contract subject matter and a name of goods on an invoice.

[0175] It should be noted that the specific values, field sources, and deployment forms used in the above application scenarios are all examples for ease of understanding, and the embodiments of this application are not limited thereto; the technical means described in the foregoing implementation methods can be implemented individually or in combination as needed, and the combination method is not limited by the above scenarios.

[0176] See Figure 2 This figure is a schematic diagram of the structure of a text semantic matching system based on a large language model provided in another embodiment of this application. Figure 2 As shown, the system includes:

[0177] The text acquisition module 201 is used to acquire a first text description and a second set of text elements, and output the first text description and the second set of text elements to the association retrieval module 202. Each element in the second set of text elements is a text fragment to be determined whether it has a preset semantic relationship with the first text description.

[0178] The association retrieval module 202 is used to retrieve the association relationship storage using the first text description and the elements in the second text element set as query conditions, and obtain a verified subset consisting of elements in the second text element set that have corresponding association records, wherein each association record records a set of text descriptions and text elements that have been verified to establish the preset semantic relationship; the association retrieval module 202 is also used to form an unverified subset of elements in the second text element set other than the verified subset, and output the first text description and the unverified subset to the semantic inference module 204;

[0179] The semantic inference module 204 is used to generate an input instruction containing the judgment requirements of the preset semantic relationship based on the first text description and the unverified subset, send the input instruction to the large language model inference service, receive the text output returned by the large language model inference service, and transmit the first text description, the unverified subset and the text output to the conclusion parsing module 205.

[0180] The conclusion parsing module 205 is used to take the conclusion values ​​that match the text output from the preset set of valid conclusions as structured conclusions, and output the first text description, the unverified subset, the text output and the structured conclusions to the differential write-back module 206, and output the structured conclusions to the result output module 207.

[0181] The differential write-back module 206 is used to write the first text description and each element in the unverified subset as a group of related records into the related relationship storage when there is a conclusion value in the set of valid conclusions that matches the text output and the structured conclusion represents the establishment of the preset semantic relationship. The module does not set a duration limit on the written related records. The written related records constitute the retrieval objects of the related retrieval module 202.

[0182] The result output module 207 is used to output the matching results corresponding to the structured conclusion.

[0183] Each module in the above system corresponds to each step in the aforementioned method embodiments. Regarding the early termination process when the verified subset matches the second set of text elements in the aforementioned method, some embodiments of this application, based on the aforementioned system, further specify that the association retrieval module 202 is used to output a matching result indicating the establishment of the preset semantic relationship to the result output module 207 when the verified subset matches the second set of text elements; the result output module 207 is also used to output the matching result output by the association retrieval module 202. In this case, the association retrieval module 202 performs the action of constructing an unverified subset when the verified subset does not match the second set of text elements.

[0184] Regarding the cache reuse step in the aforementioned method, some embodiments of this application further include a cache reuse module 203 based on the aforementioned system; in this case, the association retrieval module 202 outputs the first text description and the unverified subset to the cache reuse module 203, instead of directly outputting them to the semantic inference module 204:

[0185] The cache reuse module 203 is used to determine a cache key based on the first text description and the unverified subset, query the key-value cache using the cache key, and output the first text description, the cache key, and the unverified subset to the semantic inference module 204 when the key-value cache is not hit; the cache reuse module 203 is also used to output the matching result in the key-value cache corresponding to the cache key to the result output module 207 when the key-value cache is hit.

[0186] In an embodiment where the cache reuse module 203 is configured, the semantic inference module 204 is further configured to receive the cache key output by the cache reuse module 203 and transmit it to the conclusion parsing module 205. The conclusion parsing module 205 is further configured to output the cache key to the differential write-back module 206. The differential write-back module 206 is further configured to, when there is a conclusion value in the set of valid conclusions that matches the text output and the structured conclusion does not represent the establishment of the preset semantic relationship, write the matching result corresponding to the structured conclusion into the key-value cache using the cache key as the key, and limit the duration of the matching result to a preset valid duration. The result output module 207 is further configured to output the matching result output by the cache reuse module 203.

[0187] In another embodiment of this application, the system further includes:

[0188] The configuration management module 208 is used to retrieve the model configuration object corresponding to the scene identifier from the configuration storage according to the scene identifier of the current matching scene, output the prompt word template in the model configuration object to the semantic inference module 204, and output the set of valid conclusions in the model configuration object to the conclusion parsing module 205, wherein the scene identifier corresponds to the preset semantic relationship.

[0189] In another embodiment of this application, the text acquisition module 201 is further configured to extract text fragments at at least two granularity levels to obtain at least two subsets of text elements, and output each subset of text elements as the second set of text elements to the association retrieval module 202; the system further includes:

[0190] The aggregation module 209 is used to aggregate the matching results output by the result output module 207 for each of the text element subsets and output a comprehensive matching result.

[0191] The specific processes by which each module in the above system implements its corresponding function, including the triggering methods of the downstream modules when the verified subset matches the second set of text elements and when the key-value cache is hit, the processing method of the association retrieval module 202 and the differential write-back module 206 for enabling the status identifier of the association record, and the specific working methods of the semantic inference module 204 and the conclusion parsing module 205 under the intervention of the configuration management module 208, can all be found in the corresponding descriptions in the aforementioned embodiments of the text semantic matching method based on a large language model, and will not be repeated here.

[0192] This application also provides an electronic device. See also... Figure 5 This figure is a schematic diagram of the structure of the electronic device provided in an embodiment of this application. Figure 5 As shown, the electronic device includes a processor 501 and a memory 502, which are connected via a bus 503. The electronic device may also include a network interface 504 for communicating with the device where the large language model inference service, the relational storage, and the key-value cache are located.

[0193] The memory 502 stores a computer program that can run on the processor 501. When the computer program is executed by the processor 501, the processor 501 implements the steps of the text semantic matching method based on the large language model in the above embodiments.

[0194] Specifically, the processor 501 is configured to perform the following steps: obtain a first text description and a second set of text elements; retrieve the association relationship storage using the elements in the first text description and the second set of text elements as query conditions to obtain a verified subset consisting of elements in the second set of text elements that have corresponding association records; form an unverified subset consisting of elements in the second set of text elements that are not in the verified subset; generate an input instruction containing the judgment requirements of the preset semantic relationship based on the first text description and the unverified subset; send the input instruction to the large language model inference service; receive the returned text output; and when there is a conclusion value in the preset set of valid conclusions that matches the text output, take the matching conclusion value as a structured conclusion; when there is a conclusion value in the set of valid conclusions that matches the text output, and the structured conclusion indicates that the preset semantic relationship is established, write each element in the first text description and the unverified subset as a group of association records into the association relationship storage.

[0195] In one implementation, the processor 501 is further configured to perform the corresponding steps in the foregoing embodiments, including determining a cache key after constituting the unverified subset and querying the key-value cache with the cache key; generating the input instruction when the key-value cache is not hit; writing the matching result to the key-value cache with the cache key as the key within a time limit when the structured conclusion does not represent the preset semantic relationship; outputting the matching result and ending the current matching when the verified subset is consistent with the second set of text elements or when the key-value cache is hit; filtering the elements to be included in the verified subset according to the enabled status identifier; performing a difference operation before writing; obtaining the model configuration object from the configuration storage according to the scenario identifier; performing normalization processing and prefix matching on the text output; and concurrently processing and aggregating multiple text element subsets, etc., which will not be elaborated here.

[0196] The processor 501 can be a central processing unit, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices. The memory 502 can include volatile memory such as random access memory (RAM), or non-volatile memory such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD). The aforementioned electronic device can be a single server, a server cluster consisting of multiple servers, or a computing instance provided by a cloud computing platform. The relational storage and key-value cache can be deployed on this electronic device or on other devices connected to it via network interface 504, without affecting the implementation of the embodiments of this application.

[0197] This application also provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, the processor implements the steps of the text semantic matching method based on a large language model in the above embodiments. The computer-readable storage medium can be any medium capable of storing a computer program, such as a flash drive, portable hard drive, read-only memory, random access memory, magnetic disk, or optical disk, etc., and other media capable of storing program code.

[0198] Those skilled in the art will recognize that the units / modules and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.

[0199] In the embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For example, the division of each unit is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.

[0200] The steps in the methods of this application embodiment can be adjusted, merged, or deleted according to actual needs. The units in the system of this application embodiment can be merged, divided, or deleted according to actual needs. Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0201] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, terminal, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0202] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A text semantic matching method based on a large language model, characterized in that, include: Obtain a first text description and a second set of text elements, where each element in the second set of text elements is a text fragment to be determined whether it has a preset semantic relationship with the first text description; Using the first text description and the elements in the second text element set as query conditions, the association relationship storage is retrieved to obtain the verified subset consisting of the elements in the second text element set that have corresponding association records. Each of the association records a set of text descriptions and text elements that have been verified to establish the preset semantic relationship. The elements outside the verified subset in the second set of text elements constitute the unverified subset; Based on the first text description and the unverified subset, an input instruction containing the judgment requirements of the preset semantic relationship is generated. The input instruction is sent to the large language model inference service, the returned text output is received, and when there is a conclusion value in the preset valid conclusion set that matches the text output, the matching conclusion value is used as the structured conclusion. When there is a conclusion value in the set of valid conclusions that matches the text output, and the structured conclusion represents the establishment of the preset semantic relationship, the first text description and each element in the unverified subset are written into the association relationship storage as a group of association records. The written association records are not subject to a duration limit and constitute the retrieval objects of the retrieval association relationship storage.

2. The method according to claim 1, characterized in that, After constructing the unverified subset, the method further includes: determining a cache key based on the first text description and the unverified subset, and querying the key-value cache using the cache key; When the key-value cache is hit, the matching result corresponding to the cache key in the key-value cache is output; When there is a conclusion value in the set of valid conclusions that matches the text output, and the structured conclusion does not represent the preset semantic relationship, the matching result corresponding to the structured conclusion is written into the key-value cache using the cache key as the key, and the duration of the matching result is limited to a preset valid duration.

3. The method according to claim 1, characterized in that, The associated record also contains an activation status identifier; The verified subset consisting of elements in the second set of text elements that have corresponding associated records includes: only the elements corresponding to the associated records whose enabled status is indicated as enabled are included in the verified subset; The step of writing to the association storage includes setting the enable status identifier of the written association record to indicate enable.

4. The method according to claim 1, characterized in that, The text output is a reasoning output in natural language form, and the set of valid conclusions is an ordered sequence composed of several conclusion values ​​arranged in a preset order. The input instruction also includes an output format constraint, which requires that the conclusion value from the set of valid conclusions be given at the beginning position of the text output; The step of using the matched conclusion value as a structured conclusion includes: performing normalization processing on the text output to remove whitespace characters and special punctuation marks; The normalized text output is matched with each conclusion value in the set of valid conclusions one by one using prefix matching; the first conclusion value that successfully matches the prefix is ​​taken as the structured conclusion.

5. The method according to claim 2, characterized in that, The set of valid conclusions is an ordered sequence composed of several conclusion values ​​arranged in a preset order; the method further includes: When the text output is empty, the length of the text output is less than the minimum length of each conclusion value in the set of valid conclusions, or there is no conclusion value in the set of valid conclusions that matches the text output, the first conclusion value in the set of valid conclusions is taken as the structured conclusion, and the structured conclusion and the identifier of unsuccessful representation parsing are output as the downgraded matching result. The downgraded matching result is not written to the association storage and is not written to the key-value cache.

6. The method according to claim 1, characterized in that, The input instructions for generating the determination requirements that include the preset semantic relationships include: Based on the scene identifier of the current matching scene, retrieve the model configuration object corresponding to the scene identifier from the configuration storage. The model configuration object contains the prompt word template and the set of valid conclusions. The first text description and the unverified subset are respectively filled into the corresponding placeholders in the prompt word template to obtain the input instruction.

7. The method according to claim 1, characterized in that, The method further includes: extracting text fragments from the same data source at at least two granularity levels to obtain at least two subsets of text elements; For each of the text element subsets, the text element subset is used as the second text element set. The steps of retrieving the association relationship storage and subsequent steps are executed independently for the association relationship storage, and the matching result corresponding to the structured conclusion obtained in this execution is output as the matching result corresponding to the text element subset. After obtaining the matching results corresponding to each of the text element subsets, the matching results are aggregated to output a comprehensive matching result.

8. A text semantic matching system based on a large language model, characterized in that, include: The text acquisition module is used to acquire a first text description and a second set of text elements, and output the first text description and the second set of text elements to the association retrieval module. Each element in the second set of text elements is a text fragment to be determined whether it has a preset semantic relationship with the first text description. The association retrieval module is used to retrieve the association relationship storage using the first text description and the elements in the second text element set as query conditions, and obtain a verified subset consisting of elements in the second text element set that have corresponding association records, wherein each association record records a set of text descriptions and text elements that have been verified to establish the preset semantic relationship; the association retrieval module is also used to form an unverified subset of elements in the second text element set other than the verified subset, and output the first text description and the unverified subset to the semantic inference module; The semantic inference module is used to generate an input instruction containing the judgment requirements of the preset semantic relationship based on the first text description and the unverified subset, send the input instruction to the large language model inference service, receive the returned text output, and transmit the first text description, the unverified subset and the text output to the conclusion parsing module. The conclusion parsing module is used to take the conclusion values ​​that match the text output from the preset set of valid conclusions as structured conclusions, and output the first text description, the unverified subset, the text output and the structured conclusions to the differential write-back module, and output the structured conclusions to the result output module. The differential write-back module is used to write the first text description and each element in the unverified subset as a group of related records into the related relationship storage when there is a conclusion value in the set of valid conclusions that matches the text output and the structured conclusion represents the establishment of the preset semantic relationship. The module does not set a duration limit on the written related records. The written related records constitute the retrieval objects of the related retrieval module. The result output module is used to output the matching results corresponding to the structured conclusion.

9. An electronic device, characterized in that, It includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method as described in any one of claims 1 to 7.

10. 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 to 7.