Nutrition field retrieval enhancement generation method, system, medium and equipment

By converting external knowledge documents into question-and-answer pairs and depositing them into vector databases, the problem of inaccurate search results in the field of nutritional health question-and-answer in the prior art is solved, and more efficient and accurate retrieval and generation of nutritional health information is achieved.

CN119719286APending Publication Date: 2025-03-28ANHUI HONGYUAN JUKANG MEDICAL TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411782063.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

In the field of nutritional health questions and answers, when using user questions to directly search for external knowledge bases, it is difficult to directly provide targeted and accurate nutrient selection suggestions, and a single sentence vector model has matching errors when dealing with problems with different meanings but similar syntactic structures.

Method used

The nutritional field search enhancement generation method is adopted to convert external knowledge documents into question-and-answer pairs and store them in a vector database. The most similar questions are retrieved through the cosine similarity algorithm to generate answers, improving the directness and pertinence of the answers.

Benefits of technology

Through the search and enhancement of the generation method of question-and-answer pairs, users' questions can be matched more accurately, and more direct and targeted nutritional and health suggestions can be provided, which improves the quality and accuracy of the answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119719286A_ABST
    Figure CN119719286A_ABST
Patent Text Reader

Abstract

The invention discloses a nutrition field retrieval enhancement generation method, a nutrition field retrieval enhancement generation system, a medium and equipment. The method comprises the following specific steps: S1, collecting external knowledge documents: collecting knowledge related to a nutrition field and arranging the knowledge into an external document set; s2, constructing a question and answer pair set: converting the external document set into question and answer pairs, wherein the question and answer pairs comprise question and answer pairs formed by structured data knowledge and question and answer pairs formed by unstructured data knowledge; s3, the nutrition knowledge question-answer pairs are stored in the vector database, vectors of questions in the question-answer pairs are obtained and embedded into answer vectors in the question-answer pairs, and the embedded vectors of the question-answer pairs serve as primary key indexes in the database. Through the nutrition field retrieval enhancement generation method, the text in the document library is converted into the form of the question-answer pair, the most similar question is retrieved in the question set through similarity matching, the corresponding answer serves as the query result, noise can be effectively reduced, and matching efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of knowledge retrieval technology, and in particular to a method, system, medium and device for retrieval enhancement generation in the field of nutrition. Background Art

[0002] As public health awareness continues to increase, the demand for nutritional knowledge is also increasing. The importance of healthy diet and nutritional support in chronic disease management, rehabilitation treatment and personalized health guidance is becoming increasingly prominent. Especially for chronic diseases closely related to nutrition, such as cardiovascular disease, diabetes and obesity, scientific, timely and personalized nutritional intervention is particularly important for alleviating the development of the disease. However, there is still an imbalance in medical resources and uneven medical levels in today's society, making it difficult for residents to obtain scientific and appropriate nutritional health knowledge in a timely manner. Around 2023, ChatGPT (full name: ChatGenerative Pre-trained Transformer, a chatbot program developed by OpenAI) and other generative large language models (Large Language Model, LLM for short) developed rapidly, relying on the experience knowledge learned by LLM in the pre-training stage, it can conduct conversations with users in any field. Therefore, people have also begun to try to use LLM to obtain nutritional health knowledge.

[0003] However, considering that most LLMs are pre-trained based on general domain corpora, the prior knowledge they contain may be "general but not precise". Therefore, for tasks in specific fields, relevant corpora in that field are often required to "fine-tune" LLM. However, the tens of billions of parameters of LLM require high computing resources for "fine-tuning", which is unaffordable for most individual developers and small and medium-sized enterprises. In response to this, researchers proposed Retrieval-Augmented Generation (RAG), which relies on "external knowledge base" to improve the accuracy and scientificity of LLM's answers. Specifically, when a user asks LLM a question in a health field, LLM will first retrieve relevant information from a large external document collection, and then use the retrieved information to guide the generation of text, thereby improving the quality and accuracy of the generated answers. This large external document collection is usually referred to as an "external knowledge base".

[0004] It can be seen that although RAG can improve the quality and accuracy of LLM answers, the key lies in finding suitable "relevant information" from the external knowledge base. At present, the commonly used retrieval method is to first divide the document collection in the external knowledge base according to sentences, and then store its embedding representation (Embedding Representation) in the vector database. Next, after converting the user's question into an embedding representation, it is matched with the data in the vector database by cosine similarity to find the N document data most similar to the question, and based on this, a "prompt" is constructed to guide the generation of LLM. However, there are still the following problems when this method is applied to the field of nutrition and health questions and answers:

