WO2024027252A1 - 静态网页的生成方法、生成装置、电子设备及存储介质 - Google Patents

静态网页的生成方法、生成装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2024027252A1
WO2024027252A1 PCT/CN2023/092756 CN2023092756W WO2024027252A1 WO 2024027252 A1 WO2024027252 A1 WO 2024027252A1 CN 2023092756 W CN2023092756 W CN 2023092756W WO 2024027252 A1 WO2024027252 A1 WO 2024027252A1
Authority
WO
WIPO (PCT)
Prior art keywords
web page
static web
model
natural language
generation model
Prior art date
Application number
PCT/CN2023/092756
Other languages
English (en)
French (fr)
Inventor
郑悦闻
李青
李鹏飞
王飞
Original Assignee
杭州未名信科科技有限公司
浙江省北大信息技术高等研究院
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 杭州未名信科科技有限公司, 浙江省北大信息技术高等研究院 filed Critical 杭州未名信科科技有限公司
Publication of WO2024027252A1 publication Critical patent/WO2024027252A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces

Definitions

  • the present application relates to the field of computer technology, and specifically to a static web page generation method, generation device, electronic equipment and storage medium.
  • front-end In website development projects, the front-end often uses various technologies or frameworks such as HTML, CSS, and JavaScript to create front-end interfaces such as web pages or APPs. By reading HTML and other files through a web browser, a visual web page can be obtained for user interface browsing. and interact with.
  • HTML HyperText Markup Language
  • APPs JavaScript
  • front-end frameworks By reading HTML and other files through a web browser, a visual web page can be obtained for user interface browsing. and interact with.
  • cross-platform responsive web design have brought users an extremely high user experience.
  • the process of generating static web pages is relatively complex, with low degree of automation, heavy workload for professionals, and low work efficiency.
  • a method for generating a static web page including:
  • the static web page generation model is a Transformer-based model.
  • inputting the static web page and the newly received natural language text description instruction into the static web page generation model to obtain an updated static web page includes:
  • the method before using the trained static web page generation model to process the initial static web page source code and the received natural language text description instructions, the method further includes:
  • the initial static web page generation model is trained using the data set until the preset training completion condition is reached, and the pre-trained static web page generation model is obtained.
  • obtaining a data set for training an initial static web page generation model includes:
  • the data set is composed of all corresponding data.
  • obtaining the data set for training the initial static web page generation model further includes:
  • obtaining a data set for training an initial static web page generation model further includes:
  • the data set is randomly divided into a training set, a test set and a verification set according to a preset proportion;
  • the training set is used to train the initial static web page generation model
  • the verification set is used to verify the training effect
  • the test set is used to test the accuracy of the model after training
  • the preset training completion condition includes that the accuracy of the model after training reaches a preset accuracy threshold.
  • building a sequence-to-sequence initial static web page generation model based on Transformer includes:
  • the Transformer model consists of an encoder and a decoder connected to each other.
  • a device for generating a static web page including:
  • the initial static web page source code processing module is used to use the pre-trained static web page generation model to process the initial static web page source code and the received natural language text description instructions, and output the static web page;
  • a static web page generation module configured to repeatedly input the static web page and the newly received natural language text description instructions into the static web page generation model to obtain an updated static web page until no more new natural language text descriptions are received. Until the instructions are executed, the final static web page is obtained;
  • the static web page generation model is a Transformer-based model.
  • an electronic device including a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor executes the program, To implement the above static web page generation method.
  • a computer-readable storage medium on which a computer program is stored, and the program is executed by a processor to implement the above static web page generation method.
  • the method for generating static web pages can generate static web pages according to natural language instructions, use a model based on Seq2Seq to convert natural language instructions into static web pages, and can automatically generate static web pages quickly and at low cost, and generate static web pages.
  • the process is relatively simple and highly automated. It improves the development efficiency of professionals, reduces the workload, and improves work efficiency.
  • Figure 1 shows a flow chart of a static web page generation method according to the first embodiment of the present application.
  • Figure 2 shows a flow chart of a static web page generation method according to the second embodiment of the present application.
  • Figure 3 shows a flow chart of a static web page generation method according to the third embodiment of the present application.
  • Figure 4 shows the Text2SWeP model architecture diagram in an example of this application.
  • Figure 5 shows a schematic diagram of the source code of a static web page in an example of this application.
  • Figure 6 shows a schematic diagram of the processing result of line break removal from static web page source code in an example of this application.
  • Figure 7 shows a schematic diagram of the connection and completion of static web page source code and update instructions in an example of this application.
  • Figure 8 shows a schematic diagram of static web page updating in an example of this application.
  • Figure 9 shows a structural block diagram of a static web page generating device according to the fourth embodiment of the present application.
  • Figure 10 shows a structural block diagram of an electronic device according to the fifth embodiment of the present application.
  • Figure 11 shows a schematic diagram of a computer-readable storage medium according to the sixth embodiment of the present application.
  • Seq2Seq has highly abstract features and can be applied to a variety of serialized natural language processing tasks, such as machine translation, reply generation, speech recognition and other tasks. Because generating static web pages based on natural language can be seen as a process from the original sequence to the target sequence, the emergence of the Seq2Seq model based on deep learning makes it possible to generate static web pages through natural language. Natural language processing technology is used to convert natural language into static web pages, so that non-practitioners can easily design web pages, while improving the front-end development efficiency of practitioners.
  • the embodiment of this application proposes a static web page generation method based on the Seq2Seq deep learning model, which is used to solve the problem in the existing technology that non-practitioners cannot simply design web pages, and at the same time solve the problem of non-practitioners using some existing online designs.
  • the website has limited elements or controls when designing web pages.
  • the workload of front-end development is large and prototype development is time-consuming and laborious.
  • the embodiments of this application mainly use the Seq2Seq model for training, so that the model can generate static web pages based on natural language, and use natural language processing technology based on Seq2Seq to convert natural language text into static web pages.
  • the embodiment of this application aims at the existing technology problems of heavy front-end development workload and high technical barriers to entry for non-professionals.
  • a model for generating static web pages based on natural language is trained, and static web page sources are extracted based on this model.
  • Code features and corresponding natural language text description features are used to generate static web pages through the Seq2Seq model and apply the model.
  • the natural language text is converted into static web pages using natural language processing technology based on Seq2Seq to improve the development efficiency of professionals and Lower the entry barrier for non-professionals.
  • the first embodiment of the present application provides a method for generating static web pages, including:
  • S20 Repeatedly input the static web page and the newly received natural language text description instructions into the static web page generation model to obtain the updated static web page, until no new natural language text description instructions are received, and the final static web page is obtained;
  • the static web page generation model is a Transformer-based model.
  • the static web page and the newly received natural language text description instructions are input into the static web page generation model to obtain an updated static web page, including:
  • S202 Use the static web page generation model to add, delete and/or modify the source code of the static web page according to the newly received natural language text description instructions to obtain the processed static web page;
  • S203 Use the processed static web page to update the static web page before processing to obtain an updated static web page.
  • the method before S10, the method further includes:
  • obtaining a data set for training an initial static web page generation model includes:
  • the method of reorganizing the multiple description instructions corresponding to the above multiple blocks is:
  • each static web page source code is, ⁇ (t 1 ,w 1 ),(w 1 +t 2 ,w 1 +w 2 ),(w 1 +w 2 +t 3 ,w 1 +w 2 +w 3 )...,(w 1 +...+w n-1 +t n ,w 1 +...+w n-1 +w n ) ⁇ , where "+” is a string Splicing, a piece of data within each "()" is a piece of data input to the model, the ",” in front of "()” is the input feature value of the model, and the ",” is the input label value of the model. .
  • obtaining the data set for training the initial static web page generation model further includes: removing line breaks from the text used for model input in the data set. Character processing; add [CLS] symbols at the beginning of the text used for model input and [SEP] symbols at the end; set the maximum input text length of the BERT model to the maximum length; if the text used for model input is less than the maximum length , then use the [PAD] symbol to perform the padding operation to obtain the preprocessed text for model input.
  • obtaining a data set for training an initial static web page generation model further includes: randomly dividing the data set into a training set, a test set and a verification set according to a preset proportion; the training set is used to train the initial static web page generation model, the validation set is used to verify the training effect, and the test set is used to test the accuracy of the model after training; among them, the preset training completion conditions include that the accuracy of the model after training reaches the preset accuracy threshold.
  • building a sequence-to-sequence initial static web page generation model based on Transformer includes:
  • the Transformer model consists of interconnected encoders and decoders.
  • the method for generating static web pages provided by the embodiments of the present application can generate static web pages based on natural language instructions and use a model based on Seq2Seq to convert the natural language instructions into static web pages. It can generate static web pages quickly and at low cost, which improves the efficiency of professionals. Development efficiency reduces workload and improves work efficiency.
  • the second embodiment of the present application provides a static web page generation method, which includes:
  • step S1 may include:
  • step S2 includes:
  • the newly added BERT dictionary includes all commonly used tags for static web pages to prevent tags from being split during word segmentation.
  • step S3 includes:
  • the first round of input is blank static web page source code and user natural language description instructions
  • the output is static web page source code generated according to the instructions.
  • the model input after the first round is the static web page source code generated in the previous round and the new natural language description instructions, and the output is the static web page source code updated according to the new natural language description instructions.
  • the natural language description instructions can include three types of instructions: adding, deleting, and modifying the source code of the static web page, and finally obtaining a static web page that meets the user's requirements.
  • the method for generating static web pages can generate static web pages based on natural language instructions, use a model based on Seq2Seq to convert natural language instructions into static web pages, and can automatically generate static web pages quickly and at low cost, with a high degree of automation. It improves the development efficiency of professionals, reduces the workload, and improves work efficiency.
  • the third embodiment of the present application provides a method for generating a static web page, which includes the following steps:
  • Step S101 Obtain the source code of the static web page and the corresponding natural language text description, collect a data set, and obtain a training set.
  • the embodiment of this application needs to first obtain the source code of the static web page, and read the source code of the static web page through the browser to obtain the presentation effect of the static web page. Finally, based on the presentation of the static web page, accurate manual annotation and correspondence with the static web page are performed. Natural language processing text description.
  • the source code of the static web page can be collected through page crawling technology to obtain M pieces of static web page data.
  • each collected static web page source code needs to be split block by block to obtain N blocks, and N text descriptions corresponding to the N blocks are obtained.
  • the size of the N value is determined by the number of blocks that can be split into each static web page source code.
  • each static web page source code is, ⁇ (t 1 ,w 1 ),(w 1 +t 2 ,w 1 +w 2 ),(w 1 +w 2 +t 3 ,w 1 +w 2 +w 3 )...,(w 1 +...+w n-1 +t n ,w 1 +...+w n-1 +w n ) ⁇ , where "+” is a string Splicing, a piece of data within each "()" is a piece of data input to the model, the ",” in front of "()” is the input feature value of the model, and the ",” is the input label value of the model. .
  • the data set generated by M static web page source codes is obtained from the above steps, and multiple rounds of new instructions in actual application scenarios are simulated. In addition, it is also necessary to simulate instructions for deletion and modification in actual application scenarios. For each static web page source code, multiple modifications are added based on the original new instructions. Modify and delete instructions, update the corresponding source code according to the instructions, and incorporate this part of the data into the data set.
  • the trained model can not only add web page elements, but also be deleted and modified by users.
  • the user's instructions are that based on the generated static web page, the user can use natural language text description to express the places that need to be modified, added, or deleted, that is, to propose new instructions to further update various elements of the static web page. .
  • multiple rounds means that the user can update the generated static web page multiple times to achieve the final desired presentation effect.
  • a partitioned data set of M static web page source codes is obtained. Divide the data set and randomly divide it into a training set, a test set, and a verification set according to proportion.
  • Step S102 Construct a sequence-to-sequence encoding and decoding model.
  • This step mainly consists in building a Seq2Seq model, which is used to input the user's multiple rounds of instructions and the generated static web page code, and output the generated static web page code.
  • the Seq2Seq model is a Transformer-based model, and the model structure can be seen in Figure 4.
  • the Transformer model consists of an encoder and a decoder.
  • the encoder is stacked by multiple blocks.
  • a block is composed of Multi-Head Attention, Add&Norm, Feed Forward, and Add&Norm in sequence.
  • the main difference between the decoder and the encoder is that an additional Encoder-Decoder Attention layer is used in the decoder block.
  • the number of heads of Multi-Head Attention can be 12
  • the dimension H of the word vector is 768
  • the size of Feed Forward is set to 4H, that is, 3072.
  • Data preprocessing includes:
  • the preprocessed input natural language description annotated text needs to be segmented into words.
  • the schematic diagram of the static web page source code is shown in Figure 5.
  • the result of line break removal processing of the static web page source code is shown in Figure 6.
  • the schematic diagram of the connection and completion of the static web page source code and the update command is shown in Figure 7.
  • new tokens are added to the dictionary of the BERT model, including all tags of static web pages such as HTML and CSS, such as ⁇ tr>, ⁇ /tr>, ⁇ style>, ⁇ /style>, etc., to avoid the problem of word segmentation.
  • tags of static web pages such as HTML and CSS, such as ⁇ tr>, ⁇ /tr>, ⁇ style>, ⁇ /style>, etc.
  • Step S103 Construct the loss function and measurement index, and train the Seq2Seq model.
  • This step mainly involves inputting the processed sequence into the model for training, calculating the model error based on the loss function, and continuously adjusting the model training parameters to achieve convergence of the model.
  • the loss function may use cross-entropy.
  • WordPiece tokenizier to tokenize the input text to obtain tokens.
  • the word embedding is obtained using the embedding layer of BERT.
  • the word embedding consists of the symbol embedding layer Token Embedding, the segment embedding layer Segmentation Embedding, and the position embedding layer Position Embedding.
  • the symbol embedding layer converts tokens into fixed-dimensional vectors.
  • each token is represented by an H-dimensional vector after passing through the symbol embedding layer. Finally, a tensor with shape (Max Length,H) is obtained. In a feasible embodiment, H is the dimension 768 of the word vector.
  • the fragment embedding layer uses two vector values to distinguish two sentences within tokens.
  • the fragment embedding value of tokens before the first [SEP] tag of tokens is 0, and the rest is 1. Finally, a tensor with shape (Max Length,H) is obtained.
  • the position embedding layer records the sequence attributes of the input text.
  • the position embedding layer is a lookup table of size (Max Length, H).
  • the first row is the vector representation of any token at the first position, and the rest are analogous.
  • the mask is 1, and for the padded one, the mask is 0.
  • Add can use Residual Connection to pass the information to the next layer without any difference, and effectively focus on the different parts.
  • Norm normalizes the activation values of the layer to accelerate model convergence, and finally obtains a tensor with a shape of (B, h, Max Length, H/h).
  • the difference between the input to the decoder after the encoding is completed and the Self-Attention in the encoder is that when the decoder does Encoder-Decoder Attention, Q comes from the decoder, and K and V come from the final output of the encoder.
  • a floating-point vector is obtained from the decoder, and the vector is input into the linear layer and connected to a Softmax layer.
  • the linear layer is a simple fully connected neural network that projects vectors onto a higher dimensional vector.
  • the Softmax layer converts the vector into probability, selects the dimension with the highest probability, and obtains the corresponding token according to the index number and outputs it until the last identifier ⁇ eos> symbol is predicted.
  • the source code sequence of the static web page generated by the decoder is obtained.
  • the purpose of the metric is to measure the error between the static web page output by the decoder and the real static web page.
  • the measurement index can be TEDS evaluation index, the formula of which is:
  • Step S104 Generate the final static web page according to the user's multiple rounds of instructions.
  • This step mainly involves testing and applying the optimal model, and generating the final static web page based on multiple rounds of user instructions.
  • the data input to the model are blank static web page source codes and the user's first natural language description text.
  • the first round of model generation results in generated static web pages. If the user needs to update a static web page, the generated static web page and the user's natural language text description are input into the model again, and the updated static web page output by the model is obtained, that is, a round of update is completed.
  • a schematic diagram of the update process please refer to Figure 8. shown.
  • the embodiment of this application uses the deep learning model of Seq2Seq to train the Text2SWeP model. Finally, static web pages can be generated based on natural language to obtain visual web page effects.
  • the embodiment of this application proposes the Text2SWeP (Text to Static Web Page) model.
  • the embodiment of this application breaks the technical barriers of non-professionals and lowers the threshold of web design, so that non-professionals can Without prior knowledge, customized static web pages can be designed using only natural language.
  • Non-professionals are no longer limited by the limited number of web page elements or components that can be created for online design websites.
  • the embodiments of the present application can also reduce the workload of front-end development, improve the efficiency of development and design, accelerate the speed of prototype design, and reduce the cost of front-end development.
  • the fourth embodiment of the present application provides a device for generating static web pages, including:
  • the initial static web page source code processing module is used to use the pre-trained static web page generation model to process the initial static web page source code and the received natural language text description instructions, and output the static web page;
  • Static web page generation module used to repeatedly execute static web pages and newly received natural language text This description instruction is input into the static web page generation model to obtain the updated static web page, until no new natural language text description instructions are received, and the final static web page is obtained;
  • the static web page generation model is a Transformer-based model.
  • the static web page generation module executes inputting the static web page and the newly received natural language text description instructions into the static web page generation model to obtain the updated static web page, including:
  • the device further includes a pre-training module for obtaining the username before the initial static web page source code processing module uses the trained static web page generation model to process the initial static web page source code and the received natural language text description instructions.
  • obtaining a data set for training an initial static web page generation model includes:
  • the data set is composed of all corresponding data.
  • obtaining the data set for training the initial static web page generation model also includes:
  • obtaining a data set for training an initial static web page generation model further includes:
  • the training set is used to train the initial static web page generation model
  • the validation set is used to verify the training effect
  • the test set is used to test the accuracy of the model after training
  • the preset training completion conditions include that the model accuracy after training reaches the preset accuracy threshold.
  • building a sequence-to-sequence initial static web page generation model based on Transformer includes:
  • the Transformer model consists of interconnected encoders and decoders.
  • the static web page generation device can generate static web pages according to natural language instructions, use a model based on Seq2Seq to convert the natural language instructions into static web pages, and can automatically generate static web pages quickly and at low cost, with a high degree of automation. It improves the development efficiency of professionals, reduces the workload, and improves work efficiency.
  • the fifth embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor.
  • the processor executes the program to implement the static state of any of the above embodiments. Web page generation method.
  • the electronic device 10 may include: a processor 100, a memory 101, a bus 102 and a communication interface 103.
  • the processor 100, the communication interface 103 and the memory 101 are connected through the bus 102; the memory 101 stores information available in the processor.
  • a computer program running on the computer 100 When the processor 100 runs the computer program, the method provided by any of the foregoing embodiments of the application is executed.
  • the memory 101 may include high-speed random access memory (RAM: Random Access Memory), or may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
  • RAM Random Access Memory
  • non-volatile memory such as at least one disk memory.
  • communication interface 103 which can be wired or wireless
  • the communication connection between the system network element and at least one other network element can use the Internet, wide area network, local network, metropolitan area network, etc.
  • the bus 102 may be an ISA bus, a PCI bus, an EISA bus, etc.
  • the bus can be divided into address bus, data bus, control bus, etc.
  • the memory 101 is used to store a program, and the processor 100 executes the program after receiving the execution instruction.
  • the method disclosed in any of the embodiments of the present application can be applied to the processor 100 or implemented by the processor 100 .
  • the processor 100 may be an integrated circuit chip with signal processing capabilities. During the implementation process, each step of the above method can be completed by instructions in the form of hardware integrated logic circuits or software in the processor 100 .
  • the above-mentioned processor 100 can be a general-purpose processor, which can include a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; it can also be a digital signal processor (DSP), a dedicated integrated processor Circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • DSP digital signal processor
  • ASICs dedicated integrated processor Circuits
  • FPGAs off-the-shelf programmable gate arrays
  • Each method, step and logical block diagram disclosed in the embodiment of this application can be implemented or executed.
  • a general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
  • the steps of the method disclosed in conjunction with the embodiments of the present application can be directly implemented by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other mature storage media in this field.
  • the storage medium is located in the memory 101.
  • the processor 100 reads the information in the memory 101 and completes the steps of the above method in combination with its hardware.
  • the electronic device provided by the embodiments of the present application and the method provided by the embodiments of the present application are based on the same inventive concept, and have the same beneficial effects as the methods adopted, run or implemented.
  • the sixth embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and the program is executed by a processor to implement the static web page generation method in any of the above embodiments.
  • the embodiment of the present application also provides a computer-readable storage medium corresponding to the method provided by the previous embodiment.
  • the computer-readable storage medium shown is an optical disk 20, and a computer program ( That is, a program product), when the computer program is run by the processor, it will execute the method provided by any of the foregoing embodiments.
  • examples of computer-readable storage media may also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), and others.
  • PRAM phase change memory
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • RAM random access memory
  • ROM read-only memory
  • EEPROM electrically erasable programmable read-only memory
  • flash memory or other optical and magnetic storage media will not be described in detail here.
  • the computer-readable storage medium provided by the above embodiments of the present application is based on the same inventive concept as the method provided by the embodiments of the present application, and has the same beneficial effects as the methods adopted, run or implemented by the application programs stored therein.
  • module is not intended to be limited to a particular physical form. Depending on the specific application, modules may be implemented as hardware, firmware, software, and/or a combination thereof. Furthermore, different modules can share common components or even be implemented by the same components. There may or may not be clear boundaries between different modules.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

