Page adaptive rendering method, electronic equipment and storage medium

By converting the project source code into an abstract syntax tree and processing it using a large language model, the target source code for different device categories is solved, and efficient page rendering on different devices is achieved.

CN119806532APending Publication Date: 2025-04-11WEBANK (CHINA)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411871573.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

When implementing page adaptation of different devices in the prior art, page adaptation with similar equipment height and width is poor, and the code that the device must run before the code is run is not extracted, resulting in a reduced page rendering efficiency.

Method used

By converting the project source code into an abstract syntax tree, and calling a pre-trained large language model to process different device category information and abstract syntax trees, generating target abstract syntax trees corresponding to different device category information, then restoring it into source code and storing it in the database to realize page rendering of different devices.

Benefits of technology

It realizes that only one set of project source code needs to be developed to be used in different devices, which improves development efficiency, reduces the complexity of page rendering code, and improves page rendering efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119806532A_ABST
    Figure CN119806532A_ABST
Patent Text Reader

Abstract

The invention provides a page adaptive rendering method, electronic equipment and a storage medium, and belongs to the technical field of artificial intelligence. According to the method, a project source code is converted into an abstract syntax tree, then a pre-trained large language model is called to process different equipment category information and the abstract syntax tree, and target abstract syntax trees corresponding to the different equipment category information can be obtained. And restoring the target abstract syntax trees respectively corresponding to the different equipment category information into source codes to obtain target source codes respectively corresponding to the different equipment category information. Therefore, when the page rendering request sent by the front end is received, the target equipment category information carried in the page rendering request can be identified, and the target source code corresponding to the target equipment category information is called out according to the target equipment category information and returned to the front end for rendering; the problem that a set of project source codes are adaptive to different devices can be solved, meanwhile, the page rendering code complexity is reduced, and the page rendering efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a page self-adaptive rendering method, an electronic device and a storage medium. Background Art

[0002] With the popularity and diversification of mobile devices, users' demand for accessing web pages and applications through various devices is increasing. Traditional fixed web page design can no longer meet the experience requirements of modern users, and the adaptation of different devices has become an important task in development.

[0003] Although the device adaptation solution of media query currently used in the industry can solve the problem of page display adaptation for different screen sizes, its core principle is to distinguish based on screen height and width, which leads to poor adaptability of pages with similar screen height and width. At the same time, it is impossible to extract the code that must be run by the device before the code is run, which will lead to overall redundancy and complexity when the code is running, and reduce the efficiency of page rendering. Summary of the invention

[0004] The main purpose of the embodiments of the present application is to propose a page self-adaptive rendering method, electronic device and storage medium, aiming to solve the problem of adapting a set of project source code to different devices, so that only one set of project source code needs to be developed to be used in different devices, thereby improving development efficiency, while reducing the complexity of page rendering code and improving page rendering efficiency.

[0005] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a page adaptive rendering method, the method comprising:

[0006] Obtaining a project source code and converting the project source code into an abstract syntax tree, wherein the project source code carries unique identifiers corresponding to different device categories;

[0007] Calling a pre-trained large language model to process different device category information and the abstract syntax tree to obtain target abstract syntax trees corresponding to different device category information;

[0008] Restore the target abstract syntax trees corresponding to different device category information into source codes, obtain target source codes corresponding to different device category information, and store the target source codes corresponding to different device category information in a database;

[0009] Receive a page rendering request sent by the front end, and identify target device category information carried in the page rendering request;

[0010] According to the target device category information, the target source code corresponding to the target device category information is retrieved from the database and returned to the front end for rendering.

[0011] In one embodiment of the present application, the calling of a pre-trained large language model to process different device category information and the abstract syntax tree to obtain target abstract syntax trees corresponding to different device category information respectively includes:

[0012] Building a device category set, wherein the device category set includes different device category information;

[0013] Randomly select a piece of device category information from the device category set as target device category information;

[0014] Calling a pre-trained large language model to obtain the abstract syntax tree and the target device category information;

[0015] The pre-trained large language model is used to traverse the abstract syntax tree to identify a target node whose attribute value of a unique identifier for identifying different device categories carried in the abstract syntax tree is different from the target device category information;

[0016] The target node in the abstract syntax tree is deleted, and other nodes in the abstract syntax tree except the target node are retained to obtain a target abstract syntax tree corresponding to the target device category information;

[0017] Deleting the target device category information from the device category set to update the device category set;

[0018] Return to the step of arbitrarily selecting a piece of device category information from the device category set as the target device category information, until the target abstract syntax trees corresponding to all the device category information in the device category set are obtained.

[0019] In one embodiment of the present application, the traversal of the abstract syntax tree by the pre-trained large language model to identify a target node whose attribute value of a unique identifier for identifying different device categories carried in the abstract syntax tree is different from the target device category information includes:

[0020] The abstract syntax tree is traversed by the pre-trained large language model to identify attribute values ​​of unique identifiers for identifying different device categories respectively carried by each node in the abstract syntax tree;

