Text interaction method, system and equipment based on large language model and medium

By employing a dual-channel retrieval and relevance coefficient reordering method, combined with local vector databases and web retrieval, the problems of high update costs and insufficient timeliness of the RAG system are solved, achieving automated updates of the dynamic knowledge base and improved timeliness of retrieval results.

CN121561031APending Publication Date: 2026-02-24SEARI ELECTRIC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511555685.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-28
Publication Date
2026-02-24

AI Technical Summary

Technical Problem

The existing RAG system has high costs for updating its vector knowledge base, and the static vector knowledge base is difficult to quickly include timely information on breaking events and the latest research, resulting in a lack of timeliness in search results.

Method used

A dual-channel retrieval method is adopted, combining a local vector database and network retrieval. Vectors are reordered based on similarity and correlation coefficients to generate a vector matrix. A large language model is used for text interaction feedback to achieve dynamic knowledge base updates and improve timeliness.

Benefits of technology

It improves the timeliness of search results and the accuracy of answer matching, reduces the cost of updating the knowledge base, and realizes the automated and continuous growth of the knowledge base and the systematic integration of high-quality online content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121561031A_ABST
    Figure CN121561031A_ABST
Patent Text Reader

Abstract

The invention discloses a text interaction method, system and device based on a large language model and a medium, and belongs to the technical field of artificial intelligence. The method comprises the steps that a query statement is received, a query vector is obtained according to the query statement, and at least one local vector and a corresponding local text segment are obtained in a vector database according to the query vector; performing network retrieval according to the search keyword list of the query statement to obtain a network retrieval result, segmenting the network retrieval result to obtain at least one network text segment, and vectorizing the at least one network text segment to obtain a corresponding paragraph vector; determining a target text segment based on the sorting result; inputting the query statement and the target text segment into a large language model to obtain text interaction feedback information corresponding to the query statement; through multi-source retrieval and correlation coefficient reordering, the expansion of the retrieval coverage rate is realized, and the timeliness of the retrieval result is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, specifically to a text interaction method, system, device, and medium based on a large language model. Background Technology

[0002] Large Language Models (LLMs) are artificial intelligence models trained on massive amounts of text data that can understand and generate human language. Their core function is to achieve human-like language interaction and task processing by learning language rules. With the widespread application of LLMs in question answering, dialogue, and text generation scenarios, Retrieval-Augmented Generation (RAG) has become a technique to improve the accuracy and timeliness of model responses. Existing RAG systems mainly rely on pre-built vector knowledge bases. Their workflow involves converting massive amounts of documents into vectors using an embedding model and storing them in a vector database. When a user submits a query, the query is also converted into a vector, and a nearest neighbor search is performed in the vector database. The retrieved text segments (Top, Boolean, and Top-level) are then processed. k) Use the LLM as context input to generate the answer. Existing RAG system vector knowledge bases generally adopt a process of manual annotation, re-vectorization, and re-uploading for iterative updates, which is costly. Although it can reduce the risk of model hallucination to some extent, it still has the problem of lack of timeliness of search results. Static vector knowledge bases are difficult to quickly include timely information such as sudden events and the latest research. Summary of the Invention

[0003] A text interaction method, system, device, and medium based on a large language model are provided to at least partially solve the aforementioned technical problems.

[0004] Firstly, a text interaction method based on a large language model is provided, including the following steps: Receive a query statement, perform vectorization on the query statement to obtain a query vector, and extract keywords from the query statement to obtain a list of search keywords; Based on the query vector, a vector search is performed in a preset vector database to obtain at least one local vector and a corresponding local text segment; based on the search keyword list, a network search is performed to obtain network search results, the network search results are segmented to obtain at least one network text segment, and the at least one network text segment is vectorized to obtain a corresponding paragraph vector. Generate a vector matrix based on at least one local vector and at least one paragraph vector; Determine the similarity between each vector in the vector matrix and the query vector, and determine the correlation coefficient corresponding to each vector based on the similarity. The text segments corresponding to each vector are sorted according to the correlation coefficient, and the target text segment is determined based on the sorting results; The query statement and the target text are input into the large language model to obtain the text interaction feedback information corresponding to the query statement.

[0005] Optionally, the step of performing a vector search in a preset vector database based on the query vector to obtain at least one local vector and its corresponding local text segment includes: A similarity search is performed on the query vector in a preset vector database to determine the similarity between each local vector in the vector database and the query vector, and the vectors are sorted in descending order. Based on the descending order, a first preset number of local vectors are determined to be ranked first. The vector database includes multiple local vectors and their corresponding local text segments.

[0006] Optionally, the step of performing a web search based on the search keyword list to obtain web search results, segmenting the web search results to obtain at least one web text segment, and vectorizing the at least one web text segment to obtain a corresponding paragraph vector includes: The search engine is invoked based on the list of search keywords to obtain at least one webpage link and a summary corresponding to each webpage link; The web page links are crawled, the main text of the page is extracted and segmented to obtain the corresponding second preset number of web text segments; The second preset number of network segments are vectorized using an embedding model to obtain the corresponding second preset number of segment vectors.

