Method and device for generating domain knowledge response result, medium and terminal
By receiving the problem vector in the domain knowledge response system, calculating the similarity and semantic scores, filtering and splicing the domain knowledge vectors, and generating response results, the problems of response delay and low accuracy caused by large amount of domain knowledge information and the similarity of proper nouns are solved, and a more efficient response response is achieved.
Patent Information
- Application Number
- CN202510581907.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-07
- Publication Date
- 2025-08-05
AI Technical Summary
Due to the huge amount of information in domain knowledge, the response delay increases. At the same time, due to the high similarity of relevant proper nouns of domain knowledge, the text is similar but the semantics are different, resulting in a decrease in the accuracy of the response result.
By receiving user questions and converting them into problem vectors, the similarity scores of each vector and the problem vector in the domain knowledge vector database are calculated, the target domain knowledge vector is filtered out, and the block adjustment, super-large text block cutting and text block title supplement processing are performed, the second text block is obtained for semantic correlation scores, and the response results are stitched together.
The accuracy of the response result is improved, the response response delay is shortened, and the combination of vector matching and semantic similarity is avoided when the proper noun text is similar but the semantics are different, and the matching efficiency is improved.
Smart Images

Figure CN120429426A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the fields of artificial intelligence technology, finance, and medicine, and in particular to a method, device, medium, and terminal for generating domain knowledge response results. Background Art
[0002] With the advancement of information technology, powerful information service platforms have been launched across various industries, such as Murex, a one-stop trading and risk management platform widely used in the financial industry, and medical knowledge information databases used in the healthcare industry. Furthermore, with the development of large language model technology, more and more users are incorporating large language model technology into domain knowledge question-answering assistants to improve the accuracy of domain knowledge responses. However, the vast amount of domain knowledge information increases response latency. Furthermore, the high similarity of relevant domain knowledge terms can lead to superficial similarities in the text, but different underlying semantics, which in turn reduces the accuracy of responses. Summary of the Invention
[0003] In view of this, the present application provides a method, device, medium, and terminal for generating domain knowledge response results. The main purpose is to solve the problem that the response delay increases due to the huge amount of information in the domain knowledge, and the high similarity of the relevant proper nouns in the domain knowledge makes the text similar but the semantics different, which in turn leads to a decrease in the accuracy of the response results.
[0004] According to one aspect of the present application, a method for generating a domain knowledge response result is provided, comprising:
[0005] Receive a question input by a user regarding target domain knowledge, and convert the question into a question vector;
[0006] Calculating similarity scores between each domain knowledge vector contained in a domain knowledge vector database of the target domain and the question vector, and sorting each of the domain knowledge vectors according to the similarity scores to select a preset number of domain knowledge vectors as target domain knowledge vectors, wherein the domain knowledge vectors are obtained by preliminarily performing initial block processing on the original domain knowledge text to obtain a plurality of first text blocks, performing block adjustment processing based on context similarity scores, oversized text block cutting processing, and text block title supplementation processing on each of the first text blocks in sequence to obtain a plurality of second text blocks, and performing vectorization processing on each of the second text blocks;
[0007] Obtain the second text block corresponding to each of the target domain knowledge vectors, calculate the semantic relevance score between each of the second text blocks and the question, perform text block splicing processing on each of the second text blocks based on the semantic relevance score to obtain a spliced paragraph, and call the large model to generate a response result based on the question and the spliced paragraph.
[0008] Preferably, before calculating the similarity scores between the domain knowledge vectors contained in the target domain and the question vector, the method further includes:
[0009] Acquire multiple domain knowledge original texts of the target domain, and use each of the domain knowledge original texts as the target domain knowledge original text;
[0010] According to a preset text block size, the original text of the target domain knowledge is initially divided into blocks to obtain a plurality of first text blocks;
[0011] Performing block adjustment processing on each of the first text blocks based on the context similarity score to obtain a plurality of first text blocks after block adjustment;
[0012] Performing oversized text block cutting processing on each of the first text blocks after the block adjustment to obtain a plurality of cut first text blocks;
[0013] Supplementing a text block title to each of the cut first text blocks to obtain a plurality of second text blocks;
[0014] performing vectorization processing on each of the second text blocks respectively to obtain a plurality of domain knowledge vectors;
[0015] Mapping and storing each of the domain knowledge vectors with the corresponding second text block, respectively, to obtain a plurality of domain knowledge vector mapping relationships contained in the original text of the target domain knowledge;
[0016] The domain knowledge vector mapping relationships contained in the original texts of each target domain knowledge are integrated to obtain a domain knowledge vector database of the target domain.
[0017] Preferably, performing block adjustment processing on the first text block based on the context similarity score to obtain the first text block after block adjustment includes:
[0018] Get the current first text block, the previous first text block, and the next first text block;
[0019] Perform sentence splicing processing on the first sentence of the current first text block, the second sentence of the current first text block, and the last sentence of the previous first text block to obtain a first spliced sentence;
[0020] Perform sentence splicing processing on the last sentence of the current first text block, the first sentence of the next first text block, and the second sentence of the next first text block to obtain a second spliced sentence;
[0021] Performing vector conversion on the first concatenated sentence and the second concatenated sentence respectively to obtain a first concatenated sentence vector and a second concatenated sentence vector, and calculating a similarity score between the first concatenated sentence vector and the second concatenated sentence vector;
[0022] If the similarity score between the first concatenated sentence vector and the second concatenated sentence vector exceeds a preset similarity score threshold, and the first concatenated sentence and the second concatenated sentence belong to the same chapter, the first concatenated sentence and the second concatenated sentence are concatenated to obtain a first text block after block adjustment.
[0023] Preferably, performing super-large text block cutting processing on the first text block after the block adjustment to obtain the cut first text block includes:
[0024] If the number of sentences contained in the first text block after the block adjustment exceeds a preset sentence number threshold, the first text block after the block adjustment is equally cut to obtain the first text block after the first cutting process and the first text block after the second cutting process, and the last sentence in the first text block after the first cutting process is the same as the first sentence in the first text block after the second cutting process.
[0025] Preferably, the step of adding a text block title to the first text block after the cutting process to obtain a second text block comprises:
[0026] taking the first text block after the first segmentation process and the first text block after the second segmentation process as target first text blocks after segmentation process;
[0027] Obtaining the title of the first text block after the target segmentation process, and the parent title of the title;
[0028] The title and the parent title are connected to obtain a supplementary title of the first text block after the target segmentation process, and the supplementary title and the first text block after the target segmentation process are combined to obtain a second text block.
[0029] Preferably, before performing the block adjustment process on each of the first text blocks based on the context similarity score to obtain a plurality of first text blocks after block adjustment, the method further includes:
[0030] Counting the number of sentences contained in each of the first text blocks, and selecting the first text block having 1 sentence;
[0031] Obtaining the preceding adjacent first text block and the following adjacent first text block of each first text block having 1 sentence;
[0032] The last sentence of the preceding adjacent first text block, the first text block with 1 sentence, and the first sentence of the succeeding adjacent first text block are respectively subjected to sentence concatenation processing to obtain a plurality of updated first text blocks, and a block adjustment processing based on the context similarity score is performed on each of the updated first text blocks.
[0033] Preferably, the preset text block size is a preset line spacing or a preset number of sentences.
[0034] According to another aspect of the present application, a device for generating domain knowledge response results is provided, comprising:
[0035] A question receiving module is used to receive questions input by users regarding target domain knowledge and convert the questions into question vectors;
[0036] A domain knowledge vector matching module is configured to calculate a similarity score between each domain knowledge vector contained in the domain knowledge vector database of the target domain and the question vector, and to sort each of the domain knowledge vectors according to the similarity score, screening a preset number of domain knowledge vectors as target domain knowledge vectors, wherein the domain knowledge vectors are obtained by preliminarily performing initial block processing on the original domain knowledge text to obtain a plurality of first text blocks, and then performing block adjustment processing based on context similarity scores, oversized text block cutting processing, and text block title supplementation processing on each of the first text blocks to obtain a plurality of second text blocks, and then performing vectorization processing on each of the second text blocks;
[0037] The answer result generation module is used to obtain the second text block corresponding to each of the target domain knowledge vectors, calculate the semantic relevance score between each of the second text blocks and the question, perform text block splicing processing on each of the second text blocks based on the semantic relevance score to obtain a spliced paragraph, and call the large model to generate a response result based on the question and the spliced paragraph.
[0038] Preferably, before the domain knowledge vector matching module, the device further includes a domain knowledge vector database construction module, including:
[0039] An original text acquisition unit, configured to acquire a plurality of original texts of domain knowledge in the target domain, and use each of the original texts as the target domain knowledge original text;
[0040] An initial block division unit, configured to perform initial block processing on the original text of the target domain knowledge according to a preset text block size to obtain a plurality of first text blocks;
[0041] A block adjustment unit, configured to perform block adjustment processing on each of the first text blocks based on the context similarity score, to obtain a plurality of first text blocks after block adjustment;
[0042] An oversized text block cutting unit, configured to perform oversized text block cutting processing on each of the first text blocks after the block adjustment, to obtain a plurality of cut first text blocks;
[0043] A title supplementing unit, configured to supplement a text block title for each of the cut first text blocks to obtain a plurality of second text blocks;
[0044] a vectorization conversion unit, configured to perform vectorization processing on each of the second text blocks to obtain a plurality of domain knowledge vectors;
[0045] A mapping unit, configured to map and store each of the domain knowledge vectors with the corresponding second text block, to obtain a mapping relationship between multiple domain knowledge vectors contained in the original text of the target domain knowledge;
[0046] The vector integration unit is used to integrate the domain knowledge vector mapping relationships contained in the original texts of each target domain knowledge to obtain the domain knowledge vector database of the target domain.
[0047] Preferably, the block adjustment unit is specifically used to:
[0048] Get the current first text block, the previous first text block, and the next first text block;
[0049] Perform sentence splicing processing on the first sentence of the current first text block, the second sentence of the current first text block, and the last sentence of the previous first text block to obtain a first spliced sentence;
[0050] Perform sentence splicing processing on the last sentence of the current first text block, the first sentence of the next first text block, and the second sentence of the next first text block to obtain a second spliced sentence;
[0051] Performing vector conversion on the first concatenated sentence and the second concatenated sentence respectively to obtain a first concatenated sentence vector and a second concatenated sentence vector, and calculating a similarity score between the first concatenated sentence vector and the second concatenated sentence vector;
[0052] If the similarity score between the first concatenated sentence vector and the second concatenated sentence vector exceeds a preset similarity score threshold, and the first concatenated sentence and the second concatenated sentence belong to the same chapter, the first concatenated sentence and the second concatenated sentence are concatenated to obtain a first text block after block adjustment.
[0053] Preferably, the oversized text block cutting unit is specifically used for:
[0054] If the number of sentences contained in the first text block after the block adjustment exceeds a preset sentence number threshold, the first text block after the block adjustment is equally cut to obtain the first text block after the first cutting process and the first text block after the second cutting process, and the last sentence in the first text block after the first cutting process is the same as the first sentence in the first text block after the second cutting process.
[0055] Preferably, the title supplement unit is specifically used for:
[0056] taking the first text block after the first segmentation process and the first text block after the second segmentation process as target first text blocks after segmentation process;
[0057] Obtaining the title of the first text block after the target segmentation process, and the parent title of the title;
[0058] The title and the parent title are connected to obtain a supplementary title of the first text block after the target segmentation process, and the supplementary title and the first text block after the target segmentation process are combined to obtain a second text block.
[0059] Preferably, before the block adjustment unit, the domain knowledge vector database construction module further includes an ultra-small text block splicing unit, which is specifically used to:
[0060] Counting the number of sentences contained in each of the first text blocks, and selecting the first text block having 1 sentence;
[0061] Obtaining the preceding adjacent first text block and the following adjacent first text block of each first text block having 1 sentence;
[0062] The last sentence of the preceding adjacent first text block, the first text block with 1 sentence, and the first sentence of the succeeding adjacent first text block are respectively subjected to sentence concatenation processing to obtain a plurality of updated first text blocks, and a block adjustment processing based on the context similarity score is performed on each of the updated first text blocks.
[0063] Preferably, the preset text block size is a preset line spacing or a preset number of sentences.
[0064] According to another aspect of the present application, a storage medium is provided, in which at least one executable instruction is stored. The executable instruction enables a processor to execute operations corresponding to the method for generating domain knowledge response results as described above.
[0065] According to another aspect of the present application, there is provided a terminal, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus;
[0066] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute operations corresponding to the method for generating the above-mentioned domain knowledge answer result.
[0067] By means of the above technical solution, the technical solution provided by the embodiment of the present application has at least the following advantages:
[0068] The present application provides a method, device, medium, and terminal for generating domain knowledge answer results. The method first receives a question input by a user regarding target domain knowledge and converts the question into a question vector. Secondly, the method calculates a similarity score between each domain knowledge vector contained in a domain knowledge vector database of the target domain and the question vector, and sorts each of the domain knowledge vectors according to the similarity score to screen out a preset number of domain knowledge vectors as target domain knowledge vectors. The domain knowledge vectors are obtained by pre-processing the original domain knowledge text into multiple first text blocks, and then performing block adjustment processing, super-large text block cutting processing, and text block title supplement processing based on context similarity scores on each of the first text blocks to obtain multiple second text blocks, which are then vectorized. Finally, the second text blocks corresponding to each of the target domain knowledge vectors are obtained, and a semantic relevance score between each of the second text blocks and the question is calculated. Based on the semantic relevance score, each of the second text blocks is subjected to text block splicing processing to obtain spliced paragraphs. A large model is called to generate an answer result according to the question and the spliced paragraphs. Compared with the prior art, the embodiment of the present application first matches multiple domain knowledge vectors from the database based on the similarity score between the domain knowledge vector and the question text, and then reorders and splices the multiple text blocks based on the semantic similarity between the text blocks of the matched domain knowledge vector and the question text. Finally, the large model is called to generate a response result based on the question text and the spliced paragraphs. By combining vector matching (vector similarity) with order adjustment (semantic similarity), the situation where the text of the proper nouns is similar but the semantics are different is avoided, so that the key answers are more forward, thereby improving the accuracy of the response results; and when constructing the domain knowledge vector, a customized block strategy is adopted. The original text of the domain knowledge is initially block-processed to obtain multiple first text blocks, and then each first text block is sequentially subjected to block adjustment processing based on the context similarity score, super-large text block cutting processing and text block title supplement processing to obtain multiple second text blocks. Each of the second text blocks is vectorized, so that the block results are clearer and more indexable, thereby improving the matching efficiency and shortening the response delay.
[0069] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Various other advantages and benefits will become apparent to those skilled in the art upon reading the detailed description of the preferred embodiment below. The accompanying drawings are for illustration purposes only and are not to be considered as limiting the present application. The same reference symbols are used throughout the drawings to represent the same components. In the drawings:
[0071] Figure 1 A flow chart of a method for generating domain knowledge response results provided by an embodiment of the present application is shown;
[0072] Figure 2 A flowchart for constructing a domain knowledge vector database provided by an embodiment of the present application is shown;
[0073] Figure 3 A schematic diagram of a block adjustment process based on context similarity scoring provided in an embodiment of the present application is shown;
[0074] Figure 4 A block diagram of a device for generating domain knowledge response results provided by an embodiment of the present application is shown;
[0075] Figure 5 A schematic diagram of the structure of a terminal provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0076] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0077] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to achieve optimal results.
[0078] Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0079] Based on this, in one embodiment, Figure 1As shown, a method for generating domain knowledge response results is provided, and the method is applied to a computer device such as a server as an example for explanation. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms, such as smart medical systems and digital medical platforms. The above method includes the following steps:
[0080] 101. Receive questions input by the user regarding target domain knowledge and convert the questions into question vectors.
[0081] The target domain can be any domain such as finance, medicine, etc. The domain knowledge can be knowledge related to operation guides, technical manuals, regulations, etc. In the embodiment of the present application, the current execution end can be an intelligent question-answering assistant of the user interaction platform.
[0082] 102. Calculate the similarity scores between each domain knowledge vector contained in the domain knowledge vector database of the target domain and the question vector, sort each domain knowledge vector according to the similarity scores, and select a preset number of domain knowledge vectors as the target domain knowledge vectors.
[0083] Among them, the domain knowledge vector is obtained by pre-processing the original text of the domain knowledge into multiple first text blocks, and then performing block adjustment processing, super-large text block cutting processing and text block title supplement processing based on the context similarity score on each first text block to obtain multiple second text blocks, which are obtained by vectorizing each second text block; the similarity score is used to evaluate the similarity between the domain knowledge vector and the question vector in the text dimension. In the embodiment of the present application, the similarity score between each domain knowledge vector and the question vector contained in the domain knowledge vector database is first calculated, and each domain knowledge vector is sorted in descending order according to the similarity score; further, starting from the first place in the sequence, a preset number of domain knowledge vectors are selected as the target domain knowledge vector. Vector matching is performed based on vector similarity to screen out the target domain knowledge vector. At the same time, since a customized block strategy is adopted when constructing the domain knowledge vector, the block result is clearer and more indexable, thereby improving the efficiency of vector matching.
[0084] 103. Obtain the second text block corresponding to each target domain knowledge vector, calculate the semantic relevance score between each second text block and the question, perform text block splicing processing on each second text block based on the semantic relevance score to obtain a spliced paragraph, and call the large model to generate a response result based on the question and the spliced paragraph.
[0085] Among them, the second text block is used to represent the text block obtained after the original text is customized and segmented, and is stored in the domain knowledge vector database in a mapping manner with the domain knowledge vector; the semantic relevance score is used to evaluate the similarity between the text corresponding to the domain knowledge vector and the question in the semantic dimension. In the embodiment of the present application, the second text block corresponding to each target domain knowledge vector screened out in step 102 of the embodiment is first obtained, the semantic relevance score between it and the question text is calculated, and each second text block is sorted in descending order according to the semantic relevance score; further, each second text block is processed in order to obtain a spliced paragraph; finally, the question and the spliced paragraph are input into the large model to generate the answer result. The order is adjusted based on the semantic similarity to avoid the situation where the key answer is placed at the end because the proper nouns are similar in text but different in semantics.
[0086] Compared with the prior art, the embodiment of the present application first matches multiple domain knowledge vectors from the database based on the similarity score between the domain knowledge vector and the question text, and then reorders and splices the multiple text blocks based on the semantic similarity between the text blocks of the matched domain knowledge vector and the question text. Finally, the large model is called to generate a response result based on the question text and the spliced paragraphs. By combining vector matching (vector similarity) with order adjustment (semantic similarity), the situation where the text of the proper nouns is similar but the semantics are different is avoided, so that the key answers are more forward, thereby improving the accuracy of the response results; and when constructing the domain knowledge vector, a customized block strategy is adopted. The original text of the domain knowledge is initially block-processed to obtain multiple first text blocks, and then each first text block is sequentially subjected to block adjustment processing based on the context similarity score, super-large text block cutting processing and text block title supplement processing to obtain multiple second text blocks. Each of the second text blocks is vectorized, so that the block results are clearer and more indexable, thereby improving the matching efficiency and shortening the response delay.
[0087] In an embodiment of the present application, in order to further define and illustrate, Figure 2 As shown, before calculating the similarity scores between the domain knowledge vectors contained in the target domain and the question vector in step 102 of the embodiment, the embodiment method further includes:
[0088] 201. Obtain multiple domain knowledge original texts of the target domain, and use each domain knowledge original text as the target domain knowledge original text one by one.
[0089] The original text of domain knowledge includes but is not limited to internal documents such as system operation manuals, technical white papers, and compliance documents, external knowledge base files such as industry regulations, professional terminology libraries, and public research reports, and structured data such as database tables and JSON data returned by APIs.
[0090] 202. Perform initial block processing on the original text of the target domain knowledge according to a preset text block size to obtain a plurality of first text blocks.
[0091] The preset text block size may be a preset line spacing or a preset number of sentences; and the initial block processing is used to represent an operation of segmenting the original text of the target domain knowledge according to the preset text block size.
[0092] It should be noted that the first text block is usually a text containing 2-3 sentences.
[0093] 203. Splice the ultra-small text blocks to obtain multiple updated first text blocks.
[0094] Among them, the ultra-small text block is used to represent a text containing only a single sentence. In the embodiment of the present application, for an ultra-small text block, the text block adjacent to the front of the ultra-small text block and the text block adjacent to the back of the ultra-small text block are obtained, and the last sentence of the front adjacent text block, the ultra-small text block, and the first sentence of the back adjacent text block are processed into a sentence splicing process as the updated first text block, so as to avoid the situation of incomplete semantic logic and avoid the problem of information fragmentation.
[0095] Accordingly, step 203 of the embodiment specifically includes: counting the number of sentences contained in each first text block, and screening out the first text block with 1 sentence; obtaining the preceding adjacent first text block and the following adjacent first text block of each first text block with 1 sentence; and performing sentence splicing processing on the last sentence of the preceding adjacent first text block, the first text block with 1 sentence, and the first sentence of the following adjacent first text block, respectively, to obtain multiple updated first text blocks, and perform block adjustment processing on each updated first text block based on the context similarity score.
[0096] 204 . Perform block adjustment processing on each first text block based on the context similarity score to obtain a plurality of first text blocks after block adjustment.
[0097] The block adjustment process based on the context similarity score is used to represent the operation of adjusting the block position according to the similarity score between the spliced sentences.
[0098] For example, Figure 3 As shown in the figure, emed1 represents the previous first text block, emed2 represents the current first text block, and emed3 represents the next first text block; the first sentence of emed2, the second sentence of emed2, and the last sentence of emed1 are subjected to sentence splicing processing to obtain a first spliced sentence sen2; the last sentence of emed2, the first sentence of emed3, and the second sentence of emed3 are subjected to sentence splicing processing to obtain a second spliced sentence sen3; sen2 and sen3 are respectively vector-converted to obtain a vector of sen2 and a vector of sen3, and the similarity score distance = 0.010 between the vector of sen2 and the vector of sen3 is calculated; if the similarity score distance = 0.010 exceeds the preset similarity score threshold, and sen2 and sen3 belong to the same chapter, sen2 and sen3 are sentence-concatenated to obtain the first text block after block adjustment.
[0099] It should be noted that the first text block in the embodiment of the present application is the first text block updated in step 203 of the embodiment.
[0100] Correspondingly, step 204 of the embodiment specifically includes: obtaining the current first text block, the previous first text block, and the next first text block; performing sentence splicing processing on the first sentence of the current first text block, the second sentence of the current first text block, and the last sentence of the previous first text block to obtain a first spliced sentence; performing sentence splicing processing on the last sentence of the current first text block, the first sentence of the next first text block, and the second sentence of the next first text block to obtain a second spliced sentence; performing vector conversion on the first spliced sentence and the second spliced sentence respectively to obtain a first spliced sentence vector and a second spliced sentence vector, and calculating a similarity score between the first spliced sentence vector and the second spliced sentence vector; if the similarity score between the first spliced sentence vector and the second spliced sentence vector exceeds a preset similarity score threshold, and the first spliced sentence and the second spliced sentence belong to the same chapter, then performing sentence splicing processing on the first spliced sentence and the second spliced sentence to obtain a first text block after block adjustment.
[0101] 205 . Perform super-large text block segmentation processing on each of the first text blocks after the block adjustment to obtain a plurality of segmented first text blocks.
[0102] The super-large text block segmentation process is used to represent the operation of re-segmenting the super-large text block according to the rules.
[0103] For example, assuming that the preset sentence number threshold is 10 sentences, the first text block after block adjustment contains 12 sentences. In an embodiment of the present application, the first text block after block adjustment is equally cut, and one sentence of overlapping content is retained at the division point, thereby obtaining the first text block [1,2,...,6,7] after the first cutting process and the first text block [6,7,...,12] after the second cutting process.
[0104] Correspondingly, step 205 of the embodiment specifically includes: if the number of sentences contained in the first text block after block adjustment exceeds a preset sentence number threshold, the first text block after block adjustment is equally cut to obtain the first text block after the first cutting process and the first text block after the second cutting process, wherein the last sentence in the first text block after the first cutting process is the same as the first sentence in the first text block after the second cutting process.
[0105] 206. Supplement the text block title for each of the cut first text blocks to obtain a plurality of second text blocks.
[0106] In an embodiment of the present application, the title of the text block and the parent title are connected to serve as a supplementary title of the text block.
[0107] Correspondingly, step 206 of the embodiment specifically includes: taking the first text block after the first cutting process and the first text block after the second cutting process as the first text block after the target cutting process one by one; obtaining the title of the first text block after the target cutting process, and the parent title of the title; connecting the title and the parent title to obtain the supplementary title of the first text block after the target cutting process, and combining the supplementary title and the first text block after the target cutting process to obtain the second text block.
[0108] 207. Perform vectorization processing on each second text block to obtain multiple domain knowledge vectors.
[0109] In the embodiment of the present application, storing the second text block in the form of a domain knowledge vector can effectively improve the efficiency of matching with the question vector, thereby shortening the response delay.
[0110] 208. Map and store each domain knowledge vector with the corresponding second text block to obtain a mapping relationship of multiple domain knowledge vectors included in the original text of the target domain knowledge.
[0111] 209. Integrate the domain knowledge vector mapping relationships contained in the original texts of each target domain knowledge to obtain a domain knowledge vector database of the target domain.
[0112] Steps 208-209 of the embodiment illustrate the process of constructing the domain knowledge vector database.
[0113] The present application provides a method for generating domain knowledge answer results, which first receives a question about target domain knowledge input by a user and converts the question into a question vector; secondly, calculates a similarity score between each domain knowledge vector contained in a domain knowledge vector database of the target domain and the question vector, and sorts each of the domain knowledge vectors according to the similarity score, and screens out a preset number of domain knowledge vectors as target domain knowledge vectors, wherein the domain knowledge vectors are obtained by pre-initial block processing of the original domain knowledge text to obtain multiple first text blocks, and then each of the first text blocks is subjected to block adjustment processing, super-large text block cutting processing, and text block title supplement processing based on context similarity scores to obtain multiple second text blocks, and each of the second text blocks is vectorized; finally, obtains the second text block corresponding to each of the target domain knowledge vectors, calculates the semantic relevance score between each of the second text blocks and the question, and performs text block splicing processing on each of the second text blocks based on the semantic relevance score to obtain spliced paragraphs, and calls a large model to generate an answer result according to the question and the spliced paragraphs. Compared with the prior art, the embodiment of the present application first matches multiple domain knowledge vectors from the database based on the similarity score between the domain knowledge vector and the question text, and then reorders and splices the multiple text blocks based on the semantic similarity between the text blocks of the matched domain knowledge vector and the question text. Finally, the large model is called to generate a response result based on the question text and the spliced paragraphs. By combining vector matching (vector similarity) with order adjustment (semantic similarity), the situation where the text of the proper nouns is similar but the semantics are different is avoided, so that the key answers are more forward, thereby improving the accuracy of the response results; and when constructing the domain knowledge vector, a customized block strategy is adopted. The original text of the domain knowledge is initially block-processed to obtain multiple first text blocks, and then each first text block is sequentially subjected to block adjustment processing based on the context similarity score, super-large text block cutting processing and text block title supplement processing to obtain multiple second text blocks. Each of the second text blocks is vectorized, so that the block results are clearer and more indexable, thereby improving the matching efficiency and shortening the response delay.
[0114] Furthermore, as a response to the above Figure 1 The embodiment of the present application provides a device for generating domain knowledge response results, such as Figure 4 As shown, the device includes:
[0115] Question receiving module 31, domain knowledge vector matching module 32, answer result generating module 33;
[0116] A question receiving module 31 is configured to receive a question input by a user regarding target domain knowledge and convert the question into a question vector;
[0117] The domain knowledge vector matching module 32 is configured to calculate a similarity score between each domain knowledge vector contained in the domain knowledge vector database of the target domain and the question vector, and sort the domain knowledge vectors according to the similarity score to select a preset number of domain knowledge vectors as target domain knowledge vectors. The domain knowledge vectors are obtained by preliminarily performing an initial block processing on the original domain knowledge text to obtain a plurality of first text blocks, and then performing block adjustment processing based on context similarity scores, oversized text block cutting processing, and text block title supplementation processing on each of the first text blocks to obtain a plurality of second text blocks, and then performing vectorization processing on each of the second text blocks.
[0118] The answer result generation module 33 is used to obtain the second text block corresponding to each of the target domain knowledge vectors, calculate the semantic relevance score between each of the second text blocks and the question, perform text block splicing processing on each of the second text blocks based on the semantic relevance score to obtain a spliced paragraph, and call the large model to generate an answer result according to the question and the spliced paragraph.
[0119] In a specific application scenario, before the domain knowledge vector matching module, the device further includes a domain knowledge vector database construction module, including:
[0120] An original text acquisition unit, configured to acquire a plurality of original texts of domain knowledge in the target domain, and use each of the original texts as the target domain knowledge original text;
[0121] An initial block division unit, configured to perform initial block processing on the original text of the target domain knowledge according to a preset text block size to obtain a plurality of first text blocks;
[0122] A block adjustment unit, configured to perform block adjustment processing on each of the first text blocks based on the context similarity score, to obtain a plurality of first text blocks after block adjustment;
[0123] An oversized text block cutting unit, configured to perform oversized text block cutting processing on each of the first text blocks after the block adjustment, to obtain a plurality of cut first text blocks;
[0124] A title supplementing unit, configured to supplement a text block title for each of the cut first text blocks to obtain a plurality of second text blocks;
[0125] a vectorization conversion unit, configured to perform vectorization processing on each of the second text blocks to obtain a plurality of domain knowledge vectors;
[0126] A mapping unit, configured to map and store each of the domain knowledge vectors with the corresponding second text block, to obtain a mapping relationship between multiple domain knowledge vectors contained in the original text of the target domain knowledge;
[0127] The vector integration unit is used to integrate the domain knowledge vector mapping relationships contained in the original texts of each target domain knowledge to obtain the domain knowledge vector database of the target domain.
[0128] In specific application scenarios, the block adjustment unit is specifically used to:
[0129] Get the current first text block, the previous first text block, and the next first text block;
[0130] Perform sentence splicing processing on the first sentence of the current first text block, the second sentence of the current first text block, and the last sentence of the previous first text block to obtain a first spliced sentence;
[0131] Perform sentence splicing processing on the last sentence of the current first text block, the first sentence of the next first text block, and the second sentence of the next first text block to obtain a second spliced sentence;
[0132] Performing vector conversion on the first concatenated sentence and the second concatenated sentence respectively to obtain a first concatenated sentence vector and a second concatenated sentence vector, and calculating a similarity score between the first concatenated sentence vector and the second concatenated sentence vector;
[0133] If the similarity score between the first concatenated sentence vector and the second concatenated sentence vector exceeds a preset similarity score threshold, and the first concatenated sentence and the second concatenated sentence belong to the same chapter, the first concatenated sentence and the second concatenated sentence are concatenated to obtain a first text block after block adjustment.
[0134] In specific application scenarios, the large text block cutting unit is specifically used for:
[0135] If the number of sentences contained in the first text block after the block adjustment exceeds a preset sentence number threshold, the first text block after the block adjustment is equally cut to obtain the first text block after the first cutting process and the first text block after the second cutting process, and the last sentence in the first text block after the first cutting process is the same as the first sentence in the first text block after the second cutting process.
[0136] In specific application scenarios, the title supplement unit is specifically used to:
[0137] taking the first text block after the first segmentation process and the first text block after the second segmentation process as target first text blocks after segmentation process;
[0138] Obtaining the title of the first text block after the target segmentation process, and the parent title of the title;
[0139] The title and the parent title are connected to obtain a supplementary title of the first text block after the target segmentation process, and the supplementary title and the first text block after the target segmentation process are combined to obtain a second text block.
[0140] In a specific application scenario, before the block adjustment unit, the domain knowledge vector database construction module further includes an ultra-small text block splicing unit, which is specifically used to:
[0141] Counting the number of sentences contained in each of the first text blocks, and selecting the first text block having 1 sentence;
[0142] Obtaining the preceding adjacent first text block and the following adjacent first text block of each first text block having 1 sentence;
[0143] The last sentence of the preceding adjacent first text block, the first text block with 1 sentence, and the first sentence of the succeeding adjacent first text block are respectively subjected to sentence concatenation processing to obtain a plurality of updated first text blocks, and a block adjustment processing based on the context similarity score is performed on each of the updated first text blocks.
[0144] In a specific application scenario, the preset text block size is a preset line spacing or a preset number of sentences.
[0145] The present application provides a device for generating domain knowledge answer results. The device first receives a question about target domain knowledge input by a user and converts the question into a question vector. Secondly, the device calculates a similarity score between each domain knowledge vector contained in a domain knowledge vector database of the target domain and the question vector, and sorts each of the domain knowledge vectors according to the similarity score to screen out a preset number of domain knowledge vectors as target domain knowledge vectors. The domain knowledge vectors are obtained by pre-processing the original text of the domain knowledge into multiple first text blocks, and then performing block adjustment processing, super-large text block cutting processing and text block title supplement processing based on context similarity scores on each of the first text blocks to obtain multiple second text blocks, which are then vectorized respectively. Finally, the device obtains the second text block corresponding to each of the target domain knowledge vectors, calculates the semantic relevance score between each of the second text blocks and the question, and splices each of the second text blocks based on the semantic relevance score to obtain spliced paragraphs. The device then calls a large model to generate an answer result according to the question and the spliced paragraphs. Compared with the prior art, the embodiment of the present application first matches multiple domain knowledge vectors from the database based on the similarity score between the domain knowledge vector and the question text, and then reorders and splices the multiple text blocks based on the semantic similarity between the text blocks of the matched domain knowledge vector and the question text. Finally, the large model is called to generate a response result based on the question text and the spliced paragraphs. By combining vector matching (vector similarity) with order adjustment (semantic similarity), the situation where the text of the proper nouns is similar but the semantics are different is avoided, so that the key answers are more forward, thereby improving the accuracy of the response results; and when constructing the domain knowledge vector, a customized block strategy is adopted. The original text of the domain knowledge is initially block-processed to obtain multiple first text blocks, and then each first text block is sequentially subjected to block adjustment processing based on the context similarity score, super-large text block cutting processing and text block title supplement processing to obtain multiple second text blocks. Each of the second text blocks is vectorized, so that the block results are clearer and more indexable, thereby improving the matching efficiency and shortening the response delay.
[0146] According to one embodiment of the present application, a storage medium is provided, wherein the storage medium stores at least one executable instruction, and the computer-executable instruction can execute the method for generating a domain knowledge response result in any of the above method embodiments.
[0147] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0148] Figure 5 A schematic diagram of the structure of a terminal provided according to an embodiment of the present application is shown. The specific embodiment of the present application does not limit the specific implementation of the computer device.
[0149] like Figure 5 As shown, the terminal may include: a processor (processor) 402 , a communications interface (Communications Interface) 404 , a memory (memory) 406 , and a communication bus 408 .
[0150] The processor 402 , the communication interface 404 , and the memory 406 communicate with each other via a communication bus 408 .
[0151] The communication interface 404 is used to communicate with other devices such as clients or other servers.
[0152] The processor 402 is configured to execute the program 410 , and specifically to execute the relevant steps in the embodiment of the method for generating the domain knowledge answer result.
[0153] Specifically, the program 410 may include program codes, which include computer operation instructions.
[0154] Processor 402 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in a computer device may be processors of the same type, such as one or more CPUs, or may be processors of different types, such as one or more CPUs and one or more ASICs.
[0155] The memory 406 is used to store the program 410. The memory 406 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0156] The program 410 may be specifically configured to cause the processor 402 to perform the following operations:
[0157] Receive a question input by a user regarding target domain knowledge, and convert the question into a question vector;
[0158] Calculating similarity scores between each domain knowledge vector contained in a domain knowledge vector database of the target domain and the question vector, and sorting each of the domain knowledge vectors according to the similarity scores to select a preset number of domain knowledge vectors as target domain knowledge vectors, wherein the domain knowledge vectors are obtained by preliminarily performing initial block processing on the original domain knowledge text to obtain a plurality of first text blocks, performing block adjustment processing based on context similarity scores, oversized text block cutting processing, and text block title supplementation processing on each of the first text blocks in sequence to obtain a plurality of second text blocks, and performing vectorization processing on each of the second text blocks;
[0159] Obtain the second text block corresponding to each of the target domain knowledge vectors, calculate the semantic relevance score between each of the second text blocks and the question, perform text block splicing processing on each of the second text blocks based on the semantic relevance score to obtain a spliced paragraph, and call the large model to generate a response result based on the question and the spliced paragraph.
[0160] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the physical device used to generate the domain knowledge response results, supporting the execution of the information processing program and other software and / or programs. The network communication module is used to enable communication between components within the storage medium and with other hardware and software within the physical information processing device.
[0161] Each embodiment in this specification is described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. Reference can be made to the descriptions of the identical or similar parts between the various embodiments. For system embodiments, since they are essentially identical to the method embodiments, their description is relatively simple. For relevant parts, refer to the descriptions of the method embodiments.
[0162] The methods and systems of the present application may be implemented in many ways. For example, the methods and systems of the present application may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present application are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present application may also be implemented as programs recorded in a recording medium, which include machine-readable instructions for implementing the methods according to the present application. Therefore, the present application also covers recording media that store programs for executing the methods according to the present application.
[0163] Obviously, those skilled in the art should understand that the modules or steps of the present application described above can be implemented using a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices. Alternatively, they can be implemented using program code executable by the computing device, so that they can be stored in a storage device and executed by the computing device. In some cases, the steps shown or described can be performed in a different order than herein, or they can be made into separate integrated circuit modules, or multiple modules or steps can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0164] The above description is merely a preferred embodiment of the present application and is not intended to limit the present application. Persons skilled in the art will readily appreciate that various modifications and variations are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application shall be included within the scope of protection of the present application.
Claims
1. A method for generating domain knowledge response results, characterized in that: include: Receive a question input by a user regarding target domain knowledge, and convert the question into a question vector; Calculating similarity scores between each domain knowledge vector contained in a domain knowledge vector database of the target domain and the question vector, and sorting each of the domain knowledge vectors according to the similarity scores to select a preset number of domain knowledge vectors as target domain knowledge vectors, wherein the domain knowledge vectors are obtained by preliminarily performing initial block processing on the original domain knowledge text to obtain a plurality of first text blocks, performing block adjustment processing based on context similarity scores, oversized text block cutting processing, and text block title supplementation processing on each of the first text blocks in sequence to obtain a plurality of second text blocks, and performing vectorization processing on each of the second text blocks; Obtain the second text block corresponding to each of the target domain knowledge vectors, calculate the semantic relevance score between each of the second text blocks and the question, perform text block splicing processing on each of the second text blocks based on the semantic relevance score to obtain a spliced paragraph, and call the large model to generate a response result based on the question and the spliced paragraph.
2. The method according to claim 1, characterized in that Before calculating the similarity scores between the domain knowledge vectors contained in the target domain and the question vector, the method further includes: Acquire multiple domain knowledge original texts of the target domain, and use each of the domain knowledge original texts as the target domain knowledge original text; According to a preset text block size, the original text of the target domain knowledge is initially divided into blocks to obtain a plurality of first text blocks; Performing block adjustment processing on each of the first text blocks based on the context similarity score to obtain a plurality of first text blocks after block adjustment; Performing oversized text block cutting processing on each of the first text blocks after the block adjustment to obtain a plurality of cut first text blocks; Supplementing a text block title to each of the cut first text blocks to obtain a plurality of second text blocks; performing vectorization processing on each of the second text blocks respectively to obtain a plurality of domain knowledge vectors; Mapping and storing each of the domain knowledge vectors with the corresponding second text block, respectively, to obtain a plurality of domain knowledge vector mapping relationships contained in the original text of the target domain knowledge; The domain knowledge vector mapping relationships contained in the original texts of each target domain knowledge are integrated to obtain a domain knowledge vector database of the target domain.
3. The method according to claim 2, characterized in that Performing a block adjustment process on the first text block based on the context similarity score to obtain a first text block after block adjustment, including: Get the current first text block, the previous first text block, and the next first text block; Perform sentence splicing processing on the first sentence of the current first text block, the second sentence of the current first text block, and the last sentence of the previous first text block to obtain a first spliced sentence; Perform sentence splicing processing on the last sentence of the current first text block, the first sentence of the next first text block, and the second sentence of the next first text block to obtain a second spliced sentence; Performing vector conversion on the first concatenated sentence and the second concatenated sentence respectively to obtain a first concatenated sentence vector and a second concatenated sentence vector, and calculating a similarity score between the first concatenated sentence vector and the second concatenated sentence vector; If the similarity score between the first concatenated sentence vector and the second concatenated sentence vector exceeds a preset similarity score threshold, and the first concatenated sentence and the second concatenated sentence belong to the same chapter, the first concatenated sentence and the second concatenated sentence are concatenated to obtain a first text block after block adjustment.
4. The method according to claim 3, characterized in that Performing an oversized text block cutting process on the first text block after the block adjustment to obtain a cut first text block includes: If the number of sentences contained in the first text block after the block adjustment exceeds a preset sentence number threshold, the first text block after the block adjustment is equally cut to obtain the first text block after the first cutting process and the first text block after the second cutting process, and the last sentence in the first text block after the first cutting process is the same as the first sentence in the first text block after the second cutting process.
5. The method according to claim 4, characterized in that Supplementing the text block title to the first text block after the cutting process to obtain a second text block, including: taking the first text block after the first segmentation process and the first text block after the second segmentation process as target first text blocks after segmentation process; Obtaining the title of the first text block after the target segmentation process, and the parent title of the title; The title and the parent title are connected to obtain a supplementary title of the first text block after the target segmentation process, and the supplementary title and the first text block after the target segmentation process are combined to obtain a second text block.
6. The method according to claim 2, characterized in that Before performing the block adjustment process on each of the first text blocks based on the context similarity score to obtain a plurality of first text blocks after block adjustment, the method further includes: Counting the number of sentences contained in each of the first text blocks, and selecting the first text block having 1 sentence; Obtaining the preceding adjacent first text block and the following adjacent first text block of each first text block having 1 sentence; The last sentence of the preceding adjacent first text block, the first text block with 1 sentence, and the first sentence of the succeeding adjacent first text block are respectively subjected to sentence concatenation processing to obtain a plurality of updated first text blocks, and a block adjustment processing based on the context similarity score is performed on each of the updated first text blocks.
7. The method according to claim 2, characterized in that The preset text block size is a preset line spacing or a preset number of sentences.
8. A device for generating domain knowledge response results, characterized in that: include: A question receiving module is used to receive questions input by users regarding target domain knowledge and convert the questions into question vectors; A domain knowledge vector matching module is configured to calculate a similarity score between each domain knowledge vector contained in the domain knowledge vector database of the target domain and the question vector, and to sort each of the domain knowledge vectors according to the similarity score, screening a preset number of domain knowledge vectors as target domain knowledge vectors, wherein the domain knowledge vectors are obtained by preliminarily performing initial block processing on the original domain knowledge text to obtain a plurality of first text blocks, and then performing block adjustment processing based on context similarity scores, oversized text block cutting processing, and text block title supplementation processing on each of the first text blocks to obtain a plurality of second text blocks, and then performing vectorization processing on each of the second text blocks; The answer result generation module is used to obtain the second text block corresponding to each of the target domain knowledge vectors, calculate the semantic relevance score between each of the second text blocks and the question, perform text block splicing processing on each of the second text blocks based on the semantic relevance score to obtain a spliced paragraph, and call the large model to generate a response result based on the question and the spliced paragraph.
9. A storage medium storing at least one executable instruction, characterized in that: The executable instructions enable the processor to execute operations corresponding to the method for generating a domain knowledge answer result according to any one of claims 1 to 7.
10. A terminal comprising: A processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, wherein the executable instruction enables the processor to execute an operation corresponding to the method for generating a domain knowledge answer result according to any one of claims 1 to 7.