本申请公开了一种静态网页的生成方法、生成装置、电子设备及存储介质。该方法包括:利用预训练的静态网页生成模型处理初始静态网页源代码以及接收到的自然语言文本描述指令,输出静态网页;重复执行将所述静态网页以及新接收到的自然语言文本描述指令输入所述静态网页生成模型中得到更新后的静态网页,直至不再接收到新的自然语言文本描述指令为止,得到最终的静态网页;其中,所述静态网页生成模型为基于Transformer的模型。本申请实施例提供的静态网页的生成方法,能够根据自然语言指令生成静态网页,利用基于Seq2Seq的模型将自然语言指令转换成静态网页,能够快速、低成本地自动生成静态网页,自动化程度高,降低了工作量,提高了工作效率。

Description

静态网页的生成方法、生成装置、电子设备及存储介质 技术领域
本申请涉及计算机技术领域,具体涉及一种静态网页的生成方法、生成装置、电子设备及存储介质。
背景技术
在网站开发项目中,前端常通过HTML、CSS、JavaScript等各种技术或框架来创建网页或APP等前端界面,经由网页浏览器读取HTML等文件,即可得到可视化网页,用于用户界面浏览与交互。前端框架的发展与跨平台响应式网页设计的应用给用户带来了的极高的用户体验。现有技术中,静态网页生成过程较为复杂,自动化程度低,专业人员的工作量大,工作效率低。
发明内容
本申请的目的是提供一种静态网页的生成方法、生成装置、电子设备及存储介质。为了对披露的实施例的一些方面有一个基本的理解,下面给出了简单的概括。该概括部分不是泛泛评述,也不是要确定关键/重要组成元素或描绘这些实施例的保护范围。其唯一目的是用简单的形式呈现一些概念,以此作为后面的详细说明的序言。
根据本申请实施例的一个方面,提供一种静态网页的生成方法,包括:
利用预训练的静态网页生成模型处理初始静态网页源代码以及接收到的自然语言文本描述指令,输出静态网页;
重复执行将所述静态网页以及新接收到的自然语言文本描述指令输入所述静态网页生成模型中得到更新后的静态网页,直至不再接收到新的自然语言文本描述指令为止,得到最终的静态网页;
其中,所述静态网页生成模型为基于Transformer的模型。
在本申请的一些实施例中,所述将所述静态网页以及新接收到的自然语言文本描述指令输入所述静态网页生成模型中得到更新后的静态网页,包括:
将所述静态网页以及新接收到的自然语言文本描述指令输入所述静态网页 生成模型中;
利用所述静态网页生成模型根据所述新接收到的自然语言文本描述指令对所述静态网页的源代码进行新增、删除和/或修改的处理,得到处理后的静态网页;
利用所述处理后的静态网页更新处理之前的静态网页,得到所述更新后的静态网页。
在本申请的一些实施例中,在所述利用训练好的静态网页生成模型处理初始静态网页源代码以及接收到的自然语言文本描述指令之前,所述方法还包括:
获取用于训练初始静态网页生成模型的数据集;
基于Transformer构建序列到序列的初始静态网页生成模型;
利用所述数据集训练所述初始静态网页生成模型直至达到预设训练完成条件,得到所述预训练的静态网页生成模型。
在本申请的一些实施例中,所述获取用于训练初始静态网页生成模型的数据集,包括:
获取多份静态网页源代码,并将每份静态网页源代码拆分为多个区块;
针对所述每份静态网页源代码的多个区块,获取所述每份静态网页源代码的多个区块对应的多个描述指令;
将上述多个区块对应的多个描述指令进行重整,获得新增指令相关的数据集;
在上述数据集基础上添加删除和修改类的自然语言描述指令,并根据指令得到对应的源代码;
利用所有所述对应的数据构成所述数据集。
在本申请的一些实施例中,在所述利用所有所述对应的数据构成所述数据集之后,所述获取用于训练初始静态网页生成模型的数据集,还包括:
对所述数据集中的用于模型输入的文本进行去换行符处理;
在用于模型输入的文本的开始处添加[CLS]符号,在结束处添加[SEP]符号;
设置BERT模型的最大输入文本长度为最大长度;
若所述用于模型输入的文本小于最大长度,则使用[PAD]符号进行padding 补齐操作,得到预处理后的用于模型输入的文本。
在本申请的一些实施例中,所述获取用于训练初始静态网页生成模型的数据集,还包括:
将所述数据集按照预设比例随机划分为训练集、测试集以及验证集;
所述训练集用于训练所述初始静态网页生成模型,所述验证集用于验证训练效果,所述测试集用于测试训练后的模型准确率;
其中,所述预设训练完成条件包括所述训练后的模型准确率达到预设准确率阈值。
在本申请的一些实施例中,所述基于Transformer构建序列到序列的初始静态网页生成模型,包括:
基于Transformer构建Text2SWeP模型,采用交叉熵作为损失函数,构建TEDS作为衡量指标,得到所述序列到序列的初始静态网页生成模型;
其中,所述Transformer模型由互相连接的编码器和解码器构成。
根据本申请实施例的另一个方面,提供一种静态网页的生成装置,包括:
初始静态网页源代码处理模块,用于利用预训练的静态网页生成模型处理初始静态网页源代码以及接收到的自然语言文本描述指令,输出静态网页;
静态网页生成模块,用于重复执行将所述静态网页以及新接收到的自然语言文本描述指令输入所述静态网页生成模型中得到更新后的静态网页,直至不再接收到新的自然语言文本描述指令为止,得到最终的静态网页;
其中,所述静态网页生成模型为基于Transformer的模型。
根据本申请实施例的另一个方面,提供一种电子设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述程序,以实现上述的静态网页的生成方法。
根据本申请实施例的另一个方面,提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行,以实现上述的静态网页的生成方法。
本申请实施例的其中一个方面提供的技术方案可以包括以下有益效果:
本申请实施例提供的静态网页的生成方法,能够根据自然语言指令生成静态网页,利用基于Seq2Seq的模型将自然语言指令转换成静态网页,能够快速、低成本地自动生成静态网页,生成静态网页的过程较为简单,自动化程度高, 提高了专业人员的开发效率,降低了工作量,提高了工作效率。
本申请的其他特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者,部分特征和优点可以从说明书中推知或毫无疑义地确定,或者通过实施本申请实施例了解。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1示出了本申请的第一个实施例的静态网页的生成方法流程图。
图2示出了本申请的第二个实施例的静态网页的生成方法流程图。
图3示出了本申请的第三个实施例的静态网页的生成方法流程图。
图4示出了本申请的一个示例中的Text2SWeP模型架构图。
图5示出了本申请的一个示例中的静态网页源代码示意图。
图6示出了本申请的一个示例中的静态网页源代码去换行符处理结果示意图。
图7示出了本申请的一个示例中的静态网页源代码与更新指令连接并补齐结果示意图。
图8示出了本申请的一个示例中的静态网页更新示意图。
图9示出了本申请的第四个实施例的静态网页的生成装置结构框图。
图10示出了本申请的第五个实施例的电子设备结构框图。
图11示出了本申请的第六个实施例的计算机可读存储介质示意图。
本申请的目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,下面结合附图和具 体实施例对本申请做进一步说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本领域技术人员可以理解,除非另外定义,这里使用的所有术语(包括技术术语和科学术语),具有与本申请所属领域中的普通技术人员的一般理解相同的意义。还应该理解的是,诸如通用字典中定义的那些术语,应该被理解为具有与现有技术的上下文中的意义一致的意义,并且除非像这里一样被特定定义,否则不会用理想化或过于正式的含义来解释。
随着自然语言处理技术的发展与成熟,越来越多的研究探索从给定文本序列到目标文本序列的任务,即Sequence to Sequence任务。Seq2Seq具有高度抽象的特性,可以应用于多种序列化的自然语言处理任务中,如机器翻译、回复生成、语音识别等任务。因根据自然语言生成静态网页可以看作是从原序列到目标序列的过程,故基于深度学习的Seq2Seq模型的出现使得通过自然语言来生成静态网页成可能。在通过自然语言处理技术来将自然语言转换成静态网页,以使非从业人员也可以轻松设计网页,同时提高从业人员的前端开发效率。
本申请实施例提出一种基于Seq2Seq深度学习模型的静态网页生成的方法,用于解决现有技术中非从业人员无法简单设计出网页的问题,同时解决非从业人员在使用现有的一些在线设计网站设计网页时元素或控件有限的情况。除此之外,前端开发的工作量大,原型开发耗时费力,亟需一个可以快速、低成本生成静态网页的方案。故此,本申请实施例主要采用Seq2Seq模型进行训练,使得模型可根据自然语言生成静态网页,利用基于Seq2Seq的自然语言处理技术将自然语言文本转换成静态网页。
本申请实施例针对现有技术中前端开发工作量大、且非专业人士技术入行门槛高的问题,通过自然语言技术,训练一个根据自然语言生成静态网页的模型,并基于此模型提取静态网页源代码特征和对应的自然语言文本描述特征,通过Seq2Seq的模型生成静态网页,并对模型进行应用,利用基于Seq2Seq的自然语言处理技术将自然语言文本转换成静态网页,以提高专业人员的开发效率以及降低非专业人士的入行门槛。以下结合附图和实施例,对本申请实施例 做详细说明和介绍,详细的实施步骤如下。
如图1所示,本申请的第一个实施例提供了一种静态网页的生成方法,包括:
S10、利用预训练的静态网页生成模型处理初始静态网页源代码以及接收到的自然语言文本描述指令,输出静态网页。
S20、重复执行将静态网页以及新接收到的自然语言文本描述指令输入静态网页生成模型中得到更新后的静态网页,直至不再接收到新的自然语言文本描述指令为止,得到最终的静态网页;
其中,静态网页生成模型为基于Transformer的模型。
在一些实施方式中,将静态网页以及新接收到的自然语言文本描述指令输入静态网页生成模型中得到更新后的静态网页,包括:
S201、将静态网页以及新接收到的自然语言文本描述指令输入静态网页生成模型中;
S202、利用静态网页生成模型根据新接收到的自然语言文本描述指令对静态网页的源代码进行新增、删除和/或修改的处理,得到处理后的静态网页;
S203、利用处理后的静态网页更新处理之前的静态网页,得到更新后的静态网页。
在一些实施方式中,在S10之前,方法还包括:
获取用于训练初始静态网页生成模型的数据集;
基于Transformer构建序列到序列的初始静态网页生成模型;
利用数据集训练初始静态网页生成模型直至达到预设训练完成条件,得到预训练的静态网页生成模型。
在一些实施方式中,获取用于训练初始静态网页生成模型的数据集,包括:
获取多份静态网页源代码,并将每份静态网页源代码拆分为多个区块;针对所述每份静态网页源代码的多个区块,获取所述每份静态网页源代码的多个区块对应的多个描述指令;将上述多个区块对应的多个描述指令进行重整,获得新增指令相关的数据集;在上述数据集基础上添加删除和修改类的自然语言描述指令,并根据指令得到对应的源代码;利用所有所述对应的数据构成所述数据集。
将上述多个区块对应的多个描述指令进行重整的方式为:
记每份静态网页源代码所拆分得到的N个区块所形成的集合为W,W={w1,w2,...wN},N个区块对应的N条文本描述记为集合T,T={t1,t2,...tN}。
则每份静态网页源代码所形成的数据为,{(t1,w1),(w1+t2,w1+w2),(w1+w2+t3,w1+w2+w3)...,(w1+...+wn-1+tn,w1+...+wn-1+wn)},其中,“+”为字符串拼接,每个“()”内的一笔数据即为输入模型的一笔数据,“()”内“,”前为模型的输入的特征值,“,”后为模型的输入的标签值。
在所述利用所有所述对应的数据构成所述数据集之后,所述获取用于训练初始静态网页生成模型的数据集,还包括:对所述数据集中的用于模型输入的文本进行去换行符处理;在用于模型输入的文本的开始处添加[CLS]符号,在结束处添加[SEP]符号;设置BERT模型的最大输入文本长度为最大长度;若用于模型输入的文本小于最大长度,则使用[PAD]符号进行padding补齐操作,得到预处理后的用于模型输入的文本。
模型输入是指:
每份静态网页源代码所形成的数据为
{(t1,w1),(w1+t2,w1+w2),(w1+w2+t3,w1+w2+w3)...,(w1+...+wn-1+tn,w1+...+wn-1+wn)},其中,“+”为字符串拼接,每个“()”内的一笔数据即为输入模型的一笔数据,“()”内“,”前为模型的输入的特征值,“,”后为模型的输入的标签值。
在一些实施方式中,获取用于训练初始静态网页生成模型的数据集,还包括:将数据集按照预设比例随机划分为训练集、测试集以及验证集;训练集用于训练初始静态网页生成模型,验证集用于验证训练效果,测试集用于测试训练后的模型准确率;其中,预设训练完成条件包括训练后的模型准确率达到预设准确率阈值。
在一些实施方式中,基于Transformer构建序列到序列的初始静态网页生成模型,包括:
基于Transformer构建Text2SWeP模型,采用交叉熵作为损失函数,构建TEDS作为衡量指标,得到序列到序列的初始静态网页生成模型;
其中,Transformer模型由互相连接的编码器和解码器构成。
本申请实施例提供的静态网页的生成方法,能够根据自然语言指令生成静态网页,利用基于Seq2Seq的模型将自然语言指令转换成静态网页,能够快速、低成本地生成静态网页,提高了专业人员的开发效率,降低了工作量,提高了工作效率。
如图2所示,本申请的第二个实施例提供了一种静态网页生成方法,该方法包括:
S1、获取用于训练自然语言生成静态网页的模型的数据集。
在一些实施方式中,步骤S1可以包括:
(1)获取M份静态网页源代码,并将每份静态网页源代码分为N块。
(2)针对每份静态网页源代码的N个区块得到N条新增指令,汇整得到N条与新增指令相关的数据集。并在此基础上模拟修改和删除的指令,更新对应的网页源代码,获得与修改和删除指令相关的数据集。
(3)进行数据预处理,将静态网页进行去换行符处理,并使用[SEP]标签连接人工自然语言描述标注,作为模型的输入。
S2、基于Seq2Seq模型构建用于根据自然语言生成静态网页的模型Text2SWeP。
在一些实施方式中,步骤S2包括:
(1)基于Transformer构建Text2SWeP模型,用于输入静态网页和人工描述指令,输出新生成的静态网页。
(2)对BERT字典进行特殊符号的新增,新增后的BERT字典囊括所有静态网页常用标签,以防止在分词时标签被拆开。
(3)采用交叉熵作为损失函数训练模型,并且构建TEDS作为衡量指标。
S3、基于多轮指令生成静态网页。
在一些实施方式中,步骤S3包括:
(1)在模型推测与应用阶段,首轮的输入为空白的静态网页源代码以及用户自然语言描述指令,输出为根据指令生成的静态网页源代码。
(2)首轮之后的模型输入为前轮生成的静态网页源代码以及新自然语言描述指令,输出为根据新自然语言描述指令更新的静态网页源代码。
(3)自然语言描述指令可包括对静态网页源代码进行新增、删除、修改三类指令,最终获得符合用户要求的静态网页。
本申请实施例提供的静态网页的生成方法,能够根据自然语言指令生成静态网页,利用基于Seq2Seq的模型将自然语言指令转换成静态网页,能够快速、低成本地自动生成静态网页,自动化程度高,提高了专业人员的开发效率,降低了工作量,提高了工作效率。
如图3所示,本申请的第三个实施例提供了一种静态网页的生成方法,包括以下步骤:
步骤S101:获取静态网页的源代码以及对应的自然语言文本描述,收集数据集,并得到训练集。
应当理解,根据自然语言文本描述生成静态网页的需求,静态网页的源代码必须与自然语言文本描述相对应。
因此,本申请实施例需要先获取静态网页的源代码,并通过浏览器读取静态网页的源代码,得到静态网页的呈现效果,最终根据静态网页的呈现来进行准确的人工标注与静态网页对应的自然语言处理文本描述。
在一种可能的实施方式中,获取静态网页的源代码可通过页面抓取技术进行收集,获得M份静态网页数据。
应当理解,为模拟用户的多轮指令,需要对收集到的每一份静态网页源代码进行逐区块拆分,得到N个区块,并获取N个区块对应的N条文本描述。其中,N值大小根据每份静态网页源代码可拆分的区块数而定。
记每份静态网页源代码所拆分得到的N个区块所形成的集合为W,W={w1,w2,...wN},N个区块对应的N条文本描述记为集合T,T={t1,t2,...tN}。
则每份静态网页源代码所形成的数据为,{(t1,w1),(w1+t2,w1+w2),(w1+w2+t3,w1+w2+w3)...,(w1+...+wn-1+tn,w1+...+wn-1+wn)},其中,“+”为字符串拼接,每个“()”内的一笔数据即为输入模型的一笔数据,“()”内“,”前为模型的输入的特征值,“,”后为模型的输入的标签值。
由上述步骤得到M份静态网页源代码所产生的数据集,模拟出实际应用场景中的多轮新增指令。除此之外,还需模拟出实际应用场景中关于删除、修改的指令。针对每份静态网页源代码,在原有的新增指令的基础上,加入多个修 改和删除指令,并根据指令更新对应源代码,将此部分数据并入数据集中。使得训练出的模型不仅可以进行网页元素的新增,也可供用户进行删除和修改。
用户的指令为,用户可以在已生成的静态网页的基础上,采用自然语言文本描述的方式表达所需要修改、新增、删除的地方,即提出新的指令,进一步更新静态网页的各类元素。
其中,多轮指用户可多次对已生成静态网页进行更新,以达到最终理想中的呈现效果。
最终,得到M条静态网页源代码分区后的数据集。对数据集进行划分,按照比例随机划分为训练集、测试集、以及验证集。
针对训练集进行数据增强,比如做文本等效描述等操作。最终数据将以批处理的方式输入模型。
步骤S102:构建序列到序列的编解码模型。
该步骤主要在于构建一个Seq2Seq的模型,用于输入用户的多轮指令以及已生成的静态网页代码,并输出生成的静态网页代码。其中,Seq2Seq的模型是一个基于Transformer的模型,模型结构可参照图4所示。
Transformer模型由编码器和解码器构成,编码器由多个区块叠加,一个区块由Multi-Head Attention、Add&Norm、Feed Forward、Add&Norm依序构成。解码器与编码器主要区别在于解码器的区块内多使用一个Encoder-Decoder Attention层。在一个可行的实施例中,Multi-Head Attention的head数量可为12,词向量的维度H为768,Feed Forward的大小设置为4H,即3072。
模型构建后需对数据进行预处理,数据预处理包括:
将已生成的静态网页源代码进行去换行符的处理,得到各个标签首尾相连的静态网页;
将自然语言文本描述指令和已生成的首尾相连的静态网页进行文本层面上的连接,连接时,两者需要使用[SEP]符号进行相连。
在一个可行的实施例中,需要将预处理后的输入自然语言描述标注文本进行分词。首先,在自然语言描述标注的文本开始处添加[CLS]符号,并在结束处添加[SEP]符号。其次,设置BERT模型的最大输入文本长度为最大长度Max  Length,若输入文本小于最大长度Max Length,则需要使用[PAD]符号进行padding补齐操作。静态网页源代码的示意图如图5所示,静态网页源代码去换行符处理结果如图6所示,静态网页源代码与更新指令连接并补齐结果示意图如图7所示。
数据预处理后,在BERT模型的字典内添加新的token,囊括静态网页如HTML和CSS的所有标签,如<tr>、</tr>、<style>、</style>等,以免在分词时,标签被拆分开,最终获得更新后的字典,用于后续模型训练。
步骤S103:构造损失函数与衡量指标,训练Seq2Seq模型。
该步骤主要在于将处理后的序列输入模型中进行训练,根据损失函数计算模型误差,不断调整模型训练参数,使模型达到收敛。
在一个可行的实施例中,损失函数可采用交叉熵。
进一步地,使用WordPiece tokenizier对输入文本进行tokenizier得到tokens。
进一步地,使用BERT的嵌入层得到词嵌入,词嵌入由符号嵌入层Token Embedding、片段嵌入层Segmentation Embedding、以及位置嵌入层Position Embedding三者组成。
其中,符号嵌入层是将token转换为固定维度的向量。
在一个可行的实施例中,每个token在经过符号嵌入层之后都由一个H维度的向量表示。最终得到一个形状为(Max Length,H)的张量。在一个可行的实施例中,H为词向量的维度768。
其中,片段嵌入层采用两个向量值区分tokens内的两个句子,在tokens的第一个[SEP]标签之前的tokens的片段嵌入值为0,其余为1。最终得到一个形状为(Max Length,H)的张量。
其中,位置嵌入层记录输入文本的顺序属性,位置嵌入层为大小(Max Length,H)的查找表,其中第一行是第一个位置上任意token的向量表示,其余依次类推。将tokens输入position嵌入层,最终得到一个形状为(Max Length,H)的张量。
除此以外,因为进行了padding操作,故还需要使用Mask,对于真正的token,mask为1,对于padding出来的,mask为0。
进一步地,将上述三类嵌入层的输出进行求和,最终得到一个形状为(Max Length,H)的张量,因模型训练过程采用批处理,设定批次大小为B,则一个batch的输入形状为(B,Max Length,H)的张量。
将上述形状为(B,Max Length,H)张量进行线性变换,生成Q、K、V三个新的张量,计算三者的Self-Attention。在一个可行的实施例中,Multi-Head Attention的head数量h为12,每个head的神经元个数为H/h,即为词嵌入的大小,线性变换后得到的Q、K、V为(B,Max Length,H/h)的张量。
Self-Attention的计算方式为
最终得到形状为(B,h,Max Length,H/h)的张量。
调整上述Multi-Head Attention层输出的张量维度,并进行多头合并,得到形状为(B,Max Length,H)的张量。
进一步地,将Multi-Head Attention层得到的形状为(B,Max Length,H)的张量输入Add&Norm层。其中,Add可选用Residual Connection来将信息无差的传递到下一层,并有效的关注差异的部分。Norm进行对层的激活值的归一化,加速模型收敛,最终得到得到形状为(B,h,Max Length,H/h)的张量。
进一步地,将Add&Norm层得到的结果输入Feed Forward全连接层和下一个Add&Norm层。
进一步地,在编码完成后输入解码器,与编码器中Self-Attention的区别在于,在解码器做Encoder-Decoder Attention的时候,Q来自解码器,而K,V来自于编码器最后的输出。
进一步地,由解码器获得一个浮点型向量,将该向量输入线性层,并接上一个Softmax层。线性层是一个简单的全连接神经网络,将向量投影到一个更高维度的向量上。Softmax层将向量转换为概率,选择概率最大的一维,并根据索引号得到相应的token后输出,直到预测到最后一个标识符<eos>符号为止。最终获得由解码器生成的静态网页的源代码序列。
进一步地,衡量指标的目的在于衡量解码器输出的静态网页与真实静态网页之间的误差。在一个可行的实施例中,衡量指标可采用TEDS评价指标,其公式为:
步骤S104:根据用户的多轮指令,生成最终的静态网页。
该步骤主要在于对最优的模型进行测试与应用,并根据用户的多轮指令,生成最终的静态网页。
在一个可行的实施例中,针对首轮的模型生成静态网页中,输入模型的数据为空白的静态网页源代码以及用户的首次自然语言描述文本。
进一步地,首轮模型生成得到已生成的静态网页。若用户需要更新静态网页,则将已生成的静态网页与用户的自然语言文本描述再次输入模型中,得到模型输出的更新的静态网页,即完成一轮更新,更新的流程示意图可参阅附图8所示。
重复上述步骤,直至用户不再需要下达更新指令,即得到最终的静态网页。
本申请实施例采用Seq2Seq的深度学习模型,进行Text2SWeP模型训练,最终可基于自然语言生成静态网页,得到可视化的网页效果。
与现有技术相比,其有益效果如下:本申请实施例提出Text2SWeP(Text to Static Web Page)模型本申请实施例打破非专业人士的技术壁垒,降低网页设计的门槛,使得非专业人士可以在无先验知识的前提下,仅使用自然语言即可设计出客制化的静态网页。非专业人士不再受限于在线设计网站可创建的网页元素或组件有限的情况。除此之外,针对专业人员而言,本申请实施例也可降低其前端开发的工作量,提高开发设计的效率,加速原型设计的速度,减少前端开发的成本。
如图9所示,本申请的第四个实施例提供了一种静态网页的生成装置,包括:
初始静态网页源代码处理模块,用于利用预训练的静态网页生成模型处理初始静态网页源代码以及接收到的自然语言文本描述指令,输出静态网页;
静态网页生成模块,用于重复执行将静态网页以及新接收到的自然语言文 本描述指令输入静态网页生成模型中得到更新后的静态网页,直至不再接收到新的自然语言文本描述指令为止,得到最终的静态网页;
其中,静态网页生成模型为基于Transformer的模型。
静态网页生成模块所执行的将静态网页以及新接收到的自然语言文本描述指令输入静态网页生成模型中得到更新后的静态网页,包括:
将静态网页以及新接收到的自然语言文本描述指令输入静态网页生成模型中;
利用静态网页生成模型根据新接收到的自然语言文本描述指令对静态网页的源代码进行新增、删除和/或修改的处理,得到处理后的静态网页;
利用处理后的静态网页更新处理之前的静态网页,得到更新后的静态网页。
在一些实施方式中,装置还包括预训练模块,用于在初始静态网页源代码处理模块利用训练好的静态网页生成模型处理初始静态网页源代码以及接收到的自然语言文本描述指令之前,获取用于训练初始静态网页生成模型的数据集;基于Transformer构建序列到序列的初始静态网页生成模型;利用数据集训练初始静态网页生成模型直至达到预设训练完成条件,得到预训练的静态网页生成模型。
在一些实施方式中,获取用于训练初始静态网页生成模型的数据集,包括:
获取多份静态网页源代码,并将每份静态网页源代码拆分为多个区块;
针对所述每份静态网页源代码的多个区块,获取所述每份静态网页源代码的多个区块对应的多个描述指令;
将上述多个区块对应的多个描述指令进行重整,获得新增指令相关的数据集;
在上述数据集基础上添加删除和修改类的自然语言描述指令,并根据指令得到对应的源代码;
利用所有所述对应的数据构成所述数据集。
在所述利用所有所述对应的数据构成所述数据集之后,所述获取用于训练初始静态网页生成模型的数据集,还包括:
对所述数据集中的用于模型输入的文本进行去换行符处理;
在用于模型输入的文本的开始处添加[CLS]符号,在结束处添加[SEP]符 号;
设置BERT模型的最大输入文本长度为最大长度;
若所述用于模型输入的文本小于最大长度,则使用[PAD]符号进行padding补齐操作,得到预处理后的用于模型输入的文本。
在一些实施方式中,获取用于训练初始静态网页生成模型的数据集,还包括:
将数据集按照预设比例随机划分为训练集、测试集以及验证集;
训练集用于训练初始静态网页生成模型,验证集用于验证训练效果,测试集用于测试训练后的模型准确率;
其中,预设训练完成条件包括训练后的模型准确率达到预设准确率阈值。
在一些实施方式中,基于Transformer构建序列到序列的初始静态网页生成模型,包括:
基于Transformer构建Text2SWeP模型,采用交叉熵作为损失函数,构建TEDS作为衡量指标,得到序列到序列的初始静态网页生成模型;
其中,Transformer模型由互相连接的编码器和解码器构成。
本申请实施例提供的静态网页的生成装置,能够根据自然语言指令生成静态网页,利用基于Seq2Seq的模型将自然语言指令转换成静态网页,能够快速、低成本地自动生成静态网页,自动化程度高,提高了专业人员的开发效率,降低了工作量,提高了工作效率。
本申请的第五个实施例提供了一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行程序,以实现上述任一实施方式的静态网页生成方法。
如图10所示,电子设备10可以包括:处理器100,存储器101,总线102和通信接口103,处理器100、通信接口103和存储器101通过总线102连接;存储器101中存储有可在处理器100上运行的计算机程序,处理器100运行该计算机程序时执行本申请前述任一实施方式所提供的方法。
其中,存储器101可能包含高速随机存取存储器(RAM:Random Access Memory),也可能还可以包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。通过至少一个通信接口103(可以是有线或者无线)实 现该系统网元与至少一个其他网元之间的通信连接,可以使用互联网、广域网、本地网、城域网等。
总线102可以是ISA总线、PCI总线或EISA总线等。总线可以分为地址总线、数据总线、控制总线等。其中,存储器101用于存储程序,处理器100在接收到执行指令后,执行该程序,前述本申请实施例任一实施方式揭示的方法可以应用于处理器100中,或者由处理器100实现。
处理器100可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器100中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器100可以是通用处理器,可以包括中央处理器(Central Processing Unit,简称CPU)、网络处理器(Network Processor,简称NP)等;还可以是数字信号处理器(DSP)、专用集成电路(ASIC)、现成可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器101,处理器100读取存储器101中的信息,结合其硬件完成上述方法的步骤。
本申请实施例提供的电子设备与本申请实施例提供的方法出于相同的发明构思,具有与其采用、运行或实现的方法相同的有益效果。
本申请的第六个实施例提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行,以实现上述任一实施方式的静态网页生成方法。
本申请实施方式还提供一种与前述实施方式所提供的方法对应的计算机可读存储介质,参考图11所示,其示出的计算机可读存储介质为光盘20,其上存储有计算机程序(即程序产品),该计算机程序在被处理器运行时,会执行前述任意实施方式所提供的方法。
需要说明的是,计算机可读存储介质的例子还可以包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他 类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他光学、磁性存储介质,在此不再一一赘述。
本申请的上述实施例提供的计算机可读存储介质与本申请实施例提供的方法出于相同的发明构思,具有与其存储的应用程序所采用、运行或实现的方法相同的有益效果。
需要说明的是:
术语“模块”并非意图受限于特定物理形式。取决于具体应用,模块可以实现为硬件、固件、软件和/或其组合。此外,不同的模块可以共享公共组件或甚至由相同组件实现。不同模块之间可以存在或不存在清楚的界限。
在此提供的算法和显示不与任何特定计算机、虚拟装置或者其它设备固有相关。各种通用装置也可以与基于在此的示例一起使用。根据上面的描述,构造这类装置所要求的结构是显而易见的。此外,本申请也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本申请的内容,并且上面对特定语言所做的描述是为了披露本申请的最佳实施方式。
应该理解的是,虽然附图的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,其可以以其他的顺序执行。而且,附图的流程图中的至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,其执行顺序也不必然是依次进行,而是可以与其他步骤或者其他步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。
以上实施例仅表达了本申请的实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请的保护范围应以所附权利要求为准。