[0007] Optionally, determining the similarity between each vector in the vector matrix and the query vector, and determining the correlation coefficient corresponding to each vector based on the similarity, includes: Calculate the cosine similarity between each vector in the vector matrix and the query vector; The correlation coefficient for each vector is calculated based on the cosine similarity, the credibility factor of each vector in the vector matrix, and the timeliness factor of each vector.

[0008] Optionally, the correlation coefficient for each vector is calculated based on the cosine similarity, the credibility factor of each vector in the vector matrix, and the timeliness factor of each vector, using the following formula: λ i = α c i +β Credibility i + γ Recency i ; in, λ i The correlation coefficient is... c i The first element in the vector matrix i The cosine similarity between each vector and the query vector, Credibility i The first element in the vector matrix i The credibility factor of each vector, Recency i The first element in the vector matrix i The timeliness factor of each vector; α , β , γ All of these are preset weighting coefficients.

[0009] Optionally, the step of sorting the text segments corresponding to each vector according to the correlation coefficient and determining the target text segment based on the sorting result includes: The vectors are sorted in descending order based on their correlation coefficients to obtain the sorting results. The vectors corresponding to the third preset number of correlation coefficients in the sorting results are determined, and the text segments corresponding to the third preset number of vectors are taken as the target text segments.

[0010] Optionally, the method includes: Accept feedback instructions for the text interaction feedback information, including positive feedback instructions and negative feedback instructions; When the feedback instruction is a positive feedback instruction, the network segments and corresponding paragraph vectors in the target text segment are stored in the vector database; when the feedback instruction is a negative feedback instruction, the network segments and corresponding paragraph vectors in the target text segment are not stored in the vector database.

[0011] Secondly, a text interaction system based on a large language model is also provided, including: The statement receiving module is used to receive query statements, perform vectorization processing on the query statements to obtain query vectors, and extract keywords from the query statements to obtain a list of search keywords. The dual-channel retrieval module is used to perform vector search in a preset vector database based on the query vector to obtain at least one local vector and the corresponding local text segment; perform network retrieval based on the search keyword list to obtain network retrieval results; segment the network retrieval results to obtain at least one network text segment; and perform vectorization processing on the at least one network text segment to obtain the corresponding paragraph vector. A vector concatenation module is used to generate a corresponding vector matrix based on at least one local vector and at least one segment vector; The correlation coefficient determination module is used to determine the similarity between each vector in the vector matrix and the query vector, and to determine the correlation coefficient corresponding to each vector based on the similarity. The correlation coefficient sorting module is used to sort the text segments corresponding to each vector according to the correlation coefficient, and determine the target text segment based on the sorting result; The text interaction feedback information generation module is used to input the query statement and the target text into the large language model to obtain the text interaction feedback information corresponding to the query statement.

[0012] Thirdly, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described text interaction method based on a large language model.

[0013] Fourthly, a computer-readable storage medium is also provided, on which a computer program is stored, which is loaded by a processor to perform the steps in the above-described text interaction method based on a large language model.

[0014] This application provides a retrieval enhancement generation system based on dynamic web search. The system performs vectorization on the query statement to obtain a query vector and extracts keywords from the query statement to obtain a search keyword list. Based on the query vector, a vector search is performed in a preset vector database to obtain at least one local vector and its corresponding local text segment. A web search is performed based on the search keyword list to obtain web search results. The web search results are segmented to obtain at least one web text segment, and the at least one web text segment is vectorized to obtain a corresponding paragraph vector. A vector matrix is ​​generated based on the at least one local vector and the at least one paragraph vector. The similarity between each vector in the vector matrix and the query vector is determined, and a correlation coefficient is determined for each vector based on the similarity. The text segments corresponding to each vector are sorted based on the correlation coefficient, and a target text segment is determined based on the sorting results. The query statement and the target text segment are input into a large language model to obtain text interaction feedback information corresponding to the query statement. This system achieves real-time expansion of retrieval coverage through multi-source retrieval and reordering of correlation coefficients, improving the timeliness of retrieval results and enhancing the accuracy of answer matching for query statements. Attached Figure Description

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

[0016] Figure 1 This is a flowchart illustrating a text interaction method based on a large language model provided in an exemplary embodiment of this disclosure. Figure 2 This is a schematic diagram of the text interaction feedback information display interface of the text interaction method based on a large language model provided in the exemplary embodiments of this disclosure; Figure 3 This is a structural block diagram of a text interaction system based on a large language model provided in an exemplary embodiment of this disclosure; Figure 4 This is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this disclosure. Detailed Implementation

[0017] 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 embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0018] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the stated features. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified. "A and / or B" includes the following three combinations: A only, B only, and a combination of A and B.

[0019] The use of "applies to" or "configured to" in this application implies open and inclusive language, which does not exclude the applicability to or configuration to devices performing additional tasks or steps. Additionally, the use of "based on" implies openness and inclusivity, because processes, steps, calculations, or other actions "based on" one or more of the stated conditions or values ​​may in practice be based on additional conditions or values ​​beyond those stated.

