Document question and answer processing method and electronic equipment

By utilizing user historical question-and-answer information as context in the document question-and-answer system and filtering it, prompt information is generated to improve the accuracy of answers in large language models. This solves the problem of inaccurate answers caused by the lack of historical context in existing systems, achieving higher accuracy and efficiency.

CN120705248AActive Publication Date: 2025-09-26HONOR DEVICE CO LTD

Patent Information

Application Number
CN202410295292.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-13
Publication Date
2025-09-26
Estimated Expiration
2044-03-13

AI Technical Summary

Technical Problem

Existing document question-answering systems based on large language models have shortcomings in terms of answer accuracy, mainly due to the lack of historical context information, resulting in inaccurate answer results.

Method used

By obtaining the user's historical question and answer information in the current conversation window, screening and filtering it, generating prompt information based on the question entered by the user and the retrieved related text blocks, and inputting a large language model to improve the accuracy of the answer and avoid introducing redundant data.

Benefits of technology

The accuracy of the document question-answering system is improved, and historical question-answering information is used as context to assist the model in outputting answers, reducing the inference cost and improving the accuracy of the results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120705248A_ABST
    Figure CN120705248A_ABST
Patent Text Reader

Abstract

The invention discloses a document question and answer processing method and electronic equipment. The method comprises the steps that firstly, a first question for a first document is acquired; determining first historical question and answer information for the first document from one or more pieces of historical question and answer information; then determining a first text block associated with the first question from the first document; generating first prompt information; wherein the first prompt information comprises the first text block, the first historical question and answer information and the first question; and finally, calling a large language model to process the first prompt information to obtain a first answer corresponding to the first question, and outputting the first answer corresponding to the first question. According to the invention, the accuracy of the answer result can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computers, and in particular to a document question-and-answer processing method and electronic device. Background Art

[0002] Document question answering (QA) is a key branch of natural language processing. It requires in-depth understanding and analysis of each document in an unstructured document repository, extracting relevant information, and then providing accurate answers to user questions. The goal is to enable computers to read and understand text similarly to humans and provide accurate answers to user questions. With the significant improvement in the effectiveness of large language models (LLMs), LLM-based document question answering systems have also gained widespread application. They can provide natural language answers to questions based on a given document and question.

[0003] Currently, the typical implementation of document question-answering systems based on LLMs involves parsing, segmenting, and vectorizing user-submitted documents and storing them in a database. The user's query is then parsed and vectorized, and the top-N relevant text blocks that best match the query are retrieved from the database using vector similarity matching. A prompt is generated based on a prompt template, combining the user's question and the retrieved relevant text blocks. This prompt is then fed into a large language model, and the resulting model output is returned to the user as the answer. However, the accuracy of the answers obtained using this approach is relatively low. Summary of the Invention

[0004] The embodiments of the present application provide a document question-and-answer processing method and electronic device, which, based on the method described in the present application, is conducive to improving the accuracy of the answer results.

[0005] In a first aspect, the present application provides a document question and answer processing method, which includes: first obtaining a first question for a first document; and determining first historical question and answer information for the first document from one or more historical question and answer information; then determining a first text block associated with the first question from the first document; generating first prompt information; wherein the first prompt information includes the first text block, the first historical question and answer information and the first question; finally, calling a large language model to process the first prompt information, obtain a first answer corresponding to the first question, and output the first answer corresponding to the first question.

[0006] Based on the method described in the first aspect, for the document question and answer scenario, since the user's questions in a conversation window are usually relevant, the electronic device can obtain one or more historical question and answer information of the user in this conversation window, and use the one or more historical question and answer information as the context of the current user's question, so as to better assist the model to output the answer corresponding to the current question; at the same time, in order to avoid introducing redundant data, the one or more historical question and answer information is further filtered and screened, which is more conducive to improving the accuracy of the answer results.

[0007] In one possible implementation, when determining first historical question and answer information for one or more first documents from one or more historical question and answer information, the specific implementation method may be: when the same identifier exists in a first document identifier set and a second document identifier set, determining the degree of duplication of document identifiers in the first document identifier set and the second document identifier set; wherein the first document identifier set includes the identifiers of the one or more first documents, and the second document identifier set includes the identifier of the second document for which the historical question and answer information is intended; if the degree of duplication is greater than a first threshold, then determining that the historical question and answer information is first historical question and answer information. Because in the process of filtering out the first historical question and answer information specific to the first document from the one or more historical question and answer information, the document for which the historical question and answer information is intended may have little relevance to the document selected by the current user's question, further filtering and screening based on the degree of duplication of the documents is required to ensure the accuracy of the answer to the current question while reducing the cost of inference.

[0008] In one possible implementation, if the repetition degree is greater than a first threshold, then when determining that the historical question and answer information is the first historical question and answer information, the specific implementation may be: if the repetition degree is greater than the first threshold, then determining the intersection document identifier between the first document identifier set and the second document identifier set; then calculating the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information; if the proportion value is greater than the second threshold, determining that the historical question and answer information is the first historical question and answer information. Based on this method, if the repetition degree of the document identification of the second document identification set corresponding to a certain historical question and answer information and the document identification of the first document identification set is greater than the first threshold, it means that the historical question and answer information has a greater correlation with the document selected by the current user's question, but it does not mean that the information about the intersection document is described more in the second answer included in the historical question and answer information; if the information about the intersection document is described less in the second answer included in the historical question and answer information, then other redundant descriptions will be introduced, thereby introducing redundant data and reducing the accuracy of the answer result; therefore, it is necessary to evaluate the proportion of information about the intersection document in the answer included in the historical question and answer information, so as to determine whether the historical question and answer information can be used directly to improve the accuracy of subsequent answer results.

[0009] In one possible implementation, when calculating the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information, the specific implementation method may be: determining a keyword based on the document information corresponding to the intersection document identifier; and calculating the proportion of the first information in the second answer included in the historical question and answer information; wherein the first information includes the keyword. This can be understood as using keyword matching to determine the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information, which is simple to operate.

[0010] In one possible implementation, when determining the first text block associated with the first question from the first document, the specific implementation method may be: determining the first text block associated with the first question and the first historical question and answer information from the first document. This can be understood as combining the first question and the first historical question and answer information into a new question (a new query), and using this new query to determine the relevant first text block in the first document can further improve the accuracy of the answer result. The first text block determined here may be one or more.

[0011] In one possible implementation, there are multiple second documents, and the method further includes: if the repetition degree is less than or equal to the first threshold, and the repetition degree is greater than or equal to a third threshold, rewriting the historical question and answer information to obtain multiple sub-question and answer information; or, if the proportion value is less than or equal to the second threshold, rewriting the historical question and answer information to obtain multiple sub-question and answer information; wherein the multiple second documents correspond one-to-one to the multiple sub-question and answer information; then determining the first sub-question and answer information for the first document from the multiple sub-question and answer information; then generating second prompt information, wherein the second prompt information includes the first text block, the first sub-question and answer information and the first question; finally, calling the large language model to process the second prompt information, obtain the third answer corresponding to the first question, and output the third answer corresponding to the first question. It can be understood that if the repetition is less than or equal to the first threshold, and the repetition is greater than or equal to the third threshold, it means that the historical question and answer information is not highly relevant to the document selected by the current user's question. However, the second answer can be further rewritten to obtain multiple sub-question and answer information, so that the historical question and answer information is fully utilized, and the first sub-question and answer information for the first document is determined from the multiple sub-question and answer information. The first sub-question and answer information can then be submitted to the large language model as the context of the current user's question, which is beneficial to improving the accuracy of the answer result. In addition, if the proportion value is less than or equal to the second threshold, it means that the information about the intersection document accounts for a small proportion of the second answer included in the historical question and answer information. The second answer can also be further rewritten, specifically by splitting the second answer into multiple sub-question and answer information, so that the historical question and answer information is fully utilized. The first sub-question and answer information can then be submitted to the large language model as the context of the current user's question, which is beneficial to improving the accuracy of the answer result.

[0012] It should be noted that when there are multiple historical question and answer information, according to the corresponding situation of each historical question and answer information, part of the historical question and answer information can be determined as the first historical question and answer information, part of the historical question and answer information can be rewritten to obtain multiple sub-question and answer information, and part of the historical question and answer information can be discarded. Therefore, the first prompt template and the second prompt template mentioned above may also include the first text block, the first historical question and answer information, the first sub-question and answer information and the first question.