[0005] The relevant documents retrieved using the user's "question" are only data related to the "question". For example, if the user's question is "What nutrients are better to eat when cholesterol is high", the content retrieved from the external knowledge base may be information such as "the harm of high cholesterol" and "the metabolic process of cholesterol". Although this information is related to cholesterol, it cannot directly answer the user's nutrient selection needs. Therefore, the document data retrieved directly using the "question" may not be used to guide LLM to generate a more reasonable answer.

[0006] When using the user's "question" to retrieve relevant data from an external knowledge base, the "question" needs to be converted into an embedded representation, but the commonly used embedding representation only relies on a single sentence vector model. This makes two questions with different meanings but similar syntactic structures search for similar data from the external knowledge base. For example, a single sentence vector model will think that "What nutrients are better for high cholesterol" and "What nutrients are better for high blood pressure" are similar, and the data retrieved is also similar. Although the nutritional support for these two health problems has an intersection, they are fundamentally two different health problems.

[0007] In view of the shortcomings of the existing technology, a new retrieval enhancement generation method is needed. Summary of the invention

[0008] In order to solve the above technical problems, the present invention provides a method for enhancing the generation of nutrition field retrieval, and the technical solution adopted by the method is as follows:

[0009] A method for enhancing retrieval in the field of nutrition comprises the following specific steps:

[0010] S1. Collect external knowledge documents: Collect knowledge related to the field of nutrition and organize it into a collection of external documents;

[0011] S2. Construct a set of question-answer pairs: convert the external document set into question-answer pairs, including question-answer pairs formed by structured data knowledge and question-answer pairs formed by unstructured data knowledge;

[0012] S3. Storing the nutrition knowledge question and answer pair in the vector database, obtaining the vector of the question in the question and answer pair, embedding it into the answer vector in the question and answer pair, and using the embedded question and answer pair vector as the primary key index in the database;

[0013] S4. Query the vector database: store all question-answer pairs in the vector database, obtain user consultation information, and perform search queries on the vector database;

[0014] S5. Build user suggestions: send the vector representation into the vector database, match it with the embedded questions stored in the vector database through the cosine similarity algorithm, retrieve the most similar N (N≥0) questions and return the corresponding answers;

[0015] S6. Output results: Construct the user's query and the retrieved answer set into prompts, and output the results through a large language model.

[0016] Furthermore, in the step S1, the external document set includes unstructured data knowledge and structured data knowledge, the unstructured data knowledge is eventually converted into a txt format, and the structured data knowledge is eventually converted into source code.

[0017] Furthermore, in step S2, the question-answer pairs formed by the unstructured data knowledge can be extracted from the abstract of the paper through the big data model, wherein the unstructured data knowledge acquisition step includes:

[0018] S21. First, obtain the abstracts of RCT papers, which all have the structural elements of objects, methods, and results;

[0019] S22. Extract key information about population, intervention and results from RCT paper abstracts using a large language model;

[0020] S23. Generate question-answer pairs based on the population, intervention, and key outcome information through a high-level programming language tool, wherein the high-level programming language tool may be Python;

[0021] Question-answer pairs formed by structured data knowledge are generated by directly applying templates.

[0022] Furthermore, in the S3 step, after the question is embedded and saved, its corresponding answer is stored, and it is used as a retrieval result to guide the output of the big data model during the retrieval enhancement generation process;.

[0023] Further, the S4 step includes:

[0024] S41. Obtaining a user query, and obtaining the queried medical entity from the vector database;

[0025] S42. Constructing a vector representation of the query entity level and sentence level through medical entities;

[0026] S43. Query the vector database.

[0027] Furthermore, in step S5, the formula involved in the cosine similarity algorithm is:

[0028]

[0029] where qd i is the dot product of two vectors, which means the inner product between two vectors;

[0030] ||q|| and | ||d i || are the moduli of the vectors, and are calculated as follows:

[0031]

[0032] The result value range is [-1,1], 1 means exactly the same, -1 means completely opposite, and 0 means no correlation;

[0033] For all D i , calculate the cosine similarity with Q and sort from high to low:

[0034] Rank(Q)=argsort([CosSim(q,d1),CosSim(q,d2),...]).

[0035] Furthermore, in step S3, the key medical information in the sentence is integrated into its vector representation, and the acquired sentence vector is semantically richer by fusing the entity-level and sentence-level embeddings.

[0036] On the other hand, the present invention also provides a nutrition field search enhancement generation device, characterized in that it includes:

[0037] The external knowledge document collection module is used to collect knowledge related to the nutrition field and organize it into an external document collection;

[0038] A question-answer pair set construction module is used to convert an external document set into question-answer pairs, including question-answer pairs formed by structured data knowledge and question-answer pairs formed by unstructured data knowledge;

[0039] A vector database storage module is used to obtain the vector of the question of the question-answer pair, embed it into the vector, and store it together with the corresponding answer in the vector database;

[0040] The vector database query module is used to store all question-answer pairs into the vector database, obtain user consultation information, and perform search queries on the vector database;

[0041] The user suggestion building module is used to send the vector representation into the vector database, match it with the embedded questions stored in the vector database through the cosine similarity algorithm, retrieve the most similar N (N ≥ 0) questions and return the corresponding answers;

[0042] The result output module is used to construct the user's query and the retrieved answer set into prompts and output the results through the large language model.

[0043] In yet another aspect, the present invention further discloses a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the method as claimed in any one of claims 1 to 7.

[0044] On the other hand, the present invention further discloses a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the method as claimed in any one of claims 1 to 7.

[0045] It can be seen from the above technical solution that the present invention provides a method for enhancing the generation of nutrition field retrieval. Compared with the prior art, the present invention has the following advantages:

[0046] 1. The present invention uses a nutrition field search enhancement generation method to convert text in the document library into a question-answer pair, and retrieves the most similar questions in the question set through similarity matching, and uses the corresponding answers as query results. Since the format of questions and answers is naturally suitable for generative tasks, this method is more adaptable to the characteristics of generative large language models than traditional search enhancement generation methods, making the answers more direct and targeted, and improving the accuracy. In addition, compared with direct search in long text documents, the question-answer pair format can effectively reduce noise and improve matching efficiency.

[0047] 2. The present invention optimizes the embedding generation method of query and question sets through a nutrition field retrieval enhancement generation method. The method extracts medical entities in sentences as keywords, obtains the vector representation of keywords through word vectors, and merges it with the vector representation of sentences as a new vector representation. The above method is used for questions in the query and question sets, so that the keyword information is enhanced in the embedded representation, which is more accurate when performing retrieval matching.

[0048] 3. The present invention adopts a retrieval enhancement generation method in the field of nutrition. This question-answer based approach also enhances the model's ability to understand and reason about user questions, and can better support accurate information retrieval and knowledge enhancement generation in fields such as medicine or nutrition.

[0049] 4. The present invention adopts a nutrition field retrieval enhancement generation method. Compared with directly searching in long text documents, the question-answer pair format can effectively reduce noise and improve matching efficiency.

[0050] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become easy to understand through the following description. Of course, it is not necessary to achieve all of the advantages described above simultaneously for any product implementing the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The drawings constituting a part of the present application are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0052] Figure 1 It is a schematic diagram of the overall process of the present invention;

[0053] Figure 2 It is a model structure diagram of the method of the present invention;

[0054] Figure 3 A flowchart of the method of the present invention for constructing a question-answer pair set from an external document set;

[0055] Figure 4 A process diagram for constructing a vector representation containing medical entity information for the method of the present invention;

[0056] Figure 5 A schematic diagram of the structure of the nutrition field search enhancement generation device of the present invention;

[0057] Figure 6 A flowchart of converting unstructured data into question-answer pairs according to the present invention. DETAILED DESCRIPTION

[0058] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. In the absence of conflict, the embodiments in this application and the features in the embodiments can be combined with each other. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0059] like Figure 1 As shown, the nutrition field search enhancement generation method proposed in the embodiment of the present invention includes the following steps:

[0060] S1. Collect external knowledge documents: Collect knowledge related to the field of nutrition and organize it into a collection of external documents;

[0061] S2. Construct a set of question-answer pairs: convert the external document set into question-answer pairs, including question-answer pairs formed by structured data knowledge and question-answer pairs formed by unstructured data knowledge;