[0020] In this application, the term "exemplary" is used to mean "used as an example, illustration, or description." Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use this application. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that this application can be made without using these specific details. In other instances, well-known structures and processes are not described in detail to avoid obscuring the description of this application with unnecessary detail. Therefore, this application is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.

[0021] The following sections provide a detailed description of the text interaction method, system, device, and medium based on a large language model provided in this application.

[0022] On the one hand, in one embodiment, this embodiment provides a text interaction method based on a large language model, such as... Figure 1 As shown, the method includes the following steps S100 to S600, which are explained in detail below.

[0023] Step S100: Receive a query statement, perform vectorization processing on the query statement to obtain a query vector, and extract keywords from the query statement to obtain a list of search keywords.

[0024] In this embodiment, the user enters a query statement on the front-end page of the user terminal, such as a natural language query. This embodiment can use a lightweight intent extraction model. The Extractor extracts keywords and classifies topics for a natural language query Q, generating a list of search keywords. The Embedding model then generates the query vector Vq corresponding to the natural language query Q. An Embedding model is a type of model that transforms unstructured data (such as text, images, and audio) or discrete symbols (such as user IDs and tags) into low-dimensional, dense, semantically related vectors. The input to an Embedding model can be words, phrases, sentences, or even long texts, and the output is a fixed-dimensional numerical value (e.g., a 768-dimensional vector).

[0025] Step S200: Perform a vector search in a preset vector database based on the query vector to obtain at least one local vector and its corresponding local text segment; perform a network search based on the search keyword list to obtain network search results; segment the network search results to obtain at least one network text segment; and perform vectorization processing on the at least one network text segment to obtain the corresponding paragraph vector.

[0026] In this embodiment, a dual-channel retrieval method is adopted. The first channel retrieval method is to perform a vector search in a preset vector database based on the query vector to obtain at least one local vector and its corresponding local text segment, which is to say, to use the existing vector retrieval based on the RAG system. The query vector Vq is sent to the preset vector database, and the nearest neighbor search (ANN) is used to retrieve the local text segments corresponding to the top-k local vectors, forming a vector retrieval dataset S. The pre-defined vector database stores multiple local vectors and their corresponding local text segments. The similarity between the query vector and each local vector in the vector database is calculated, and the top k local vectors and their corresponding local text segments are used as the vector retrieval dataset corresponding to the query vector.

[0027] In step S200, the step of performing a vector search in a preset vector database based on the query vector to obtain at least one local vector and its corresponding local text segment includes: A similarity search is performed on the query vector in a preset vector database to determine the similarity between each local vector in the vector database and the query vector, and the vectors are sorted in descending order. Based on the descending order, a first preset number of local vectors are determined to be ranked first. The vector database includes multiple local vectors and their corresponding local text segments.

[0028] In this embodiment, multiple target local vectors that meet the similarity criteria are found in the vector database based on the query vector. Specifically, the similarity value between the target local vector and the query vector is greater than a preset similarity threshold. Then, the multiple target local vectors are sorted (e.g., in descending order), and a preset number of target local vectors are selected based on the sorting result, that is, the Top-k (e.g., k can be 10, 20, etc.) target local vectors. The local text segments corresponding to the Top-k target local vectors can also be determined.

[0029] In this embodiment, a dual-channel retrieval method is adopted. The second channel retrieval method involves performing a web search based on the search keyword list to obtain web search results, segmenting the web search results to obtain at least one web text segment, and then vectorizing the at least one web text segment to obtain the corresponding paragraph vector. That is, a web search is performed based on the search keyword list, the web search results are segmented to obtain multiple web text segments, and then the multiple web text segments are vectorized using the same processing method as in step S100 to obtain the corresponding paragraph vector.

[0030] In step S200, the process of performing a web search based on the search keyword list to obtain web search results, segmenting the web search results to obtain at least one web text segment, and vectorizing the at least one web text segment to obtain a corresponding paragraph vector includes: The search engine is invoked based on the list of search keywords to obtain at least one webpage link and a summary corresponding to each webpage link; The web page links are crawled, the main text of the page is extracted and segmented to obtain the corresponding second preset number of web text segments; The second preset number of network segments are vectorized using an embedding model to obtain the corresponding second preset number of segment vectors.

[0031] In this embodiment, an external search engine API (such as Bing, Google, or enterprise internal search) can be called based on the search keyword list to obtain the first X (X can be 5, 10, 15, etc.) webpage URLs and summaries. Then, a web crawler is used to retrieve the complete page, extract the main text, and segment it into multiple paragraphs. Paragraph vectors corresponding to these paragraphs are generated using the same embedding model, forming a web retrieval dataset S. w The web retrieval dataset includes multiple web text segments and their corresponding paragraph vectors. The second preset number can be N, where N is a positive integer, such as 10 or 20, and is not limited.

[0032] In practical applications, the retrieved web page summaries and local documents are vectorized using a unified embedding model (such as OpenAI Embedding or Sentence BERT).

