Language model training method and device based on semantic analysis and medium

CN119271700APending Publication Date: 2025-01-07MOBILE TECH COMPANY CHINA TRAVELSKY HLDG
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411390532.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-08
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

[0002]目前通过语言转换模型实现自然语言与sql语言的转换,传统的语言转换模型先将自然语言进行分析拆解,再根据传统的语言转换规则,对拆解得到的词组进行sql语言转换,即对词组直接进行语义转换,当需要转换的自然语言语句的语义过低时,经过sql语言转换得到的sql语言语句可能无法准确的表达转换前的自然语言语句的本意,因此,得到的sql语言语句可能存在表述不清的情况,对sql语言语句的后续应用造成影响

Benefits of technology

[0036] The language model training method based on semantic analysis of the present invention performs semantic analysis on each historical natural sentence to obtain several historical natural word segments included in each historical natural sentence, and then performs SQL language conversion on each historical natural word segmentation to obtain Get natural points for each history The historical initial SQL language segmentation corresponding to the word, and based on the segmentation character length and segmentation information entropy of each historical initial SQL language segmentation, the sentence character length and sentence information entropy corresponding to each historical natural sentence are obtained. If any historical natural sentence corresponds to The sentence character length and If the sentence information entropy meets the preset rewriting conditions, the historical natural sentence will be determined as the target historical natural sentence. According to the preset sentence rewriting rules, several historical initial SQL language segmentations corresponding to each target historical natural sentence will be rewritten. to get the history of each target since Several historical rewritten sql language segmentations corresponding to the natural sentences are input into the preset initial language model for training to obtain the target language. Model. By rewriting several historical initial sql language segmentations corresponding to the target historical natural sentences that meet the rewriting conditions, the semantics of the obtained historical rewritten sql language segmentations are richer than the semantics of the historical initial sql language segmentations before rewriting, which is convenient for sql language Convert.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271700A_ABST
    Figure CN119271700A_ABST
Patent Text Reader

Abstract

The invention provides a language model training method and device based on semantic analysis and a medium, and the method comprises the steps: carrying out the semantic analysis of a historical natural statement, so as to obtain a plurality of historical natural segmented words; performing sql language conversion on the historical natural segmented words to obtain historical initial sql language segmented words; if any historical natural statement meets the rewriting condition, determining the historical natural statement as a target historical natural statement; rewriting the historical initial sql language segmented words corresponding to the target historical natural statement to obtain historical rewritten sql language segmented words; and respectively inputting the plurality of historical initial sql language segmented words and the plurality of historical rewritten sql language segmented words corresponding to each target historical natural statement into an initial language model for training to obtain a target language model. By rewriting the plurality of historical initial sql language segmented words corresponding to the target historical natural statements meeting the rewriting conditions, the semantics of the obtained historical rewritten sql language segmented words are richer.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] At present, the conversion between natural language and SQL language is realized through language conversion model. The traditional language conversion model first analyzes and decomposes the natural language, and then converts the decomposed phrases into SQL language according to the traditional language conversion rules, that is, the phrases are directly semantically converted. When the semantics of the natural language sentence to be converted is too low, the SQL language sentence obtained after SQL language conversion may not accurately express the original meaning of the natural language sentence before conversion. Therefore, the obtained SQL language sentence may be unclear, which affects the subsequent application of the SQL language sentence. Summary of the invention

[0003] In view of the above technical problems, the technical solution adopted by the present invention is:

[0004] According to one aspect of the present application, a language model training method based on semantic analysis is provided, comprising the following steps:

[0005] Step S100, obtaining a number of historical natural sentences;

[0006] Step S200: performing semantic analysis on each historical natural sentence to obtain a number of historical natural participles included in each historical natural sentence;

[0007] Step S300: Perform SQL language conversion on each historical natural participle to obtain the historical initial SQL language participle corresponding to each historical natural participle;

[0008] Step S400, according to the word segmentation character length and word segmentation information entropy of each historical initial SQL language word segmentation, obtain the sentence character length and sentence information entropy corresponding to each historical natural sentence;