[0021] Comparing whether the attribute value of the unique identifier carried by the node for identifying different device categories is the same as the target device category information;

[0022] If the attribute value of the unique identifier carried by the node and used to identify different device categories is different from the target device category information, the node is determined to be the target node.

[0023] In one embodiment of the present application, the target device category information includes a target device identifier, and whether the attribute value of the unique identifier carried by the comparison node for identifying different device categories is the same as the target device category information includes:

[0024] The attribute value of the unique identifier carried by the comparison node for identifying different device categories is the same as the target device identifier.

[0025] In one embodiment of the present application, pre-training a large language model includes:

[0026] Establishing a first database table and a second database table, wherein the first database table includes different device category information, and the second database table includes different abstract syntax trees, and the abstract syntax trees are in JSON state;

[0027] Performing text vectorization processing on the data in the first database table and storing them in a first vector database, and performing text vectorization processing on the data in the second database table and storing them in a second vector database;

[0028] Performing structural construction on the data in the second vector database to obtain a corresponding structural database;

[0029] Model building is performed based on the structure database, wherein each node in each structure in the structure database respectively builds a sub-model, each sub-model corresponds to a training node, and the output of the previous training node is used as the input of the current training node;

[0030] Acquire the first vector database and the structure database to pre-train a large language model;

[0031] Conduct multiple rounds of dialogue and fine-tune the pre-trained large language model to obtain a trained large language model.

[0032] In one embodiment of the present application, constructing a model based on the structure database includes:

[0033] Traversing each structure in the structure database to obtain a node array corresponding to each structure starting with a root node;

[0034] Constructing a sub-model based on the order of the node array, wherein one sub-model is constructed corresponding to one node;

[0035] Each sub-model is used as a training node, and the output of the previous training node is used as the input of the current training node.

[0036] In one embodiment of the present application, using the output of the previous training node as the input of the current training node includes:

[0037] Get the previous output of the previous training node and the current input of the current training node;

[0038] The previous output and the current input are fused to obtain a fused input, and the fused input is used as the input of the current training node.

[0039] In one embodiment of the present application, converting the project source code into an abstract syntax tree includes:

[0040] Splitting the project source code into multiple lexical units by a lexical analyzer;

[0041] Each of the lexical units is received through a syntax analyzer, and each of the lexical units is constructed according to grammatical rules to obtain an abstract syntax tree, wherein each node in the abstract syntax tree represents a grammatical structure in the project source code, and different node types represent different grammatical structures.

[0042] To achieve the above-mentioned purpose, the second aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the method described in any embodiment of the present application when executing the computer program.

[0043] To achieve the above-mentioned purpose, a third aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any embodiment of the present application is implemented.

[0044] In the technical solution provided in one embodiment of the present application, the project source code is first converted into an abstract syntax tree, and then a pre-trained large language model is called to process different device category information and abstract syntax trees, so that target abstract syntax trees corresponding to different device category information can be obtained. The target abstract syntax trees corresponding to different device category information are then restored to source code, and target source codes corresponding to different device category information can be obtained. Therefore, when a page rendering request sent by the front end is received, the target device category information carried in the page rendering request can be identified, and the target source code corresponding to the target device category information can be retrieved according to the target device category information and returned to the front end for rendering, which can solve the problem of adapting a set of project source codes to different devices, and realize that only one set of project source codes needs to be developed to be used in different devices, which can improve development efficiency, while reducing the complexity of page rendering code and improving page rendering efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1is a flow chart of a page adaptive rendering method provided by an embodiment of the present application;

[0046] Figure 2 It is a flowchart of steps for converting project source code into an abstract syntax tree provided by an embodiment of the present application;

[0047] Figure 3 is a flowchart of the steps of pre-training a large language model provided in an embodiment of the present application;

[0048] Figure 4 It is a flowchart of the steps of model construction based on the structure database provided in one embodiment of the present application;

[0049] Figure 5 A flowchart of the steps of calling a pre-trained large language model to process different device category information and abstract syntax trees to obtain target abstract syntax trees corresponding to different device category information, provided by an embodiment of the present application;

[0050] Figure 6 A flowchart of the steps of traversing an abstract syntax tree by a pre-trained large language model to identify a target node whose attribute value of a unique identifier for identifying different device categories carried in the abstract syntax tree is different from the target device category information, provided by an embodiment of the present application;

[0051] Figure 7 This is an example diagram of the project source code provided by an embodiment of the present application;

[0052] Figure 8 is an example diagram of an abstract syntax tree converted from project source code provided by an embodiment of the present application;

[0053] Fig. 9 is an example diagram of a modified abstract syntax tree provided by an embodiment of the present application;

[0054] Fig.10 It is a schematic diagram of the hardware structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0055] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0056] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0057] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0058] Terminology explanation:

[0059] Abstract Syntax Tree: An Abstract Syntax Tree (AST) is a tree representation of the abstract syntax structure of the source code. It represents the structure of a programming language in the form of a tree, and each node in the tree represents a structure in the source code. In AST, leaf nodes usually represent constants or variables, while internal nodes represent constructs (such as expressions, statements, and function definitions).