[0013] In one possible implementation, there are multiple first historical question and answer information, and the multiple first historical question and answer information in the first prompt information are arranged in chronological order from the earliest to the latest or from the latest to the earliest; or, the multiple first historical question and answer information in the first prompt information are arranged in chronological order from the largest to the smallest or from the smallest to the largest according to the first similarity, where the first similarity is the similarity between the first historical question and answer information and the first question. It can be understood that the ordering method of different historical question and answer information affects the accuracy of the results returned by the model, so a certain strategy is needed to sort the multiple historical question and answer information. Based on this approach, it is beneficial to improve the accuracy of the answer results.

[0014] In the second aspect, the present application provides a document question and answer processing device, which can be an electronic device, a device in an electronic device, or a device that can be used in combination with an electronic device; wherein, the document question and answer processing device can also be a chip system, and the document question and answer processing device can execute the method executed by the electronic device in the first aspect. The functions of the document question and answer processing device can be implemented by hardware, or by hardware executing corresponding software implementations. The hardware or software includes one or more units corresponding to the above functions. The unit can be software and / or hardware. The operations and beneficial effects performed by the document question and answer processing device can refer to the methods and beneficial effects described in the first aspect above, and the repeated parts will not be repeated.

[0015] In a third aspect, the present application provides an electronic device comprising one or more processors and one or more memories. The one or more memories are coupled to the one or more processors, the memories are configured to store a computer program, and the processors are configured to invoke the computer program, so that the electronic device executes the method described in the first aspect.

[0016] In a fourth aspect, the present application provides a chip system for use in an electronic device, the chip system comprising at least one processor and an interface, the interface being used to receive instructions and transmit them to the at least one processor; the at least one processor executes the instructions so that the electronic device executes the method described in the first aspect.

[0017] In a fifth aspect, the present application provides a document question and answer processing system, which includes an electronic device; wherein the electronic device is used to execute the method described in the first aspect.

[0018] In a sixth aspect, the present application provides a document question and answer processing device, which includes functions or units for executing any one of the methods in the first aspect.

[0019] In a seventh aspect, the present application provides a computer storage medium having a computer program / instruction stored thereon, which, when executed by a processor, implements the method and steps described in the first aspect.

[0020] In an eighth aspect, the present application provides a computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the method and steps described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1A This is a schematic diagram of a document question and answer system provided in an embodiment of the present application;

[0022] Figure 1B This is a flowchart of a document question and answer background processing provided by an embodiment of the present application;

[0023] Figure 2 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;

[0024] Figure 3 This is a software structure block diagram of an electronic device provided in an embodiment of the present application;

[0025] Figure 4 This is a flowchart of a document question-and-answer process provided by an embodiment of the present application;

[0026] Figure 5A is a schematic diagram of a desktop and text assistant provided in an embodiment of the present application;

[0027] Figure 5B This is a schematic diagram of another document question and answer system provided in an embodiment of the present application;

[0028] Figure 5C is a schematic diagram of a dialog range selection box provided in an embodiment of the present application;

[0029] Figure 6A This is a schematic diagram of filtering historical question and answer information provided by an embodiment of the present application;

[0030] Figure 6B This is a schematic diagram of rewriting historical question and answer information provided by an embodiment of the present application;

[0031] Figure 7 This is a flowchart of another document question and answer background processing provided by an embodiment of the present application;

[0032] Figure 8 This is a flowchart of another document question-and-answer process provided by an embodiment of the present application;

[0033] Figure 9This is a flowchart of another document question-and-answer process provided by an embodiment of the present application;

[0034] Figure 10 This is a structural diagram of a task execution device provided in an embodiment of the present application;

[0035] Figure 11 This is a schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION

[0036] The following is a clear and detailed description of the technical solutions in the embodiments of the present application in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text is only a description of the association relationship between related objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0037] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood to imply or suggest relative importance or implicitly indicate the number of the technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of this application, unless otherwise specified, "plurality" means two or more.

[0038] The term "user interface (UI)" in the following embodiments of this application refers to a medium interface for interaction and information exchange between an application or operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. The user interface is a source code written in a specific computer language such as Java and extensible markup language (XML). The interface source code is parsed and rendered on an electronic device and finally presented as content that the user can recognize. The commonly used form of user interface is graphical user interface (GUI), which refers to a user interface related to computer operations that is displayed in a graphical manner. It can be a visual interface element such as time, date, text, icon, button, menu, tab, text box, dialog box, status bar, navigation bar, widget, etc. displayed on the display screen of an electronic device.

[0039] To facilitate understanding of the solutions provided by the embodiments of the present application, the following describes the relevant concepts involved in the embodiments of the present application:

[0040] 1. Large language model (LLM)

[0041] LLM is a natural language processing model based on deep learning. It learns the syntax and semantics of natural languages ​​to generate human-readable text. LLM can handle a variety of natural language tasks, such as text classification, question-answering, and conversation, and is an important path to artificial intelligence. Common LLMs include the ChatGPT (Chat Generative Pre-trained Transformer) model and the LaMDA (Language Model for Dialogue Applications) model. The ChatGPT model is an AI-powered natural language processing tool that generates responses based on patterns and statistical regularities observed during pre-training. It can also interact based on the chat context, allowing users to chat and communicate like humans, and even complete tasks such as writing emails, video scripts, copywriting, translation, and coding. The LaMDA model is a large language model based on the Transformer architecture that can generate and understand text content. Its unique feature is its conversational interaction approach, allowing users to communicate more naturally with computers.

[0042] 2. Retrieval augmented generation (RAG)

[0043] RAG is a technology that assists LLMs in generating answers by retrieving information from data sources. In short, RAG combines search technology with the prompting capabilities of LLMs. This means asking questions to the model, using the information found by the search algorithm as background context. These queries and the retrieved context are incorporated into the prompts sent to the LLMs. RAG has become one of the most popular architectures for LLM-based systems. Numerous products are built almost entirely on RAG, ranging from question-answering services that combine web search engines and LLMs to hundreds of applications that "talk to data."

[0044] 3. Document Q&A

[0045] Document question answering (QA) is a key branch of natural language processing (NLP). This task requires in-depth understanding and analysis of each document in an unstructured document repository, extracting relevant information, and then providing accurate answers to user questions. The goal is to enable computers to read and understand text similarly to humans and provide accurate answers to user questions. With the significant improvement in LLM performance, LLM-based document question answering systems have become widely used. They can provide natural language answers to questions based on a given document and question.

[0046] See Figure 1A , Figure 1A A schematic diagram of a document Q&A interface is shown. The document Q&A interface includes a question input box, a dialog box, an upload document button, and a send button. Users can click the upload document button to upload documents, for example, document 1, document 2, and document 3. After the documents are uploaded, the user can enter a question about the three documents in the question input box. The question is sent to the electronic device using the send button and displayed in the dialog box. The electronic device then parses the question entered by the user, outputs the answer, and displays it in the dialog box.

[0047] For the background processing flow, such as Figure 1B As shown, the current implementation method for the document question answering system based on LLM can be:

[0048] (1) Parse and segment the documents uploaded by users.

[0049] Since the model's input length is fixed, to improve the overall quality and accessibility of the text while avoiding information loss, it is necessary to parse and segment the user-uploaded documents, breaking them into paragraphs of appropriate size while preserving their original meaning (for example, dividing the document into sentences or paragraphs rather than splitting a single sentence into two parts). There are various text segmentation tools available on the market that can be used for this task.

[0050] (2) Vectorize the segmented text blocks.

[0051] Text vectorization involves representing text information as vectors that express the text's semantics, using numerical vectors to represent the text's semantics. Word embedding, a method for converting words in a text into numerical vectors, falls under the umbrella of text vectorization. Common text vector and word embedding methods include the one-hot model, the bag-of-words model, the term frequency-inverse document frequency (TF-IDF), the N-gram model, the word-to-vector model (Word2vec), and the document-to-vector model (Doc2vec).

[0052] (3) Store the vectorized text block in the database.

[0053] (4) Parse and vectorize the query input by the user.

[0054] (5) Retrieve the top-N related text blocks with the highest matching degree from the database through vector similarity matching.

[0055] Vector similarity measures the numerical proximity between two vectors. Vector similarity matching can be used to retrieve relevant text blocks from the database that semantically match the user's input question. Vector similarity matching can be expressed using methods such as cosine similarity, Pearson correlation coefficient, Euclidean distance, and Manhattan distance.

[0056] (6) Generate a prompt based on the prompt template, combining the query entered by the user and the retrieved related text blocks, and enter the LLM.

[0057] (7) Obtain the output of the LLM and return it to the user as the answer to the question.

[0058] However, in this conversation window, the user's questions are usually relevant. If we only use the current user's single question to retrieve relevant text blocks to provide to LLM to answer questions, the lack of historical context information will lead to a decrease in the accuracy of the answer results.