[0009] Step S500: If the sentence character length and sentence information entropy corresponding to any historical natural sentence both meet the preset rewriting conditions, then the historical natural sentence is determined as the target historical natural sentence;

[0010] Step S600: rewrite several historical initial SQL language participles corresponding to each target historical natural sentence according to a preset sentence rewriting rule to obtain several historical rewritten SQL language participles corresponding to each target historical natural sentence;

[0011] Step S700: Input a number of historical initial SQL language segmentations and a number of historical rewritten SQL language segmentations corresponding to each target historical natural sentence into a preset initial language model for training to obtain a target language model.

[0012] In an exemplary embodiment of the present application, step S200 includes:

[0013] Step S210: Perform semantic analysis on each historical natural sentence to obtain a number of historical natural word segments included in each historical natural sentence, so as to determine a historical natural word segmentation list set F = (F1, F2, ..., F r ,...,F s );F r =(F r1 ,F r2 ,...,F rt ,...,F ru(r) ), where r = 1, 2, ..., s, s is the number of historical natural sentences, F r is the list of historical natural word segments corresponding to the r-th historical natural sentence; t=1,2,...,u(r); ​​u(r) is the number of historical natural word segments included in the r-th historical natural sentence; F rt is the tth historical natural participle included in the rth historical natural sentence.

[0014] In an exemplary embodiment of the present application, step S300 includes:

[0015] Step S310: traverse each historical natural word in the historical natural word list set F, and rt Perform SQL language conversion to obtain F rt The corresponding historical initial SQL language segmentation G rt .

[0016] In an exemplary embodiment of the present application, step S400 includes:

[0017] Step S410: Obtain the word segmentation character length of each historical initial SQL language word segmentation corresponding to the rth historical natural sentence, and obtain the word segmentation character length list H corresponding to the rth historical natural sentence r =(H r1 ,H r2 ,...,H rt ,...,H ru(r) ), where H rt G rt The length of the word segmentation characters;

[0018] Step S420: Determine the sentence character length I corresponding to the rth historical natural sentence r =(∑ u(r) t=1 H rt ) / u(r);

[0019] Step S430: Obtain the word segmentation information entropy of each historical initial SQL language word segmentation corresponding to the rth historical natural sentence, and obtain the word segmentation information entropy list J corresponding to the rth historical natural sentencer =(J r1 ,J r2 ,...,J rt ,...,J ru(r) ), where J rt G rt The word segmentation information entropy;

[0020] Step S440: Determine the sentence information entropy R corresponding to the rth historical natural sentence r =(∑ u(r) t=1 J rt ) / u(r).

[0021] In an exemplary embodiment of the present application, step S500 includes:

[0022] Step S510: traverse the sentence information entropy corresponding to each historical natural sentence. If R r ≤R0, then execute step S520; wherein R0 is a preset information entropy threshold;

[0023] Step S520: If r ≤I0, the rth historical natural sentence is determined as the target historical natural sentence; where I0 is the preset character length threshold.

[0024] In an exemplary embodiment of the present application, step S600 includes:

[0025] Step S610, obtaining the rewrite identifier included in each historical initial SQL language segmentation corresponding to any target historical natural sentence;

[0026] Step S620: According to the preset statement rewriting rules corresponding to each rewriting identifier, the historical initial SQL language participle corresponding to the rewriting identifier is rewritten to obtain the historical rewritten SQL language participle corresponding to the historical initial SQL language participle; the information entropy of any historical rewritten SQL language participle is greater than the information entropy of the historical initial SQL language participle corresponding to the historical rewritten SQL language participle.

[0027] In an exemplary embodiment of the present application, step S510 further includes:

[0028] Step S511: If R r >R0, and I r >I0, the rth historical natural sentence is determined as the key historical natural sentence;

[0029] Step S512: abbreviate each historical initial SQL language segmentation corresponding to the key historical natural sentence according to a preset character abbreviation rule to obtain a number of historical rewritten SQL language segmentations corresponding to the key historical natural sentence; the character length of any historical rewritten SQL language segmentation is less than the character length of the historical initial SQL language segmentation corresponding to the historical rewritten SQL language segmentation;