Claims (10)

  1. 一种静态网页的生成方法,其特征在于,包括:
    利用预训练的静态网页生成模型处理初始静态网页源代码以及接收到的自然语言文本描述指令,输出静态网页;
    重复执行将所述静态网页以及新接收到的自然语言文本描述指令输入所述静态网页生成模型中得到更新后的静态网页,直至不再接收到新的自然语言文本描述指令为止,得到最终的静态网页;
    其中,所述静态网页生成模型为基于Transformer的模型。
  2. 根据权利要求1所述的方法,其特征在于,所述将所述静态网页以及新接收到的自然语言文本描述指令输入所述静态网页生成模型中得到更新后的静态网页,包括:
    将所述静态网页以及新接收到的自然语言文本描述指令输入所述静态网页生成模型中;
    利用所述静态网页生成模型根据所述新接收到的自然语言文本描述指令对所述静态网页的源代码进行新增、删除和/或修改的处理,得到处理后的静态网页;
    利用所述处理后的静态网页更新处理之前的静态网页,得到所述更新后的静态网页。
  3. 根据权利要求1所述的方法,其特征在于,在所述利用训练好的静态网页生成模型处理初始静态网页源代码以及接收到的自然语言文本描述指令之前,所述方法还包括:
    获取用于训练初始静态网页生成模型的数据集;
    基于Transformer构建序列到序列的初始静态网页生成模型;
    利用所述数据集训练所述初始静态网页生成模型直至达到预设训练完成条件,得到所述预训练的静态网页生成模型。
  4. 根据权利要求3所述的方法,其特征在于,所述获取用于训练初始静态网页生成模型的数据集,包括:
    获取多份静态网页源代码,并将每份静态网页源代码拆分为多个区块;
    针对所述每份静态网页源代码的多个区块,获取所述每份静态网页源代 码的多个区块对应的多个描述指令;
    将上述多个区块对应的多个描述指令进行重整,获得新增指令相关的数据集;
    在上述数据集基础上添加删除和修改类的自然语言描述指令,并根据指令得到对应的源代码;
    利用所有所述对应的数据构成所述数据集。
  5. 根据权利要求4所述的方法,其特征在于,在所述利用所有所述对应的数据构成所述数据集之后,所述获取用于训练初始静态网页生成模型的数据集,还包括:
    对所述数据集中的用于模型输入的文本进行去换行符处理;
    在用于模型输入的文本的开始处添加[CLS]符号,在结束处添加[SEP]符号;
    设置BERT模型的最大输入文本长度为最大长度;
    若所述用于模型输入的文本小于最大长度,则使用[PAD]符号进行padding补齐操作,得到预处理后的用于模型输入的文本。
  6. 根据权利要求4所述的方法,其特征在于,所述获取用于训练初始静态网页生成模型的数据集,还包括:
    将所述数据集按照预设比例随机划分为训练集、测试集以及验证集;
    所述训练集用于训练所述初始静态网页生成模型,所述验证集用于验证训练效果,所述测试集用于测试训练后的模型准确率;
    其中,所述预设训练完成条件包括所述训练后的模型准确率达到预设准确率阈值。
  7. 根据权利要求3所述的方法,其特征在于,所述基于Transformer构建序列到序列的初始静态网页生成模型,包括:
    基于Transformer构建Text2SWeP模型,采用交叉熵作为损失函数,构建TEDS作为衡量指标,得到所述序列到序列的初始静态网页生成模型;
    其中,所述Transformer模型由互相连接的编码器和解码器构成。
  8. 一种静态网页的生成装置,其特征在于,包括:
    初始静态网页源代码处理模块,用于利用预训练的静态网页生成模型处理初始静态网页源代码以及接收到的自然语言文本描述指令,输出静态网页;
    静态网页生成模块,用于重复执行将所述静态网页以及新接收到的自然语言文本描述指令输入所述静态网页生成模型中得到更新后的静态网页,直至不再接收到新的自然语言文本描述指令为止,得到最终的静态网页;
    其中,所述静态网页生成模型为基于Transformer的模型。
  9. 一种电子设备,其特征在于,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述程序,以实现如权利要求1-7中任一所述的方法。
  10. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行,以实现如权利要求1-7中任一所述的方法。