[0059] Therefore, in order to improve the accuracy of the answer results, the present application provides a document question and answer processing method and electronic device. The document question and answer processing method mainly uses RAG technology to use the user's historical question and answer information in the current conversation window as the context of the current user's question, and can further filter the user's historical question and answer information. Then, a prompt is generated by combining the filtered user historical question and answer information, the question entered by the user, and the retrieved related text blocks. The prompt is then input into the large language model for answering, thereby improving the accuracy of the model's answer without introducing redundant data.

[0060] In a specific implementation, the document question and answer processing method mentioned here can be executed by an electronic device 100. The electronic device 100 can be a laptop, a tablet computer, a personal computer (PC), an ultra-mobile personal computer (UMPC), a desktop computer, a personal digital assistant (PDA), a server, etc.; it can also be a mobile phone, a wearable electronic device with wireless communication function (such as a smart watch), a smart car, etc., but is not limited to this. Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution servers (Content Delivery Network, CDN), and big data and artificial intelligence platforms. The electronic device 100 can be configured with a display screen and can be installed with a preset application (APP), such as a document question and answer APP (which can be resident on the main interface in the form of an icon), etc., which is not limited here. For example, users can submit documents through the document Q&A app on the display screen, ask questions about the documents in the document Q&A app and get answers, etc.

[0061] The hardware structure of the electronic device 100 is introduced below. Figure 2 , Figure 2 Schematic diagram of the hardware structure of the electronic device 100 provided in an embodiment of the present application.

[0062] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0063] It should be understood that the structure illustrated in the embodiments of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0064] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.

[0065] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0066] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or is reusing. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system. The processor 110 calls the instructions or data stored in the memory, causing the electronic device 100 to execute the document question-and-answer processing method executed by the electronic device in the following method embodiment.

[0067] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface.

[0068] The charging management module 140 is configured to receive charging input from a charger, which may be a wireless charger or a wired charger.

[0069] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to provide power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, and the wireless communication module 160. In some other embodiments, the power management module 141 can also be set in the processor 110.

[0070] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0071] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.

[0072] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0073] The modem processor includes a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a medium- or high-frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is passed to the application processor.

[0074] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as Wi-Fi networks), Bluetooth (BT), BLE broadcasting, global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc. applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0075] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150 , and antenna 2 is coupled to wireless communication module 160 , so that electronic device 100 can communicate with the network and other devices through wireless communication technology.

[0076] Electronic device 100 implements display functionality through a GPU, display screen 194, and an application processor. A GPU is a microprocessor for image processing that connects display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.

[0077] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than one.

[0078] Electronic device 100 can implement a camera function using an ISP, camera 193, a video codec, a GPU, a display 194, and an application processor. The ISP processes data fed back by camera 193. Camera 193 is used to capture still images or video. The digital signal processor processes digital signals, and can process not only digital image signals but also other digital signals. The video codec compresses or decompresses digital video. Electronic device 100 may support one or more video codecs.

[0079] NPU is a neural-network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn.

[0080] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function.

[0081] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an application required for at least one function (such as a sound playback function), etc. The data storage area can store data (such as audio data) created during the use of the electronic device 100, etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as a flash memory device, etc.

[0082] The electronic device 100 can implement audio functions such as music playback and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0083] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be provided in the processor 110, or some functional modules of the audio module 170 can be provided in the processor 110.

[0084] Speaker 170A, also known as a "speaker," is used to convert audio electrical signals into sound signals. Receiver 170B, also known as a "handset," is used to convert audio electrical signals into sound signals. Microphone 170C, also known as a "microphone" or "microphone," is used to convert sound signals into electrical signals. Headphone jack 170D is used to connect wired headphones. Pressure sensor 180A is used to sense pressure signals and convert them into electrical signals.

[0085] In some embodiments, the pressure sensor 180A can be set on the display screen 194. The gyroscope sensor 180B can be used to determine the motion posture of the electronic device 100. The air pressure sensor 180C is used to measure air pressure. The magnetic sensor 180D includes a Hall sensor. The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). The distance sensor 180F is used to measure distance. The proximity light sensor 180G can include, for example, a light emitting diode (LED) and a light detector. The ambient light sensor 180L is used to sense the brightness of ambient light. The fingerprint sensor 180H is used to collect fingerprints. The temperature sensor 180J is used to detect temperature. The touch sensor 180K, also known as a "touch panel", can be set on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also known as a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The bone conduction sensor 180M can obtain vibration signals. Buttons 190 include a power button and volume buttons. Motor 191 can generate vibration prompts. Indicator 192 can be an indicator light that can be used to indicate charging status, power level changes, messages, missed calls, notifications, etc. SIM card interface 195 is used to connect a SIM card.

[0086] It should be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0087] In addition, an operating system runs on top of the above components. For example, operating systems such as iOS and Android. The operating system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a microservice architecture, or a cloud architecture. The embodiment of the present application takes the Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100. It should be noted that although the embodiment of the present application is described using the Android system as an example, its basic principles are also applicable to electronic devices with other operating systems.

[0088] Figure 3: This is a software structure block diagram of the electronic device 100 in an embodiment of the present application. The software structure adopts a layered architecture, which divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In an embodiment of the present application, the operating system (taking the Android system, where the Android system runs on an AP as an example) can be divided into six layers, from top to bottom, namely the application layer (application, APP), the application framework layer (framework, FWK), the Android runtime (Android runtime) and system library, the hardware abstraction layer (hardware abstraction layer, HAL), the kernel layer, and the hardware layer.

[0089] The application layer can include a series of application packages. Figure 3 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, and document Q&A. The application layer may also include a system UI (system UI), which is used to display the electronic device interface, such as the camera interface. For example, a user can submit a document in a document Q&A application, ask questions about the document using a question box in the application interface, and receive corresponding answers using an answer box in the application interface.

[0090] The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 3 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, a camera service, etc., and the embodiments of the present application do not impose any restrictions on this.

[0091] The window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, take screenshots, etc.

[0092] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0093] The view system includes visual controls, such as those for displaying text and images. The view system is used to build applications. A display interface can consist of one or more views. For example, a display interface containing a text notification icon might include a view for displaying text and a view for displaying images.

[0094] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including answering, hanging up, etc.).

[0095] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0096] The Notification Manager allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically without user interaction. For example, the Notification Manager is used to notify users of completed downloads and message reminders. The Notification Manager can also display notifications in the top status bar of the system as icons or scrolling text, such as notifications from background applications, or as dialog windows on the screen. Examples include text messages in the status bar, beeps, vibrations on electronic devices, and flashing indicator lights.

[0097] The camera service is the core process module of the camera framework. It mainly provides API interface functions to the application layer and calls the camera hardware abstraction layer downward through HIDL (hardware interface definition language).

[0098] The Android runtime includes the core library and the virtual machine. The Android runtime is responsible for scheduling and management of the Android system.

[0099] The core library consists of two parts: one is the function that needs to be called by the Java language, and the other is the Android core library.

[0100] The application layer and application framework layer run in a virtual machine. The virtual machine executes Java files in the application layer and application framework layer as binary files. The virtual machine manages object lifecycles, stack management, thread management, security and exception management, and garbage collection.

[0101] The system library can include multiple functional modules, such as a surface manager, media libraries, a 3D graphics processing library (such as OpenGL ES), and a 2D graphics engine (such as SGL).

[0102] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.

[0103] The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library can support multiple audio and video encoding formats.

[0104] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0105] A 2D graphics engine is a drawing engine for 2D drawings.

[0106] The hardware abstraction layer is an interface layer between the operating system kernel and the hardware circuit. Its purpose is to abstract the hardware. It hides the hardware interface details of a specific platform and can provide a virtual hardware platform for the operating system. The hardware abstraction layer is an encapsulation of the Linux kernel driver, providing an interface to the upper layer and shielding the implementation details of the low-level hardware. Figure 3 As shown, the hardware abstraction layer may include Wi-Fi HAL, audio HAL, camera HAL, etc.

[0107] The kernel layer is the layer between hardware and software, the core of an operating system. It is the first layer of software extension based on the hardware, providing the most basic operating system functions and the foundation of the operating system. It manages the system's processes, memory, device drivers, files, and network systems, and determines system performance and stability. The kernel layer can include display drivers, audio drivers, camera drivers, sensor drivers, and more. The camera driver is the driver layer for camera devices and is primarily responsible for interacting with the hardware.

[0108] The hardware layer includes displays, cameras, sensors, etc.