[0030] Step S513: If the difference between the information entropy of each historical rewritten SQL language word corresponding to the key historical natural sentence and the information entropy of the historical initial SQL language word corresponding to the historical rewritten SQL language word is less than the preset information entropy difference threshold, then the key historical natural sentence is determined as the target historical natural sentence, and step S700 is executed.

[0031] In an exemplary embodiment of the present application, step S520 further includes:

[0032] Step S521: If r >I0, and MAX(H r ) corresponding to the historical initial SQL language word segmentation information entropy is less than R0, then MAX(H r ) The historical initial SQL language word segmentation corresponding to the rth historical natural sentence is deleted, and step S400 is executed.

[0033] According to one aspect of the present application, a non-transitory computer-readable storage medium is provided, in which at least one instruction or at least one program is stored, and the at least one instruction or the at least one program is loaded and executed by a processor to implement the aforementioned language model training method based on semantic analysis.

[0034] According to one aspect of the present application, an electronic device is provided, including a processor and the aforementioned non-transitory computer-readable storage medium.

[0035] The present invention has at least the following beneficial effects:

[0036] The language model training method based on semantic analysis of the present invention performs semantic analysis on each historical natural sentence to obtain a number of historical natural words included in each historical natural sentence, and then performs SQL language conversion on each historical natural word to obtain a historical initial SQL language word segmentation corresponding to each historical natural word, and obtains a sentence character length and sentence information entropy corresponding to each historical natural sentence according to the word segmentation character length and word segmentation information entropy of each historical initial SQL language word segmentation. If the sentence character length and sentence information entropy corresponding to any historical natural sentence meet the preset rewriting conditions, the historical natural sentence is determined as a target historical natural sentence, and according to the preset sentence rewriting rules, the several historical initial SQL language word segmentations corresponding to each target historical natural sentence are rewritten to obtain a number of historical rewritten SQL language word segmentations corresponding to each target historical natural sentence, and the several historical initial SQL language word segmentations and the several historical rewritten SQL language word segmentations corresponding to each target historical natural sentence are respectively input into a preset initial language model for training to obtain a target language model. By rewriting several historical initial SQL language word segments corresponding to the target historical natural sentences that meet the rewriting conditions, the semantics of the historical rewritten SQL language word segments are richer than the semantics of the historical initial SQL language word segments before rewriting, which facilitates the conversion of SQL language. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0038] Figure 1 A flowchart of a language model training method based on semantic analysis provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0039] 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, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0040] like Figure 1 As shown, the language model training method based on semantic analysis described in this application includes the following steps:

[0041] Step S100, obtaining a number of historical natural sentences;

[0042] Historical natural sentences are user question sentences written in natural language during a historical period.

[0043] Step S200: performing semantic analysis on each historical natural sentence to obtain a number of historical natural participles included in each historical natural sentence;

[0044] Semantic analysis is performed on each historical natural sentence to determine a number of historical natural participles that can express semantics in each historical natural sentence. Existing semantic analysis methods are used for the semantic analysis of natural sentences.

[0045] Further, step S200 includes step S210:

[0046] Step S210: Perform semantic analysis on each historical natural sentence to obtain a number of historical natural word segments included in each historical natural sentence, so as to determine a historical natural word segmentation list set F = (F1, F2, ..., F r ,...,F s );F r =(F r1 ,F r2 ,...,F rt ,...,F ru(r) ), where r = 1, 2, ..., s, s is the number of historical natural sentences, F r is the list of historical natural word segments corresponding to the r-th historical natural sentence; t=1,2,...,u(r); ​​u(r) is the number of historical natural word segments included in the r-th historical natural sentence; F rt is the tth historical natural participle included in the rth historical natural sentence.

[0047] Step S300: Perform SQL language conversion on each historical natural participle to obtain the historical initial SQL language participle corresponding to each historical natural participle;

[0048] Since most of the data in the current information database is stored in SQL language, it is necessary to convert the historical natural word segmentation of natural language into SQL language, and then integrate the historical initial SQL language segmentation corresponding to each historical natural word to get the corresponding SQL statement. Perform semantic analysis on each historical natural statement to get several historical natural word segmentations, and then convert each historical natural word into SQL. Compared with the method of directly converting historical natural statements into SQL, there is no need to convert segmentations with less semantics into SQL, which reduces the data processing amount of language conversion.