PCT/CN2023/092756 2022-08-02 2023-05-08 静态网页的生成方法、生成装置、电子设备及存储介质 WO2024027252A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210921418.0 2022-08-02
CN202210921418.0A CN115454423A (zh) 2022-08-02 2022-08-02 静态网页的生成方法、生成装置、电子设备及存储介质

Publications (1)

Publication Number Publication Date
WO2024027252A1 true WO2024027252A1 (zh) 2024-02-08

Family

ID=84296050

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/092756 WO2024027252A1 (zh) 2022-08-02 2023-05-08 静态网页的生成方法、生成装置、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN115454423A (zh)
WO (1) WO2024027252A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115454423A (zh) * 2022-08-02 2022-12-09 杭州未名信科科技有限公司 静态网页的生成方法、生成装置、电子设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170255445A1 (en) * 2015-11-03 2017-09-07 Ovservepoint, Inc. Translation of natural language into user interface actions
US20200234084A1 (en) * 2018-08-06 2020-07-23 Functionize, Inc. Training a system to perform a task with multiple specific steps given a general natural language command
CN112558964A (zh) * 2020-11-27 2021-03-26 华帝股份有限公司 一种网页生成方法、计算机设备及存储介质
CN113504906A (zh) * 2021-05-31 2021-10-15 北京房江湖科技有限公司 代码生成方法、装置、电子设备及可读存储介质
CN114372499A (zh) * 2021-11-11 2022-04-19 万里云医疗信息科技(北京)有限公司 一种自然语言处理方法、装置、设备和计算机可读存储介质
CN115454423A (zh) * 2022-08-02 2022-12-09 杭州未名信科科技有限公司 静态网页的生成方法、生成装置、电子设备及存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170255445A1 (en) * 2015-11-03 2017-09-07 Ovservepoint, Inc. Translation of natural language into user interface actions
US20200234084A1 (en) * 2018-08-06 2020-07-23 Functionize, Inc. Training a system to perform a task with multiple specific steps given a general natural language command
CN112558964A (zh) * 2020-11-27 2021-03-26 华帝股份有限公司 一种网页生成方法、计算机设备及存储介质
CN113504906A (zh) * 2021-05-31 2021-10-15 北京房江湖科技有限公司 代码生成方法、装置、电子设备及可读存储介质
CN114372499A (zh) * 2021-11-11 2022-04-19 万里云医疗信息科技(北京)有限公司 一种自然语言处理方法、装置、设备和计算机可读存储介质
CN115454423A (zh) * 2022-08-02 2022-12-09 杭州未名信科科技有限公司 静态网页的生成方法、生成装置、电子设备及存储介质

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
QIFAN WANG; YI FANG; ANIRUDH RAVULA; FULI FENG; XIAOJUN QUAN; DONGFANG LIU: "WebFormer: The Web-page Transformer for Structure Information Extraction", ARXIV.ORG, 1 February 2022 (2022-02-01), XP091148482 *

