Language model-based question and answer method and device and data source construction method and device
Through the question-answering method based on the language model and the integration of multiple retrieval strategies and data source construction strategies, the problem of insufficient information acquisition in the RAG system in complex problem processing is solved, and an efficient and flexible question-answering solution is achieved.
Patent Information
- Application Number
- CN202510795906.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-13
- Publication Date
- 2025-10-28
AI Technical Summary
When dealing with complex, diverse, or cross-domain problems, the RAG system has difficulty obtaining relevant contextual information comprehensively and accurately, which affects the quality of question answering. In addition, the combined use of multiple RAG architectures increases R&D complexity and cost.
A question-answering method based on a language model is adopted. By obtaining the retrieval strategy node in the retrieval workflow, indicating the retrieval and data source construction strategy, multiple retrieval types are integrated to generate answers.
It improves the versatility and applicability of the question-answering framework, reduces the difficulty and cost of research and development, improves the quality of question-answering and development efficiency, and meets the needs of efficient question-answering in different business scenarios.
Smart Images

Figure CN120851186A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to the fields of artificial intelligence, information retrieval, natural language processing, large models, and deep learning. In particular, it relates to a question-answering method, a data source construction method, and an apparatus based on a language model. Background Technology
[0002] Retrieval-Augmented Generation (RAG) systems, as an innovative technical architecture, have the core advantage of dynamically acquiring contextual information closely related to the question. In this way, RAG systems provide large models with richer and more accurate background knowledge, enabling them to generate more controllable, accurate, and practically relevant content when generating answers (or responses) based on this contextual information.
[0003] Currently, the RAG system has been widely and deeply applied in private domain data source construction scenarios, providing strong support for enterprise knowledge management and customer service. However, the RAG framework is not without its limitations, and some inherent limitations restrict its versatility to a certain extent. Summary of the Invention
[0004] This disclosure provides a question-answering method, a data source construction method, and an apparatus based on a language model.
[0005] According to one aspect of this disclosure, a language model-based question-answering method is provided. The method includes: acquiring a question to be processed and acquiring a retrieval workflow; wherein the retrieval workflow includes at least one retrieval strategy node, the retrieval strategy node being used to indicate retrieval strategy information and a data source construction strategy; retrieving a target database corresponding to the retrieval strategy node according to the retrieval strategy information indicated by the retrieval strategy node to obtain retrieval information matching the question; wherein the target database is constructed based on the data source construction strategy indicated by the corresponding retrieval strategy node; and generating an answer to the question using a language model based on the retrieval information.
[0006] According to another aspect of this disclosure, a data source construction method is provided, the method comprising: in response to a configuration operation performed on a configuration page, obtaining a retrieval workflow; wherein the retrieval workflow includes at least one retrieval strategy node, the retrieval strategy node being used to indicate a retrieval strategy and a data source construction strategy; for original text, constructing a corresponding target database according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow, wherein the target database is used by the corresponding retrieval strategy node to retrieve retrieval information for generating answers to questions according to the indicated retrieval strategy.
[0007] According to another aspect of this disclosure, a language model-based question-answering device is provided. The device includes: an acquisition module for acquiring a question to be processed and an acquisition retrieval workflow; wherein the retrieval workflow includes at least one retrieval strategy node, the retrieval strategy node indicating retrieval strategy information and a data source construction strategy; a retrieval module for retrieving a target database corresponding to the retrieval strategy node according to the retrieval strategy information indicated by the retrieval strategy node, to obtain retrieval information matching the question; wherein the target database is constructed based on the data source construction strategy indicated by the corresponding retrieval strategy node; and a generation module for generating an answer to the question using a language model based on the retrieval information.
[0008] According to another aspect of this disclosure, a data source construction apparatus is provided, the apparatus comprising: an acquisition module, configured to acquire a retrieval workflow in response to a configuration operation performed on a configuration page; wherein the retrieval workflow includes at least one retrieval strategy node, the retrieval strategy node being used to indicate a retrieval strategy and a data source construction strategy; and a construction module, configured to construct a corresponding target database for the original text according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow, wherein the target database is used by the corresponding retrieval strategy node to retrieve retrieval information for generating answers to questions according to the indicated retrieval strategy.
[0009] According to another aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the language model-based question-answering method or data source construction method proposed above in this disclosure.
[0010] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided that stores computer instructions for causing a computer to execute the language model-based question-answering method or data source construction method proposed in this disclosure above.
[0011] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the language model-based question-answering method or data source construction method proposed above.
[0012] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0013] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0014] Figure 1 This is a schematic diagram based on the first embodiment of the present disclosure;
[0015] Figure 2 This is a schematic diagram according to the second embodiment of the present disclosure;
[0016] Figure 3 This is a schematic diagram according to the third embodiment of the present disclosure;
[0017] Figure 4 This is a schematic diagram according to the fourth embodiment of the present disclosure;
[0018] Figure 5 This disclosure provides an offline data source construction framework and an online question-and-answer framework for a pipeline-based RAG system.
[0019] Figure 6 This is a schematic diagram according to the fifth embodiment of the present disclosure;
[0020] Figure 7 This is a schematic diagram according to the sixth embodiment of the present disclosure;
[0021] Figure 8 This is a block diagram of an electronic device used to implement the language model-based question-answering method or data source construction method of the embodiments of this disclosure. Detailed Implementation
[0022] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0023] The RAG framework is not without its limitations, which restricts its versatility to some extent. For example, when dealing with certain complex, diverse, or cross-domain problems, the RAG system may struggle to obtain all relevant contextual information comprehensively and accurately, thus affecting the quality of the response.
[0024] To improve the accuracy of RAG question-answering systems across various question-answering scenarios and meet the diverse needs of different users, various RAG derivative architectures have emerged in the industry. Among them, Graph RAG enhances retrieval capabilities by building knowledge graphs, enabling it to better handle questions with complex relationships; Agentic RAG introduces the concept of intelligent agents, allowing the system to proactively acquire and process information; and parent-child slicing recall RAG improves recall accuracy by slicing documents. These derivative architectures have improved the performance of RAG systems to some extent, but they often perform better only for a certain type of question or a specific scenario, and are unlikely to perform well in all business scenarios.
[0025] In practical applications, for specific business scenarios, it is often necessary to combine multiple RAG architectures to fully leverage their respective advantages and compensate for each other's shortcomings. However, this combined approach not only increases the complexity and cost of development but also places higher demands on the technical skills of developers.
[0026] To address the aforementioned issues, this disclosure proposes a question-answering method, a data source construction method, and an apparatus based on a language model.
[0027] Figure 1 The diagram is based on the first embodiment of this disclosure. It should be noted that the language model-based question-answering method of this disclosure can be applied to a language model-based question-answering device, which can be configured in an electronic device so that the electronic device can perform question-answering functions.
[0028] Among them, electronic devices can be any device with computing capabilities, such as personal computers (PCs), mobile terminals, servers, etc. Mobile terminals can be, for example, in-vehicle devices, mobile phones, tablets, personal digital assistants, wearable devices, smart speakers, servers, server clusters, and other hardware devices with various operating systems, touch screens and / or displays.
[0029] The question-answering device based on the language model can also be software in an electronic device, such as question-answering software. The following embodiments use an electronic device as an example for illustration.
[0030] like Figure 1 As shown, this language model-based question-answering method may include the following steps:
[0031] Step 101: Obtain the problem to be processed and the retrieval workflow; wherein, the retrieval workflow includes at least one retrieval strategy node, which is used to indicate retrieval strategy information and data source construction strategy.
[0032] It should be noted that this disclosure does not limit the number of retrieval strategy nodes included in the retrieval workflow. That is, the retrieval workflow may include one or more retrieval strategy nodes, and the retrieval strategy nodes may be used to indicate retrieval strategy information and data source construction strategies.
[0033] Among them, retrieval strategy information can be used to indicate the retrieval strategy adopted, and the retrieval strategy can be used to indicate the specific retrieval logic.
[0034] Optionally, in some embodiments, the retrieval strategy node can also be used to indicate the retrieval type to which the retrieval strategy belongs. The retrieval type may include, but is not limited to, dense vector retrieval, sparse retrieval, web page search, graph search, etc., and this disclosure does not impose any limitations on this.
[0035] Optionally, in some embodiments, the retrieval strategy information can also be used to instruct a format adjustment strategy, which can be used to instruct the retrieved information to be converted into a corresponding format, such as instructing the retrieved information to be converted into a text format suitable for large model processing.
[0036] The data source construction strategy refers to the methods and principles followed in planning, selecting, integrating, and processing data sources. It should be noted that the data source construction strategy corresponding to the retrieval strategy node can be empty. When the data source construction strategy is empty, it indicates that there is no need to construct the database or data source corresponding to the retrieval strategy node.
[0037] In this embodiment of the disclosure, questions to be processed can be acquired. In one example, questions to be processed can be acquired in response to user input on the client. It should be noted that this disclosure does not limit the number of questions to be acquired.
[0038] In this embodiment of the disclosure, a retrieval workflow can also be obtained. In one example, relevant users (such as platform administrators or relevant staff) can customize the retrieval workflow through the visual operation interface provided by the low-code platform. During the configuration process, relevant users can flexibly set the retrieval strategies, format adjustment strategies, and data source construction strategies indicated by each retrieval strategy node according to actual business needs. After the configuration is completed, the question-and-answer system will save the configuration information and convert it into an executable retrieval workflow, thereby enabling electronic devices to obtain the retrieval workflow.
[0039] Step 102: Search the target database corresponding to the search strategy node according to the search strategy information indicated by the search strategy node to obtain search information that matches the question.
[0040] The target database can be constructed based on the data source construction strategy indicated by the corresponding retrieval strategy node.
[0041] Optionally, in some embodiments, when the data source construction strategy indicated by the retrieval strategy node is empty and the retrieval type of the retrieval strategy indicated by the retrieval strategy node is a web search type, the target database corresponding to the retrieval strategy node can be the database corresponding to the corresponding search engine.
[0042] The number of information items retrieved can be, but is not limited to, one; this disclosure does not impose any restrictions on this.
[0043] In this embodiment of the disclosure, the target database corresponding to the retrieval strategy node can be searched according to the retrieval strategy information indicated by the retrieval strategy node, thereby obtaining retrieval information that matches the question.
[0044] In one example, when there are multiple retrieval strategy nodes, the retrieval process of the target database corresponding to each retrieval strategy node can be executed concurrently according to the retrieval strategy information indicated by each retrieval strategy node, thereby obtaining retrieval information that matches the question.
[0045] In another example, when there are multiple retrieval strategy nodes, the retrieval process of the target database corresponding to each retrieval strategy node can be executed sequentially according to the retrieval strategy information indicated by each retrieval strategy node, based on a set order, so as to obtain retrieval information that matches the question.
[0046] The order can be preset and is used to indicate the retrieval order of the target database corresponding to each retrieval strategy node.
[0047] Step 103: Based on the retrieved information, use a language model to generate the answer to the question.
[0048] The language model can be a large model that has the function of generating answers to questions.
[0049] In one example, the retrieved information is input into a language model, which then integrates and arranges the information. The output of the language model is then used as the answer to the question.
[0050] The language model-based question-answering method of this disclosure obtains the question to be processed and a retrieval workflow. The retrieval workflow includes at least one retrieval strategy node, which indicates retrieval strategy information and a data source construction strategy. Following the retrieval strategy information indicated by the retrieval strategy node, a retrieval is performed on the target database corresponding to the retrieval strategy node to obtain retrieval information matching the question. The target database is constructed based on the data source construction strategy indicated by the corresponding retrieval strategy node. Based on the retrieval information, a language model is used to generate the answer to the question. By relying solely on the retrieval strategy information indicated by the retrieval strategy node in the retrieval workflow, key information can be retrieved from the corresponding target database, and an answer can be generated. Therefore, by simply setting the retrieval strategy node in the retrieval workflow and formulating personalized retrieval strategies and data source construction strategies, multiple retrieval strategies and data sources can be integrated within a single framework. This allows questions to be used freely regardless of their type, improving the versatility and applicability of the question-answering framework. Furthermore, without complex architectural combinations, efficient question-answering can be achieved in different business scenarios. This helps improve the quality of question-answering and reduces development difficulty and costs, thus improving development efficiency.
[0051] like Figure 2 As shown, this disclosure also proposes a question-answering method based on a language model. Figure 2 The diagram illustrates a second embodiment of this disclosure. The language model-based question-answering method may include the following steps:
[0052] Step 201: Obtain the problem to be processed and the retrieval workflow; wherein, the retrieval workflow includes at least one retrieval strategy node, which is used to indicate retrieval strategy information and data source construction strategy.
[0053] It should be noted that the execution process of step 201 can refer to the execution process of any embodiment of this disclosure, and will not be repeated here.
[0054] Step 202: Process the question according to the search type to obtain the search conditions.
[0055] Optionally, in some embodiments, when the retrieval type includes a dense vector retrieval type, feature extraction can be performed on the question to obtain a question vector as a retrieval condition. In one example, a deep learning model is used to extract features from the question to obtain a question vector as a retrieval condition. When the retrieval type includes a dense vector retrieval type, feature extraction of the question can capture rich semantic information in the question. Furthermore, using the extracted features as retrieval conditions helps improve the accuracy and precision of the retrieval process in subsequent retrieval processes.
[0056] Optionally, in some embodiments, when the search type includes a sparse search type, the question can be segmented to obtain at least one word as a search condition. Specifically, the question is segmented to obtain words, and these words are used as search conditions. When the search type includes a sparse search type,
[0057] It should be noted that this disclosure does not limit the number of word segments.
[0058] Optionally, in some embodiments, the obtained word segments can also be filtered to filter out stop words, sensitive words, etc. in at least one word segment.
[0059] Optionally, in some embodiments, when the search type includes a web search type, the question can be used as the text of the search criteria.
[0060] Optionally, in some embodiments, when the search type includes a graph search type, the question can be parsed to obtain entities and / or relationships as search conditions. Specifically, the question is parsed to obtain entities and / or relationships in the question, and the obtained entities and / or relationships are used as search conditions.
[0061] Therefore, by adopting a processing method that is compatible with the search type to handle the problem, it helps to improve the matching degree between the search conditions and the corresponding information in the target database in the subsequent search process, enhance the accuracy of information matching, and adopt corresponding processing methods for different search types to handle the problem, which can meet the diverse search needs in different scenarios and improve the flexibility and applicability of information retrieval.
[0062] Step 203: Based on the search criteria and in accordance with the search strategy indicated by the search strategy information, perform a search in the corresponding target database to obtain search information that matches the question.
[0063] Optionally, in some embodiments, the retrieval strategy node for any retrieval type may have a corresponding target database. In one example, the target database corresponding to the retrieval strategy node for dense vector retrieval type may be a vector database, wherein the vector database can be a database system used to store, index, and query high-dimensional vector data, such as the Milvus database; the target database corresponding to the retrieval strategy for sparse retrieval type may be a database used for full-text retrieval, such as Elasticsearch; the target database corresponding to the retrieval strategy node for graph search type may be a graph database, wherein the graph database is a database management system used to store, manage, and query graph structure data.
[0064] Optionally, in some embodiments, the retrieval strategy under the dense vector retrieval type may include: based on the question vector and the index of multiple first statements in the vector database, retrieving multiple first statements in the vector database to determine the first target statement that matches the question from the multiple first statements, and determining the first target statement as the retrieval information.
[0065] The index structure of the vector database can be, for example, HNSW (Hierarchical Navigable SmallWorld) or FLAT, and this disclosure does not impose any restrictions on it.
[0066] In one example, based on the question vector, using the index of the vector database, the first statements with a similarity greater than a set threshold to the question vector are determined from multiple first statements in the vector database. These first statements are then identified as the first target statements matching the question, and thus the first target statements can be used as the retrieval information. The set threshold can be pre-set, and this disclosure does not restrict the value of the set threshold.
[0067] In one example, when the vector database has a multi-level index (or multi-level index) architecture, based on the question vector and the indexes of multiple first statements in the vector database, parent-child slicing retrieval is performed on the multiple first statements in the vector database to obtain the first target statement. For example, the indexes of each first statement in the vector database include parent indexes and child indexes. By calculating the similarity between the question vector and the shard center vector indicated by the parent index corresponding to the first statement in each shard (or cluster) of the vector database, the Top-K shards are selected from the multiple shards in the vector database. Then, within the selected clusters, the Top-N similar vectors similar to the question vector are retrieved through the child indexes of each first statement within the cluster. The first statements corresponding to the Top-N similar vectors of each selected cluster are then determined as the first target statement.
[0068] Therefore, by utilizing the search strategies and conditions under the dense vector retrieval type, it is possible to quickly locate the search information matching the question in the corresponding target database.
[0069] Optionally, in some embodiments, the retrieval strategy under the sparse retrieval type may include: determining at least one second statement associated with the question from the target database; determining the term frequency and inverse document frequency of each term in any second statement for at least one term used as a retrieval condition; determining a second target statement from the at least one second statement based on the term frequency and inverse document frequency, and determining the second target statement as retrieval information.
[0070] Optionally, in some embodiments, statements containing any of the segments can be determined from the target database based on at least one segment used as a retrieval condition, and the statements containing any of the segments can be used as second statements associated with the question.
[0071] Specifically, for any word segment used as a search condition, the term frequency and inverse document frequency (IVF) of that word in any second sentence can be determined. In one example, for any word segment and any second sentence, the target database can be queried based on the word segment and the second sentence to directly obtain the word frequency and IVF of the word in the second sentence. In another example, for any word segment and any second sentence, the number of times the word appears in the second sentence and the total number of words in the second sentence can be obtained. Then, the word frequency of the word in the second sentence is determined based on the ratio of the number of times the word appears in the second sentence to the total number of words in the second sentence. Simultaneously, the number of target sentences containing the word in the target database and the total number of sentences in the target database can be obtained. Then, the IVF of the word is determined based on the number of target sentences containing the word in the target database and the total number of sentences in the target database.
[0072] Specifically, a second target statement can be determined from at least one second statement based on term frequency and inverse document frequency. In one example, the BM25 algorithm can be used to determine the relevance score between any second statement and the question based on term frequency and inverse document frequency; thus, the second statement with a relevance score greater than a set score is determined as the second target statement.
[0073] The set score can be preset, and this disclosure does not restrict the value of the set score.
[0074] Optionally, in some embodiments, the retrieval strategy under the webpage search type may include: obtaining webpage content that matches the question through the service interface of the target search engine based on the text used as the retrieval condition, and determining the webpage content as the retrieval information.
[0075] Optionally, in some embodiments, the retrieval strategy under the graph search type may include: querying multiple reference triples in the graph database based on entities and / or relations used as retrieval conditions to obtain target triples that match the question; and analyzing the target triples to determine retrieval information.
[0076] This involves querying multiple reference triples in a graph database based on entities and / or relations used as search criteria to obtain target triples that match the query. In one example, triples containing entities can be identified from multiple reference triples in the graph database based on entities used as search criteria, and these triples can be designated as target triples.
[0077] In another example, based on the relation used as a retrieval condition, triples that include the relation can be determined from multiple reference triples in the graph database, and triples that include the relation can be identified as target triples.
[0078] In another example, triples that include entities and relations can be identified from multiple reference triples in the graph database based on entities and relations used as retrieval criteria, and these triples can be identified as target triples.
[0079] This involves analyzing the target triples to determine the retrieval information. In one example, if the retrieval criteria only include entity 1, information other than entity 1 in the target triples (such as entity 2, and the relationship between entity 1 and entity 2) can be identified as the retrieval information.
[0080] In another example, when the search criteria include entity 1 and relation, information other than entity 1 and relation (such as entity 2) in the target triple can be identified as the search information.
[0081] It should be noted that by adopting search strategies that are compatible with the search type and conducting searches based on search conditions, the accuracy and efficiency of information retrieval can be improved. Furthermore, by employing corresponding search strategies for different search types, diverse search needs in different scenarios can be met, enhancing the flexibility and applicability of information retrieval.
[0082] Optionally, in some embodiments, the retrieval workflow may also include a proxy node, which may be the parent node of at least one retrieval strategy node.
[0083] Optionally, in some embodiments, when the retrieval workflow includes a proxy node, and the proxy node is the parent node of at least one retrieval strategy node, the child nodes of the proxy node and the retrieval type indicated by the child nodes can be determined among the retrieval strategy nodes included in the retrieval workflow. The agent configured by the proxy node can select a retrieval strategy node from the child nodes according to the retrieval type and question, so as to perform a retrieval using the target database and retrieval strategy corresponding to the selected retrieval strategy node, and obtain retrieval information matching the question.
[0084] The agent can be a large model with the ability to determine the retrieval type applicable to the problem.
[0085] In one example, if the retrieval workflow includes a proxy node, and the proxy node is the parent node of both the sparse retrieval type retrieval strategy node and the web search type retrieval strategy node, then the child nodes of this proxy node can be determined to be the sparse retrieval type retrieval strategy node and the web search type retrieval strategy node, respectively. The retrieval types indicated by these child nodes are the sparse retrieval type and the web search type, respectively. The agent configured on the proxy node (referred to as the intelligent agent in this disclosure) can determine the target retrieval type matching the question based on the question, from the aforementioned retrieval types, namely the sparse retrieval type and the web search type. The retrieval strategy node corresponding to the target retrieval type is then selected as the retrieval strategy node. Furthermore, the target database and retrieval strategy corresponding to the selected retrieval strategy node can be used to perform a retrieval to obtain retrieval information matching the question. For example, assuming the selected retrieval strategy node is a sparse retrieval type retrieval strategy node, then the target database and retrieval strategy corresponding to the sparse retrieval type retrieval strategy node are used to perform a retrieval to obtain retrieval information matching the question.
[0086] Optionally, in some embodiments, when the retrieval workflow includes a proxy node, and the proxy node is the parent node of at least one retrieval strategy node, the child nodes of the proxy node and the retrieval strategy information indicated by the child nodes can be determined among the retrieval strategy nodes included in the retrieval workflow. The agent configured by the proxy node can select a retrieval strategy node from the child nodes according to the retrieval strategy information and the question, so as to perform a retrieval using the target database and retrieval strategy corresponding to the selected retrieval strategy node, and obtain retrieval information matching the question.
[0087] The agent can be a large model that has the ability to determine a retrieval strategy suitable for the problem.
[0088] In one example, if the retrieval workflow includes a proxy node, and the proxy node is the parent node of a sparse retrieval strategy node and a web search strategy node, then the child nodes of the proxy node can be determined to be sparse retrieval strategy nodes and web search strategy nodes, along with the retrieval strategy information corresponding to the aforementioned child nodes. An agent can then determine the matching degree between the question and the retrieval strategy information, and based on this matching degree, select a retrieval strategy node from the child nodes. The selected retrieval strategy node's target database and retrieval strategy will then be used to perform the retrieval, obtaining retrieval information that matches the question.
[0089] For example, strategy features of retrieval strategy information can be obtained, where strategy features can be used to indicate the scenarios in which the retrieval strategy indicated by the corresponding retrieval strategy information is applicable; through the intelligent agent configured by the agent node, features are extracted from the question to obtain the first feature, and the matching degree between the question and the retrieval strategy is determined based on the similarity or Euclidean distance between the first feature and the strategy features of the retrieval strategy information; then, a retrieval strategy node can be selected from the retrieval strategy information corresponding to the above-mentioned sub-nodes, and the selected retrieval strategy node can be activated to perform a retrieval using the target database and retrieval strategy corresponding to the selected retrieval strategy node, thereby obtaining retrieval information that matches the question.
[0090] It should be noted that the above examples only illustrate that the proxy node is the parent node of the retrieval strategy node for sparse retrieval type and the retrieval strategy node for web search type. In practical applications, the proxy node can also be the parent node of retrieval strategy nodes for other retrieval types, and this disclosure does not impose any restrictions on this.
[0091] Therefore, an intelligent agent can quickly and accurately select a suitable retrieval strategy node from the child nodes, and perform retrieval according to the target database and retrieval strategy corresponding to the selected retrieval strategy node. This improves the intelligence and automation of retrieval strategy selection, avoids manual intervention, and improves the efficiency and accuracy of retrieval.
[0092] Step 204: Based on the retrieved information, use a language model to generate the answer to the question.
[0093] It should be noted that the execution process of step 204 can refer to the execution process of any embodiment of this disclosure, and will not be repeated here.
[0094] Optionally, in some embodiments, when there is at least one piece of retrieval information, the at least one piece of retrieval information can be post-processed, and an answer to the question can be generated based on the processed retrieval information using a language model.
[0095] Post-processing may include information filtering, reordering, deduplication, etc., which can be added or set according to actual needs, and this disclosure does not impose any restrictions on them.
[0096] It is understandable that the retrieved information may contain duplicates, redundancies, or be of varying quality. By post-processing the retrieved information, irrelevant or redundant information can be removed, retaining only the most valuable information that closely matches the question. This information can then be logically sorted to form a clear and well-structured set, thereby improving the accuracy and effectiveness of the subsequently generated answers.
[0097] Optionally, in some implementations, where the retrieval strategy information is also used to indicate the format adjustment strategy, the retrieval information corresponding to the retrieval strategy node can be formatted based on the format adjustment strategy corresponding to the retrieval strategy node. This can enhance the readability of the retrieval information in the subsequent answer generation process, thereby helping to improve the efficiency of answer generation and enhance the accuracy and quality of the answers.
[0098] The language model-based question-answering method of this disclosure processes the question to correspond with the search type, thereby obtaining search conditions. Based on the search conditions, and following the search strategy indicated by the search strategy information, a search is performed in the corresponding target database to obtain search information matching the question. Therefore, by processing the question to be compatible with the search type, the relevance and effectiveness of the obtained search conditions are improved. Furthermore, searching based on the search conditions can effectively avoid blind searching, improve search efficiency, and enhance the accuracy of search results.
[0099] like Figure 3 As shown, this disclosure proposes a method for constructing a data source. Figure 3 The schematic diagram is based on a third embodiment of this disclosure. The data source construction method may include the following steps:
[0100] Step 301: In response to the configuration operation performed on the configuration page, obtain the retrieval workflow; wherein the retrieval workflow includes at least one retrieval strategy node, which is used to indicate retrieval strategy information and data source construction strategy.
[0101] It should be noted that the explanations and descriptions of the retrieval workflow, retrieval strategy nodes, retrieval strategy information, and data source construction strategy in any of the above embodiments of this disclosure also apply to this embodiment, and will not be repeated here.
[0102] The configuration page can be used by relevant users or staff to perform configuration operations to obtain the configuration retrieval workflow. These configuration operations may include, but are not limited to, input operations, drag-and-drop operations, deletion operations, click operations, etc., and this disclosure does not impose any restrictions on them.
[0103] In one example, the platform administrator can configure the retrieval strategy information and data source construction strategy indicated by each retrieval strategy node in the retrieval workflow by dragging and dropping interface elements on the configuration page of the low-code platform, and / or by the platform administrator's input operations, so as to realize the configuration of the retrieval workflow and thus realize the acquisition of the retrieval workflow.
[0104] Step 302: For the original text, construct the corresponding target database according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow.
[0105] It should be noted that this disclosure does not limit the amount of original text. In one example, the original text can be text from a document database corresponding to a private domain scenario (such as within an enterprise).
[0106] The target database can be used by the corresponding retrieval strategy nodes to retrieve retrieval information to generate answers to questions based on the indicated retrieval strategy information.
[0107] In this embodiment of the disclosure, the original text can be processed according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow to construct the corresponding target database. In one example, when there are multiple retrieval strategy nodes in the retrieval workflow, the construction process of the target database corresponding to each retrieval strategy node can be executed concurrently according to the data source construction strategy corresponding to each retrieval strategy node. Therefore, by executing the database construction in parallel, the efficiency of data source construction is improved.
[0108] In another example, strategies can be constructed for the original text according to the data source corresponding to each retrieval strategy node, and the construction of the target database corresponding to each retrieval strategy node can be performed in parallel based on a preset concurrency level.
[0109] The concurrency level can be preset and refers to the number of tasks or operations that the corresponding system can process simultaneously during parallel computing or task execution.
[0110] Therefore, based on a preset concurrency level, on the one hand, the efficiency of data source construction can be improved by executing database construction in parallel; on the other hand, control over the parallel execution of database construction can be achieved, thereby improving the stability and reliability of data source construction and enhancing the quality and accuracy of the constructed data source.
[0111] In another example, when there are multiple retrieval strategy nodes in the retrieval workflow, the construction of the target database corresponding to each retrieval strategy node can be performed sequentially according to the retrieval strategy information indicated by each retrieval strategy node, based on a set order.
[0112] The order can be preset and is used to indicate the construction order of the target database corresponding to each retrieval strategy node.
[0113] Therefore, by executing the database construction sequentially, data errors caused by uneven resource allocation in the parallel construction process can be avoided, thereby improving the accuracy and completeness of the data in the constructed database.
[0114] The data source construction method of this disclosure obtains a retrieval workflow in response to a configuration operation performed on a configuration page. The retrieval workflow includes at least one retrieval strategy node, which indicates retrieval strategy information and a data source construction strategy. For the original text, a corresponding target database is constructed according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow. The target database is used by the corresponding retrieval strategy node to retrieve retrieval information for generating answers to questions based on the indicated retrieval strategy information. Therefore, by configuring the retrieval workflow on the configuration page, different data sources can be automatically constructed based on the data source construction strategies corresponding to each retrieval strategy node in the retrieval workflow. This improves the flexibility, convenience, and efficiency of data source construction, effectively reduces manual intervention, and allows for the implementation of multiple data sources and retrieval strategies within a single framework. This eliminates the need for questions to be limited to specific types, enabling efficient question answering in different business scenarios. On the one hand, this helps improve the quality of question answering; on the other hand, it reduces development difficulty and costs, thus improving development efficiency.
[0115] like Figure 4 As shown, this disclosure proposes a method for constructing a data source. Figure 4 The schematic diagram is based on the fourth embodiment of this disclosure. The data source construction method may include the following steps:
[0116] Step 401: In response to the configuration operation performed on the configuration page, obtain the retrieval workflow; wherein the retrieval workflow includes at least one retrieval strategy node, which is used to indicate retrieval strategy information and data source construction strategy.
[0117] It should be noted that the execution process of step 401 can refer to the execution process of any embodiment of this disclosure, and will not be repeated here.
[0118] Step 402: Process the original text according to the search type to obtain the stored data.
[0119] The search type may include, but is not limited to, dense vector search type, sparse search type, graph search type, web page search type, etc., and this disclosure does not impose any restrictions on it.
[0120] Optionally, in some embodiments, when the retrieval type includes a dense vector retrieval type, the original text can be sliced first to obtain multiple first statements; based on any one first statement, a text vector model is used to generate a corresponding first statement vector; and the first statement and the corresponding first statement vector are used as storage data.
[0121] Among them, text vector models, such as the BGE-LRAGE-ZH model and the STELLA-LARGE-ZH model, have the function of generating corresponding text vectors from text.
[0122] In one example, the original text can be sliced to obtain multiple sentences in the original text. Each sentence can then be input into a text vector model to obtain the sentence vector corresponding to each sentence. Finally, the sentences and their corresponding sentence vectors can be stored as data.
[0123] Optionally, in some embodiments, when the retrieval type includes a sparse retrieval type, the original text can be sliced a second time to obtain multiple second statements; any second statement can be segmented into multiple words; and the multiple second statements and their corresponding words can be stored as data.
[0124] Optionally, in some embodiments, when the retrieval type includes a graph search type, the original text is sliced into a third slice to obtain multiple third statements; triples are extracted from any third statement to obtain the triples corresponding to the third statement, and the triples can be used as stored data.
[0125] Therefore, by processing the original text using a processing method that matches the retrieval type, the relevance and practicality of the acquired stored data can be effectively enhanced, and the matching degree between the subsequently constructed database and the retrieval strategy under the corresponding retrieval type can be improved, thereby helping to improve the efficiency and accuracy of information retrieval. Moreover, by using appropriate processing methods to process the original text for different retrieval types, the needs of building diverse data sources in different scenarios can be met, improving the flexibility and applicability of data source construction.
[0126] Step 403: Based on the stored data, construct the corresponding target database according to the data source construction strategy.
[0127] Optionally, in some embodiments, the data source construction strategy can be used to indicate construction logic and indexing rules, etc. The construction logic can be used to indicate the design rules or methods for the structure, hierarchy, and relationships of data in the corresponding data source, and the indexing rules can be used to indicate the strategy for designing indexes for data tables in the corresponding data source to optimize query performance.
[0128] Optionally, in some embodiments, the target database corresponding to the retrieval strategy node of the dense vector retrieval type is a vector database. The data source construction strategy under the dense vector retrieval type may include: writing each first statement and its corresponding first statement vector as storage data into the vector database, and constructing an index for any first statement in the vector database based on the similarity between each first statement vector.
[0129] In one example, a multi-level index (or multi-layer index) can be built on the first statements written to the vector database based on the similarity between the vectors of each first statement. Here, parent-child slicing refers to optimizing the organization and retrieval of information by dividing documents or data into hierarchical fragments. For example, documents or data can be divided into parent blocks and child blocks, where the parent block can serve as a larger semantic unit, and the child block can be used for vector embedding.
[0130] Optionally, in some embodiments, the data source construction strategy under sparse retrieval type may include: for any word used as stored data, determining target sentences containing the word in multiple second sentences, as well as the word frequency and inverse document frequency of the word in the target sentences; generating an inverted index table based on the target sentences containing the word, as well as the word frequency and inverse document frequency of the word in the target sentences; and constructing a target database based on the inverted index table.
[0131] Optionally, in some embodiments, the target database corresponding to the retrieval strategy node of the graph search type can be a graph database, and the data source construction strategy under the graph search type can include: writing triples as stored data into the graph database, and building an index on the entities and / or relations in the triples.
[0132] Therefore, by adopting a data source construction strategy that matches the retrieval type to build a data source based on the corresponding stored data, the directionality, accuracy, and efficiency of data source construction can be improved. Furthermore, by adopting corresponding data source construction strategies for different retrieval types, the diverse data source construction needs in different scenarios can be met, enhancing the flexibility and applicability of data source construction.
[0133] Optionally, in some embodiments, the retrieval workflow may further include a proxy node, which is the parent node of at least one retrieval strategy node, and the parent node is configured with an agent.
[0134] Optionally, in some embodiments, the agent can be used to select a retrieval strategy node from the child nodes of the agent node, so as to perform a retrieval using the target database and retrieval strategy corresponding to the selected retrieval strategy node, and obtain retrieval information.
[0135] It should be noted that the method for selecting a retrieval strategy node from the child nodes of the agent node in the above embodiments of this disclosure is also applicable to this embodiment, and will not be described in detail here.
[0136] Therefore, an intelligent agent can quickly and accurately select a suitable retrieval strategy node from the child nodes, and perform retrieval according to the target database and retrieval strategy corresponding to the selected retrieval strategy node. This improves the intelligence and automation of retrieval strategy selection, avoids manual intervention, and improves the efficiency and accuracy of retrieval.
[0137] Optionally, in some embodiments, when the database storing the original text is updated, in response to the update, the corresponding target database can be reconstructed according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow. This enables synchronization between the data in the target database and the original text data, improving the stability and reliability of information retrieval.
[0138] The data source construction method of this disclosure involves processing the original text according to the retrieval type to obtain stored data; based on the stored data, a corresponding target database is constructed according to the data source construction strategy. Therefore, by processing the original text to match the retrieval type, the relevance and effectiveness of the acquired stored data are improved. Furthermore, constructing a database based on the stored data effectively avoids data redundancy and interference from irrelevant information, improving the accuracy and quality of the data in the constructed database, thus contributing to improved accuracy in information retrieval and ultimately enhancing the quality of the generated answers.
[0139] To clearly illustrate the language model-based question answering method and data source construction method disclosed herein, a detailed explanation is provided below with examples.
[0140] As an example, this paper illustrates the application of language model-based question-answering methods and data source construction methods to a pipelined RAG system. For example... Figure 5 As shown, the offline data source construction framework and online question-answering framework of the pipeline-based RAG system include the following steps:
[0141] I. The offline data source construction framework for a pipeline-based RAG system may include the following steps:
[0142] 1. Editing and publishing the recall workflow (referred to as the retrieval workflow in this disclosure)
[0143] Platform administrators can perform configuration operations on the low-code platform's configuration page to configure different recall strategy nodes (referred to as retrieval strategy nodes in this disclosure) to form a recall workflow.
[0144] Each recall strategy node has attribute information including node type (referred to as retrieval type in this disclosure), recall strategy information (referred to as retrieval strategy information in this disclosure), and data source construction strategy.
[0145] The recall strategy information indicates the data source retrieved during the recall process and the specific retrieval logic. It also indicates the format adjustment strategy, such as how to adjust the retrieval results to a text format suitable for large models. The recall strategy information can be used for Agent scheduling.
[0146] The data source construction strategy can be used to generate corresponding data source construction tasks. It should be noted that the data source construction strategy can be empty; if empty, it means that no data source construction task needs to be generated.
[0147] For example, the relevant definitions of recall strategy nodes are shown in Table 1:
[0148]
[0149] 2. Offline data source construction
[0150] 2.1 Obtain the build task set according to the recall workflow.
[0151] Specifically, after confirming the recall workflow, the system will automatically generate a set of data source tasks to be built based on the workflow content. It should be noted that different recall strategy nodes correspond to different data source construction tasks; that is, different recall strategy nodes build corresponding data sources.
[0152] 2.2 Execute the build task
[0153] The system can concurrently execute various data source build tasks to complete the construction and updating of data sources. Within a single build task, processing may include document parsing, slicing, entity extraction, and other procedures. It's worth noting that the concurrency level can be configured when executing various data source build tasks concurrently, allowing the execution of each task to be based on that level of concurrency.
[0154] II. The online question-answering framework of a pipeline-based RAG system may include the following steps:
[0155] 1. Obtaining the question
[0156] It can respond to user input and retrieve the problem to be solved.
[0157] 2. Recall
[0158] According to the recall strategy information indicated by each recall strategy node in the recall workflow, the offline data source is retrieved to obtain reference information matching the problem (referred to as retrieval information in this disclosure).
[0159] 3. Post-processing
[0160] Post-processing of the reference information may include filtering sensitive information, re-ranking, deduplication, etc.
[0161] 4. Generate answers
[0162] Based on the post-processed reference information, the answer to the question is generated using an LLM (Large Language Model) model.
[0163] In summary, pipeline-based RAG systems have at least the following advantages:
[0164] 1. With the help of a low-code platform, the recall workflow can be flexibly configured, and the optimal recall strategy can be dynamically and quickly combined to meet diverse needs, helping relevant users (such as private domain users) to quickly build a RAG question-and-answer system suitable for their own use cases.
[0165] 2. The system boasts high compatibility, adapting to various RAG derivatives (such as Agentic RAG, Graph RAG, etc.) and multiple recall strategies (such as parent-child slice recall, multi-way recall, etc.). Through the organic combination of recall strategies, synergistic effects are achieved, resulting in a "1+1>2" outcome.
[0166] 3. The overall framework design is highly scalable and can easily cope with future function iterations and scenario expansions.
[0167] To implement the above embodiments, this disclosure also provides a question-answering device based on a language model. For example... Figure 6 As shown, Figure 6 This is a schematic diagram according to the fifth embodiment of the present disclosure. The language model-based question-answering device 600 may include: an acquisition module 601, a retrieval module 602, and a generation module 603.
[0168] The acquisition module 601 is used to acquire the problem to be processed and to acquire the retrieval workflow; the retrieval workflow includes at least one retrieval strategy node, which is used to indicate retrieval strategy information and data source construction strategy.
[0169] The retrieval module 602 is used to retrieve the target database corresponding to the retrieval strategy node according to the retrieval strategy information indicated by the retrieval strategy node, so as to obtain retrieval information matching the question; wherein, the target database is constructed based on the data source construction strategy indicated by the corresponding retrieval strategy node.
[0170] The generation module 603 is used to generate answers to questions based on the retrieved information using a language model.
[0171] In one possible implementation of this disclosure, retrieval strategy information is used to indicate a retrieval strategy, and the retrieval strategy node is also used to indicate the retrieval type to which the retrieval strategy belongs; the retrieval module 602 is used to: process the question in accordance with the retrieval type to obtain retrieval conditions; and according to the retrieval conditions, perform a retrieval in the corresponding target database in accordance with the retrieval strategy indicated by the retrieval strategy information to obtain retrieval information matching the question.
[0172] In one possible implementation of this disclosure, the retrieval module 602 is configured to: extract features from the question to obtain a question vector as a retrieval condition when the retrieval type includes a dense vector retrieval type.
[0173] In one possible implementation of this disclosure, the target database corresponding to the retrieval strategy node of the dense vector retrieval type is a vector database; the retrieval strategy under the dense vector retrieval type includes: based on the question vector and the index of multiple first statements in the vector database, retrieving multiple first statements in the vector database to determine the first target statement that matches the question from the multiple first statements, and determining the first target statement as the retrieval information.
[0174] In one possible implementation of this disclosure, the retrieval module 602 is configured to: when the retrieval type includes a sparse retrieval type, segment the question to obtain at least one segmented word as a retrieval condition.
[0175] In one possible implementation of this disclosure, the retrieval strategy under the sparse retrieval type includes: determining at least one second statement associated with the question from the target database; determining the term frequency and inverse document frequency of each term in any second statement for at least one term used as a retrieval condition; determining a second target statement from the at least one second statement based on the term frequency and inverse document frequency, and determining the second target statement as retrieval information.
[0176] In one possible implementation of this disclosure, the retrieval module 602 is configured to: use the question as the text of the retrieval condition when the retrieval type includes a web search type.
[0177] In one possible implementation of this disclosure, the retrieval strategy under the webpage search type includes: based on the text used as the retrieval condition, obtaining webpage content that matches the question through the service interface of the target search engine, and determining the webpage content as retrieval information.
[0178] In one possible implementation of this disclosure, the retrieval module 602 is configured to: parse the question to obtain entities and / or relationships as retrieval conditions when the retrieval type includes a graph search type.
[0179] In one possible implementation of this disclosure, the target database corresponding to the retrieval strategy node of the graph search type is a graph database; the retrieval strategy under the graph search type includes: querying multiple reference triples in the graph database based on entities and / or relations as retrieval conditions to obtain target triples that match the question; and analyzing the target triples to determine retrieval information.
[0180] In one possible implementation of this disclosure, the retrieval workflow further includes a proxy node, which is the parent node of at least one retrieval strategy node; the retrieval module 602 is further configured to: determine the child nodes of the proxy node and the retrieval type indicated by the child node among the retrieval strategy nodes included in the retrieval workflow; and, through an agent configured by the proxy node, select a retrieval strategy node from the child nodes according to the retrieval type and question, so as to perform a retrieval using the target database and retrieval strategy corresponding to the selected retrieval strategy node, and obtain retrieval information matching the question.
[0181] In one possible implementation of this disclosure, the retrieval strategy information is further used to indicate a formatting adjustment strategy. The language model-based question-answering device 600 may also include:
[0182] The adjustment module is used to adjust the format of the corresponding search information based on the format adjustment strategy indicated by the search strategy information.
[0183] In one possible implementation of this disclosure, the retrieval information is at least one, and the generation module 603 is used to: perform post-processing on the at least one retrieval information, wherein the post-processing includes at least one of information filtering, reordering, and deduplication; and generate an answer to the question based on the processed retrieval information using a language model.
[0184] The language model-based question-answering device of this disclosure acquires a question to be processed and a retrieval workflow. The retrieval workflow includes at least one retrieval strategy node, which indicates retrieval strategy information and a data source construction strategy. Following the retrieval strategy information indicated by the retrieval strategy node, a retrieval is performed on the target database corresponding to the retrieval strategy node to obtain retrieval information matching the question. The target database is constructed based on the data source construction strategy indicated by the corresponding retrieval strategy node. Based on the retrieval information, a language model is used to generate the answer to the question. By relying on the retrieval strategy information indicated by the retrieval strategy node in the retrieval workflow, key information can be retrieved from the corresponding target database, thereby generating the answer. Therefore, by simply setting the retrieval strategy node in the retrieval workflow and formulating personalized retrieval strategies and data source construction strategies, multiple retrieval strategies and data sources can be integrated within a single framework. This allows questions to be used without being limited to specific types, improving the versatility and applicability of the question-answering framework. Furthermore, without complex architectural combinations, efficient question-answering in different business scenarios can be achieved. This helps improve the quality of question-answering and reduces development difficulty and costs, thus improving development efficiency.
[0185] To implement the above embodiments, this disclosure also provides a data source construction apparatus. For example... Figure 7 As shown, Figure 7 This is a schematic diagram according to a sixth embodiment of the present disclosure. The data source construction apparatus 700 may include: an acquisition module 701 and a construction module 702.
[0186] The acquisition module 701 is used to acquire the retrieval workflow in response to the configuration operation performed on the configuration page; wherein the retrieval workflow includes at least one retrieval strategy node, which is used to indicate retrieval strategy information and data source construction strategy.
[0187] The construction module 702 is used to construct a target database for the original text according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow. The target database is used by the corresponding retrieval strategy node to retrieve retrieval information to generate the answer to the question according to the indicated retrieval strategy information.
[0188] In one possible implementation of this disclosure, retrieval strategy information is used to indicate a retrieval strategy, and the retrieval strategy node is also used to indicate the retrieval type to which the retrieval strategy belongs; the construction module 702 is used to: process the original text in accordance with the retrieval type to obtain stored data; and construct the corresponding target database according to the stored data and the data source construction strategy.
[0189] In one possible implementation of this disclosure, the construction module 702 is configured to: when the retrieval type includes a dense vector retrieval type, perform a first slice on the original text to obtain multiple first sentences; based on any first sentence, use a text vector model to generate a corresponding first sentence vector; and use the first sentence and the corresponding first sentence vector as storage data.
[0190] In one possible implementation of this disclosure, the target database corresponding to the retrieval strategy node of the dense vector retrieval type is a vector database; the data source construction strategy under the dense vector retrieval type includes: writing each first statement and its corresponding first statement vector as stored data into the vector database, and constructing an index for any first statement in the vector database based on the similarity between each first statement vector.
[0191] In one possible implementation of this disclosure, the construction module 702 is configured to: perform a second slice on the original text to obtain multiple second statements when the retrieval type includes a sparse retrieval type; perform word segmentation on any second statement to obtain multiple words; and store the multiple second statements and the corresponding multiple words as storage data.
[0192] In one possible implementation of this disclosure, the data source construction strategy under the sparse retrieval type includes: for any word used as stored data, determining a target statement containing the word in a plurality of second statements, as well as the word frequency and inverse document frequency of the word in the target statement; generating an inverted index table based on the target statement containing the word, the word frequency of the word in the target statement, and the inverse document frequency of the word; and constructing a target database based on the inverted index table.
[0193] In one possible implementation of this disclosure, the construction module 702 is configured to: perform a third slice on the original text to obtain multiple third statements when the retrieval type includes a graph search type; extract triples from any third statement to obtain the triples corresponding to the third statement; and use the triples as storage data.
[0194] In one possible implementation of this disclosure, the target database corresponding to the retrieval strategy node of the graph search type is a graph database; the data source construction strategy under the graph search type includes: writing triples as stored data into the graph database, and building an index on the entities and / or relations in the triples.
[0195] In one possible implementation of this disclosure, the retrieval type may further include a web page search type.
[0196] In one possible implementation of this disclosure, the retrieval workflow further includes a proxy node, which is the parent node of at least one retrieval strategy node, and the parent node is configured with an agent; wherein the agent is used to select a retrieval strategy node from the child nodes of the proxy node, and to perform a retrieval using the target database and retrieval strategy corresponding to the selected retrieval strategy node to obtain retrieval information.
[0197] In one possible implementation of this disclosure, the construction module 702 is used to: construct strategies for the original text according to the data source corresponding to each retrieval strategy node, and construct the target database corresponding to each retrieval strategy node in parallel based on a preset concurrency level.
[0198] In one possible implementation of this disclosure, the data source construction apparatus 700 may further include: an update module, configured to: in response to an update of the database storing the original text, reconstruct the corresponding target database for the text in the updated database according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow.
[0199] The data source construction apparatus of this disclosure acquires a retrieval workflow in response to a configuration operation performed on a configuration page. The retrieval workflow includes at least one retrieval strategy node, which indicates retrieval strategy information and a data source construction strategy. For the original text, a corresponding target database is constructed according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow. The target database is used by the corresponding retrieval strategy node to retrieve retrieval information for generating answers to questions based on the indicated retrieval strategy information. Therefore, by configuring the retrieval workflow on the configuration page, different data sources can be automatically constructed based on the data source construction strategies corresponding to each retrieval strategy node in the retrieval workflow. This improves the convenience and efficiency of data source construction, effectively reduces manual intervention, and allows for the implementation of multiple data sources and retrieval strategies within a single framework. This eliminates the need for questions to be limited to specific types, enabling efficient question answering in different business scenarios. On the one hand, this helps improve the quality of question answering; on the other hand, it reduces development difficulty and costs, thus improving development efficiency.
[0200] The collection, storage, use, processing, transmission, provision, and disclosure of users' personal information are all conducted with the consent of the users and comply with relevant laws and regulations, and do not violate public order and good morals.
[0201] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0202] Figure 8A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0203] like Figure 8 As shown, device 800 includes a computing unit 801, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 802 or a computer program loaded from storage unit 808 into random access memory (RAM) 803. RAM 803 may also store various programs and data required for the operation of device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via bus 804. Input / output (I / O) interface 805 is also connected to bus 804.
[0204] Multiple components in device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of monitors, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0205] The computing unit 801 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as language model-based question-answering methods or data source construction methods. For example, in some embodiments, the language model-based question-answering method or data source construction method can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed on device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the language model-based question-answering method or data source construction method described above can be performed. Alternatively, in other embodiments, the computing unit 801 may be configured in any other suitable manner (e.g., by means of firmware) to perform a language model-based question-and-answer method or a data source construction method.
[0206] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0207] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0208] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0209] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0210] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0211] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0212] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0213] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A question-answering method based on a language model, wherein, The method comprises: The system acquires the issues to be processed and the retrieval workflow; wherein the retrieval workflow includes at least one retrieval strategy node, which is used to indicate retrieval strategy information and data source construction strategy. According to the retrieval strategy information indicated by the retrieval strategy node, the target database corresponding to the retrieval strategy node is searched to obtain retrieval information matching the question; wherein, the target database is constructed based on the data source construction strategy indicated by the corresponding retrieval strategy node; Based on the retrieved information, a language model is used to generate the answer to the question.
2. The method according to claim 1, wherein, The retrieval strategy information is used to indicate the retrieval strategy, and the retrieval strategy node is also used to indicate the retrieval type to which the retrieval strategy belongs; the step of searching the target database corresponding to the retrieval strategy node according to the retrieval strategy information indicated by the retrieval strategy node to obtain retrieval information matching the question includes: The question is processed according to the search type to obtain the search conditions; Based on the search criteria and in accordance with the search strategy indicated by the search strategy information, a search is performed in the corresponding target database to obtain search information that matches the question.
3. The method according to claim 2, wherein, The process of processing the question in accordance with the search type to obtain search conditions includes: When the search type includes a dense vector search type, feature extraction is performed on the question to obtain a question vector that serves as the search condition.
4. The method according to claim 3, wherein, The target database corresponding to the retrieval strategy node of the dense vector retrieval type is a vector database; The retrieval strategy under the dense vector retrieval type includes: based on the question vector and the index of multiple first statements in the vector database, retrieving multiple first statements in the vector database to determine a first target statement that matches the question from the multiple first statements, and determining the first target statement as the retrieval information.
5. The method according to claim 2, wherein, The process of processing the question in accordance with the search type to obtain search conditions includes: When the search type includes a sparse search type, the question is segmented to obtain at least one segmented word as a search condition.
6. The method according to claim 5, wherein, The retrieval strategies under the sparse retrieval type include: Determine at least one second statement associated with the problem from the target database; For at least one word used as a retrieval condition, determine the term frequency and inverse document frequency of each word in any second statement; Based on the word frequency and the inverse document frequency, a second target statement is determined from the at least one second statement, and the second target statement is determined as the retrieval information.
7. The method according to claim 2, wherein, The method further includes: If the search type includes web page search, the question will be used as the text of the search criteria.
8. The method according to claim 7, wherein, The retrieval strategies under the aforementioned webpage search types include: Based on the text used as search criteria, web page content matching the question is obtained through the service interface of the target search engine, and the web page content is identified as the search information.
9. The method according to claim 2, wherein, The process of processing the question in accordance with the search type to obtain search conditions includes: When the search type includes a graph search type, the question is parsed to obtain entities and / or relationships as search conditions.
10. The method according to claim 9, wherein, The target database corresponding to the retrieval strategy node of the graph search type is a graph database; the retrieval strategies under the graph search type include: Based on entities and / or relations used as retrieval criteria, multiple reference triples in the graph database are queried to obtain target triples that match the problem. The target triples are analyzed to determine the retrieval information.
11. The method according to claim 2, wherein, The retrieval workflow also includes proxy nodes, which are the parent nodes of at least one of the retrieval strategy nodes; The method further includes: Among the search strategy nodes included in the search workflow, the child nodes of the proxy node and the search type indicated by the child nodes are determined. The agent configured through the agent node selects a retrieval strategy node from the sub-nodes according to the retrieval type and the question, and performs a retrieval using the target database and retrieval strategy corresponding to the selected retrieval strategy node to obtain retrieval information matching the question.
12. The method according to claim 2, wherein, The retrieval strategy information is also used to indicate format adjustment strategies, and the method further includes: Based on the format adjustment strategy indicated by the retrieval strategy information, the format of the corresponding retrieval information is adjusted.
13. The method according to any one of claims 1-12, wherein, The retrieved information is at least one, and the step of generating the answer to the question using a language model based on the retrieved information includes: Post-processing is performed on at least one of the retrieved information, wherein the post-processing includes at least one of information filtering, reordering, and deduplication; Based on the processed retrieval information, a language model is used to generate the answer to the question.
14. A method for constructing a data source, wherein, The method comprises: In response to a configuration operation performed on the configuration page, a retrieval workflow is obtained; wherein, the retrieval workflow includes at least one retrieval strategy node, the retrieval strategy node being used to indicate retrieval strategy information and data source construction strategy; For the original text, a corresponding target database is constructed according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow. The target database is used by the corresponding retrieval strategy node to retrieve retrieval information to generate the answer to the question according to the indicated retrieval strategy information.
15. The method according to claim 14, wherein, The retrieval strategy information is used to indicate the retrieval strategy, and the retrieval strategy node is also used to indicate the retrieval type to which the retrieval strategy belongs; the step of constructing the corresponding target database for the original text according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow includes: The original text is processed according to the search type to obtain stored data; Based on the stored data, and in accordance with the data source construction strategy, construct the corresponding target database.
16. The method according to claim 15, wherein, The process of processing the original text according to the retrieval type to obtain stored data includes: When the search type includes dense vector search type, the original text is sliced first to obtain multiple first sentences; Based on any of the first statements, a corresponding first statement vector is generated using a text vector model; The first statement and its corresponding first statement vector are used as the stored data.
17. The method according to claim 16, wherein, The target database corresponding to the retrieval strategy node of the dense vector retrieval type is a vector database; The data source construction strategy under the dense vector retrieval type includes: Each first statement and its corresponding first statement vector, which are stored as data, are written into the vector database, and an index is constructed for any first statement in the vector database based on the similarity between each first statement vector.
18. The method according to claim 15, wherein, The process of processing the original text according to the retrieval type to obtain stored data includes: When the search type includes a sparse search type, the original text is sliced a second time to obtain multiple second sentences; Perform word segmentation on any of the second statements to obtain multiple words; The plurality of second statements and their corresponding words are used as the stored data.
19. The method according to claim 18, wherein, The data source construction strategy under the sparse retrieval type includes: For any of the words used as stored data, determine the target statement in which the word is contained in the plurality of second statements, and the word frequency and inverse document frequency of the word in the target statement; An inverted index table is generated based on the target sentence containing the word, the word frequency in the target sentence, and the inverse document frequency corresponding to the word; The target database is constructed based on the inverted index table.
20. The method of claim 15, wherein, The process of processing the original text according to the retrieval type to obtain stored data includes: When the search type includes a graph search type, the original text is sliced in the third way to obtain multiple third sentences; Extract triples from any of the third statements to obtain the triples corresponding to the third statement; The triples are used as the stored data.
21. The method according to claim 20, wherein, The target database corresponding to the retrieval strategy node of the graph search type is a graph database; the data source construction strategy under the graph search type includes: The triples, which are used as the stored data, are written into the graph database, and an index is built on the entities and / or relations in the triples.
22. The method according to claim 15, wherein, The search types also include web page search types.
23. The method according to claim 14, wherein, The retrieval workflow also includes a proxy node, which is the parent node of at least one of the retrieval strategy nodes, and the parent node is configured with an intelligent agent; The agent is used to select a retrieval strategy node from the child nodes of the agent node, and to perform a retrieval using the target database and retrieval strategy corresponding to the selected retrieval strategy node, thereby obtaining the retrieval information.
24. The method according to claim 14, wherein, The step of constructing a corresponding target database for the original text according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow includes: For the original text, the construction of the target database corresponding to each retrieval strategy node is performed in parallel according to the data source construction strategy corresponding to each retrieval strategy node based on a preset concurrency level.
25. The method according to any one of claims 14-24, wherein, The method further includes: In response to an update to the database storing the original text, the corresponding target database is reconstructed for the text in the updated database according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow.
26. A question-answering device based on a language model, wherein, The device comprises: The acquisition module is used to acquire the issues to be processed and to acquire the retrieval workflow; wherein, the retrieval workflow includes at least one retrieval strategy node, which is used to indicate retrieval strategy information and data source construction strategy; The retrieval module is used to retrieve the target database corresponding to the retrieval strategy node according to the retrieval strategy information indicated by the retrieval strategy node, so as to obtain retrieval information matching the question; wherein, the target database is constructed based on the data source construction strategy indicated by the corresponding retrieval strategy node; The generation module is used to generate an answer to the question based on the retrieved information using a language model.
27. A data source construction apparatus, wherein, The device comprises: The acquisition module is used to acquire the retrieval workflow in response to the configuration operation performed on the configuration page; wherein, the retrieval workflow includes at least one retrieval strategy node, the retrieval strategy node is used to indicate retrieval strategy information and data source construction strategy; The construction module is used to construct a corresponding target database from the original text according to the data source construction strategy corresponding to the retrieval strategy node in the retrieval workflow. The target database is used by the corresponding retrieval strategy node to retrieve retrieval information to generate answers to questions based on the indicated retrieval strategy information.
28. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the method of any one of claims 1 to 13, or the method of any one of claims 14 to 25.
29. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1 to 13, or the method according to any one of claims 14 to 25.
30. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 13, or the method according to any one of claims 14 to 25.