[0109] Based on the above, the following takes the electronic device as a personal computer (PC) as an example to further describe in detail a document question and answer processing method provided by the embodiment of the present application. Figure 4 As shown, the document question and answer processing method includes the following steps S401 to S406. Figure 4 The method shown may be performed by the electronic device mentioned above. Alternatively, Figure 4 The execution entity of the method shown may be a chip in an electronic device, which is not limited in the embodiments of the present application. Figure 4 The method is described by taking an electronic device as an example of an execution subject.

[0110] S401: The electronic device obtains a first question for a first document.

[0111] In the embodiment of the present application, the first document here refers to the document to which the user asks the question; the first question is the question raised by the user regarding the first document. The first document can be one or more.

[0112] like Figure 5A As shown, various APPs can be installed in the PC, such as Word, Excel, PowerPoint, music, video, recycle bin, document Q&A, etc., and the icons of various APPs can be displayed on the main desktop of the PC. When the PC is turned on, the document Q&A APP can be displayed on the main desktop as a resident process. For example, the icon of "Text Assistant" can be displayed on the main desktop of the PC. The user can directly click on the "Text Assistant" icon to enter the document Q&A process and display the document Q&A interface. Figure 5B As shown, the document Q&A interface includes a dialog box, a question input box, a dialog scope selection box, an upload document button, a send button, and a document display box. In this dialog window, users can upload documents to their PC by clicking the upload document button. For example, users can upload Document 1, Document 2, and Document 3 to their PC. After receiving the uploaded documents, the electronic device can generate a unique identifier for each document and can also use methods such as Hush encryption and digital signatures to enhance security.

[0113] After the user uploads a document, the uploaded document can be viewed in the dialog range selection box. The user can also select the document to which the question is directed in the dialog range selection box. For example, the user can select Document 1 in the dialog range selection box. The user can then enter a question for Document 1 in the question input box and click the Send button to send the question for Document 1 to the electronic device. The electronic device then receives the question for Document 1 entered by the user and displays it in the dialog box. Document 1 here can be considered the first document, and the question for Document 1 can be considered the first question.

[0114] It should be noted that the electronic device can retain all documents uploaded by the user in this conversation window (it can be understood that as long as it is in this conversation window, no matter whether it is a document uploaded in the past or a document currently uploaded, as long as it is uploaded in this conversation window, it can be retained), and can be displayed in the conversation range selection box for the user to select. Of course, the style of the conversation range selection box can be adopted as follows Figure 5B The style shown can also be used as Figure 5C The styles shown can also be other styles, which are not limited here.

[0115] S402: The electronic device determines first historical question and answer information for the first document from one or more historical question and answer information.

[0116] In an embodiment of the present application, the electronic device saves one or more historical question and answer information of the user in the current conversation window to a historical question and answer database. The historical question and answer information here refers to the questions asked by the user in the current conversation window and the corresponding output answers. Because the questions asked by the user in a conversation window are usually related, the electronic device can obtain one or more historical question and answer information of the user from the historical question and answer database and use the one or more historical question and answer information as the context of the current user's question to better assist the model in outputting the answer.

[0117] After the electronic device obtains one or more historical question and answer information, if this historical question and answer information is directly used as the context of the current user's question, redundant data may be introduced, affecting the accuracy of the model's answer. For example, in a dialogue window, after the user uploads Document 1, Document 2, and Document 3, assuming that a historical question and answer information is a question about Document 1, and the current user is asking a question about Document 2, if this historical question and answer information is directly used as the context of the current user's question, a description of Document 1 will be introduced, thereby introducing redundant data. Therefore, the electronic device needs to further filter (screen) out the first historical question and answer information only for the first document from one or more historical question and answer information, so as to better assist the model in outputting answers later.

[0118] For example, in this conversation window, the user first asked question 1 about document 1 and received answer 1. Question 1 and answer 1 constitute historical question and answer information 1. The user asked question 2 about document 2 and received answer 2. Question 2 and answer 2 constitute historical question and answer information 2. At this point, two pieces of historical question and answer information are obtained: historical question and answer information 1 and historical question and answer information 2. The current user asks question 3 about document 1. The electronic device then needs to filter out the historical question and answer information for document 1 from historical question and answer information 1 and historical question and answer information 2, i.e., determine historical question and answer information 1 as the first piece of historical question and answer information.

[0119] Specifically, since the electronic device generates a unique identifier for each document, the identifiers of one or more first documents can be summarized as a first document identifier set; taking a certain historical question and answer information as an example, the identifiers of the second document targeted by the historical question and answer information can also be summarized as a second document identifier set. During the actual filtering process, it is necessary to filter out the first historical question and answer information that only targets the first document from one or more historical question and answer information. In this case, as long as the first document identifier set and the second document identifier set have the same (intersecting) identifier (which can be understood as at least one identifier in the second document identifier set that appears in the first document identifier set), the historical question and answer information corresponding to the second document identifier set can be filtered out as the first historical question and answer information.

[0120] For example, assume that the identifier of document 1 is 1, the identifier of document 2 is 2, and the identifier of document 3 is 3. In this conversation window, the user first asked question 1 for document 1 and document 2 and received the corresponding answer 1. Then question 1 and the corresponding answer 1 constitute historical question and answer information 1, and the second document identifier set corresponding to historical question and answer information 1 includes 1 and 2. The user asked question 2 for document 2 for the second time and received the corresponding answer 2. Then question 2 and the corresponding answer 2 constitute historical question and answer information 2, and the second document identifier set corresponding to historical question and answer information 2 includes 2. The user asked question 3 for document 3 for the third time and received the corresponding answer 3. Then question 3 and the corresponding answer 3 constitute historical question and answer information 3, and the second document identifier set corresponding to historical question and answer information 3 includes 3. At this point, three pieces of historical question and answer information are obtained, namely historical question and answer information 1, historical question and answer information 2, and historical question and answer information 3.

[0121] The current user asks question 4 for documents 1 and 3, so the first document identification set involved in the current question includes 1 and 3. Therefore, the second document identification set corresponding to historical question and answer information 1 has the same identifier as the first document identification set, and the second document identification set corresponding to historical question and answer information 3 has the same identifier as the first document identification set. Therefore, the electronic device needs to filter out historical question and answer information 1 and historical question and answer information 3 from historical question and answer information 1, historical question and answer information 2, and historical question and answer information 3, that is, to determine historical question and answer information 1 and historical question and answer information 3 as the first historical question and answer information.

[0122] It should be noted that examples of the historical question and answer information stored in the database may be:

[0123] {

[0124] "_id":"65d16e538f35100c7805262e",

[0125] "udid":"4cb712ac-aecf-11ee-af29-c9d3c89142e6",

[0126] "conversation_id":"65bf1aed6f3813563819ba32",

[0127] "resource_id":[ / / Second document identification set

[0128] "6c12a5bf1bfc3a009f4d220bf110",

[0129] "7c1yf2a5bf1bfc3a009f4d220bf1"

[0130] ],

[0131] "parent_id":"65bf1bfc3a009f4d220bf110",

[0132] "context_type":"FILE",

[0133] "prompt_text":"******", / / Questions raised by users

[0134] “prompt_answer”: “*********”, / / LLM answer

[0135] "completion_tokens":"-1",

[0136] "total_tokens":"-1",

[0137] "record_status":"KEPT",

[0138] "create_user":"4cb712ac-aecf-11ee-af29-c9d3c89142e6",

[0139] "create_time":"2024-02-04T05:11:12.784Z",

[0140] "update_user":"4cb712ac-aecf-11ee-af29-c9d3c89142e6",

[0141] "update_time":"2024-02-04T05:11:12.784Z"

[0142] }

[0143] Therefore, when the historical question and answer information is used as the context of the user's current question, it can be described in the following format:

[0144]

[0145] For example, assuming a user has three historical Q&A messages, they can be represented using Table 1 below. Table 1 includes the three historical Q&A messages and the corresponding time points. Each historical Q&A message includes a question and an answer. The question included in each historical Q&A message can be referred to as the second question for the second document, and the answer included in each historical Q&A message can be referred to as the second answer corresponding to the second question.

[0146] Table 1

[0147]

[0148] Of course, the stored information sample of the historical question and answer information and the format adopted when the historical question and answer information is used as the context of the user's current question can also be expressed in other ways, which are not limited here.

[0149] However, in the process of filtering and selecting historical question and answer information, there may be a situation where there are only a small number of intersection document identifiers between the first document identifier set and the second document identifier set (for example, there is only one document identifier in common between the first document identifier set and the second document identifier set). In this case, when the historical question and answer information corresponding to the second document identifier set is subsequently processed as the first historical question and answer information, more redundant data will be introduced, resulting in a decrease in the accuracy of the answer result. For example, the first document identifier set includes 1 and 2, and the second document identifier set includes 1, 2, 3, 4, 5, 6, and 7; at this time, there is only one intersection document identifier (i.e., identifier 1) between the first document identifier set and the second document identifier set. If the historical question and answer information corresponding to the second document identifier set is used as the first historical question and answer information, then the descriptions of the documents corresponding to identifiers 2, 3, 4, 5, 6, and 7 will be introduced, thereby introducing more redundant data.