[0062] S3. Storing the nutrition knowledge question and answer pair in the vector database, obtaining the vector of the question in the question and answer pair, embedding it into the answer vector in the question and answer pair, and using the embedded question and answer pair vector as the primary key index in the database;

[0063] S4. Query the vector database: store all question-answer pairs in the vector database, obtain user consultation information, and perform search queries on the vector database;

[0064] S5. Build user suggestions: send the vector representation into the vector database, match it with the embedded questions stored in the vector database through the cosine similarity algorithm, retrieve the most similar N (N≥0) questions and return the corresponding answers;

[0065] S6. Output results: Construct the user's query and the retrieved answer set into prompts, and output the results through a large language model.

[0066] The following is a detailed description of each step:

[0067] S1. Collect external knowledge documents, collect knowledge related to the field of nutrition and organize it into an external document collection;

[0068] Nutrition-related knowledge includes relevant guidelines, papers, and websites, including 3,650 abstracts of papers on nutrition from the Cochrane database, and online resources, including authoritative data on nutrition on the Internet, including Baidu Encyclopedia, Fadao Nutrition Network, etc.; external document collections include unstructured data knowledge and structured data knowledge. Unstructured knowledge is what is usually called text, including guidelines and papers; these files are in the formats of PDF, Word, and txt. Unstructured data knowledge is eventually converted to txt format for storage, and structured knowledge is what is usually called tables. Structured data knowledge is eventually converted into source code;

[0069] In a specific embodiment, the applicable nutrients, dosages, and recommended reasons for a disease on the Fadao Nutrition Network are displayed in a table tag in HTML (full name: Hypertext Markup Language, a markup language).

[0070]

[0071] Figure 4

[0072]

[0073]

[0074]

[0075]

[0076]

[0077]

[0078] Figure 6

[0079]

[0080]

[0081]

[0082]

[0083]

[0084]

[0085]

[0086]

[0087]

[0088] Presentation, in which the structured tabular data is stored in a relational data table in MySQL. S2. Construct a set of question-answer pairs, and transform the external document set into question-answer pairs; as shown, transform the external document set into question-answer pairs ("question-answer pairs" are referred to as QA pairs, indicating that a question corresponds to a corresponding answer, where Q represents "question" and A represents "answer"). Question-answer pairs include question-answer pairs formed by structured data knowledge and question-answer pairs formed by unstructured data knowledge; question-answer pairs formed by unstructured data knowledge are obtained by extracting them from the abstract of the paper using a big data model, and the acquisition steps include: S21. First, obtain the abstract of the RCT paper, which has object, method and result structure elements; S22. Extract the key information of the population, intervention and results in the RCT paper abstract through a large language model; S23. Based on the key information of the population, intervention and results, generate question-answer pairs formed by unstructured data knowledge through high-level programming language tools. ; The high-level programming language tool is python; for unstructured data, that is, the text data saved as txt in S1, it is converted into QA pairs through a large language model; in a specific embodiment, as shown, the abstract of the RCT paper is first obtained, and the abstract of the RCT paper has Object, Method and Result structural elements, and it is converted into txt format, and the PIO information (P refers to Population, which means "population"; I refers to Intervention, which means "intervention"; O refers to Outcome, which means "result") in the RCT paper abstract is extracted through LLM, and finally the API interface of LLM is called according to the Python language tool, the abstract information of the RCT paper is input, and the corresponding PIO information is output. Then, Python converts the PIO information into corresponding QA pairs according to the template, where the main codes involved in the corresponding python are: template_Q=f"What is the effect of {pio['p']](pio['i']}?" template_A=f"The result of (pio['p']}(pio['i']} is {pio['o']}; For structured data, that is, the data saved as a relational data table in S1, it is converted into QA pairs according to the template by using python (a high-level programming language) tools; in one example, it is converted into QA pairs according to the template by using Java tools (a high-level programming language); in one example, it is converted into QA pairs according to the template by using C++ tools (a high-level programming language); Question and answer pairs formed by structured data knowledge are obtained by directly applying template generation; in a specific embodiment, the relevant evidence-based nutritional knowledge definition of DHA (a nutrient) in the Fadao Nutrition Network is shown in the following table; Table 1 Definition of structured nutritional knowledge for prevention and control of atherosclerosis: Nutritional Name Recommended dosage Recommended reason Coenzyme Q101 By tag Inhibits LDL oxidation and adhesion to blood vessels

