Qwen2-7b model intelligent service method and system based on dynamic hierarchical fine tuning

Through the application of dynamic hierarchical fine-tuning methods on the Qwen2-7B model, combined with the knowledge information in the professional database, the existing systems are inaccurate in the inaccurate knowledge of complex professional knowledge and case answers, and the efficient and accurate knowledge consulting services have been achieved.

CN119358677APending Publication Date: 2025-01-24KAITUO INFORMATION SYST
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411498352.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-25
Publication Date
2025-01-24

Smart Images

  • Figure CN119358677A_ABST
    Figure CN119358677A_ABST
Patent Text Reader

Abstract

The invention discloses a Qwen2-7b model intelligent service method and system based on dynamic level fine tuning, and relates to the field of knowledge consultation. The method comprises the following steps: acquiring professional knowledge information data in a professional database; extracting text information therein and performing structured processing to obtain a professional knowledge text with a uniform format; preprocessing the professional knowledge text to obtain a language material; training the Qwen2-7b model by using a language material, and performing fine tuning on the Qwen2-7b model by applying a dynamic hierarchical fine tuning method in a training period; and after training of the Qwen2-7b model is finished, when a question text is received, reasoning the question text by using the trained Qwen2-7b model to obtain an answer text, and exporting the answer text. The technical effects of the application are that the system can efficiently extract and associate professional knowledge information from a rich knowledge base, provide real-time and accurate consultation service, and meet the urgent demand of a user for knowledge consultation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of knowledge consulting, and in particular to a Qwen2-7b model intelligent service method and system based on dynamic hierarchical fine-tuning. Background Art

[0002] The Qwen2-7B model is a powerful open source large model released by the Alibaba Tongyi Qianwen team. It is a medium-sized model in the Qwen2 series. Dynamic layer fine-tuning refers to optimization by dynamically selecting the layers that need fine-tuning based on the pre-trained model. Model intelligent service refers to the use of advanced models and algorithms combined with artificial intelligence technology to provide users with intelligent and efficient services.

[0003] With the continuous advancement of social progress and the rapid development of informatization and intelligence, the demand for knowledge consulting services is increasing. Although the existing knowledge question-and-answer system has tried to introduce some intelligent algorithms, it is difficult for users to obtain comprehensive and accurate information when dealing with complex professional knowledge and cases. For example, in the medical field, when asking about the diagnosis and treatment of a specific disease, it may involve complex factors such as the patient's medical history, genetic background, existing symptoms and lifestyle. Simple answers may not take into account individual differences, resulting in inaccurate advice. Therefore, under the existing technology, when it comes to complex professional knowledge and cases, the answers given by the knowledge question-and-answer system are incomplete and inaccurate. Summary of the invention

[0004] In order to better provide intelligent answers to professional knowledge questions, this application provides a Qwen2-7b model intelligent service method and system based on dynamic hierarchical fine-tuning.

[0005] In the first aspect, the present application provides a Qwen2-7b model intelligent service method based on dynamic level fine-tuning, which adopts the following technical solution: the method comprises:

[0006] Obtain professional knowledge information data from professional databases;

[0007] Extracting text information of the professional knowledge information data, and performing structured processing on the text information to obtain professional knowledge text in a unified format;

[0008] Preprocessing the professional knowledge text to obtain language materials, wherein the preprocessing includes removing redundant information of the professional knowledge text and standardizing the professional knowledge text;

[0009] Using the language material to train the Qwen2-7b model, and applying a dynamic hierarchical fine-tuning method to fine-tune the Qwen2-7b model during a training cycle;

[0010] After the training of the Qwen2-7b model is completed, when a question text is received, the trained Qwen2-7b model is used to infer the question text to obtain an answer text, and the answer text is exported.

[0011] Through the above technical solution, by comprehensively reading the professional knowledge in the professional database, rich relevant professional knowledge information can be efficiently extracted from the knowledge base, such as special terms and court judgments in the legal field, professional knowledge and treatment cases in the medical field, etc., and real-time and accurate consulting services can be provided through the trained Qwen2-7b model to meet users' urgent needs for knowledge consulting, thereby promoting the sustainable development and intelligent process of knowledge consulting services.

[0012] In a specific possible implementation scheme, the text information is structured to obtain a professional knowledge text in a unified format, including:

[0013] Use the natural language processing tool spaCy to perform named entity recognition to obtain entity sets, each of which contains entities of the same type;