[0033] Step S300: Generate a vector matrix based on at least one of the local vectors and at least one paragraph vector.

[0034] In this embodiment, a vector matrix M is formed by combining all local vectors obtained using the first-channel retrieval method and all paragraph vectors obtained using the second-channel retrieval method. In practical applications, a vector matrix can also be formed by combining all local vectors and their corresponding local text segments, and all paragraph vectors and their corresponding paragraph vector sets.

[0035] Step S400: Determine the similarity between each vector in the vector matrix and the query vector, and determine the correlation coefficient corresponding to each vector based on the similarity.

[0036] Specifically, existing similarity algorithms can be used to calculate the similarity between each vector in the vector matrix and the query vector. In this embodiment, the cosine similarity between each vector in the vector matrix and the query vector is calculated, and then the correlation coefficient corresponding to each vector is determined based on the cosine similarity using a preset relational function. The vectors in the vector matrix include the top-k target local vectors and N (N can be 10, 20, etc., without limitation) segment vectors.

[0037] The steps for determining the correlation coefficient in this embodiment, including the sub-steps of steps S401 to S402, will be described in detail below.

[0038] Step S401: Calculate the cosine similarity between each vector in the vector matrix and the query vector; Step S402: Calculate the correlation coefficient corresponding to each vector based on the cosine similarity, the credibility factor of each vector in the vector matrix, and the timeliness factor of each vector.

[0039] In this embodiment, each vector V in the vector matrix is ​​calculated. i cosine similarity c with query vector Vq i The value of i ranges from i=1,2,3…k+N. Then, based on multiple dimensions such as similarity score, network freshness, and content credibility, the correlation coefficient of each vector in the vector matrix is ​​calculated, thus making the obtained correlation coefficient more timely.

[0040] In some embodiments, the correlation coefficient for each vector is calculated based on the cosine similarity, the credibility factor of each vector in the vector matrix, and the timeliness factor of each vector, using the following formula: λ i = α c i + β Credibility i + γ Recency i ; in, λ i The correlation coefficient is... c i The first element in the vector matrix i The cosine similarity between each vector and the query vector, Credibility i The first element in the vector matrix i The credibility factor of each vector, Recency i The first element in the vector matrix i The timeliness factor of each vector; α , β , γ All of these are preset weighting coefficients.