[0049] Further, step S300 includes step S310:

[0050] Step S310: traverse each historical natural word in the historical natural word list set F, and rt Perform SQL language conversion to obtain F rt The corresponding historical initial SQL language segmentation G rt .

[0051] Step S400, according to the word segmentation character length and word segmentation information entropy of each historical initial SQL language word segmentation, obtain the sentence character length and sentence information entropy corresponding to each historical natural sentence;

[0052] According to the conversion rules between natural language and SQL language, each historical natural word segmentation is converted into SQL to obtain the corresponding historical initial SQL language word segmentation.

[0053] Currently, in the conversion scenario between natural language and SQL language, it is usually used in user intelligent question and answer systems. Users input natural language question statements into the user intelligent question and answer system, and the user intelligent question and answer system converts the question statements into index conditions in SQL language, and then searches for corresponding retrieval data from the information database through the index conditions, and then converts the SQL language retrieval data into natural language answer statements and outputs them to the user.

[0054] The character length of the index condition is directly proportional to the index time and the computing power occupied by the index. Therefore, when indexing information, the longer the character length of the index condition, the greater the computing power occupied by the index and the longer the index time. Therefore, the character length of the index condition becomes a key factor in reducing the index time.

[0055] The word segmentation information entropy of the historical initial SQL language segmentation indicates the amount of information contained in the historical initial SQL language segmentation. The larger the information entropy, the more information is contained in the corresponding historical initial SQL language segmentation, that is, the more important the historical initial SQL language segmentation is when performing information indexing.

[0056] Therefore, after obtaining each historical initial SQL language word segmentation, its word segmentation character length and word segmentation information entropy are obtained to determine whether some historical initial SQL language word segmentations need to be corrected and adjusted.

[0057] Further, step S400 includes step S410-step S440:

[0058] Step S410: Obtain the word segmentation character length of each historical initial SQL language word segmentation corresponding to the rth historical natural sentence, and obtain the word segmentation character length list H corresponding to the rth historical natural sentence r =(H r1 ,H r2 ,...,H rt ,...,H ru(r)), where H rt G rt The length of the word segmentation characters;

[0059] Step S420: Determine the sentence character length I corresponding to the rth historical natural sentence r =(∑ u(r) t=1 H rt ) / u(r);

[0060] Step S430: Obtain the word segmentation information entropy of each historical initial SQL language word segmentation corresponding to the rth historical natural sentence, and obtain the word segmentation information entropy list J corresponding to the rth historical natural sentence r =(J r1 ,J r2 ,...,J rt ,...,J ru(r) ), where J rt G rt The word segmentation information entropy;

[0061] Step S440: Determine the sentence information entropy R corresponding to the rth historical natural sentence r =(∑ u(r) t=1 J rt ) / u(r).

[0062] Step S500: If the sentence character length and sentence information entropy corresponding to any historical natural sentence both meet the preset rewriting conditions, then the historical natural sentence is determined as the target historical natural sentence;

[0063] Further, step S500 includes step S510-step S520:

[0064] Step S510: traverse the sentence information entropy corresponding to each historical natural sentence. If R r ≤R0, execute step S520; otherwise, execute steps S511 to S513; wherein R0 is a preset information entropy threshold;

[0065] Step S511: If R r >R0, and I r >I0, the rth historical natural sentence is determined as the key historical natural sentence;

[0066] Step S512: abbreviate each historical initial SQL language word segment corresponding to the key historical natural sentence according to a preset character abbreviation rule to obtain a number of historical rewritten SQL language word segments corresponding to the key historical natural sentence;

[0067] The character length of any historical rewritten SQL language word segment is less than the character length of the historical initial SQL language word segment corresponding to the historical rewritten SQL language word segment.

[0068] Step S513: If the difference between the information entropy of each historical rewritten SQL language segment corresponding to the key historical natural sentence and the information entropy of the historical initial SQL language segment corresponding to the historical rewritten SQL language segment is less than a preset information entropy difference threshold, the key historical natural sentence is determined as the target historical natural sentence, and step S700 is executed;