[0150] Therefore, in order to subsequently better assist the model in outputting answers and further improve the accuracy of the answer results, in one possible implementation, when the electronic device determines the first historical question and answer information for the first document from one or more historical question and answer information, taking a certain historical question and answer information as an example, the specific implementation process may be:

[0151] If the first document identification set and the second document identification set contain the same identifier, the electronic device further determines the degree of duplication of the document identifiers in the first document identification set and the second document identification set. There are one or more first documents, the first document identification set includes the identifiers of the one or more first documents, and the second document identification set includes the identifier of a second document for which the historical question and answer information is intended.

[0152] The core purpose of calculating repetition here is to assess the relevance between the documents targeted by the historical Q&A information and the document selected by the current user. If the relevance is low, submitting it to the LLM as context for the current user's question will affect the accuracy of the answer to the current question and increase inference cost. Specifically, the repetition of the document identifiers in the first and second document identifier sets can be calculated using the Jaccard similarity coefficient, using the following formula:

[0153]

[0154] In formula (1), Threshold represents the duplication of document identifiers in the first document identifier set and the second document identifier set; raw_ids represents the first document identifier set; and context_ids_filter represents the second document identifier set.

[0155] Furthermore, the action taken by the electronic device is determined based on the interval of the repeatability, as described in formula (2):

[0156]

[0157] In formula (2), T max is the first threshold; T min It should be noted that the first threshold and the third threshold can be set by the developer himself or determined based on experimental data, and are not limited here.

[0158] like Figure 6A As shown, the following describes in detail the actions to be taken when the repetition rate is in different intervals:

[0159] Case 1: If the repetition rate is greater than the first threshold (T max ), the electronic device can directly use the historical question and answer information or further determine the proportion of the information about the intersection document in the second answer included in the historical question and answer information.

[0160] In a specific implementation, if the repetitiveness is greater than the first threshold, the electronic device may perform the following two operations:

[0161] Method 1: The electronic device directly determines that the historical question and answer information is the first historical question and answer information.

[0162] It can be understood that if the repetition degree of the second document identification set corresponding to a certain historical question and answer information and the document identification of the first document identification set is greater than the first threshold, it means that the historical question and answer information has a high correlation with the document selected by the current user's question, and it can be directly used as the first historical question and answer information, and subsequently submitted to the LLM as the context of the current user's question, that is, the following steps S403 to S406 are executed.

[0163] Method 2: The electronic device further determines the intersection document identifier between the first document identifier set and the second document identifier set; calculates the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information; if the proportion is greater than the second threshold, the electronic device determines that the historical question and answer information is the first historical question and answer information.

[0164] It can be understood that, for example, the first document identification set includes 1 and 2, and the second document identification set includes 1 and 3; at this time, there is an intersection document between the first document identification set and the second document identification set (that is, document 1 corresponding to identification 1); the historical question and answer information corresponding to the second document identification set includes the second answer with an overall length of 2,000 words, but the description of document 1 in the second answer is only 10 words. If the historical question and answer information is directly used as the first historical question and answer information, then other redundant descriptions will be introduced, and more redundant data will be introduced.

[0165] Therefore, if the repetition degree between the second document identification set corresponding to a certain historical question and answer information and the document identification of the first document identification set is greater than the first threshold, the electronic device can further determine the intersection document identification between the first document identification set and the second document identification set, and calculate the proportion of the document information corresponding to the intersection document identification in the second answer included in the historical question and answer information. The core of this is to evaluate the proportion of information about the intersection document in the answer included in the historical question and answer information, so as to determine whether the historical question and answer information can be used directly.

[0166] Optionally, when the electronic device calculates the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information, it can be implemented in the following ways:

[0167] Method A: The electronic device calculates the ratio using a trained model.

[0168] Specifically, the electronic device can use some training samples to train a model for calculating the proportion value, and directly use the model to make judgments when calculating the proportion value.

[0169] Method B: The electronic device calculates the proportion by keyword matching.

[0170] Specifically, the electronic device determines a keyword based on the document information corresponding to the intersection document identifier; then calculates the proportion of the first information in the second answer included in the historical question and answer information; wherein the first information includes the keyword, and the intersection document identifier may be one or more. In other words, the electronic device can determine the corresponding keyword in the document information corresponding to each intersection document identifier, and determine the proportion based on the sentence or paragraph in which the keyword is located.

[0171] Assume that the intersection document identifier between the second document identifier set and the first document identifier set corresponding to a certain historical question and answer information is 1, that is, the intersection document is document 1; the corresponding keyword 1 can be determined based on the document information corresponding to document 1, and the corresponding keyword 2 can be determined based on the document information corresponding to document 2. Then, in the second answer included in the historical question and answer information, the sentence containing keyword 1 (specifically, the sentence can be divided according to the end mark to ensure the integrity of the sentence) can be used as the relevant content of keyword 1 (that is, the first information); the sentence containing keyword 2 (to ensure the integrity of the sentence) can be used as the relevant content of keyword 2; if a sentence contains both keyword 1 and keyword 2, the sentence is discarded and not counted. Then calculate the proportion of the length of the relevant content of keyword 1 in the relevant content of all keywords in the second answer included in the historical question and answer information (that is, the relevant content of keyword 1 and the relevant content of keyword 2), which is the proportion of the first information in the second answer included in the historical question and answer information.

[0172] Taking keyword 1 as an example, the following formula (3) can be used to calculate the percentage value:

[0173]

[0174] In formula (3), length(keyword 1) represents the relevant content of keyword 1 (i.e., the first information); length(keyword i) represents the relevant content of all keywords in the second answer included in the historical question and answer information (i.e., the relevant content of keyword 1 and the relevant content of keyword 2); and n represents the total number of keywords.

[0175] For example, it is assumed that the second answer included in the historical question and answer information is as follows:

[0176]

[0177] The second answer consists of three sentences. The first sentence contains keyword 1 and can be considered as related content for keyword 1. The second sentence contains keyword 2 and can be considered as related content for keyword 2. The third sentence contains both keywords 1 and 2 and is not counted. The percentage of document information corresponding to document 1 in the second answer included in the historical question and answer information is:

[0178] Of course, other methods can also be used to calculate the proportion. For example, the electronic device can segment the second answer according to the end symbol, and determine the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information through semantic clustering. This is not limited here.

[0179] Furthermore, after the electronic device determines the ratio, it can judge the ratio and perform corresponding actions. The following describes in detail the two cases of the judgment results:

[0180] Case a: If the proportion is greater than the second threshold, the electronic device determines that the historical question and answer information is the first historical question and answer information.

[0181] It can be understood that if this percentage is greater than the second threshold, it indicates that the information about the intersection document accounts for a significant portion of the second answer included in the historical Q&A information. This information can be directly used as the first historical Q&A information and subsequently submitted to the LLM as the context for the current user's question, executing the following steps S403-S406. The second threshold here can be set by the developer or determined based on experimental data, and is not limited here.

[0182] Case b: If the percentage is less than or equal to the second threshold, the electronic device rewrites the historical question-and-answer information to obtain multiple sub-question-and-answer information; and determines the first sub-question-and-answer information for the first document from the multiple sub-question-and-answer information. The multiple second documents correspond one-to-one to the multiple sub-question-and-answer information.

[0183] It can be understood that if the proportion value is less than or equal to the second threshold, it means that the information about the intersection document accounts for a small proportion of the second answer included in the historical question and answer information. The second answer can be further rewritten, specifically by splitting the second answer into multiple sub-question and answer information so that the historical question and answer information can be fully utilized; then, the first sub-question and answer information for the first document can be determined from the multiple sub-question and answer information. The first sub-question and answer information can then be submitted to the LLM as the context of the current user's question. For details, please refer to the following Figure 8 The description of is omitted here.

[0184] For example, assuming that the documents targeted by the historical question and answer information include document 1, document 2, document 3, and document 4, and the first document includes document 1 and document 2, then Figure 6BAs shown, the second question and the second answer corresponding to the second question included in the historical question and answer information can be split and rewritten into: sub-question and answer information 1 for document 1, sub-question and answer information 2 for document 2, sub-question and answer information 3 for document 3, and sub-question and answer information 4 for document 4. The electronic device then determines the first sub-question and answer information for the first document from these four sub-question and answer information, namely, sub-question and answer information 1 and sub-question and answer information 2.