[0014] Standardizing all the entities in each of the entity sets to obtain professional knowledge texts in a unified format;

[0015] The formula for named entity recognition is:

[0016] E={e1,e2,…,e n}

[0017] Where E represents the identified entity set, e i Represents the i-th entity.

[0018] Through the above technical solution, text information is processed in advance, the format of text information of the same category is unified, and system operation errors are reduced, making the efficiency higher.

[0019] In a specific implementation scheme, the preprocessing of the professional knowledge text to obtain the language material includes:

[0020] Use regular expressions to remove extra punctuation and spaces in the professional knowledge text;

[0021] The professional knowledge text is represented by calculating a word frequency vector, and the professional knowledge text is segmented and tagged with parts of speech to obtain a language material;

[0022] The formula for representing the professional knowledge text by calculating the word frequency vector is:

[0023] V={f1,f2,…,f n}

[0024] Among them, V represents the set of recognized entities, f i represents the i-th entity.

[0025] Through the above technical solution, redundant punctuation and spaces are removed to achieve the purpose of removing redundant information and standardization. The text is converted into a text vector by calculating the word frequency vector to represent the text. Since the text vector of the input model needs to have a unified dimension, this also achieves standardization. Through preprocessing, the training of the Qwen2-7b model is more efficient.

[0026] In a specific implementation scheme, the fine-tuning of the Qwen2-7b model by applying the dynamic level fine-tuning method during the training cycle includes:

[0027] At the beginning of the training cycle, according to the probability distribution P(L i ) The result is to randomly select a set of layers as the selected layers for fine-tuning, where L i is the i-th layer of the model;

[0028] Dynamically weighting the output features of the selected layer;

[0029] Randomly activate a certain proportion of neurons;

[0030] When the training cycle is over, check whether the loss function exceeds the threshold;

[0031] If the loss function does not exceed the threshold, it is determined that the Qwen2-7b model training is completed;

[0032] Otherwise, increase the fine-tuning level or adjust the feature weights and retrain the Qwen2-7b model.

[0033] Through the above technical solution, the Qwen2-7b model is fine-tuned by applying the dynamic hierarchical fine-tuning method, which can improve the flexibility and efficiency of training while maintaining the model performance.

[0034] In a specific embodiment, the probability distribution P(L i ) is generated by:

[0035]

[0036] Among them, α i is a dynamic parameter related to the importance of the level, and N is the number of model layers;

[0037] The dynamically adjusting the weight of the output features of the selected layer comprises:

[0038] Dynamically adjust the weight of the output feature of the selected layer according to the adjusted neuron weight of the selected layer;

[0039] The adaptive adjustment formula of the neuron weights of the selected layer is:

[0040] W i,j =W i,j ·(1+β·grad(L))

[0041] Among them, W i,j is the weight of the jth neuron in the i-th layer, β is the learning rate adjustment factor, and grad(L) is the gradient of the loss function with respect to the output of this layer;

[0042] The randomly activating a certain proportion of neurons includes:

[0043] Randomly activate a certain proportion of neurons according to the probability of neuron activation;

[0044] The calculation formula of the neuron activation probability is:

[0045]

[0046] Where γ is the adjustment factor, x is the feature strength of the current sample, and μ is the feature mean;

[0047] The loss function is:

[0048]

[0049] Among them, y i is the true label, is the model's predicted value.

[0050] In a specific implementation scheme, the use of the trained Qwen2-7b model to infer the question text to obtain the answer text includes:

[0051] Extract keywords and context information from the question text to form input data X;

[0052] The trained Qwen2-7b model performs inference based on the input data X to obtain the answer vector Y, and the calculation process is:

[0053]