[0069] Step S520: If r ≤I0, the rth historical natural sentence is determined as the target historical natural sentence, and step S600 is executed; otherwise, step S521 is executed; wherein I0 is a preset character length threshold;

[0070] Step S521: If r >I0, and MAX(H r ) corresponding to the historical initial SQL language word segmentation information entropy is less than R0, then MAX(H r ) The historical initial SQL language word segmentation corresponding to the rth historical natural sentence is deleted, and step S400 is executed.

[0071] The preset rewriting condition is determined by the sentence information entropy and sentence character length of each historical natural sentence, and it is judged whether the sentence information entropy and sentence character length of each historical natural sentence are greater than the corresponding preset thresholds.

[0072] If the sentence information entropy and sentence character length of the historical natural sentence are both greater than their respective corresponding preset thresholds, it means that the historical natural sentence is semantically rich but the character length is too long, and it needs to be abbreviated to shorten its character length. Then, it is determined whether the difference between the information entropy of the historical rewritten SQL language word segmentation obtained after abbreviation and the information entropy of the historical initial SQL language word segmentation before abbreviation is too large. If it is less than the preset information entropy difference threshold, it means that the historical rewritten SQL language word segmentation after abbreviation does not lose much semantic information compared to the historical initial SQL language word segmentation before abbreviation, and the character length is also shortened. Therefore, the key historical natural sentence composed of it is determined as the target historical natural sentence.

[0073] If the sentence information entropy of the historical natural sentence is greater than the information entropy threshold, and the sentence character length is less than or equal to the character length threshold, it means that the historical natural sentence is semantically rich and short in character length. Since it has little impact on the indexing time and has too much semantic information, there is no need to rewrite it.

[0074] If the sentence information entropy of the historical natural sentence is less than or equal to the information entropy threshold, and the sentence character length is greater than the character length threshold, it means that the historical natural sentence has less semantic information and the character length is too long, which means that the historical natural sentence has little impact on the entire indexing process, but will extend the indexing time. Therefore, it is determined whether the information entropy of the historical initial SQL language segmentation with the longest character length in the historical natural sentence is less than the information entropy threshold. If it is less than the information entropy threshold, it means that the historical initial SQL language segmentation has little impact on the semantic understanding of the entire historical natural sentence. Therefore, it is deleted to reduce the data processing volume of the index. If the information entropy of the historical initial SQL language segmentation with the longest character length in the historical natural sentence is greater than the information entropy threshold, it means that the information content of the historical initial SQL language segmentation is relatively rich, and it will not be rewritten.

[0075] Step S600: rewrite several historical initial SQL language participles corresponding to each target historical natural sentence according to a preset sentence rewriting rule to obtain several historical rewritten SQL language participles corresponding to each target historical natural sentence;

[0076] Further, step S600 includes step S610-step S620:

[0077] Step S610, obtaining the rewrite identifier included in each historical initial SQL language segmentation corresponding to any target historical natural sentence;

[0078] Step S620: rewrite the historical initial SQL language participle corresponding to each rewrite identifier according to the preset statement rewriting rule corresponding to the rewrite identifier to obtain the historical rewritten SQL language participle corresponding to the historical initial SQL language participle;

[0079] The information entropy of any historical rewritten SQL language segmentation is greater than the information entropy of the historical initial SQL language segmentation corresponding to the historical rewritten SQL language segmentation.

[0080] If the sentence information entropy and sentence character length of the historical natural sentence are both less than or equal to their respective corresponding preset thresholds, it means that the historical natural sentence has less semantic information and a shorter character length. Due to its short character length, even if it is deleted, it will not cause a significant increase in the indexing speed. It needs to be rewritten to improve its information entropy. The rewriting rules are obtained based on the developer's rewriting statistics of historical sentences. The developer rewrites the historical sentences and obtains a rewriting information table based on the statistics. The rewriting information table stores each word segmentation identifier before and after the rewrite, as well as the corresponding rewriting rules. The corresponding rewriting rules are determined from the rewriting information table through the rewriting identifier included in the historical initial SQL language word segmentation, and are rewritten to make the information meaning of the rewritten word segmentation richer, so as to improve the accuracy of the index.