[0185] Of course, the electronic device may also rewrite the second answer in other ways, which are not limited here.

[0186] Case 2: If the repetition rate is less than or equal to the first threshold (T max ), and the repetition is greater than or equal to the third threshold (T min ), the electronic device rewrites the historical question-and-answer information to obtain multiple sub-question-and-answer information; and determines the first sub-question-and-answer information for the first document from the multiple sub-question-and-answer information. The multiple second documents correspond one-to-one to the multiple sub-question-and-answer information.

[0187] In a specific implementation, if the repetition is less than or equal to the first threshold, and the repetition is greater than or equal to the third threshold, it means that the historical question and answer information is not highly relevant to the document selected by the current user. However, the second answer can be further rewritten, specifically by splitting the second answer into multiple sub-question and answer information so that the historical question and answer information can be fully utilized. Then, the first sub-question and answer information for the first document can be determined from the multiple sub-question and answer information. The first sub-question and answer information can then be submitted to the LLM as the context of the current user's question. For details, please refer to the following Figure 9 The description of is omitted here.

[0188] The specific rewriting method can refer to the description in the above case b, which will not be repeated here; of course, the electronic device can also rewrite the second answer in other ways, which are not limited here.

[0189] Case 3: If the repetition rate is less than the third threshold (T min ), the electronic device discards the historical question and answer information.

[0190] In a specific implementation, if the repetition degree between the second document identification set corresponding to a certain historical question and answer information and the document identification of the first document identification set is less than the third threshold, it means that the historical question and answer information has little relevance to the document selected by the current user's question. If it is subsequently submitted to LLM as the context of the current user's question, it will affect the accuracy of the answer to the current question. Therefore, the historical question and answer information can be directly discarded.

[0191] S403: The electronic device determines a first text block associated with the first question from the first document.

[0192] In the implementation of this application, the electronic device needs to parse and segment the documents uploaded by the user, then vectorize the segmented text blocks, and store the vectorized text blocks in the database. In addition, the electronic device will also parse and vectorize the first question input by the user, and retrieve the top-N first text blocks with the highest matching degree (i.e., the first text blocks associated with the first question) from the first document stored in the database through vector similarity matching. Among them, N here is a positive integer, which can be set by the developer or determined based on experimental data, and is not limited here. For details, please refer to the above Figure 1B The description of steps (1), (2), (3), (4) and (5) is omitted here. It should be noted that, when the electronic device determines the first text block associated with the first question from the first document, the execution order of step S402 and step S403 is not limited.

[0193] In one possible implementation, when the electronic device determines the first text block associated with the first question from the first document, a specific implementation may be: the electronic device determines the first text block associated with the first question and the first historical question and answer information from the first document.

[0194] It can be understood that the electronic device can form a new query (i.e., the third question) with the first question and the first historical question and answer information, and then parse and vectorize the new query, and retrieve the top-N first text blocks with the highest matching degree (i.e., the first text blocks associated with the first question and the first historical question and answer information) from the first document stored in the database through vector similarity matching. In this way, the accuracy of the answer result can be further improved. It should be noted that, in the case where the electronic device determines the first text block associated with the first question and the first historical question and answer information from the first document, step S402 needs to be executed before step S402.

[0195] The first text block determined by the electronic device may be one or more.

[0196] S404. The electronic device generates first prompt information; the first prompt information includes the first text block, the first historical question and answer information, and the first question.

[0197] S405: The electronic device calls the large language model to process the first prompt information to obtain a first answer corresponding to the first question.

[0198] S406: The electronic device outputs a first answer corresponding to the first question.

[0199] In the implementation of this application, the electronic device generates a first prompt message (prompt) based on the first prompt template (prompt template), combining the first text block, the first historical question and answer information and the first question; then inputs the first prompt message into the LLM for processing, outputs the first answer corresponding to the first question, and returns the first answer to the user. Figure 5B As shown, after receiving the first question regarding document 1 input by the user, the electronic device performs parsing processing, outputs the first answer corresponding to the first question, and displays it in a dialog box; in addition, the specific content of document 1 selected by the user can also be displayed in the document display box.

[0200] For example, the first prompt template is as follows:

[0201]

[0202] Optionally, the first prompt information also includes first sub-question and answer information. It can be understood that, when there are multiple historical question and answer information, based on the corresponding circumstances of each historical question and answer information, part of the historical question and answer information can be determined as the first historical question and answer information, part of the historical question and answer information can be rewritten to obtain multiple sub-question and answer information, or part of the historical question and answer information can be discarded. Therefore, the first prompt template mentioned above can also include the first text block, the first historical question and answer information, the first sub-question and answer information, and the first question.

[0203] For example, the first prompt template may be as follows:

[0204]

[0205] Of course, other forms of first prompt templates may also be used, which are not limited here.

[0206] In one possible implementation, the ordering of different historical Q&A information affects the accuracy of the model's returned results, so a certain strategy is needed to sort multiple historical Q&A information. Assuming there are multiple first historical Q&A information, these multiple first historical Q&A information can be sorted in the first prompt information using the following two methods:

[0207] Mode a: The plurality of first historical question-and-answer pieces of information in the first prompt information are arranged in chronological order from front to back or from back to front.

[0208] In other words, the historical Q&A information can be sorted according to the time of occurrence (in reverse or forward order). As shown in Table 1 above, the three historical Q&A information in Table 1 are arranged in order from the time of occurrence, that is, historical Q&A information 1, historical Q&A information 2, and historical Q&A information 3. Of course, the three historical Q&A information in Table 1 can also be arranged in order from the time of occurrence, that is, historical Q&A information 3, historical Q&A information 2, and historical Q&A information 1.

[0209] Mode b: The plurality of first historical question and answer information in the first prompt information are arranged in order from large to small or from small to large according to the first similarity, where the first similarity is the similarity between the first historical question and answer information and the first question.

[0210] That is, the similarity between the first question asked by the current user and the second question or the second answer in the historical question and answer information is calculated, and the similarities are sorted in order of similarity (from large to small or from small to large). The first similarity here can be represented by cosine similarity, Pearson correlation coefficient, Euclidean distance, Manhattan distance, etc.

[0211] Of course, other methods may also be used to sort the plurality of first historical question and answer information, which are not limited here.

[0212] In general, for the background processing flow, such as Figure 7 As shown, after the user uploads a document, the electronic device parses and segments the uploaded document, then vectorizes the segmented text blocks, and stores the vectorized text blocks in a database.

[0213] Of course, the electronic device will save one or more historical question and answer information of the user in the current conversation window to the historical question and answer database. The historical question and answer information here refers to the questions asked by the user in the current conversation window and the corresponding answers output. Because the questions asked by the user in a conversation window are usually related, the electronic device can also obtain one or more historical question and answer information of the user from the historical question and answer database and use this one or more historical question and answer information as the context of the current user's question to better assist the model in outputting the answer later.

[0214] Furthermore, if all of these historical question and answer information are used as the context of the current user's question, redundant data may be introduced, affecting the accuracy of the model's answer. Therefore, it is necessary to filter and screen the one or more historical question and answer information to obtain the first historical question and answer information and / or the first sub-question and answer information. The specific process of filtering the historical question and answer information can refer to the description in the above step S402 and will not be repeated here.

[0215] Furthermore, the user can enter the first question for the first document in the question input box, and the electronic device will parse and vectorize the first question entered by the user, and retrieve the top-N first text blocks with the highest matching degree (i.e., the first text blocks associated with the first question) from the first document stored in the database through vector similarity matching. Optionally, the first question entered by the user for the first document and the filtered first historical question and answer information can be combined into a new query, and then the new query is parsed and vectorized, and the top-N first text blocks with the highest matching degree (i.e., the first text blocks associated with the first question and the first historical question and answer information) can be retrieved from the first document stored in the database through vector similarity matching. In this way, the accuracy of the answer results can be further improved.

[0216] Furthermore, the electronic device generates a first prompt message based on the first prompt template, in combination with the first text block, the first historical question and answer information, and the first question; then inputs the first prompt message into the LLM for processing, outputs the first answer corresponding to the first question, and returns the first answer to the user. Of course, the electronic device can also generate a second prompt message based on the second prompt template, in combination with the first text block, the first sub-question and answer information, and the first question; then inputs the second prompt message into the LLM for processing, outputs the third answer corresponding to the first question, and returns the third answer to the user. It should be noted that when there are multiple historical question and answer information, according to the corresponding situation of each historical question and answer information, part of the historical question and answer information can be determined as the first historical question and answer information, part of the historical question and answer information can be rewritten to obtain multiple sub-question and answer information, and part of the historical question and answer information can be discarded. Therefore, the first prompt template and the second prompt template mentioned above can also include the first text block, the first historical question and answer information, the first sub-question and answer information, and the first question. This completes the entire process of document question and answer processing. It can be seen that compared to Figure 1B , added the process of obtaining historical question and answer information and filtering historical question and answer information.