[0089] For this structured table, you can directly apply the template to build it into a QA pair. The knowledge in the above table can generate four QA pairs according to the following template. The specific steps are:

[0090] Step 1:

[0091] question=f'{title}'s nutritional intervention methods'

[0092] answer = f'You can use {nutrient}, the recommended dosage is {dosage}, and the reason for the recommendation is {reason}.'

[0093] Step 2:

[0094] question=f'What nutrients are used for {title}'

[0095] answer = f'For {title}, it is recommended to use {nutrient}.'

[0096] Step 3:

[0097] question=f'What is the recommended amount of {nutrient} for {title}'

[0098] answer = f'The recommended dosage of {nutrient} is {dosage}.'

[0099] Step 4:

[0100] question=f'Why is {nutrient} recommended for {title}'

[0101] answer = f'The reason for recommendation is {reason}.'

[0102] Ultimately, the above method can transform unstructured or structured nutritional knowledge into QA pairs. In the preliminary experiments, 138,740 QA pairs have been preliminarily constructed and stored in the database to facilitate user queries.

[0103] S3. Storing the nutrition knowledge question and answer pair in the vector database, obtaining the vector of the question in the question and answer pair, embedding it into the answer vector in the question and answer pair, and using the embedded question and answer pair vector as the primary key index in the database;

[0104] After the question is embedded and saved, its corresponding answer is stored and used as the retrieval result to guide the output of the big data model in the retrieval enhancement generation process;

[0105] In a specific implementation, the vector representation of Q in the QA pair is obtained, and then the embedding and the corresponding A are stored in the vector database. A QA pair is:

[0106] Q: Why is coenzyme Q10 recommended for the prevention and treatment of atherosclerosis (over 76 years old)?

[0107] A: The reason for recommendation is to inhibit LDL oxidation and adhesion to blood vessels, and support vascular function and anti-aging.

[0108] Its representation in the ChromaDB (a vector database) vector database is shown in the following table:

[0109] Table 2 Storage format of data in ChromaDB vector database:

[0110] id Embed Recommended reason 1 [0.1,0.3,2.8…] The reason for recommendation is to inhibit LDL…

[0111] After the embedding of Q is saved, the corresponding A is also stored and used as the retrieval result to guide the output of LLM in the subsequent RAG process;

[0112] The key medical information in the sentence is integrated into its vector representation. By fusing entity-level and sentence-level embedding, the obtained sentence vector is more semantically rich.

[0113] In one specific embodiment, if Figure 4As shown, for Q in the QA pair, in addition to obtaining the embedding of its sentence, the present invention also extracts the medical entity therein and obtains the embedding of the entity. The medical entity in Q is extracted through the UIE (Universal Information Extraction) model of PaddleNLP (the natural language processing tool library in the Paddle ecosystem). The entity types include: part, disease, symptom and nutrient. For the sentence "Why is coenzyme Q10 recommended for atherosclerosis prevention and control (over 76 years old)?", the UIE model extracts the nutrient "coenzyme Q10"; next, the embedding of the entity is obtained through the word vector. The word vector model uses w2v.baidu_encyclopedia.target.word-character.char1-2.dim300 provided by PaddleNLP. The word vector comes from Baidu Encyclopedia. The vector length of each word is 300 dimensions. If there are multiple medical entities, the vectors of each medical entity are added and averaged as the final entity-level embedding. For the original sentence of Q, this method uses the sentence vector model all-mpnet-base-v2 (a vector model) to obtain its sentence-level embedding. Finally, the entity-level and sentence-level vectors are concat-connected to obtain the final vector representation of Q and store it in the vector database ChromaDB. In addition to saving the vector representation of the current Q, the vector database ChromaDB also saves the corresponding A.

[0114] S4. Query the vector database, store all question-answer pairs in the vector database, obtain user consultation information, and perform search and query on the vector database. The specific steps of S4 include:

[0115] S41. Obtaining a user query, and obtaining the queried medical entity from the vector database;

[0116] S42. Constructing a vector representation of the query entity level and sentence level through medical entities;

[0117] S43. Query the vector database.

[0118] S5. Construct user suggestions: send the vector representation to the vector database, match it with the embedded questions stored in the vector database through the cosine similarity algorithm, retrieve the most similar N (N ≥ 0) questions and return the corresponding answers. In step S5, the formula involved in the cosine similarity algorithm is:

[0119]

[0120] where qd i is the dot product of two vectors, which means the inner product between two vectors;

[0121] ||q|| and ||d i || are the moduli of the vectors, and are calculated as follows:

[0122]

[0123] The result value range is [-1,1], 1 means exactly the same, -1 means completely opposite, and 0 means no correlation;

[0124] For all D i , calculate the cosine similarity with Q and sort from high to low:

[0125] Rank(Q)=argsort([CosSim(q,d1),CosSim(q,d2),...]).

[0126] S6. Output the results, construct the user's query and the retrieved answer set into a prompt, output the results through the large language model, build a prompt based on the prompt template, submit it to the large language model (LLM), and use the LLM to generate more accurate nutrition answers, thereby improving the knowledge retrieval and generation capabilities in the field of medicine or nutrition. This method improves retrieval efficiency and accuracy, and enhances the scientificity and usability of the generated content.

[0127] like Figure 5 , the embodiment of the present invention includes a nutrition field retrieval enhancement generation device;

[0128] The device comprises: an external knowledge document collection module 101, which is used to collect knowledge related to the field of nutrition and organize it into an external document collection;

[0129] A question-answer pair set construction module 101 is used to convert an external document set into question-answer pairs, wherein the question-answer pairs include question-answer pairs formed by structured data knowledge and question-answer pairs formed by unstructured data knowledge;

[0130] The vector database storage module 103 is used to obtain the vector of the question of the question-answer pair, embed it into the vector, and store it together with the corresponding answer in the vector database;

[0131] The vector database query module 104 is used to store all question-answer pairs into the vector database, obtain user consultation information, and perform search and query on the vector database;

[0132] The user suggestion building module 105 is used to send the vector representation into the vector database, match it with the embedded questions stored in the vector database through the cosine similarity algorithm, retrieve the most similar N (N≥0) questions and return the corresponding answers;

[0133] The result output module 106 is used to construct a prompt from the user's query and the retrieved answer set, and output the result through the large language model.

[0134] On the other hand, the present invention further discloses a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the steps of the above method.

[0135] On the other hand, the present invention further discloses a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above method.

[0136] In another embodiment provided by the present application, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute any one of the nutrition field retrieval enhancement generation methods in the above embodiments.

[0137] It is understandable that the system provided by the embodiment of the present invention corresponds to the method provided by the embodiment of the present invention, and the explanation, examples and beneficial effects of the relevant contents can refer to the corresponding parts in the above method.

[0138] The embodiment of the present application also provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0139] Memory, used to store computer programs;

[0140] The processor is used to implement the above-mentioned nutrition field retrieval enhancement generation method when executing the program stored in the memory.

[0141] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc.

[0142] The communication interface is used for communication between the above electronic device and other devices.

[0143] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor, and more specific examples of the storage device (a non-exhaustive list) include: a portable disk connected with one or more wires, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0144] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, and discrete hardware components.

[0145] It should also be noted that electronic devices also include terminal devices, which can also be called terminals, user equipment (UE), mobile stations (MS), mobile terminals (MT), etc. Terminal devices can be mobile phones, smart TVs, wearable devices, tablet computers (Pad), computers with wireless transceiver functions, virtual reality (VR) terminal devices, augmented reality (AR) terminal devices, wireless terminals in industrial control, wireless terminals in self-driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, etc. The embodiments of the present application do not limit the specific technology and specific device form adopted by the terminal devices.

[0146] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

[0147] In addition, it should be noted that if the embodiments of the present invention involve directional indications (such as up, down, left, right, front, back, etc.), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components in a certain specific posture. If the specific posture changes, the directional indication will also change accordingly.

[0148] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present invention, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the meaning of "and / or" appearing in the full text includes three parallel schemes. Taking "A and / or B" as an example, it includes scheme A, or scheme B, or schemes that A and B meet at the same time. In addition, in the embodiments of the present invention, "multiple" refers to more than two. In addition, the technical solutions between the various embodiments can be combined with each other, but it must be based on the ability of ordinary technicians in the field to implement. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.

Claims