[0081] Step S700: Input a number of historical initial SQL language segmentations and a number of historical rewritten SQL language segmentations corresponding to each target historical natural sentence into a preset initial language model for training to obtain a target language model.

[0082] The language model training method based on semantic analysis of the present invention performs semantic analysis on each historical natural sentence to obtain a number of historical natural words included in each historical natural sentence, and then performs SQL language conversion on each historical natural word to obtain a historical initial SQL language word segmentation corresponding to each historical natural word, and obtains a sentence character length and sentence information entropy corresponding to each historical natural sentence according to the word segmentation character length and word segmentation information entropy of each historical initial SQL language word segmentation. If the sentence character length and sentence information entropy corresponding to any historical natural sentence meet the preset rewriting conditions, the historical natural sentence is determined as a target historical natural sentence, and according to the preset sentence rewriting rules, the several historical initial SQL language word segmentations corresponding to each target historical natural sentence are rewritten to obtain a number of historical rewritten SQL language word segmentations corresponding to each target historical natural sentence, and the several historical initial SQL language word segmentations and the several historical rewritten SQL language word segmentations corresponding to each target historical natural sentence are respectively input into a preset initial language model for training to obtain a target language model. By rewriting several historical initial SQL language word segments corresponding to the target historical natural sentences that meet the rewriting conditions, the semantics of the historical rewritten SQL language word segments are richer than the semantics of the historical initial SQL language word segments before rewriting, which facilitates the conversion of SQL language.

[0083] An embodiment of the present invention further provides a computer program product, which includes program code. When the program product is run on an electronic device, the program code is used to enable the electronic device to execute the steps of the method according to various exemplary embodiments of the present invention described above in this specification.

[0084] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0085] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0086] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.

[0087] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".

[0088] The electronic device according to this embodiment of the present invention is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0089] The electronic device is presented in the form of a general-purpose computing device. The components of the electronic device may include, but are not limited to: the at least one processor mentioned above, the at least one storage device mentioned above, and a bus connecting different system components (including storage devices and processors).

[0090] The storage stores program codes, which can be executed by the processor, so that the processor executes the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification.

[0091] The memory may include readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory, and may further include read only memory (ROM).

[0092] The storage may also include a program / utility having a set (at least one) of program modules, such program modules including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include the implementation of a network environment.

[0093] The bus may represent one or more of several types of bus structures including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures.

[0094] The electronic device may also communicate with one or more external devices (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device, and / or any device that enables the electronic device to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface. Furthermore, the electronic device may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter.

[0095] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0096] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.

[0097] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, 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 of the above.

[0098] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0099] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0100] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).

[0101] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0102] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0103] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A language model training method based on semantic analysis, characterized in that: The method comprises the following steps: Step S100, obtaining a number of historical natural sentences; Step S200: performing semantic analysis on each of the historical natural sentences to obtain a number of historical natural participles included in each of the historical natural sentences; Step S300: performing SQL language conversion on each of the historical natural participles to obtain historical initial SQL language participles corresponding to each of the historical natural participles; Step S400, obtaining the sentence character length and sentence information entropy corresponding to each of the historical natural sentences according to the word segmentation character length and word segmentation information entropy of each of the historical initial SQL language word segmentations; Step S500: If the sentence character length and sentence information entropy corresponding to any of the historical natural sentences satisfy the preset rewriting conditions, the historical natural sentence is determined as the target historical natural sentence; Step S600: rewrite several historical initial SQL language participles corresponding to each of the target historical natural sentences according to a preset sentence rewriting rule, so as to obtain several historical rewritten SQL language participles corresponding to each of the target historical natural sentences; Step S700: Input a plurality of historical initial SQL language segmentations and a plurality of historical rewritten SQL language segmentations corresponding to each of the target historical natural sentences into a preset initial language model for training to obtain a target language model.