[0060] Device adaptation: Device adaptation refers to a technology that allows web pages and applications to display and work well on different devices and screen sizes. It usually involves using methods such as responsive design, media queries, and flexible layout to ensure that the user interface has a good user experience on various devices.

[0061] Media query: Media query is a technique in CSS (Cascading Style Sheets) that is used to apply different styles for different device characteristics (such as screen width, height, resolution, etc.). It adjusts the layout and design of web pages by detecting the characteristics of the device to achieve responsive design. Media query can help web pages provide a good user experience on various devices.

[0062] Large Language Model: Large Language Model (LLM) is an AI model trained on large amounts of text data, designed to understand and generate natural language. It uses deep learning techniques, specifically neural network architectures such as Transformer, to predict and generate text. These models are capable of performing a variety of tasks.

[0063] RAG: RAG (Retrieval-Augmented Generation) is an artificial intelligence technology that combines information retrieval technology with language generation models. It retrieves relevant information from external knowledge bases and inputs it as prompts to large language models (LLMs) to enhance the model's ability to handle knowledge-intensive tasks.

[0064] With the popularity and diversification of mobile devices, users' demand for accessing web pages and applications through various devices is increasing. Traditional fixed web page design can no longer meet the experience requirements of modern users, and the adaptation of different devices has become an important task in development.

[0065] There are currently a large number of different development devices (such as tablets, mobile phones, computers, etc.). For these different devices, there are a large number of pages with similar interactions and logic. How to reuse code, improve development efficiency, and reduce labor costs has become an urgent problem to be solved.

[0066] At present, the device adaptation direction is mainly based on media queries, which define the style of the code on screens with different resolutions to achieve adaptation of different devices. However, this solution can only be used in multiple devices with completely different screen resolutions, and cannot identify and be compatible with devices with similar screen sizes. At the same time, this method cannot distinguish the code logic that can be executed in different devices, and thus cannot implement different code execution in different devices, resulting in overall redundancy and complexity when the code is running, and reduced page rendering efficiency.

[0067] Based on this, an embodiment of the present application proposes a page adaptive rendering method, which does not achieve device adaptation based on device size (or resolution), but modifies the abstract syntax tree of the project source code based on a trained large language model to achieve precise adaptation of different devices; at the same time, the code is modified before the code is rendered, and the code that does not need to be rendered on the current device is deleted, which can reduce the code complexity and improve the code runtime efficiency.

[0068] Reference Figure 1 , Figure 1 It is a flowchart of a page adaptive rendering method provided in an embodiment of the present application, including but not limited to steps S110 to S140.

[0069] Step S110, obtaining the project source code and converting the project source code into an abstract syntax tree, wherein the project source code carries unique identifiers corresponding to different device categories.

[0070] In the embodiment of the present application, a developer develops a set of project source code, and the project source code needs to be adapted to all device categories, that is, the project source code carries unique identifiers corresponding to all different device categories. For example, considering that the application corresponding to the project can be adapted to all currently existing device categories (such as 100 types), when developing the project source code, it is necessary to include code segments adapted to all device categories, wherein the code segment of each device category carries a unique identifier corresponding to the device category.

[0071] Exemplarily, all currently existing device categories include 10 types, namely device 1, device 2, device 3, device 4, device 5, device 6, device 7, device 8, device 9 and device 10. The corresponding developed project source code should include code segment 1 corresponding to device 1, code segment 2 corresponding to device 2, code segment 3 corresponding to device 3, code segment 4 corresponding to device 4, code segment 5 corresponding to device 5, code segment 6 corresponding to device 6, code segment 7 corresponding to device 7, code segment 8 corresponding to device 8, code segment 9 corresponding to device 9 and code segment 10 corresponding to device 10. Among them, code segment 1 carries a unique identifier for identifying device 1, code segment 2 carries a unique identifier for identifying device 2, code segment 3 carries a unique identifier for identifying device 3, code segment 4 carries a unique identifier for identifying device 4, code segment 5 carries a unique identifier for identifying device 5, code segment 6 carries a unique identifier for identifying device 6, code segment 7 carries a unique identifier for identifying device 7, code segment 8 carries a unique identifier for identifying device 8, code segment 9 carries a unique identifier for identifying device 9, and code segment 10 carries a unique identifier for identifying device 10.

[0072] After the developer develops the project source code, he can upload the project source code to the platform, and the platform can convert the project source code into an abstract syntax tree.

[0073] Reference Figure 2 , Figure 2 It is a flowchart of the steps of converting project source code into an abstract syntax tree provided by an embodiment of the present application, including but not limited to steps S210 to S220.

[0074] Step S210, splitting the project source code into multiple lexical units through a lexical analyzer;

[0075] Step S220, receiving each lexical unit through a syntax analyzer, and constructing each lexical unit according to the syntax rules to obtain an abstract syntax tree, wherein each node in the abstract syntax tree represents a syntax structure in the project source code, and different node types represent different syntax structures.