[0041] In this embodiment, a correlation coefficient λ is introduced. i Correlation coefficient λ i Based on search score ( α c i ), credibility of the text source ( β Credibility i Timeliness γ Recency i The credibility factor is weighted by factors such as (e.g., online and local sources). It should be noted that the credibility factor can be simply divided into online and local sources. For local text sources, the credibility factor can be 1.0; for online text sources, the credibility factor can be 0.8 to 1.0. Specifically, the credibility factor can be set according to the credibility of the online text source (e.g., authoritative websites, academic journals, etc.). The timeliness factor can be weighted by factors such as (e.g., timeliness factor). i For each vector, the capture time t_i and the current time t_now of the corresponding text segment are used to calculate the corresponding decay factor (i.e., the expiration factor). The decay factor is exp(-(t_now-t_i) / τ) (τ is a time constant, defaulting to 30 days). α, β, and γ are empirical weights (which can be optimized through offline experiments). Weights can be set to α=0.6, β=0.3, and γ=0.1 (which can be optimized through cross-validation).

[0042] Step S500: Sort the text segments corresponding to each vector according to the correlation coefficient, and determine the target text segment based on the sorting result.

[0043] In this embodiment, based on the correlation coefficient λ i The vectors in the vector matrix are sorted, for example, in descending order, to determine the top m vectors (which could be 8, 10, 15, etc.). This allows us to identify the m text segments corresponding to these m vectors as the target text segments. This embodiment optimizes the matching accuracy between the target text segments and the query statement by uniformly vectorizing the web search results and vector search results, and then reordering them using relevance coefficients.

[0044] The step of sorting the text segments corresponding to each vector according to the correlation coefficient and determining the target text segment based on the sorting result includes: The vectors are sorted in descending order based on their correlation coefficients to obtain the sorting results. The vectors corresponding to the third preset number of correlation coefficients in the sorting results are determined, and the text segments corresponding to the third preset number of vectors are taken as the target text segments.

[0045] In this embodiment, the text segments corresponding to each vector are sorted in descending order according to the correlation coefficient, and the vectors corresponding to the top-m correlation coefficients are taken as target vectors, and the text segments corresponding to the top-m target vectors are taken as top-m target text segments.

[0046] Understandably, depending on the actual situation, the top-m target vectors are selected from the top-k target local vectors and N paragraph vectors. Then, the top-m target vectors may contain only target local vectors, or they may contain both target local vectors and paragraph vectors, or they may contain only paragraph vectors.

[0047] Step S600: Input the query statement and the target text into the large language model to obtain the text interaction feedback information corresponding to the query statement.

[0048] In this embodiment, the query statement and the top-m target text segments are concatenated and input into the large language model. The target text segments sorted by relevance coefficient are concatenated and input into the LLM to generate and return a structured answer, that is, the text interaction feedback information corresponding to the query statement, which is then fed back to the user terminal corresponding to the query statement for display.

[0049] The text interaction method based on a large language model provided in this application can also be flexibly expanded. The detailed processing steps for the first-channel retrieval method and the second-channel retrieval method are as follows: Based on the query vector, a similarity search is performed in a preset vector database to determine the similarity between each local vector in the vector database and the query vector. Local vectors with a similarity greater than a preset similarity threshold are selected. If the number of local vectors with a similarity greater than the preset similarity threshold is less than a first preset number, then a second-channel retrieval method is activated. The second-channel retrieval method involves performing a web search based on the search keyword list to obtain web search results, segmenting the web search results to obtain at least one web text segment, and vectorizing the at least one web text segment to obtain the corresponding paragraph vector.

[0050] Specifically, if vector search is used and the vector database has sufficient matches, then web search is not necessarily used. When vector matches in the vector database are insufficient, a real-time web search is initiated to obtain the latest and most relevant external documents, thereby improving retrieval coverage.

[0051] The text interaction method based on a large language model provided in this application also includes: Accept feedback instructions for the text interaction feedback information, including positive feedback instructions and negative feedback instructions; When the feedback instruction is a positive feedback instruction, the network segments and corresponding paragraph vectors in the target text segment are stored in the vector database.

[0052] In this embodiment, when the feedback instruction is a negative feedback instruction, the network segment and its corresponding paragraph vector in the target text segment are not stored in the vector database. A button for accepting or rejecting can be displayed on the user's terminal page, allowing the user to provide further feedback on the text interaction. If it is a positive feedback instruction (i.e., accept), then the network segment and its corresponding paragraph vector in the target text segment can be updated and stored in the vector database.

[0053] Understandably, depending on the actual situation, the Top-k target vectors are selected from the Top-k target local vectors and N paragraph vectors. These Top-m target vectors may contain only target local vectors, or they may contain both target local vectors and paragraph vectors, or they may contain only paragraph vectors. If a paragraph vector is among the Top-m target vectors, and the user clicks the "accept" button (i.e., sends a positive feedback command), then the network text segment and its corresponding paragraph vector in the target text segment are updated and stored in the vector database.

[0054] This solves the problem of high update costs for existing knowledge bases. This embodiment implements a closed-loop system of manual feedback and automatic vectorized writing, enabling the knowledge base to automatically and continuously grow with use, and enabling unified retrieval. Sort The feedback loop enables the systematic and sustainable integration of web crawled content into the vector database; the automated incremental learning mechanism automatically fills in gaps in the knowledge base during use. In this embodiment, high-quality web text segments are manually verified, vectorized using an embedding model, and written into the vector database, achieving continuous self-completion of the vector database.

[0055] Given that existing RAG systems typically only return generated text, lacking explicit identification of the source text for the answer, and thus failing to meet compliance auditing and user trust requirements, this application provides a text interaction method based on a large language model. This method stores multiple local vectors, corresponding local text segments, and corresponding paragraph IDs in a vector database, with each paragraph ID corresponding one-to-one with the text segment. This application obtains network search results through network retrieval, segments these results to obtain at least one network text segment, and assigns a corresponding paragraph ID to each segment.

[0056] In other words, step S200 further includes: Based on the query vector, a vector search is performed in a preset vector database to obtain at least one local vector and its corresponding local text segment and local paragraph number; based on the search keyword list, a network search is performed to obtain network search results; the network search results are segmented to obtain at least one network text segment and its corresponding network paragraph number; and the at least one network text segment is vectorized to obtain the corresponding paragraph vector.

[0057] It should be noted that paragraph numbers for local and online text segments can be generated using preset paragraph numbering (i.e., paragraph ID) encoding rules. Paragraph IDs can include document type, unique document ID, chapter number, and paragraph number. In practical applications, [Document Type-ID] is used. Chapter number A unique identifier in the form of a paragraph number. The components of a paragraph ID are document type (DOC / WEB), unique document number (e.g., 12, 2024-09-15), chapter number (optional), and paragraph number. For example: DOC12-3-5 represents [document number 12, chapter 3, paragraph 5]; WEB-2024-09-15-7 represents [webpage, 2024-09-15, paragraph 7]. Of course, you can also associate the paragraph ID with the corresponding source text.

[0058] In some embodiments, the text segments corresponding to each vector are sorted according to the correlation coefficient, and the target text segments are determined based on the sorting results, retaining the paragraph ID corresponding to each target text segment. Then, the query statement Q is concatenated with the target text segments (i.e., the recall context C) sorted by correlation coefficient and marked with paragraph IDs, and sent to the LLM to generate text interaction feedback information (answer A). The corresponding paragraph ID is displayed on the text interaction feedback information.

[0059] It should be noted that this application sorts all target text segments in descending order based on their relevance coefficients, selecting the Top... The target text segment m (where m is less than or equal to the upper limit of the context window) is used as the recall context C, thus ensuring that the most relevant information is provided within the LLM context window limit. In this way, the problem that the context window of the existing LLM (typically 4k~128k tokens) is insufficient to accommodate all retrieved text segments, which requires truncation and is prone to losing key information is solved, thus avoiding the limitation of the context window length.

[0060] Please see Figure 2 In practical applications, Answer A includes paragraph citation markers, such as [1] and [3]. Answer A also includes a citation mapping table, which includes the mapping relationship between paragraph ID and the corresponding original text link or file path. When the user clicks on the paragraph ID, the corresponding original text link or file path can be further displayed. Answer A also includes a visual highlight link. When the user clicks on the citation, a sidebar will pop up to display the original paragraph. Each text segment returned by the retrieval is accompanied by a unique paragraph ID. The user terminal displays the citation marker next to the answer based on the serial number. After the user clicks on a citation marker, the user terminal can pop up the original text corresponding to the citation marker in the sidebar and highlight it. For example, the text segment corresponding to the citation marker can be highlighted in the original text, or the corresponding text segment can be highlighted in Answer A. In this way, the traceability of the answer is realized, which solves the problem that the existing system usually only returns the generated text and lacks a clear identification of the text segment from which the answer is sourced, making it difficult to meet the requirements of compliance audit and user trust. This application adds fine-grained citations of the source of the answer (such as paragraph number and chapter marker), which allows users to quickly locate the original text.

[0061] In practical applications, to avoid excessively frequent updates to the vector database and wasted resources, a virtual button for accepting or rejecting a cited passage is provided on the user's terminal page, allowing the user to provide feedback for each cited passage. i∈{positive, negative}. For positive segments, their original text, Paragraph ID, vector Vi, and metadata (source, fetch time) are stored in an incremental cache. Then, the data in the incremental cache is periodically updated to the vector database. For example, an incremental learning task is triggered periodically (e.g., daily / weekly): the segments in the incremental cache are uniformly vectorized using an embedding model and written to the vector storage layer, and the metadata index is updated; simultaneously, cached data already written to the vector database in the incremental cache is cleared. In this way, this application achieves automatic filling of blank areas in the vector library as it is used, reducing manual construction costs and improving retrieval coverage and timeliness. All retrieval results (local and online) use the same embedding / rerank model, avoiding the problem of cross-modal vector incompatibility.

[0062] The following is an example illustrating the text interaction method based on a large language model of this application.

[0063] The system receives a query, extracts intent from it, and uses the lightweight model distilbert-base-uncased to extract keywords, returning the keywords. Using vector search, it searches the query vector Vq using FAISS to find the top 20 local vectors (top_k=20, i.e., the first 20 sorted vectors). Using web search, it calls the Bing Search API (count=10) to obtain the URL, uses Playwright to crawl and clean the webpage, retaining only the main text. The main text is then segmented into paragraphs (approximately 150 characters). (200 tokens / segment), vectorized using the same Embedding model to obtain the corresponding N segment vectors.

[0064] The correlation coefficients of 20 local vectors and N paragraph vectors were calculated using weighted averages and sorted in descending order. The top-ranked vectors were selected. When m (e.g., m=8) enters the LLM context, and when calling LLM (e.g., gpt-4o), you can set max_tokens=1024 and temperature=0.1 to ensure the stability of the answer.

[0065] The answer display area is parsed using [Segment ID] regular expression processing to automatically generate clickable superscript references. When a user clicks on a superscript reference, a reference details panel pops up on the right, loading the URL of the original text corresponding to that superscript reference (if it is a local document, it is read from local storage), and using JavaScript to highlight the corresponding paragraph in the original text.

[0066] For example, a user asks, "What are the limitations of vector retrieval in the RAG system?". Vector retrieval returns 6 similar paragraphs from the vector database; web retrieval retrieves the two most recent academic blog posts; after sorting by relevance coefficient, 4 local paragraphs and 2 web paragraphs are selected. LLM generates the answer, citing [DOC45-2-4][WEB-2024-08-30-3]. After clicking, the user sees the corresponding chapter and the original blog post on the right. If the user provides positive feedback on a blog paragraph, the system automatically vectorizes the entire blog post and writes it to the vector database the next day. Subsequent similarity queries will directly match that paragraph, reducing web requests.

[0067] A user asked, "What is the latest GPT model size for 2025?" The vector database did not contain the latest information. The system immediately triggered a web search, crawled the OpenAI official blog, and extracted model parameters. After weighted sorting, only the web-related paragraphs were retained (Credibility=0.95, Recency=1.0), and the answers only contained web citations. After the user accepted the answer, the system added the blog paragraph to the vector database, allowing subsequent identical queries to retrieve the data directly from the local vector database.

[0068] On the other hand, in one embodiment, this embodiment provides a text interaction system based on a large language model, such as... Figure 3 As shown, it includes: The statement receiving module 210 is used to receive a query statement, perform vectorization processing on the query statement to obtain a query vector, and extract keywords from the query statement to obtain a list of search keywords. The dual-channel retrieval module 220 is used to perform vector search in a preset vector database according to the query vector to obtain at least one local vector and the corresponding local text segment; perform network retrieval according to the search keyword list to obtain network retrieval results; segment the network retrieval results to obtain at least one network text segment; and perform vectorization processing on the at least one network text segment to obtain the corresponding paragraph vector. Vector concatenation module 230 is used to generate a corresponding vector matrix based on at least one local vector and at least one segment vector; The correlation coefficient determination module 240 is used to determine the similarity between each vector in the vector matrix and the query vector, and to determine the correlation coefficient corresponding to each vector based on the similarity. The correlation coefficient sorting module 250 is used to sort the text segments corresponding to each vector according to the correlation coefficient, and determine the target text segment based on the sorting result; The text interaction feedback information generation module 260 is used to input the query statement and the target text into a large language model to obtain the text interaction feedback information corresponding to the query statement.

[0069] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the text interaction system based on the large language model described above can be referred to the corresponding process in the aforementioned text interaction method based on the large language model, and will not be elaborated further here.

[0070] To better implement the text interaction method based on a large language model of the present invention, please refer to [link / reference needed]. Figure 4 This application also provides an electronic device that integrates any of the large language model-based text interaction systems provided by this invention. The electronic device may include a processor 501 with one or more processing cores, a memory 502 with one or more computer-readable storage media, a power supply 503, and an input unit 504, etc. Specifically, in this invention, the processor 501 in the electronic device can load executable files corresponding to processes of one or more application programs into the memory 502 according to the following instructions, and the processor 501 runs the application programs stored in the memory 502 to achieve various functions, as follows: Receive a query statement, perform vectorization on the query statement to obtain a query vector, and extract keywords from the query statement to obtain a list of search keywords; Based on the query vector, a vector search is performed in a preset vector database to obtain at least one local vector and a corresponding local text segment; based on the search keyword list, a network search is performed to obtain network search results, the network search results are segmented to obtain at least one network text segment, and the at least one network text segment is vectorized to obtain a corresponding paragraph vector. Generate a vector matrix based on at least one local vector and at least one paragraph vector; Determine the similarity between each vector in the vector matrix and the query vector, and determine the correlation coefficient corresponding to each vector based on the similarity. The text segments corresponding to each vector are sorted according to the correlation coefficient, and the target text segment is determined based on the sorting results; The query statement and the target text are input into the large language model to obtain the text interaction feedback information corresponding to the query statement.

[0071] Those skilled in the art will understand that Figure 4 The device structure shown does not constitute a limitation on the device. Electronic devices may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0072] In this electronic device, processor 501 serves as the control center, connecting various parts of the device via various interfaces and lines. It executes software programs and / or unit modules stored in memory 502, and calls data stored in memory 502, performing various functions and processing data to monitor the electronic device as a whole. Optionally, processor 501 may include one or more processing cores; processor 501 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. Preferably, processor 501 can integrate an application processor and a modem processor, where the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the aforementioned modem processor may not be integrated into processor 501.