Also Published As

Publication number Publication date
CN115454423A (zh) 2022-12-09

Similar Documents

Publication Publication Date Title
WO2022095682A1 (zh) 文本分类模型的训练方法、文本分类方法、装置、设备、存储介质及计算机程序产品
CN109670191B (zh) 机器翻译的校准优化方法、装置与电子设备
CN112329465A (zh) 一种命名实体识别方法、装置及计算机可读存储介质
US9058317B1 (en) System and method for machine learning management
EP3679483A1 (en) Pruning engine
CN112527999A (zh) 引入农业领域知识的抽取式智能问答方法及系统
CN113076739A (zh) 一种实现跨领域的中文文本纠错方法和系统
CN110309282A (zh) 一种答案确定方法及装置
WO2024027252A1 (zh) 静态网页的生成方法、生成装置、电子设备及存储介质
CN114580424B (zh) 一种用于法律文书的命名实体识别的标注方法和装置
CN110738059B (zh) 一种文本相似度计算方法及系统
CN115759119B (zh) 一种金融文本情感分析方法、系统、介质和设备
CN110298038A (zh) 一种文本打分方法及装置
CN113836891A (zh) 基于多元标注策略的结构化信息抽取方法和装置
CN108664464B (zh) 一种语义相关度的确定方法及确定装置
US20220164536A1 (en) Method and apparatus for sequence labeling on entity text, and non-transitory computer-readable recording medium
CN117787226A (zh) 标签生成模型训练方法、装置、电子设备及存储介质
CN117113937A (zh) 一种基于大规模语言模型的电力领域阅读理解方法和系统
CN114372467A (zh) 命名实体抽取方法及装置、电子设备、存储介质
CN115495085A (zh) 一种基于深度学习细粒度代码模板的生成方法及装置
CN114528459A (zh) 一种基于语义的网页信息抽取方法及系统
CN114840680A (zh) 一种实体关系联合抽取方法、装置、存储介质及终端
CN110852112B (zh) 词向量嵌入方法及装置
CN112257461A (zh) 一种基于注意力机制的xml文档翻译及评价方法
CN113449490B (zh) 一种文档信息汇总方法、系统、电子设备及介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23848963

Country of ref document: EP

Kind code of ref document: A1