[0076] In the embodiment of the present application, the project source code can be split into multiple lexical units by a lexical analyzer, and then each lexical unit is received by a syntax analyzer, and each lexical unit is constructed according to the grammatical rules to obtain an abstract syntax tree. Among them, the abstract syntax tree is an abstract representation of the grammatical structure of the source code. It represents the grammatical structure of the programming language in a tree-like form, and each node on the tree represents a structure in the source code. Specifically, the lexical analyzer (Lexer) can split the source code into lexical units (tokens), such as variable names, keywords, operators, punctuation marks, etc. It identifies and classifies these lexical units according to a set of defined rules (lexical specifications). The syntax analyzer (Parser) receives the lexical units generated by the lexical analyzer and constructs an abstract syntax tree according to the grammatical rules. The syntax analyzer uses context-free grammar to define the grammatical rules of the language. It processes these rules through recursive descent, LR (1) algorithm, etc. to determine whether the input conforms to the grammatical rules and generate a corresponding abstract syntax tree. In the process of syntax analysis, the syntax analyzer constructs an abstract syntax tree according to the grammatical rules. The abstract syntax tree is a tree structure in which each node represents a syntax structure in the source code, such as an expression, statement, function, etc. Different node types represent different syntax structures, and the parent-child relationship and sibling relationship between them represent the hierarchy and logical association of the source code.

[0077] It should be noted that in the embodiment of the present application, since the project source code carries unique identifiers corresponding to different device categories, after the project source code is converted into an abstract syntax tree, the nodes in the abstract syntax tree will also carry unique identifiers corresponding to different device categories.

[0078] Step S120 , calling a pre-trained large language model to process different device category information and abstract syntax trees, and obtaining target abstract syntax trees corresponding to different device category information.

[0079] In the embodiment of the present application, after converting the developed project source code that can adapt to all device categories into an abstract syntax tree, considering that although the project source code can adapt to all device categories, the code it contains is redundant and complex, which will lead to low operating efficiency. Based on this, the embodiment of the present application pre-trains a large language model, so that the trained large language model can process different device category information and abstract syntax trees, identify the nodes corresponding to different device categories in the abstract syntax tree, and obtain the target abstract syntax trees corresponding to different device category information by modifying the abstract syntax tree.

[0080] Reference Figure 3 , Figure 3It is a flowchart of the steps of pre-training a large language model provided in an embodiment of the present application, including but not limited to steps S310 to S360.

[0081] Step S310, establishing a first database table and a second database table, wherein the first database table includes different device category information, and the second database table includes different abstract syntax trees, and the abstract syntax trees are in JSON state;

[0082] Step S320, performing text vectorization processing on the data in the first database table and storing them in the first vector database, and performing text vectorization processing on the data in the second database table and storing them in the second vector database;

[0083] Step S330, constructing a structure for the data in the second vector database to obtain a corresponding structure database;

[0084] Step S340, constructing a model based on the structure database, wherein each node in each structure in the structure database is corresponding to a sub-model, each sub-model is corresponding to a training node, and the output of the previous training node is used as the input of the current training node;

[0085] Step S350, obtaining a first vector database and a structure database to pre-train a large language model;

[0086] Step S360: Perform multiple rounds of dialogue and fine-tune the pre-trained large language model to obtain a trained large language model.

[0087] In an embodiment of the present application, two database tables are first established, namely the first database table and the second database table. The first database table includes all different device category information. The second database table includes abstract syntax trees corresponding to source codes of different projects, and the abstract syntax trees are in JSON state. The first database table must contain all device category data, and increase the amount of data in the second database table as much as possible. Based on the standard RAG (retrieval enhanced generation) process, the data in the first database table and the second database table are cleaned and text segmented, and the document and syntax tree text are vectorized based on Word2vec and Doc2vec. The vectorized data are stored in the vector databases respectively to obtain the corresponding first vector database and second vector database.

[0088] In the embodiment of the present application, considering that simple text training cannot meet the requirements of the large language model for deep traversal and attribute comparison of the abstract syntax tree, in order to solve this problem, the embodiment of the present application constructs an indexable structured data in the second vector database. The constructed structure can completely preserve the hierarchical characteristics of the abstract syntax tree, and by creating nodes, the indexing of leaf nodes can be quickly realized. Specifically, the construction tool codeGraph (structure builder) can be used to construct the structure of the data in the second vector database. The construction includes creating nodes and creating edges. The constructed structure can structure the vector data and has structural features that can be recognized by the large language model. The constructed valid structure is then stored in the structure database to obtain a structure database.

[0089] In the embodiment of the present application, the node attributes and edge type attributes in the structure can be defined based on business needs. Node attributes may include id (unique identifier), type (node ​​type), path (path corresponding to the root node), line_number (level number), detail (syntax tree content); edge type attributes may include contains (hierarchical structure), and by building structured indexable data, the structural database required for training can be realized.

[0090] Next, the model is constructed based on the structure database, wherein each node in each structure in the structure database constructs a sub-model respectively, each sub-model corresponds to a training node, and the output of the previous training node serves as the input of the current training node.