[0073] The memory 502 can be used to store software programs and modules. The processor 501 executes various functional applications and data processing by running the software programs and modules stored in the memory 502. The memory 502 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function, etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 502 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 502 may also include a memory controller to provide the processor 501 with access to the memory 502.

[0074] The electronic device may also include a power supply 503 that supplies power to the various components. Preferably, the power supply 503 is logically connected to the processor 501 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 503 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0075] The electronic device may also include an input unit 504 and an output unit 505. The input unit 504 can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control. Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here.

[0076] Those skilled in the art will understand that all or part of the steps in the various methods described above can be accomplished by instructions, or by controlling related hardware with instructions. These instructions can be stored in a computer-readable storage medium and loaded and executed by the processor 501.

[0077] Therefore, this application provides a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, etc. Computer instructions are stored thereon, and these computer instructions are loaded by processor 501 to execute the steps in any of the text interaction methods based on a large language model provided in this application. For example, when the computer instructions are executed by processor 501, they perform the following functions: Receive a query statement, perform vectorization on the query statement to obtain a query vector, and extract keywords from the query statement to obtain a list of search keywords; Based on the query vector, a vector search is performed in a preset vector database to obtain at least one local vector and a corresponding local text segment; based on the search keyword list, a network search is performed to obtain network search results, the network search results are segmented to obtain at least one network text segment, and the at least one network text segment is vectorized to obtain a corresponding paragraph vector. Generate a vector matrix based on at least one local vector and at least one paragraph vector; Determine the similarity between each vector in the vector matrix and the query vector, and determine the correlation coefficient corresponding to each vector based on the similarity. The text segments corresponding to each vector are sorted according to the correlation coefficient, and the target text segment is determined based on the sorting results; The query statement and the target text are input into the large language model to obtain the text interaction feedback information corresponding to the query statement.