[0054] Where (P(Y|X) represents the conditional probability of outputting the answer vector Y given the input X;

[0055] The answer vector Y is decoded using a decoder to obtain the answer text.

[0056] Through the above technical solution, the question text is converted into input data, reasoning is performed to obtain the answer vector, and encryption is performed to generate the answer text. After a series of processing, the model can run normally and understand the question text. The exported answer text is in a form that the user can understand and analyze.

[0057] In a specific implementation scheme, the use of the trained Qwen2-7b model to infer the question text to obtain the answer text also includes:

[0058] The question text, the answer text and the relevant information used for the Qwen2-7b model solution are stored in the professional database to update the professional database;

[0059] The Qwen2-7b model intelligent service method based on dynamic level fine-tuning also includes:

[0060] The professional database is monitored in real time. When the professional database is updated, the language material is updated through Web Scraping and information extraction technology, and the Qwen2-7b model is retrained.

[0061] Through the above technical solutions, professional databases can be detected in real time, language materials can be updated dynamically, the latest knowledge information can be reflected in a timely manner, and users can be provided with instant and accurate consulting services, promoting the intelligent and sustainable development of services.

[0062] In the second aspect, the present application provides a Qwen2-7b model intelligent service system based on dynamic level fine-tuning, which adopts the following technical solution: the system includes:

[0063] A data reading module is used to obtain professional knowledge information data in a professional database;

[0064] A data structuring processing module, used to extract text information of the professional knowledge information data, perform structural processing on the text information, and obtain professional knowledge text in a unified format;

[0065] A text preprocessing module, which preprocesses the professional knowledge text to obtain language materials, wherein the preprocessing includes removing redundant information of the professional knowledge text and standardizing the professional knowledge text;

[0066] A model training and fine-tuning module, which uses the language material to train the Qwen2-7b model, and applies a dynamic hierarchical fine-tuning method to fine-tune the Qwen2-7b model during a training cycle;

[0067] After the Qwen2-7b model training is completed, the model application module uses the trained Qwen2-7b model to infer the question text to obtain the answer text when receiving the question text, and then exports the answer text.

[0068] In a third aspect, the present application provides a computer device that adopts the following technical solution: it includes a memory and a processor, and the memory stores a computer program that can be loaded by the processor and executes the Qwen2-7b model intelligent service method based on dynamic level fine-tuning as described above.

[0069] In a fourth aspect, the present application provides a computer-readable storage medium, which adopts the following technical solution: storing a computer program that can be loaded by a processor and execute the above-mentioned Qwen2-7b model intelligent service method based on dynamic level fine-tuning.

[0070] In summary, this application has the following beneficial technical effects:

[0071] This application integrates large language models, knowledge engineering and knowledge graph technology. By collecting a wide range of relevant professional knowledge data sources and performing structured processing and natural language analysis, the system can understand user intentions in real time, provide targeted consulting answers, and efficiently and accurately answer users' relevant professional questions. In particular, this system uses a dynamic hierarchical fine-tuning method to enhance the model's understanding and reasoning ability of problems, ensuring the accuracy and timeliness of relevant professional knowledge. In addition, the system also has adaptive update capabilities, can dynamically update the knowledge base, and promptly reflect the latest knowledge information. This intelligent service system can be widely used in multiple fields, providing users with instant and accurate consulting services, and promoting the intelligent and sustainable development of services. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] Figure 1 It is a flow chart of the Qwen2-7b model intelligent service method based on dynamic level fine-tuning in an embodiment of the present application.

[0073] Figure 2 It is a schematic diagram of the Qwen2-7b model intelligent service method based on the dynamic level fine-tuning method in an embodiment of the present application.

[0074] Figure 3 It is a schematic diagram of the dynamic level fine-tuning method in an embodiment of the present application.

[0075] Figure 4 It is a structural block diagram of the Qwen2-7b model intelligent service system based on the dynamic level fine-tuning method in the embodiment of the present application.

[0076] Figure numerals: 401, data reading module; 402, data structuring processing module; 403, text preprocessing module; 404, model training and fine-tuning module; 405, model application module. DETAILED DESCRIPTION

[0077] The following is combined with Figure 1 - Provide further details of this application.

[0078] The embodiment of the present application discloses a Qwen2-7b model intelligent service method based on dynamic level fine-tuning, which is used to answer users' relevant professional questions.

[0079] The Qwen2-7B model is a powerful open source large model released by the Alibaba Tongyi Qianwen team. It is a medium-sized model in the Qwen2 series. Dynamic layer fine-tuning refers to optimization by dynamically selecting the layers that need fine-tuning based on the pre-trained model. Model intelligent service refers to the use of advanced models and algorithms combined with artificial intelligence technology to provide users with intelligent and efficient services.

[0080] With the continuous advancement of social progress and the rapid development of informatization and intelligence, the demand for knowledge consulting services is increasing. The current knowledge consulting systems mostly rely on manual or simple search engines, which leads to a long and costly answering process. In addition, when dealing with diverse legal issues, there are often limitations such as lack of understanding and untimely feedback.