[0091] Reference Figure 4 , Figure 4 It is a flowchart of the steps of building a model based on a structural database provided in an embodiment of the present application, including but not limited to steps S410 to S430.

[0092] Step S410, traverse each structure in the structure database to obtain a node array corresponding to each structure starting with a root node;

[0093] Step S420, constructing a sub-model based on the order of the node array, wherein one sub-model is constructed corresponding to one node;

[0094] Step S430, taking each sub-model as a training node, and taking the output of the previous training node as the input of the current training node.

[0095] In an embodiment of the present application, during the training process, a sub-network is constructed based on each structured node in the structure database, which can ensure that each abstract syntax tree bifurcation can establish complete feature parameters, and realize a sequential link training method for establishing a multi-layer sub-network. Specifically, for each structure in the structure database, a node array starting with the root node corresponding to each structure can be obtained based on the traversal algorithm, and a sub-model is constructed based on the order of the node array, so that there will be corresponding sub-models in the model from the structure root node to the leaf node. Each training node represents a sub-model, and the training of subsequent sub-models not only depends on its own input data, but also is affected by the output of the previous sub-model. That is, each sub-model is taken as a training node, and the output of the previous training node is taken as the input of the current training node.

[0096] The embodiment of the present application proposes an information transmission mechanism between sub-models, which realizes the sequential transmission of information during the training process by defining the dependency relationship between the previous and next sub-models. The specific algorithm logic is as follows:

[0097] Assume that a structure in the structural database consists of multiple nodes, denoted as G = (V, E), where V represents a node set, each node corresponds to a sub-model; E represents an edge set, which defines the topological relationship between sub-models.

[0098] For large language models trained sequentially, assume that the nodes are numbered sequentially {V 1 ,V 2 ,…,V n}, each node V i The corresponding sub-model is denoted as S i Each sub-model S i The output of not only depends on its own input data, but is also affected by the output of the preceding sub-model.

[0099] For sub-model S i , its input can be expressed as: Z i =f(X i ,H i-1 ), where Z i Represents sub-model S i The fusion input, X i Represents sub-model S i The current input, which represents the structure node V i The input features, H i-1 Represents the previous sub-model (i.e. the previous sub-model) S i-1 The output of f(x) is the fusion function used to integrate the current sub-model S i The input and pre-sub-model S i-1 The specific fusion method can be dynamic weight fusion, first calculate the dynamic weight: Among them, A represents the dynamic weight, which can reflect the sub-model S i The current input X i (through the query vector Q) and the previous sub-model S i-1 The correlation of the output of QK T is the dot product of the query and the key, reflecting the sub-model S i The similarity between the current input and the output of the previous sub-model, is a scaling factor that prevents the dot product value from being too large, which leads to unstable gradients. The f(x) function converts the similarity score into a probability distribution, which represents the weight of each pre-model. Then, weighted fusion is performed, and the value vector V is weighted summed by the dynamic weight A to obtain the fused feature vector Z. i . Eigenvector Among them, Z i Represents sub-model S i AV is the weighted sum of the attention weights on the output of the previous sub-model. You can get the previous output of the previous training node and the current input of the current training node, fuse the previous output and the current input to get the fused input, and use the fused input as the input of the current training node.

[0100] Sub-model S i The output result H i Calculated by the following formula:

[0101] H i =g i (W i *Z i +b i );

[0102] Among them, W i and b i The sub-models S i The weight matrix and bias vector, g i (x) is the sub-model S i The non-sensitive activation function, Z i It is a sub-model S i fused input.

[0103] The embodiment of the present application implements a mechanism for mutual feedback between nodes during the training process for the pre-training logic of the large language model. This sequential training method is more sufficient for model training. The training of each sub-model not only depends on its own input data, but is also affected by the output of the previous sub-model. The feature parameters established in the previous training node will be strengthened in the next training node. At the same time, the next training node will independently construct feature parameters that the previous training node does not have. By analogy, the data of each existing training node will be completely parameterized, and the integrity of the overall feature parameters will be finally achieved. Complete feature parameters will make the model more accurate in attribute recognition.

[0104] By comparing the results achieved after pre-training of the large language model (based on the accuracy of attribute recognition of the abstract syntax tree), it can be determined that in this abstract syntax tree pre-training scenario, the attribute recognition accuracy of the seed model sequential construction training method is higher than that of the general training method.

[0105] The modification process of the abstract syntax tree by the large language model is realized in the fine-tuning process after the large language model is pre-trained. After the large language model is pre-trained, it provides the ability to have conversations. Based on multiple rounds of conversations and fine-tuning schemes on the pre-trained model (adjusting hyperparameters such as learning rate and batch size, optimizing the model convergence speed and stability, and modifying the number of model layers and width to improve model performance), the model accuracy can be continuously improved.

[0106] During the fine-tuning process, by adding a fixed prefix in multiple rounds of dialogue, implicit initial conditions are set, and based on the query arrangement method, the abstract syntax tree can be modified.