1. A method for enhancing the generation of nutrition-related retrieval, characterized in that: The specific steps include: S1. Collect external knowledge documents: Collect knowledge related to the field of nutrition and organize it into a collection of external documents; S2. Construct a set of question-answer pairs: convert the external document set into question-answer pairs, including question-answer pairs formed by structured data knowledge and question-answer pairs formed by unstructured data knowledge; S3. Storing the nutrition knowledge question and answer pair in the vector database, obtaining the vector of the question in the question and answer pair, embedding it into the answer vector in the question and answer pair, and using the embedded question and answer pair vector as the primary key index in the database; S4. Query the vector database: store all question-answer pairs in the vector database, obtain user consultation information, and perform search queries on the vector database; S5. Build user suggestions: send the vector representation into the vector database, match it with the embedded questions stored in the vector database through the cosine similarity algorithm, retrieve the most similar N (N≥0) questions and return the corresponding answers; S6. Output results: Construct the user's query and the retrieved answer set into prompts, and output the results through a large language model.

2. A method for enhancing the generation of nutrition domain retrieval according to claim 1, characterized in that: The external document collection in the S1 step includes unstructured data knowledge and structured data knowledge. The unstructured data knowledge is eventually converted into a txt format, and the structured data knowledge is eventually converted into source code.

3. A method for enhancing the generation of nutrition domain retrieval according to claim 1, characterized in that: The question-answer pairs formed by the unstructured data knowledge in step S2 are obtained by extracting from the abstract of the paper using a big data model, wherein the specific steps include: S21. First, obtain the abstracts of RCT papers, which all have the structural elements of objects, methods, and results; S22. Extract key information about population, intervention and results from RCT paper abstracts using a large language model; S23. Generate question-answer pairs based on the key information of population, intervention and outcome through high-level programming language tools; The high-level programming language tool is a Python language tool; Question-answer pairs formed by structured data knowledge are generated by directly applying templates.

4. A method for enhancing the generation of nutrition domain retrieval according to claim 1, characterized in that: In the S3 step, after the question is embedded and saved, its corresponding answer is stored, and it is used as a retrieval result to guide the output of the big data model during the retrieval enhancement generation process.

5. A method for enhancing the generation of nutrition domain retrieval according to claim 1, characterized in that: The method for querying the vector database in step S4 is: S41. Obtaining a user query, and obtaining the queried medical entity from the vector database; S42. Constructing a vector representation of the query entity level and sentence level through medical entities; S43. Query the vector database.

6. A method for enhancing the generation of nutrition domain retrieval according to claim 1, characterized in that: In step S5, the formula involved in the cosine similarity algorithm is: where qd i is the dot product of two vectors, which means the inner product between two vectors; ||q|| and ||d i || are the moduli of the vectors, respectively, and are calculated as: The result value range is [-1,1], 1 means exactly the same, -1 means completely opposite, and 0 means no correlation; For all D i , calculate the cosine similarity with Q and sort them from high to low: Rank(Q)=argsort([CosSim(q,d1),CosSim(q,d2),...]).

7. A method for enhancing the generation of nutrition domain retrieval according to claim 4, characterized in that: In step S3, the vector of the question of the question-answer pair is obtained, and then the vector is embedded, including the key medical information in the sentence being integrated into the vector for representation. By fusing the embedding at the entity level and the sentence level, the obtained sentence vector is semantically richer.

8. A nutrition field search enhancement generation system, characterized in that: include: The external knowledge document collection module is used to collect knowledge related to the nutrition field and organize it into an external document collection; A question-answer pair set construction module is used to convert an external document set into question-answer pairs, including question-answer pairs formed by structured data knowledge and question-answer pairs formed by unstructured data knowledge; A vector database storage module is used to obtain the vector of the question of the question-answer pair, embed it into the vector, and store it together with the corresponding answer in the vector database; The vector database query module is used to store all question-answer pairs into the vector database, obtain user consultation information, and perform search queries on the vector database; The user suggestion building module is used to send the vector representation into the vector database, match it with the embedded questions stored in the vector database through the cosine similarity algorithm, retrieve the most similar N (N ≥ 0) questions and return the corresponding answers; The result output module is used to construct the user's query and the retrieved answer set into prompts and output the results through the large language model.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 7.

10. A computer device comprising a memory and a processor, characterized in that: The memory stores a computer program, and when the computer program is executed by the processor, the processor executes the method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Multi-strategy fusion large model retrieval enhancement generation method

    CN121166867A