[0078] The computer instructions stored in the computer-readable storage medium can execute the present application as follows. Figure 1 Corresponding to the steps in the text interaction method based on a large language model in any embodiment, the present application can be implemented as described above. Figure 1For details on the beneficial effects that the text interaction method based on the large language model can achieve in any of the embodiments, please refer to the preceding description, and will not be repeated here in some of the embodiments.

[0079] The foregoing has provided a detailed description of a text interaction method, system, device, and medium based on a large language model provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A text interaction method based on a large language model, characterized in that, include: Receive a query statement, perform vectorization on the query statement to obtain a query vector, and extract keywords from the query statement to obtain a list of search keywords; Based on the query vector, a vector search is performed in a preset vector database to obtain at least one local vector and a corresponding local text segment; based on the search keyword list, a network search is performed to obtain network search results, the network search results are segmented to obtain at least one network text segment, and the at least one network text segment is vectorized to obtain a corresponding paragraph vector. Generate a vector matrix based on at least one local vector and at least one paragraph vector; Determine the similarity between each vector in the vector matrix and the query vector, and determine the correlation coefficient corresponding to each vector based on the similarity. The text segments corresponding to each vector are sorted according to the correlation coefficient, and the target text segment is determined based on the sorting results; The query statement and the target text are input into the large language model to obtain the text interaction feedback information corresponding to the query statement.