[0107] The model fine-tuning can continuously improve the model's traversal recognition accuracy and the ability to modify the abstract syntax tree. Through multiple rounds of fine-tuning, the model can traverse the abstract syntax tree, accurately identify the target device category information, and modify the abstract syntax tree.

[0108] Reference Figure 5 , Figure 5 It is a flowchart of the steps of calling a pre-trained large language model to process different device category information and abstract syntax trees to obtain target abstract syntax trees corresponding to different device category information, including but not limited to steps S510 to S560, provided in an embodiment of the present application.

[0109] Step S510, constructing a device category set, the device category set including different device category information;

[0110] Step S520, randomly selecting a piece of device category information from the device category set as target device category information;

[0111] Step S530, calling a pre-trained large language model to obtain an abstract syntax tree and target device category information;

[0112] Step S540, traversing the abstract syntax tree using a pre-trained large language model to identify a target node whose attribute value of a unique identifier for identifying different device categories carried in the abstract syntax tree is different from the target device category information;

[0113] Step S550, deleting the target node in the abstract syntax tree, and retaining other nodes in the abstract syntax tree except the target node, to obtain a target abstract syntax tree corresponding to the target device category information;

[0114] Step S560, deleting the target device category information from the device category set to update the device category set, and then returning to step S520, until the target abstract syntax trees corresponding to all the device category information in the device category set are obtained.

[0115] In an embodiment of the present application, a device category set is first constructed, wherein the device category set includes different device category information. If there are 100 types of devices, the device information (such as device identifiers) corresponding to these 100 types of devices are collected to obtain a device category set. Then, any device category information is selected from the device category set as the target device category information and input into the pre-trained large language model. At the same time, the abstract syntax tree corresponding to the project source code is also input into the large language model. Thus, the large language model can traverse the abstract syntax tree to identify the node attributes of each node in the abstract syntax tree, and can identify the attribute values ​​of the unique identifiers carried by each node in the abstract syntax tree for identifying different device categories. Then compare whether the attribute values ​​of the unique identifiers carried by the nodes for identifying different device categories are the same as the target device category information. If they are the same, it is determined that the node is the node to which the target device category information belongs and needs to be retained. If they are not the same, it is determined that the node is not the node to which the target device category information belongs and needs to be deleted. In an embodiment of the present application, by comparing the attribute value of the unique identifier carried by the node for identifying different device categories with the target device category information, a target node whose attribute value of the unique identifier carried in the abstract syntax tree for identifying different device categories is different from the target device category information can be obtained, and the node in the abstract syntax tree that does not belong to the target device category information can be obtained. In this regard, the trained large language model can delete the node (i.e., the target node) in the abstract syntax tree that does not belong to the target device category information, and retain the other nodes in the abstract syntax tree except the target node, and obtain the target abstract syntax tree corresponding to the target device category information and output it. Then, the target device category information is deleted from the device category set, and the device category set is updated and then returned to step S520, so that the target abstract syntax tree corresponding to the next target device category information can be obtained. In this way, the target abstract syntax trees corresponding to all the device category information in the device category set can be obtained.

[0116] Reference Figure 6 , Figure 6 A flowchart of the steps provided by an embodiment of the present application, in which a pre-trained large language model is used to traverse an abstract syntax tree to identify target nodes whose attribute values ​​of unique identifiers used to identify different device categories carried in the abstract syntax tree are different from the target device category information, including but not limited to steps S610 to S630.

[0117] Step S610, traversing the abstract syntax tree using a pre-trained large language model to identify attribute values ​​of unique identifiers for identifying different device categories carried by each node in the abstract syntax tree;

[0118] Step S620, comparing whether the attribute value of the unique identifier carried by the node for identifying different device categories is the same as the target device category information;

[0119] Step S630: If the attribute value of the unique identifier carried by the node and used to identify different device categories is different from the target device category information, the node is determined to be a target node.

[0120] In the embodiment of the present application, the device category information includes a device identifier, and the corresponding target device category information includes a target device identifier. For example, in the project source code, "version" can be used as the identifier of the device, and the project source code contains the value of "version" corresponding to device 1 as phone12, then the corresponding abstract syntax tree also contains a node with a version attribute value of phone12. It should be noted that the device identifier used to distinguish different device categories can be other strings in addition to version, and the embodiment of the present application does not limit this.

[0121] In the embodiment of the present application, after the pre-trained large language model traverses the abstract syntax tree, it can identify the attribute values ​​of the unique identifiers used to identify different device categories carried by each node in the abstract syntax tree, and then compare whether the attribute values ​​of the unique identifiers used to identify different device categories carried by the node are the same as the target device category information; if the attribute values ​​of the unique identifiers used to identify different device categories carried by the node are different from the target device category information, then the node is determined to be the target node, that is, it is determined that the node does not belong to the node to which the target device category information belongs. If the attribute values ​​of the unique identifiers used to identify different device categories carried by the node are the same as the target device category information, then the node is determined to belong to the node to which the target device category information belongs.