[0217] It can be seen that based on Figure 4 The described method is aimed at the document question and answer scenario. Since the questions asked by users in a conversation window are usually relevant, the electronic device can obtain one or more historical question and answer information of the user in this conversation window, and use the one or more historical question and answer information as the context of the current user's question, so as to better assist the model in outputting the answer corresponding to the current question; at the same time, in order to avoid introducing redundant data, the one or more historical question and answer information are further filtered and screened, which is more conducive to improving the accuracy of the answer results.

[0218] Figure 8This is a flow chart of another document question-answering processing method provided by an embodiment of the present application. Figure 8 As shown, the document question and answer processing method includes the following steps S801 to S808. Figure 8 The method shown may be performed by the electronic device mentioned above. Alternatively, Figure 8 The execution entity of the method shown may be a chip in an electronic device, which is not limited in the embodiments of the present application. Figure 8 The method is described by taking an electronic device as an example of an execution subject.

[0219] S801: The electronic device obtains a first question for a first document.

[0220] S802: When the same identifier exists in the first document identifier set and the second document identifier set, the electronic device determines the degree of duplication of the document identifiers in the first document identifier set and the second document identifier set.

[0221] There are one or more first documents, the first document identification set includes the identifications of the one or more first documents, and the second document identification set includes the identification of the second document to which the historical question and answer information is directed.

[0222] S803. If the degree of repetition is greater than a first threshold, the electronic device determines an intersection document identifier between the first document identifier set and the second document identifier set; and calculates a proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information.

[0223] S804: If the proportion is less than or equal to a second threshold, the electronic device rewrites the historical question and answer information to obtain multiple sub-question and answer information; and determines first sub-question and answer information for the first document from the multiple sub-question and answer information.

[0224] The plurality of second documents correspond one-to-one to the plurality of sub-question-and-answer information.

[0225] S805: The electronic device determines a first text block associated with the first question from the first document.

[0226] The specific implementation of steps S801 to S805 may refer to the specific implementation of steps S401 to S403 above, and will not be described in detail here.

[0227] S806. The electronic device generates second prompt information; the second prompt information includes the first text block, the first sub-question and answer information, and the first question.

[0228] S807: The electronic device calls the large language model to process the second prompt information to obtain a third answer corresponding to the first question.

[0229] S808. The electronic device outputs a third answer corresponding to the first question.

[0230] In the implementation of this application, taking a certain historical question and answer information as an example, for case b in step S402 and case 2 in step S402, the electronic device rewrites the historical question and answer information to obtain multiple sub-question and answer information; and after determining the first sub-question and answer information for the first document from the multiple sub-question and answer information, determines the first text block associated with the first question from the first document, and then generates a second prompt information (prompt) based on the second prompt template (prompt template) in combination with the first text block, the first sub-question and answer information and the first question; and then inputs the second prompt information into the LLM for processing, outputs a third answer corresponding to the first question, and returns the third answer to the user.

[0231] For example, the second prompt template is as follows:

[0232]

[0233] Optionally, the second prompt template also includes the first historical question and answer information. It can be understood that when there are multiple historical question and answer information, depending on the conditions satisfied by the historical question and answer information, part of the historical question and answer information can be determined as the first historical question and answer information, part of the historical question and answer information can be rewritten to obtain multiple sub-question and answer information, or part of the historical question and answer information can be discarded. Therefore, the second prompt template mentioned above can also include the first text block, the first historical question and answer information, the first sub-question and answer information, and the first question.

[0234] For example, the second prompt template may be as follows:

[0235]

[0236] Of course, other forms of second prompt templates may also be used, which are not limited here.

[0237] It can be seen that based on Figure 8 The described method is aimed at the document question and answer scenario. Since the questions asked by users in a conversation window are usually relevant, the electronic device can obtain one or more historical question and answer information of the user in this conversation window, and use the one or more historical question and answer information as the context of the current user's question, so as to better assist the model in outputting the answer corresponding to the current question; at the same time, in order to avoid introducing redundant data, the one or more historical question and answer information are further filtered and rewritten, which is more conducive to improving the accuracy of the answer results.

[0238] Figure 9This is a flow chart of another document question-answering processing method provided by an embodiment of the present application. Figure 9 As shown, the document question and answer processing method includes the following steps S901 to S907. Figure 9 The method shown may be performed by the electronic device mentioned above. Alternatively, Figure 9 The execution entity of the method shown may be a chip in an electronic device, which is not limited in the embodiments of the present application. Figure 9 The method is described by taking an electronic device as an example of an execution subject.

[0239] S901: The electronic device obtains a first question for a first document.

[0240] S902: When the same identifier exists in the first document identifier set and the second document identifier set, the electronic device determines the degree of duplication of the document identifiers in the first document identifier set and the second document identifier set.

[0241] There are one or more first documents, the first document identification set includes the identifications of the one or more first documents, and the second document identification set includes the identification of the second document to which the historical question and answer information is directed.

[0242] S903: If the repetition degree is less than or equal to the first threshold and the repetition degree is greater than or equal to the third threshold, the electronic device rewrites the historical question and answer information to obtain multiple sub-question and answer information; and determines first sub-question and answer information for the first document from the multiple sub-question and answer information.

[0243] The plurality of second documents correspond one-to-one to the plurality of sub-question-and-answer information.

[0244] S904: The electronic device determines a first text block associated with the first question from the first document.

[0245] The specific implementation of steps S901 to S904 may refer to the specific implementation of steps S401 to S403 above, and will not be described in detail here.

[0246] S905. The electronic device generates second prompt information; the second prompt information includes the first text block, the first sub-question and answer information, and the first question.

[0247] S906: The electronic device calls the large language model to process the second prompt information to obtain a third answer corresponding to the first question.

[0248] S907: The electronic device outputs a third answer corresponding to the first question.

[0249] The specific implementation of steps S905 to S907 may refer to the specific implementation of steps S806 to S808 above, and will not be described in detail here.

[0250] It can be seen that based on Figure 9 The described method is aimed at the document question and answer scenario. Since the questions asked by users in a conversation window are usually relevant, the electronic device can obtain one or more historical question and answer information of the user in this conversation window, and use the one or more historical question and answer information as the context of the current user's question, so as to better assist the model in outputting the answer corresponding to the current question; at the same time, in order to avoid introducing redundant data, the one or more historical question and answer information are further filtered and rewritten, which is more conducive to improving the accuracy of the answer results.

[0251] See Figure 10 , Figure 10 A schematic structural diagram of a document question-and-answer processing device 1000 according to an embodiment of the present application is shown. Figure 10 The document question and answer processing device shown may be an electronic device, or a device within an electronic device, or a device that can be used in conjunction with an electronic device. Figure 10 The document question-answering processing apparatus shown may include an acquisition unit 1001, a determination unit 1002, and a processing unit 1003.

[0252] An acquiring unit 1001 is configured to acquire a first question for a first document;

[0253] A determining unit 1002 is configured to determine first historical question and answer information for the first document from one or more historical question and answer information;

[0254] The determining unit 1002 is further configured to determine a first text block associated with the first question from the first document;

[0255] The processing unit 1003 is configured to generate a first prompt message, wherein the first prompt message includes the first text block, the first historical question and answer information, and the first question;

[0256] The processing unit 1003 is further configured to call the large language model to process the first prompt information to obtain a first answer corresponding to the first question;

[0257] The processing unit 1003 is further configured to output a first answer corresponding to the first question.

[0258] In one possible implementation, there are one or more first documents, and when the determination unit 1002 determines the first historical question and answer information for the first document from one or more historical question and answer information, the specific implementation method may be: when the same identifier exists in the first document identification set and the second document identification set, determine the repetition of the document identifiers in the first document identification set and the second document identification set; wherein the first document identification set includes the identifiers of the one or more first documents, and the second document identification set includes the identifier of the second document to which the historical question and answer information is directed; if the repetition is greater than a first threshold, determine that the historical question and answer information is the first historical question and answer information.

[0259] In one possible implementation, when the determination unit 1002 determines that the historical question and answer information is the first historical question and answer information if the repetition degree is greater than a first threshold, the specific implementation may be: if the repetition degree is greater than the first threshold, determining the intersection document identifier between the first document identifier set and the second document identifier set; then calculating the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information; if the proportion is greater than the second threshold, determining that the historical question and answer information is the first historical question and answer information.