2. The method according to claim 1, characterized in that, The step of performing a vector search in a preset vector database based on the query vector to obtain at least one local vector and its corresponding local text segment includes: A similarity search is performed on the query vector in a preset vector database to determine the similarity between each local vector in the vector database and the query vector, and the vectors are sorted in descending order. Based on the descending order, a first preset number of local vectors are determined to be ranked first. The vector database includes multiple local vectors and their corresponding local text segments.

3. The method according to claim 1, characterized in that, The process of performing a web search based on the search keyword list to obtain web search results, segmenting the web search results to obtain at least one web text segment, and vectorizing the at least one web text segment to obtain a corresponding paragraph vector includes: The search engine is invoked based on the list of search keywords to obtain at least one webpage link and a summary corresponding to each webpage link; The web page links are crawled, the main text of the page is extracted and segmented to obtain the corresponding second preset number of web text segments; The second preset number of network segments are vectorized using an embedding model to obtain the corresponding second preset number of segment vectors.

4. The method according to claim 1, characterized in that, The step of determining the similarity between each vector in the vector matrix and the query vector, and determining the correlation coefficient corresponding to each vector based on the similarity, includes: Calculate the cosine similarity between each vector in the vector matrix and the query vector; The correlation coefficient for each vector is calculated based on the cosine similarity, the credibility factor of each vector in the vector matrix, and the timeliness factor of each vector.

5. The method according to claim 4, characterized in that, The correlation coefficient for each vector is calculated based on the cosine similarity, the credibility factor of each vector in the vector matrix, and the timeliness factor of each vector, using the following formula: λ i = α c i + β Credibility i + γ Recency i ; in, λ i The correlation coefficient is... c i The first element in the vector matrix i The cosine similarity between each vector and the query vector, Credibility i The first element in the vector matrix i The credibility factor of each vector, Recency i The first element in the vector matrix i The timeliness factor of each vector; α , β , γ All of these are preset weighting coefficients.

6. The method according to claim 4, characterized in that, The step of sorting the text segments corresponding to each vector according to the correlation coefficient and determining the target text segment based on the sorting result includes: The vectors are sorted in descending order based on their correlation coefficients to obtain the sorting results. The vectors corresponding to the third preset number of correlation coefficients in the sorting results are determined, and the text segments corresponding to the third preset number of vectors are taken as the target text segments.

7. The method according to claim 5, characterized in that, The method includes: Accept feedback instructions for the text interaction feedback information, including positive feedback instructions and negative feedback instructions; When the feedback instruction is a positive feedback instruction, the network segments and corresponding paragraph vectors in the target text segment are stored in the vector database.

8. A text interaction system based on a large language model, characterized in that, include: The statement receiving module is used to receive query statements, perform vectorization processing on the query statements to obtain query vectors, and extract keywords from the query statements to obtain a list of search keywords. The dual-channel retrieval module is used to perform vector search in a preset vector database based on the query vector to obtain at least one local vector and the corresponding local text segment; perform network retrieval based on the search keyword list to obtain network retrieval results; segment the network retrieval results to obtain at least one network text segment; and perform vectorization processing on the at least one network text segment to obtain the corresponding paragraph vector. A vector concatenation module is used to generate a corresponding vector matrix based on at least one local vector and at least one segment vector; The correlation coefficient determination module is used to determine the similarity between each vector in the vector matrix and the query vector, and to determine the correlation coefficient corresponding to each vector based on the similarity. The correlation coefficient sorting module is used to sort the text segments corresponding to each vector according to the correlation coefficient, and determine the target text segment based on the sorting result; The text interaction feedback information generation module is used to input the query statement and the target text into the large language model to obtain the text interaction feedback information corresponding to the query statement.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the text interaction method based on a large language model as described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the text interaction method based on a large language model as described in any one of claims 1 to 7.