[0122] Exemplarily, there are 10 different devices, and the device category information (such as device identifiers) of these 10 different devices are collected to obtain a device category set. Any device category information is selected from the device category set as the target device category information and input into the pre-trained large language model. For example, the device category information corresponding to device 1 is selected from the device category set as phone12 and input into the large language model. Then the abstract syntax tree corresponding to the project source code is input into the large language model. The large language model traverses the abstract syntax tree and identifies the node attributes of each node in the abstract syntax tree, that is, identifies the attribute value of the unique identifier carried by each node in the abstract syntax tree for identifying different device categories. At the same time, the node attributes of each node are compared with the target device category information to determine the node that is the same as the target device category information and the node that is different from the target device category information. If it is identified that the attribute value of the unique identifier carried by a node in the abstract syntax tree for identifying different device categories is phone12, it can be determined that the node is the node to which device 1 belongs. If it is identified that the attribute value of the unique identifier carried by a node in the abstract syntax tree for identifying different device categories is phone13, it can be determined that the node does not belong to device 1. Then the nodes with the same target device category information are retained, and the nodes with different target device category information are deleted to obtain a modified abstract syntax tree as the target abstract syntax tree corresponding to the target device category information. For example, if the node carrying the attribute value of the unique identifier for identifying different device categories as phone12 is retained, and the node carrying the attribute value of the unique identifier for identifying different device categories as phone13 is deleted, a modified abstract syntax tree can be obtained, and the modified abstract syntax tree is used as the target abstract syntax tree corresponding to device 1.

[0123] Exemplarily, providing Figure 7 The project source code shown in the figure can be adapted to device 1 (phone12) and device 2 (phone13). The project source code carries the unique identifier corresponding to device 1 (version=phone12) and the unique identifier corresponding to device 2 (version=phone13). Convert the project source code into Figure 8 The abstract syntax tree shown in FIG. 1 shows a node whose version attribute value is phone12 and a node whose version attribute value is phone13. The device category information phone12 corresponding to device 1 is input into the pre-trained large language model, and Figure 8The abstract syntax tree shown is input into the large language model, and the large language model traverses the abstract syntax tree to identify nodes to which device 1 belongs and nodes to which device 1 does not belong. By deleting nodes to which device 1 does not belong and retaining nodes to which device 1 belongs, the pruned abstract syntax tree can be obtained as shown in FIG. Fig. 9 As shown. Fig. 9 It can be seen from the abstract syntax tree shown that the pruned abstract syntax tree only contains the nodes belonging to device 1.

[0124] Step S130 , restore the target abstract syntax trees corresponding to different device category information into source codes, obtain target source codes corresponding to different device category information, and store the target source codes corresponding to different device category information into a database.

[0125] In an embodiment of the present application, after using a trained large language model to obtain the target abstract syntax tree corresponding to each device category information in the device category set, the target abstract syntax tree corresponding to each device category information can be restored to the source code to obtain the target source code corresponding to each device category information, and the target source code corresponding to each device category information can be stored in a database. For example, after obtaining the target source code corresponding to each device category information, a mapping relationship table between the device category information and the target source code can be formulated and stored in the database. Since the target abstract syntax tree corresponding to the target device category information obtained after modifying the abstract syntax tree through the large language model only contains the nodes belonging to the target device category information, the target source code corresponding to the target device category information finally obtained only contains the code segment belonging to the target device category information, thereby reducing the code size.

[0126] Step S140, receiving a page rendering request sent by the front end, and identifying target device category information carried in the page rendering request.

[0127] In an embodiment of the present application, when a user uses a device to open an application corresponding to a project, the front end sends a page rendering request to the back end. After receiving the page rendering request sent by the front end, the back end can identify the target device category information carried in the page rendering request, thereby determining the device category used by the user.

[0128] Step S150, according to the target device category information, the target source code corresponding to the target device category information is retrieved from the database and returned to the front end for rendering.

[0129] In the embodiment of the present application, after the backend identifies the target device category information, the backend can retrieve the target source code corresponding to the target device category information from the database and return it to the front end for rendering. Since the target source code has deleted the information that does not need to be rendered by the target device, the target source code is more streamlined, which can effectively improve the page rendering efficiency.

[0130] In the embodiment of the present application, an abstract syntax tree is generated from the project source code, and the abstract syntax tree is modified based on a pre-trained large language model, redundant information of non-target devices in the abstract syntax tree is deleted, and the final source code is restored based on the modified abstract syntax tree to achieve package rendering. It can solve the problem of poor page adaptability and low operating efficiency caused by code redundancy when the same set of project codes are adapted to different devices. By modifying the abstract syntax tree corresponding to the project source code to reduce the complexity of the final page rendering code, the page rendering efficiency can be improved.

[0131] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned page adaptive rendering method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0132] See also Fig.10 , Fig.10 : is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application, the electronic device includes:

[0133] The processor 1001 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0134] The memory 1002 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1002 can store an operating system and other applications. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1002, and the processor 1001 calls and executes the page adaptive rendering method of the embodiment of this application;

[0135] Input / output interface 1003, used to implement information input and output;

[0136] The communication interface 1004 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);