2. The method according to claim 1, characterized in that The step S200 includes: Step S210: semantically analyze each of the historical natural sentences to obtain a number of historical natural word segments included in each of the historical natural sentences, so as to determine a historical natural word segmentation list set F = (F1, F2, ..., F r ,...,F s );F r =(F r1 ,F r2 ,...,F rt ,...,F ru(r) ), where r = 1, 2, ..., s, s is the number of historical natural sentences, F r is a list of historical natural word segments corresponding to the r-th historical natural sentence; t=1, 2, ..., u(r); ​​u(r) is the number of historical natural word segments included in the r-th historical natural sentence; F rt It is the tth historical natural participle included in the rth historical natural sentence.

3. The method according to claim 2, characterized in that The step S300 includes: Step S310: traverse each historical natural word in the historical natural word list set F, and rt Perform SQL language conversion to obtain F rt The corresponding historical initial SQL language segmentation G rt .

4. The method according to claim 3, characterized in that: The step S400 includes: Step S410: Obtain the word segmentation character length of each historical initial SQL language word segmentation corresponding to the rth historical natural sentence, and obtain the word segmentation character length list H corresponding to the rth historical natural sentence. r =(H r1 ,H r2 ,...,H rt ,...,H ru(r) ), where H rt G rt The length of the word segmentation characters; Step S420: Determine the sentence character length I corresponding to the rth historical natural sentence r =(∑ u(r) t=1 H rt ) / u(r); Step S430: Obtain the word segmentation information entropy of each of the historical initial SQL language word segments corresponding to the rth historical natural sentence, and obtain the word segmentation information entropy list J corresponding to the rth historical natural sentence r =(J r1 ,J r2 ,...,J rt ,...,J ru(r) ), where J rt G rt The word segmentation information entropy; Step S440: Determine the sentence information entropy R corresponding to the rth historical natural sentence r =(∑ u(r) t=1 J rt ) / u(r).

5. The method according to claim 4, characterized in that The step S500 includes: Step S510: traverse the sentence information entropy corresponding to each of the historical natural sentences. If R r ≤R0, then execute step S520; wherein R0 is a preset information entropy threshold; Step S520: If r ≤I0, the rth historical natural sentence is determined as the target historical natural sentence; wherein I0 is a preset character length threshold.

6. The method according to claim 5, characterized in that The step S600 includes: Step S610, obtaining a rewrite identifier included in each historical initial SQL language word segmentation corresponding to any of the target historical natural sentences; Step S620: According to the preset statement rewriting rules corresponding to each rewriting identifier, the historical initial SQL language participle corresponding to the rewriting identifier is rewritten to obtain the historical rewritten SQL language participle corresponding to the historical initial SQL language participle; the information entropy of any of the historical rewritten SQL language participles is greater than the information entropy of the historical initial SQL language participle corresponding to the historical rewritten SQL language participle.

7. The method according to claim 5, characterized in that The step S510 further includes: Step S511: If R r >R0, and I r >I0, the rth historical natural sentence is determined as a key historical natural sentence; Step S512: abbreviate each historical initial SQL language segmentation corresponding to the key historical natural sentence according to a preset character abbreviation rule to obtain a plurality of historical rewritten SQL language segmentations corresponding to the key historical natural sentence; the character length of any of the historical rewritten SQL language segmentations is less than the character length of the historical initial SQL language segmentation corresponding to the historical rewritten SQL language segmentation; Step S513: If the difference between the information entropy of each historical rewritten SQL language word corresponding to the key historical natural sentence and the information entropy of the historical initial SQL language word corresponding to the historical rewritten SQL language word is less than a preset information entropy difference threshold, then the key historical natural sentence is determined as the target historical natural sentence, and step S700 is executed.

8. The method according to claim 5, characterized in that The step S520 further includes: Step S521: If r >I0, and MAX(H r ) corresponding to the historical initial SQL language word segmentation information entropy is less than R0, then MAX(H r ) The historical initial SQL language word segmentation corresponding to the rth historical natural sentence is deleted, and step S400 is executed.

9. A non-transitory computer-readable storage medium, wherein at least one instruction or at least one program is stored in the storage medium, characterized in that: The at least one instruction or the at least one program is loaded and executed by the processor to implement the language model training method based on semantic analysis as described in any one of claims 1-8.

10. An electronic device, characterized in that: The invention comprises a processor and the non-transitory computer-readable storage medium as claimed in claim 9.