[0260] In one possible implementation, when the determination unit 1002 calculates the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information, the specific implementation method may be: determining the keyword based on the document information corresponding to the intersection document identifier; calculating the proportion of the first information in the second answer included in the historical question and answer information; wherein the first information includes the keyword.

[0261] In one possible implementation, when the determination unit 1002 determines the first text block associated with the first question from the first document, a specific implementation method may be: determining the first text block associated with the first question and the first historical question and answer information from the first document.

[0262] In one possible implementation, there are multiple second documents, and the processing unit 1003 is further used to: if the repetition degree is less than or equal to the first threshold, and the repetition degree is greater than or equal to the third threshold, rewrite the historical question and answer information to obtain multiple sub-question and answer information; or, if the proportion value is less than or equal to the second threshold, rewrite the historical question and answer information to obtain multiple sub-question and answer information; wherein the multiple second documents correspond one-to-one to the multiple sub-question and answer information; then determine the first sub-question and answer information for the first document from the multiple sub-question and answer information; then generate second prompt information, wherein the second prompt information includes the first text block, the first sub-question and answer information and the first question; finally, call the large language model to process the second prompt information, obtain the third answer corresponding to the first question, and output the third answer corresponding to the first question.

[0263] It should be noted that when there are multiple historical question and answer information, according to the conditions satisfied by the historical question and answer information, part of the historical question and answer information can be determined as the first historical question and answer information, part of the historical question and answer information can be rewritten to obtain multiple sub-question and answer information, and part of the historical question and answer information can be discarded. Therefore, the first prompt template and the second prompt template mentioned above may also include the first text block, the first historical question and answer information, the first sub-question and answer information and the first question.

[0264] In one possible implementation, there are multiple first historical question and answer information, and the multiple first historical question and answer information in the first prompt information are arranged in chronological order from front to back or from back to front; or, the multiple first historical question and answer information in the first prompt information are arranged in chronological order from large to small or from small to large according to the first similarity, wherein the first similarity is the similarity between the first historical question and answer information and the first question.

[0265] For the case where the document question answering processing device can be a chip or a chip system, please refer to Figure 11 Schematic diagram of the chip structure shown. Figure 11 The chip 1100 shown includes a processor 1101 and an interface 1102. Optionally, it may also include a memory 1103. The number of processors 1101 may be one or more, and the number of interfaces 1102 may be multiple.

[0266] For the case where the chip is used to implement the electronic device in the embodiment of the present application:

[0267] The interface 1102 is used to receive or output signals;

[0268] The processor 1101 is used to perform data processing operations of the electronic device.

[0269] It is understood that some optional features in the embodiments of the present application may, in certain scenarios, be implemented independently of other features, such as the solution on which they are currently based, to solve corresponding technical problems and achieve corresponding effects. They may also be combined with other features in certain scenarios as needed. Accordingly, the document question and answer processing device provided in the embodiments of the present application can also implement these features or functions accordingly, which will not be described in detail here.

[0270] It should be understood that the processor in the embodiment of the present application can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method embodiment can be completed by an integrated logic circuit of hardware in the processor or instructions in the form of software. The above processor can be a general-purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component.

[0271] It is understood that the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus RAM (DR RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0272] The present application also provides an antenna switching system, which includes an electronic device; wherein the electronic device is used to execute the method executed by the electronic device in any of the above method embodiments.

[0273] The present application also provides a computer storage medium having a computer program / instruction stored thereon, which implements the method and steps of any of the above method embodiments when the computer program / instruction is executed by a processor.

[0274] The present application also provides a computer program product, including a computer program / instruction, which implements the method and steps of any of the above method embodiments when executed by a processor.

[0275] As used in the specification and appended claims of the present application, the singular expressions "a", "an", "said", "above", "the" and "this" are intended to include plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more of the listed items. As used in the above embodiments, the term "when..." can be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...". Similarly, the phrase "when determining..." or "if (stated condition or event) is detected" can be interpreted to mean "if determining..." or "in response to determining..." or "when (stated condition or event) is detected" or "in response to detecting (stated condition or event)", depending on the context.

[0276] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a high-density digital video disc (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)). A person skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by a computer program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium. When the program is executed, it may include the processes of the above-mentioned method embodiments. The aforementioned storage media include various media that can store program codes, such as ROM or random access memory RAM, magnetic disks or optical disks.

[0277] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A document question-answering method, characterized in that: The method comprises: Obtaining a first question for a first document; Determining first historical question and answer information for the first document from one or more historical question and answer information; determining, from the first document, a first block of text associated with the first question; Generate first prompt information; the first prompt information includes the first text block, the first historical question and answer information, and the first question; Invoking a large language model to process the first prompt information to obtain a first answer corresponding to the first question; Output a first answer corresponding to the first question.

2. The method according to claim 1, characterized in that There are one or more first documents, and determining first historical question and answer information for the first documents from the one or more historical question and answer information includes: In a case where the same identifier exists in a first document identifier set and a second document identifier set, determining the degree of duplication of the document identifiers in the first document identifier set and the second document identifier set; the first document identifier set includes identifiers of the one or more first documents, and the second document identifier set includes identifiers of second documents for which the historical question and answer information is intended; If the repetition degree is greater than a first threshold, the historical question and answer information is determined to be the first historical question and answer information.

3. The method according to claim 2, characterized in that If the repetition degree is greater than a first threshold, determining that the historical question and answer information is the first historical question and answer information includes: If the degree of repetition is greater than a first threshold, determining an intersection document identifier between the first document identifier set and the second document identifier set; Calculating a proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information; If the proportion value is greater than a second threshold, the historical question and answer information is determined to be the first historical question and answer information.

4. The method according to claim 3, characterized in that The calculating of the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information includes: Determining keywords based on document information corresponding to the intersection document identifier; The proportion of the first information in the second answer included in the historical question and answer information is calculated; the first information includes the keyword.

5. The method according to any one of claims 2 to 4, characterized in that The determining, from the first document, a first text block associated with the first question, comprises: A first text block associated with the first question and the first historical question and answer information is determined from the first document.

6. The method according to any one of claims 3 to 5, characterized in that Having a plurality of second documents, the method further comprises: If the repetition degree is less than or equal to the first threshold and the repetition degree is greater than or equal to a third threshold, rewriting the historical question and answer information to obtain multiple sub-question and answer information; or, if the proportion value is less than or equal to the second threshold, rewriting the historical question and answer information to obtain multiple sub-question and answer information; the multiple second documents correspond one-to-one to the multiple sub-question and answer information; Determining first sub-question and answer information for the first document from the plurality of sub-question and answer information; Generate second prompt information; the second prompt information includes the first text block, the first sub-question and answer information and the first question; Invoking a large language model to process the second prompt information to obtain a third answer corresponding to the first question; Output a third answer corresponding to the first question.

7. The method according to any one of claims 1 to 6, characterized in that There are a plurality of first historical question-and-answer information, and the plurality of first historical question-and-answer information are arranged in chronological order from front to back or from back to front in the first prompt information; or, The plurality of first historical question and answer information in the first prompt information are arranged in order from large to small or from small to large according to a first similarity, where the first similarity is the similarity between the first historical question and answer information and the first question.

8. An electronic device, characterized in that: include: One or more processors, one or more memories; wherein the one or more memories are coupled to the one or more processors, the one or more memories are used to store computer program code, the computer program code includes computer instructions, and when the one or more processors execute the computer instructions, the electronic device performs the method as described in any one of claims 1-7.

9. A document question-answering processing system, characterized in that: The invention comprises an electronic device; wherein the electronic device is used to execute the method according to any one of claims 1 to 7.

10. A chip, characterized in that: The method comprises a processor and an interface, wherein the processor and the interface are coupled; the interface is used to receive or output signals, and the processor is used to execute code instructions so that the method according to any one of claims 1 to 7 is executed.

11. A computer storage medium, characterized in that The computer storage medium stores a computer program, which includes program instructions. When the program instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 7.

12. A computer program product, characterized in that When the computer program product is run on a computer, the computer is caused to perform the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Text generation method, device and equipment and readable storage medium

    CN115146050A

  • Text reading understanding method and device, equipment and storage medium

    CN116975221A

  • User question answering method and device, equipment and medium

    CN117251547A

  • Information processing method and device based on large language model, equipment and storage medium

    CN117521675A

  • Method for Recommending Content to Ingest as Corpora Based on Interaction History in Natural Language Question and Answering Systems

    US20160196490A1

Cited By

  • Intelligent document question and answer and voice generation system and method

    CN121681731A