[0081] Although the existing knowledge question-and-answer system has been improved and some intelligent algorithms have been introduced, it is difficult for users to obtain comprehensive and accurate information when dealing with complex professional knowledge and cases. For example, in the medical field, when asking about the diagnosis and treatment of a specific disease, it may involve complex factors such as the patient's medical history, genetic background, existing symptoms and lifestyle. Simple answers may not take into account individual differences, resulting in inaccurate suggestions. Therefore, under the existing technology, when it comes to complex professional knowledge and cases, the answers given by the knowledge question-and-answer system are incomplete and inaccurate.

[0082] Therefore, this application proposes a Qwen2-7b model intelligent service method based on dynamic hierarchical fine-tuning to answer users' relevant professional questions.

[0083] like Figure 1 and Figure 2 As shown, the method specifically comprises the following steps:

[0084] S10, obtaining professional knowledge information data in a professional database.

[0085] Specifically, the professional database is mainly composed of two parts, one is the existing knowledge base such as Westlaw, LexisNexis, etc., and the other is a private knowledge database. The professional knowledge information data is obtained by first obtaining the ID and URL of all professional documents in the professional database, and then crawling the professional knowledge information data according to the ID and URL of the document, which ensures the integrity of the professional knowledge information data. The professional knowledge information data mainly includes professional knowledge data and professional case data. When crawling data, API interface and web crawler technology are used. The crawler can crawl data that cannot be accessed by the API interface, making the acquired professional knowledge information data extensive and continuous.

[0086] S20, extracting text information of the professional knowledge information data, and performing structured processing on the text information to obtain professional knowledge text in a unified format.

[0087] Specifically, to obtain professional knowledge information data, we must first extract the text information therein. Text information is easier to process, such as structuring the messy text information to obtain professional knowledge text with a unified format, such as the date is uniformly expressed in the YYYY-MM-DD format.

[0088] S30, preprocessing the professional knowledge text to obtain language materials, wherein the preprocessing includes removing redundant information of the professional knowledge text and standardizing the professional knowledge text.

[0089] Specifically, the structured professional knowledge text achieves a unified format for the same type of knowledge text, but the professional knowledge text still needs to be preprocessed before it can be used to train the model. The preprocessing mainly includes removing redundant information from the professional knowledge text and standardizing the professional knowledge text.

[0090] S40, uses language materials to train the Qwen2-7b model, and applies the dynamic hierarchical fine-tuning method to fine-tune the Qwen2-7b model during the training cycle.

[0091] Specifically, the Qwen2-7b model is trained based on the acquired and processed language materials. During the training cycle, the dynamic hierarchical fine-tuning method is used to fine-tune the Qwen2-7b model to obtain a Qwen2-7b model that can solve professional problems related to language materials.

[0092] S50, after the Qwen2-7b model training is completed, when a question text is received, the trained Qwen2-7b model is used to infer the question text to obtain the answer text, and the answer text is exported.

[0093] Specifically, after the Qwen2-7b model training is completed, the model is mature and put into use. When receiving the user's question text, the trained Qwen2-7b model performs reasoning and calculation based on the question text, obtains the answer text through calculation decoding and other processes, and exports the answer text as feedback to the user.

[0094] This application system integrates large language models, knowledge engineering and knowledge graph technologies, as well as a unique dynamic hierarchical fine-tuning method, and can efficiently and accurately answer users' relevant professional questions. By collecting a wide range of relevant professional knowledge data sources, and performing structured processing and natural language analysis, the system can understand user intentions in real time and provide targeted consulting answers.

[0095] In one embodiment, considering that the acquired professional knowledge information data is in the initial data format, directly using the messy initial data to train the Qwen2-7b model may cause obstacles and the system may be difficult to run. For example, when designing the date format, the time format is YYYY-MM-DD or YYYY / MM / DD. If the format is not unified, two formats may appear when the system recognizes the date, which is not conducive to system operation.

[0096] In order to facilitate the smooth operation of the system, the text information is structured to obtain professional knowledge text in a unified format. This step can be specifically performed as follows:

[0097] First, use the natural language processing tool spaCy to perform named entity recognition to obtain entity sets. Each entity set contains entities of the same type. Specifically, taking the legal field as an example, using spaCy to perform named entity recognition on the relevant text information in the extracted legal documents mainly includes two parts: the first part identifies entities and takes specific entities in the text, such as the names of laws and regulations, the parties to the case, the date of the case, etc.; the second part labels the identified entities according to categories. Each entity set obtained contains entities of the same type. Then, all entities in each entity set are standardized to obtain professional knowledge text with a unified format. Specifically, if each entity in the entity set of the case date is the specific date of the case, where the date format mainly includes two types: YYYY-MM-DD and YYYY / MM / DD, the entity set of the case date is standardized, and all formats are uniformly expressed as YYYY-MM-DD. The formula for named entity recognition is:

[0098] E={e1,e2,…,e n}

[0099] Among them, E represents the set of identified entities, e i represents the i-th entity.

[0100] Unify the format of text information of the same category to reduce system operation errors and make the system more efficient.

[0101] In one embodiment, the step of preprocessing the professional knowledge text to obtain the language material may be specifically performed as follows:

[0102] First, regular expressions are used to remove redundant punctuation and spaces in the professional knowledge text. Specifically, redundant spaces usually refer to multiple consecutive spaces. Redundant punctuation may include repeated punctuation or some unnecessary punctuation. Removing redundant punctuation and spaces can be achieved by writing appropriate regular expressions. This step not only removes redundant information but also realizes part of standardization. Then, the professional knowledge text is represented by calculating the word frequency vector, and the professional knowledge text is segmented and tagged to obtain language materials. Specifically, the word frequency vector is a text representation method that counts the frequency of each word in the text. The steps of calculating the word frequency vector to represent the professional knowledge text are to build a vocabulary, count the word frequency, and then build the word frequency vector; word segmentation is the process of dividing a continuous text sequence into individual words, and part of speech tagging is to determine the part of speech in the text for each word, such as noun, verb, adjective, etc. Using the word frequency vector to represent the professional knowledge text, segmenting and tagging the professional knowledge text is a common text processing method in the field of NLP. It is implemented in the system using the relevant functions in Pytorch, and the steps realize the standardization of the professional knowledge text. The above steps are processed to obtain the language material for training the Qwen2-7b model.

[0103] The formula for calculating the word frequency vector to represent professional knowledge text is:

[0104] V={f1,f2,…,f n}

[0105] Among them, V represents the set of recognized entities, f i represents the i-th entity.

[0106] In one embodiment, in order to enhance the model's understanding and reasoning ability of the problem, Figure 3 , the step of fine-tuning the Qwen2-7b model using the dynamic level fine-tuning method during the training cycle can be specifically performed as follows:

[0107] First, at the beginning of the training cycle, according to the probability distribution P(L i ) The result is to randomly select a set of layers as the selected layers for fine-tuning, where L i is the i-th layer of the model. Specifically, dynamic layer fine-tuning will not adjust all layers, so it involves the problem of selecting layers. This application first calculates the probability distribution P(L i ), where L iFor the i-th layer of the model, a set of layers are randomly selected as the selected layers for fine-tuning according to the results, where the probability distribution P(L i ) is generated by:

[0108]

[0109] Among them, α i It is a dynamic parameter related to the importance of the level, and N is the number of model layers.

[0110] Then, the output features of the selected layer are dynamically weighted. Specifically, after selecting the layer, the expected weight that the top layer wants to be adjusted to is calculated first, and then the existing weight is dynamically adjusted to the expected weight. The adaptive adjustment formula of the neuron weight of the selected layer is:

[0111] W i,j =W i,j ·(1+β·grad(L))

[0112] Among them, W i,j is the weight of the jth neuron in the i-th layer, β is the learning rate adjustment factor, and grad(L) is the gradient of the loss function with respect to the output of this layer.

[0113] Next, a certain proportion of neurons are randomly activated. Specifically, in each training iteration, a certain proportion of neurons are randomly activated according to the probability of neuron activation to increase the robustness of the model so that the Qwen2-7b model remains stable during fine-tuning. The calculation formula for the probability of neuron activation is:

[0114]

[0115] Where γ is the adjustment factor, x is the feature strength of the current sample, and μ is the feature mean.

[0116] Finally, when the training cycle is over, check whether the loss function exceeds the threshold. If the loss function does not exceed the threshold, the Qwen2-7b model training is judged to be over. Otherwise, increase the fine-tuning level or adjust the feature weights, and retrain the Qwen2-7b model. Specifically, when the training cycle is over, the criterion for whether the trained Qwen2-7b model can be put into use is whether the loss function exceeds the threshold. If the loss function does not exceed the threshold, the performance of the Qwen2-7b model meets the requirements, and the Qwen2-7b model training is judged to be over and put into use; if the loss function exceeds the threshold, the performance of the Qwen2-7b model does not meet the requirements, and it is necessary to increase the fine-tuning level or adjust the feature weights, and retrain the Qwen2-7b model. The calculation formula of the loss function is:

[0117]

[0118] Among them, y i is the true label, is the model's predicted value.

[0119] It should be noted that the number of retraining here is not infinite. If the threshold is set too low, the loss function always exceeds the threshold. Infinite retraining may cause model failure. Set a limit on the number of retraining. If the training is not completed within the limit, adjust the standard according to the actual situation.

[0120] A dynamic hierarchical fine-tuning method is adopted to enhance the model's understanding and reasoning ability of problems, achieve accurate identification and intelligent answers to knowledge problems, and provide instant and accurate information services to the public and professionals.

[0121] In one embodiment, the step of using the trained Qwen2-7b model to infer the question text to obtain the answer text can be specifically performed as follows:

[0122] First, extract the keywords and context information in the question text to form the input data X. Specifically, since the question text is colloquial and the information is messy, the Qwen2-7b model cannot directly reason about the question text and extract the keywords and context information in the question text to form the input data X.

[0123] Then, the trained Qwen2-7b model performs inference based on the input data X to obtain the answer vector Y. Specifically, the trained Qwen2-7b model is used to infer the input data X, and the answer vector Y is first obtained through inference calculation. The calculation process is:

[0124]

[0125] Where (P(Y|X) represents the conditional probability of outputting the answer vector Y given the input X;

[0126] Finally, the decoder is used to decode the answer vector Y to obtain the answer text. Specifically, the answer vector Y cannot be directly displayed to the user and is not in a form that the user can normally understand. The decoder is used to decode the answer vector Y to obtain the answer text.

[0127] The question text is converted into input data, and the answer vector is obtained through reasoning. The answer text can then be generated through encryption. After a series of processing, the model can run normally and understand the question text. The exported answer text is in a form that the user can understand and analyze.

[0128] In one embodiment, in order to reflect the latest knowledge information and provide users with instant and accurate consulting services, after using the trained Qwen2-7b model to perform reasoning to obtain the answer text, the following steps can also be performed:

[0129] The question text, answer text and related information used in answering the Qwen2-7b model are saved in a professional database to update the professional database. Specifically, answering users' questions is also a professional-related case. After the answer is completed, the question text, answer text and related information used in answering the Qwen2-7b model are saved in a professional database. In this case, it is usually saved in a private knowledge database to update the professional database.

[0130] The Qwen2-7b model intelligent service method based on dynamic level fine-tuning can also be specifically implemented as follows:

[0131] Real-time monitoring of professional databases. When professional databases are updated, the language materials are updated through Web Scraping and information extraction technology, and the Qwen2-7b model is retrained. Specifically, in addition to the above-mentioned update methods: saving the question text, answer text, and related information used by the Qwen2-7b model to answer in the professional database to update the professional database, it also includes the following update methods: existing knowledge bases such as Westlaw, LexisNexis, etc. are updated. For example, in terms of relevant legal knowledge, laws will be updated, new legal documents will be released, and the existing knowledge base will be updated accordingly. When real-time monitoring of professional database updates, the updated content is captured through Web Scraping and information extraction technology, extracted as new language materials, added to the original language materials, the language materials are updated, and then the Qwen2-7b model is retrained to provide users with instant and accurate consulting services.

[0132] Based on the above method, the embodiment of the present application also discloses a Qwen2-7b model intelligent service system based on dynamic level fine-tuning. Figure 4 The system includes the following modules:

[0133] The data reading module 401 is used to obtain professional knowledge information data in the professional database;

[0134] The data structured processing module 402 is used to extract text information of the professional knowledge information data, perform structured processing on the text information, and obtain professional knowledge text in a unified format;

[0135] A text preprocessing module 403 preprocesses the professional knowledge text to obtain language materials, wherein the preprocessing includes removing redundant information of the professional knowledge text and standardizing the professional knowledge text;

[0136] A model training and fine-tuning module 404 is used to train the Qwen2-7b model using language materials, and to fine-tune the Qwen2-7b model using a dynamic hierarchical fine-tuning method during a training cycle;

[0137] After the Qwen2-7b model training is completed, the model application module 405 uses the trained Qwen2-7b model to infer the question text to obtain the answer text when receiving the question text, and then exports the answer text.

[0138] In one embodiment, the data structured processing module 402 is specifically used to use the natural language processing tool spaCy to perform named entity recognition to obtain entity sets, each entity set contains entities of the same type; all entities in each entity set are standardized to obtain professional knowledge text in a unified format; the formula for named entity recognition is:

[0139] E={e1,e2,…,e n}

[0140] Among them, E represents the set of identified entities, e i represents the i-th entity.

[0141] In one embodiment, the text preprocessing module 403 is specifically used to remove redundant punctuation and spaces in the professional knowledge text by using regular expressions; the professional knowledge text is represented by calculating the word frequency vector, and the professional knowledge text is segmented and POS tagged to obtain the language material; the formula for representing the professional knowledge text by calculating the word frequency vector is:

[0142] V={f1,f2,…,f n}

[0143] Among them, V represents the set of recognized entities, f i represents the i-th entity.

[0144] In one embodiment, the model training fine-tuning module 404 is specifically configured to, at the beginning of a training cycle, adjust the model training fine-tuning module 404 according to the probability distribution P(L i ) The result is to randomly select a set of layers as the selected layers for fine-tuning, where L i The i-th layer of the model; dynamically adjust the weights of the output features of the selected layer; randomly activate a certain proportion of neurons; when the training cycle is over, check whether the loss function exceeds the threshold. If the loss function does not exceed the threshold, the Qwen2-7b model training is judged to be over, otherwise increase the fine-tuning level or adjust the feature weights, and retrain the Qwen2-7b model.

[0145] In one embodiment, the model training fine-tuning module 404 is specifically used for probability distribution P(L i) is generated by:

[0146]

[0147] Among them, α i is a dynamic parameter related to the importance of the level, and N is the number of model layers;

[0148] Dynamically adjust the weight of the output features of the selected layer according to the adjusted neuron weights of the selected layer;

[0149] The adaptive adjustment formula of the neuron weights of the selected layer is:

[0150] W i,j =W i,j ·(1+β·grad(L))

[0151] Among them, W i,j is the weight of the jth neuron in the i-th layer, β is the learning rate adjustment factor, and grad(L) is the gradient of the loss function with respect to the output of this layer;

[0152] Randomly activate a certain proportion of neurons according to the probability of neuron activation;

[0153] The calculation formula for the probability of neuron activation is:

[0154]

[0155] Where γ is the adjustment factor, x is the feature strength of the current sample, and μ is the feature mean;

[0156] The loss function is calculated as:

[0157]

[0158] Among them, y i is the true label, is the model's predicted value.

[0159] In one embodiment, the model application module 405 is specifically used to extract keywords and context information from the question text to form input data X;

[0160] The trained Qwen2-7b model performs inference based on the input data X and obtains the answer vector Y. The calculation process is:

[0161]

[0162] Where (P(Y|X) represents the conditional probability of outputting the answer vector Y given the input X;

[0163] Use the decoder to decode the answer vector Y to get the answer text.

[0164] In one embodiment, the model application module 405 is specifically used to save the question text, answer text and related information used by the Qwen2-7b model to answer in a professional database to update the professional database; monitor the professional database in real time, and when the professional database is updated, update the language material through Web Scraping and information extraction technology, and retrain the Qwen2-7b model.

[0165] The embodiment of the present application also discloses a computer device.

[0166] Specifically, the computer device includes a memory and a processor, and the memory stores a computer program that can be loaded by the processor and execute the above-mentioned Qwen2-7b model intelligent service method based on dynamic level fine-tuning.

[0167] The embodiment of the present application also discloses a computer-readable storage medium.

[0168] Specifically, the computer-readable storage medium stores a computer program that can be loaded by a processor and execute the Qwen2-7b model intelligent service method based on dynamic level fine-tuning as described above. The computer-readable storage medium includes, for example: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

Claims

1. Qwen2-7b model intelligent service method based on dynamic level fine-tuning, characterized in that: The method is based on the Qwen2-7b model, and the method comprises: Obtain professional knowledge information data from professional databases; Extracting text information of the professional knowledge information data, and performing structured processing on the text information to obtain professional knowledge text in a unified format; Preprocessing the professional knowledge text to obtain language materials, wherein the preprocessing includes removing redundant information of the professional knowledge text and standardizing the professional knowledge text; Using the language material to train the Qwen2-7b model, and applying a dynamic hierarchical fine-tuning method to fine-tune the Qwen2-7b model during a training cycle; After the training of the Qwen2-7b model is completed, when a question text is received, the trained Qwen2-7b model is used to infer the question text to obtain an answer text, and the answer text is exported.

2. The method according to claim 1, characterized in that: The structural processing of the text information to obtain a professional knowledge text in a unified format includes: Use the natural language processing tool spaCy to perform named entity recognition to obtain entity sets, each of which contains entities of the same type; Standardizing all the entities in each of the entity sets to obtain professional knowledge texts in a unified format; The formula for named entity recognition is: E}{e1,e2,…,e n } Where E represents the identified entity set, e i Represents the i-th entity.

3. The method according to claim 1, characterized in that: The preprocessing of the professional knowledge text to obtain the language material comprises: Use regular expressions to remove extra punctuation and spaces in the professional knowledge text; The professional knowledge text is represented by calculating a word frequency vector, and the professional knowledge text is segmented and tagged with parts of speech to obtain a language material; The formula for representing the professional knowledge text by calculating the word frequency vector is: V={f1,f2,…,f n } Among them, V represents the set of recognized entities, f i represents the i-th entity.

4. The method according to claim 1, characterized in that: The step of applying the dynamic level fine-tuning method to fine-tune the Qwen2-7b model during the training cycle includes: At the beginning of the training cycle, according to the probability distribution P(L i ) The result is to randomly select a set of layers as the selected layers for fine-tuning, where L i is the i-th layer of the model; Dynamically weighting the output features of the selected layer; Randomly activate a certain proportion of neurons; When the training cycle is over, check whether the loss function exceeds the threshold; If the loss function does not exceed the threshold, it is determined that the Qwen2-7b model training is completed; Otherwise, increase the fine-tuning level or adjust the feature weights and retrain the Qwen2-7b model.

5. The method according to claim 4, characterized in that: The probability distribution P(L i ) is generated by: Among them, α i is a dynamic parameter related to the importance of the level, and N is the number of model layers; The dynamically weighting the output features of the selected layer comprises: Dynamically adjust the weight of the output feature of the selected layer according to the adjusted neuron weight of the selected layer; The adaptive adjustment formula of the neuron weights of the selected layer is: IN i,j =In i,j (1+β·grad(L)) Among them, W i,j is the weight of the jth neuron in the i-th layer, β is the learning rate adjustment factor, and grad(L) is the gradient of the loss function with respect to the output of this layer; The randomly activating a certain proportion of neurons includes: Randomly activate a certain proportion of neurons according to the probability of neuron activation; The calculation formula of the neuron activation probability is: Where γ is the adjustment factor, x is the feature strength of the current sample, and μ is the feature mean; The loss function is: Among them, y i is the true label, is the model's predicted value.

6. The method according to claim 1, characterized in that: The method of using the trained Qwen2-7b model to infer the question text to obtain the answer text includes: Extract keywords and context information from the question text to form input data X; The trained Qwen2-7b model performs inference based on the input data X to obtain the answer vector Y, and the calculation process is: Where (P(Y|X) represents the conditional probability of outputting the answer vector Y given the input X; The answer vector Y is decoded into answer text using a decoder.

7. The method according to claim 1, characterized in that: After the trained Qwen2-7b model is used for reasoning to obtain the answer text, the method further includes: The question text, the answer text and the relevant information used for the Qwen2-7b model solution are stored in the professional database to update the professional database; The Qwen2-7b model intelligent service method based on dynamic level fine-tuning also includes: The professional database is monitored in real time. When the professional database is updated, the language material is updated through Web Scraping and information extraction technology, and the Qwen2-7b model is retrained.

8. Qwen2-7b model intelligent service system based on dynamic level fine-tuning, characterized by: The system comprises: A data reading module (401) is used to obtain professional knowledge information data in a professional database; A data structuring processing module (402) is used to extract text information of the professional knowledge information data, perform structural processing on the text information, and obtain professional knowledge text in a unified format; A text preprocessing module (403) preprocesses the professional knowledge text to obtain language materials, wherein the preprocessing includes removing redundant information of the professional knowledge text and standardizing the professional knowledge text; A model training and fine-tuning module (404) is used to train the Qwen2-7b model using the language material, and to fine-tune the Qwen2-7b model using a dynamic hierarchical fine-tuning method during a training cycle; The model application module (405) uses the trained Qwen2-7b model to infer the question text to obtain the answer text when receiving the question text after the Qwen2-7b model training is completed, and then exports the answer text.

9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program which can be loaded by the processor and executes the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: A computer program is stored which can be loaded by a processor and execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Mineral knowledge question answering method and system based on large language model

    CN118193708A

  • Pre-trained language model fine-tuning method and apparatus and non-transitory computer-readable medium

    EP4020305A1