[0137] A bus 1005 , which transmits information between various components of the device (e.g., the processor 1001 , the memory 1002 , the input / output interface 1003 , and the communication interface 1004 );

[0138] The processor 1001 , the memory 1002 , the input / output interface 1003 and the communication interface 1004 are connected to each other in communication within the device via the bus 1005 .

[0139] An embodiment of the present application further provides a storage medium, which is a computer-readable storage medium and stores a computer program. When the computer program is executed by a processor, the above-mentioned page adaptive rendering method is implemented.

[0140] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0141] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0142] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0143] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0144] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0145] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0146] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0147] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0148] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0149] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0150] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0151] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and substance of the present invention should be within the scope of the rights of the present invention.

Claims

1. A page adaptive rendering method, characterized in that: The method comprises: Obtaining a project source code and converting the project source code into an abstract syntax tree, wherein the project source code carries unique identifiers corresponding to different device categories; Calling a pre-trained large language model to process different device category information and the abstract syntax tree to obtain target abstract syntax trees corresponding to different device category information; Restore the target abstract syntax trees corresponding to different device category information into source codes, obtain target source codes corresponding to different device category information, and store the target source codes corresponding to different device category information in a database; Receive a page rendering request sent by the front end, and identify target device category information carried in the page rendering request; According to the target device category information, the target source code corresponding to the target device category information is retrieved from the database and returned to the front end for rendering.

2. The method according to claim 1, characterized in that The calling of the pre-trained large language model to process different device category information and the abstract syntax tree to obtain target abstract syntax trees corresponding to different device category information respectively includes: Building a device category set, wherein the device category set includes different device category information; Randomly select a piece of device category information from the device category set as target device category information; Calling a pre-trained large language model to obtain the abstract syntax tree and the target device category information; The pre-trained large language model is used to traverse the abstract syntax tree to identify a target node whose attribute value of a unique identifier for identifying different device categories carried in the abstract syntax tree is different from the target device category information; The target node in the abstract syntax tree is deleted, and other nodes in the abstract syntax tree except the target node are retained to obtain a target abstract syntax tree corresponding to the target device category information; Deleting the target device category information from the device category set to update the device category set; Return to the step of arbitrarily selecting a piece of device category information from the device category set as the target device category information, until the target abstract syntax trees corresponding to all the device category information in the device category set are obtained.

3. The method according to claim 2, characterized in that The traversing of the abstract syntax tree by the pre-trained large language model to identify a target node whose attribute value of a unique identifier for identifying different device categories carried in the abstract syntax tree is different from the target device category information includes: The abstract syntax tree is traversed by the pre-trained large language model to identify attribute values ​​of unique identifiers for identifying different device categories respectively carried by each node in the abstract syntax tree; Comparing whether the attribute value of the unique identifier carried by the node for identifying different device categories is the same as the target device category information; If the attribute value of the unique identifier carried by the node and used to identify different device categories is different from the target device category information, the node is determined to be the target node.

4. The method according to claim 3, characterized in that The target device category information includes a target device identifier, and whether the attribute value of the unique identifier carried by the comparison node for identifying different device categories is the same as the target device category information includes: The attribute value of the unique identifier carried by the comparison node for identifying different device categories is the same as the target device identifier.

5. The method according to claim 1, characterized in that Pre-trained large language models include: Establishing a first database table and a second database table, wherein the first database table includes different device category information, and the second database table includes different abstract syntax trees, and the abstract syntax trees are in JSON state; Performing text vectorization processing on the data in the first database table and storing them in a first vector database, and performing text vectorization processing on the data in the second database table and storing them in a second vector database; Performing structural construction on the data in the second vector database to obtain a corresponding structural database; The model is constructed based on the structure database, wherein each node in each structure in the structure database respectively constructs a sub-model, each sub-model corresponds to a training node, and the output of the previous training node is used as the input of the current training node; Acquire the first vector database and the structure database to pre-train a large language model; Conduct multiple rounds of dialogue and fine-tune the pre-trained large language model to obtain a trained large language model.

6. The method according to claim 5, characterized in that Model building based on the structure database includes: Traversing each structure in the structure database to obtain a node array corresponding to each structure starting with a root node; Constructing a sub-model based on the order of the node array, wherein one sub-model is constructed corresponding to one node; Each sub-model is used as a training node, and the output of the previous training node is used as the input of the current training node.

7. The method according to claim 6, characterized in that Using the output of the previous training node as the input of the current training node includes: Get the previous output of the previous training node and the current input of the current training node; The previous output and the current input are fused to obtain a fused input, and the fused input is used as the input of the current training node.

8. The method according to claim 1, characterized in that Converting the project source code into an abstract syntax tree includes: Splitting the project source code into multiple lexical units by a lexical analyzer; Each of the lexical units is received through a syntax analyzer, and each of the lexical units is constructed according to grammatical rules to obtain an abstract syntax tree, wherein each node in the abstract syntax tree represents a grammatical structure in the project source code, and different node types represent different grammatical structures.

9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 8 when executing the computer program.

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