A method and system for extracting attribute values ​​from semi-structured web pages based on prompt learning

By adopting a prompt learning method in the semi-structured web page attribute value extraction, using two-perspective prompt information and pre-trained language model, the problem of limited model learning ability caused by the scarcity of domain labeling data is solved, and effective attribute information extraction and good generalization ability are achieved.

CN116628303BActive Publication Date: 2025-03-14INSTITUTE OF INFORMATION ENGINEERING CHINESE ACADEMY OF SCIENCES
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310462355.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-26
Publication Date
2025-03-14
Estimated Expiration
2043-04-26

AI Technical Summary

Technical Problem

The existing semi-structured web page attribute value extraction method. When the domain labeling data is scarce, the model's learning ability is limited, making it difficult to effectively extract the attribute information of semi-structured web pages.

Method used

Using a prompt learning method, the attribute value extraction and type prediction are performed through the dual-view prompt information from the DOM tree perspective and the task template perspective, combined with the encoder-decoder structure of the pre-trained language model.

Benefits of technology

It improves the domain knowledge retrieval ability and task understanding ability of the pre-trained language model, and can effectively extract the attribute information of semi-structured web pages when the domain labeling data is scarce, and has good generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116628303B_ABST
    Figure CN116628303B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for extracting attribute values ​​of a semi-structured web page based on prompt learning, which relates to the field of the Internet. Firstly, a DOM tree perspective prompt of a variable node is retrieved according to a DOM tree simplification algorithm, and then a task template containing a task description is designed to obtain template perspective prompt information. Finally, a pre-trained language model based on an encoder-decoder structure is introduced, and "prompt" is used as a core operation to comprehensively analyze the characteristics of domain data and target task characteristics, design prompt information of two perspectives, and fuse the dual-perspective prompt information through template filling. The pre-trained language model is jointly guided to perform task learning at the semantic level and the task level through prompt learning, thereby realizing an effective combination of the pre-trained language model and the attribute value extraction task, and achieving superior model performance in a scenario where domain annotation data is scarce.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet, and in particular to a method and system for extracting attribute values ​​of semi-structured web pages based on prompt learning. Background Art

[0002] There are a large number of semi-structured web pages on the Internet that are used to describe entities. The content of these web pages is usually carefully edited and reviewed, and contains a large amount of high-quality entity attribute information. As a valuable means of production, attribute information is widely used in various scientific research and actual business scenarios to help improve the results of downstream tasks. However, due to the large scale of semi-structured web pages, the complex content and varied layout of web pages, extracting structured attribute information from semi-structured web pages is an extremely challenging task. At present, semi-structured web page attribute value extraction methods are mainly divided into the following three categories:

[0003] The first is a wrapper-based semi-structured web page attribute value extraction method, that is, a method of constructing extraction rules or templates based on the shallow rules of the target data in the web page. For each website, the web pages in the site usually have the same or similar layout structure. This feature makes the data in the web page have certain presentation rules. Therefore, formulating rules based on the relevant rules found can achieve the extraction of target data. Reference "Hammer J, Mchugh JG, Garcia-Molin H. Semistructured data: the TSIMMIS experience. British Computer Society, 1997." First, by analyzing the web page source code to find the rules of the target data HTML tags, XPath paths and other features, and then designing a series of sequential execution instructions based on these rules, so as to achieve accurate extraction of target data. Reference "Li Ping, Zhu Jianbo, Zhou Lixin, et al. Shopping information extraction method based on rapid template construction [J]. Computer Applications, 2014, 34 (3): 733-737." A set of search positioning language and operation language are designed to quickly build web page information extraction templates and determine extraction rules. During the extraction process, the method first matches the corresponding information extraction template through the URL of the web page, and then uses the template to parse the web page content, extract the target data domain, and form structured data.

[0004] The second is a semi-structured web page attribute value extraction method based on visual features. This type of method starts from the characteristics of web page layout and considers visual features such as the size, proportion and layout relevance of text blocks in web pages. In order to facilitate viewers to quickly understand and locate web page content, web pages usually divide and arrange information based on visual structures. Therefore, it is a very important method to analyze and understand web page content based on visual features. The literature "Hao Q, Rui C, Pang Y, et al. From one tree to a forest: a unified solution for structured web data extraction [C] / / International Acm Sigir Conference on Research & Development in Information Retrieval. ACM, 2011." proposed a method based on rendering features, using visual features such as the size and position of node text blocks in the DOM tree to explore the distance between web page blocks, and then used for extracting attribute values ​​in web pages. The paper "Kumar A, Morabia K, Wang J, et al.CoVA: Context-aware Visual Attention for Webpage Information Extraction[J].arXiv e-prints, 2021." proposed a neural network model for encoding visual features, namely, COVA, which includes a representation network consisting of a CNN, a pooling layer, and a position encoder, and a graph attention neural network. The model first uses the representation network to learn the visual features such as the size and spatial position of the content blocks of each node in the webpage screenshot, and then further applies the graph attention neural network to transfer and aggregate the visual features of the node to enhance the visual representation of the node.

[0005] The third is the semi-structured web page attribute value extraction method based on DOM tree features. This type of method mainly focuses on the relevant features in the underlying DOM tree of the web page, such as node Xpath, node HTML tag, node text content, and node association. The presentation effect of the web page is closely related to the way the HTML source code is written. The web page DOM tree is the analysis of the HTML document. Therefore, it is a very important way to locate or understand the content of the web page using the underlying DOM tree features. The literature "Lin BY, Sheng Y, VoN, et al. FreeDOM: A Transferable Neural Architecture for Structured Information Extraction on Web Documents [J]. ACM, 2020." constructs a two-stage model FreeDOM to realize the inference of DOM tree node attribute types. In the first stage of learning, the model mainly extracts local features of nodes to realize node classification, mainly including node text features, previous text semantic features, node HTML tags, node content format and other discrete features. In the second stage of learning, the model learns the dependency relationship between nodes by constructing node pairs, thereby correcting the classification results of the first stage. SimpDOM proposed in the document "Zhou Y, Sheng Y, Vo N, et al. Simplified DOM Trees for Transferable Attribute Extraction from the Web[J]. 2021." simplifies the two-stage model of FreeDOM and constructs a holistic attribute value extraction model. After retrieving the current node context according to the DOM tree, the model serializes and concatenates the text features of the node and its context nodes to obtain an enhanced representation of the node semantics. At the same time, this method introduces discrete features such as node XPath and node HTML tags to further improve the generalization of the model. The above work enables SimpDOM to be trained on seed websites and extract on new websites.

[0006] Although early wrapper-based methods only require a small number of annotated web pages for each website, building and regularly updating templates for each website requires huge manpower and time costs, and is less practical. Feature learning-based methods do not rely on templates, but instead use a few seed websites to generalize the model to other websites in the same field. However, each seed website requires thousands of annotated web pages, which means that a large amount of web-level data collection and annotation work is still required. Otherwise, the scarcity of annotated data will limit the learning ability of the model. Summary of the invention

[0007] The purpose of the present invention is to propose a method and system for extracting attribute values ​​of semi-structured web pages based on prompt learning, which is used to solve the problem that the scarcity of domain annotation data leads to limited learning ability of existing models. It can extract attribute information of semi-structured web pages and has generalization ability.

[0008] To achieve the above object, the present invention adopts the following technical solutions:

[0009] A method for extracting attribute values ​​from semi-structured web pages based on prompt learning comprises the following steps:

[0010] For semi-structured web pages, the text nodes in the DOM tree of the web page include fixed nodes and variable nodes. For each variable node, the DOM tree perspective hint at the semantic level is retrieved;

[0011] Design task templates to add task prompts to the text content of variable nodes to obtain template perspective prompts at the task level;

[0012] Rewrite the text content of each variable node and its DOM tree perspective prompt through the task template, and mask the label mapping text in the task template to achieve the fusion of the DOM tree perspective prompt and the template perspective prompt to obtain a dual-perspective prompt;

[0013] Using a pre-trained language model based on an encoder-decoder structure, the dual-view prompt information is input to the encoder, and the decoder predicts the text at the mask position. The text is composed of words in the vocabulary of the pre-trained language model, and the attribute type is determined based on the mapping relationship between the text and the predefined attributes.

[0014] Training the pre-trained language model, calculating the matching probability between the text output by the decoder and the label mapping text, and calculating the loss function according to the matching probability, and optimizing the loss function;

[0015] For the semi-structured web pages to be processed, the pre-trained language model is used to predict the attribute types of the variable nodes, and the normalized probability output of each position on the decoder side is obtained. The score of each attribute type is calculated based on the probability, and the attribute type with the highest score is taken as the prediction result.

[0016] Furthermore, for each variable node, the step of retrieving the semantic hint information from the DOM tree perspective includes:

[0017] First, for all nodes, retrieve their ancestor nodes according to Xpath, and put the node into the collection corresponding to each of its ancestor nodes;

[0018] Then, for the variable node, backtrack from its nearest ancestor node. If there is only one fixed node in the set corresponding to the ancestor, and the distance between the fixed node and the current variable node meets the requirements, stop backtracking and use it as semantic prompt information from the DOM tree perspective. Otherwise, continue backtracking to higher-level ancestor nodes and repeat the above process.

[0019] Furthermore, when using a pre-trained language model based on an encoder-decoder structure for prediction, a mask is set in advance at a blank position in the task template as a label placeholder, and then the pre-trained language model learns content information and length information of the mask position through training.

[0020] Furthermore, the loss function is a log-likelihood loss function, and optimizing the loss function refers to minimizing the negative log-likelihood of all variable nodes.

[0021] Furthermore, when calculating the score, the predicted attribute type name is converted into a label, and the score is normalized using the length of the label mapping text.

[0022] A system for extracting attribute values ​​of semi-structured web pages based on prompt learning comprises a memory and a processor. A computer program is stored in the memory, and the steps of the above method are implemented when the processor executes the program.

[0023] The advantages of the present invention are as follows:

[0024] The present invention proposes a semi-structured web page attribute value extraction method based on prompt learning. First, the DOM tree perspective prompt of the variable node is retrieved according to the DOM tree simplification algorithm, which can improve the domain knowledge retrieval ability of the pre-trained language model. Then, a task template containing a task description is designed to obtain the template perspective prompt information, which can stimulate the task understanding ability of the pre-trained language model. Finally, since the rich prior knowledge and semantic expression of the pre-trained language model can effectively alleviate the problem of lack of task information, the present invention introduces a pre-trained language model based on an encoder-decoder structure, and takes "prompt" as the core operation, comprehensively analyzes the characteristics of the domain data and the characteristics of the target task, designs prompt information of two perspectives, and fuses the dual-perspective prompt information through template filling. The pre-trained language model is jointly guided to perform task learning at the semantic level and the task level through prompt learning, realizing the effective combination of the pre-trained language model and the attribute value extraction task, and achieving superior model performance in the scenario of scarce domain annotation data. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 This is a framework diagram of a semi-structured web page attribute value extraction method based on prompt learning proposed by the present invention.

[0026] Figure 2 This is a general flow chart of semi-structured web page attribute value extraction.

[0027] Figure 3 This is a diagram of the ablation experiment results of a semi-structured web page attribute value extraction method based on prompt learning proposed in the present invention. DETAILED DESCRIPTION

[0028] In order to make the various technical features and advantages or technical effects in the above technical solutions of the present invention more obvious and easy to understand, they are described in detail below with reference to the accompanying drawings.

[0029] As described in the document "Devlin J, Chang MW, Lee K, et al. Bert: Pre-training of deep bidirectional transformers for language understanding [J]. arXiv preprint arXiv: 1810.04805, 2018.", the rich prior knowledge and semantic expression of the pre-trained language model can effectively alleviate the problem of lack of task information. Therefore, the present invention introduces a pre-trained language model based on an encoder-decoder structure, and adopts a prompt learning paradigm to realize the effective combination of the model and the attribute value extraction task. The present invention first retrieves the DOM tree perspective prompts at the semantic level of the variable node according to the DOM tree simplification algorithm, then designs a task template containing a task description, obtains the template perspective prompts at the task level, and finally fills in the template to fuse the dual-perspective prompt information, jointly guides the pre-trained language model to perform task learning at the semantic level and the task level, and improves the domain knowledge retrieval ability and task understanding ability of the pre-trained language model, thereby coping with the small sample extraction scenario at the web page level.

[0030] The present invention proposes a method and system for extracting attribute values ​​of semi-structured web pages based on prompt learning (hereinafter referred to as EDDVPL) as follows: Figure 1 As shown in the figure, EDDVPL consists of five components, namely, the construction of DOM tree perspective prompts, template perspective prompts and dual perspective prompts, label word mapping, model training and model inference. Each part will be introduced in detail below.

[0031] (1) Construction of DOM tree perspective prompts.

[0032] In semi-structured web pages, the contexts corresponding to different structural relationships can provide different clues for the classification of variable nodes, and this feature is generalizable between different semi-structured web pages. Among them, the descriptive context of the variable node explicitly and intuitively indicates what type of information the current node content is at the semantic level, which has important reference significance. Figure 2For example, when the variable node corresponds to "Vicky Jenson", its descriptive context "Director" can prompt the relevant definition of the variable node. Therefore, the goal of this section is to retrieve the descriptive context for each variable node x as its prompt information based on the DOM tree perspective.

[0033] The text nodes in the web page DOM tree can be divided into fixed nodes N f and variable node N v . Among them, fixed nodes remain consistent between different web pages of the same website, while the content of variable nodes changes frequently. Since attribute values ​​are usually different in different web pages, EDDVPL narrows the scope of nodes to be classified (also called candidate nodes) in web pages to variable nodes. After determining the variable nodes, EDDVPL retrieves DOM tree perspective hints for each variable node x. A DOM tree is a hierarchical structure consisting of a series of nodes. It originates from a node called "root", that is, the root node, and extends downward layer by layer. For each variable node x, all nodes on the path from the root node to x (excluding x itself) are its ancestors. Given a set of text nodes Satisfy x and x n ∈X n The distance to their lowest common ancestor does not exceed a constant D, and the DOM tree perspective of x exists in a fixed set of nodes containing at most one node. In the set, x DOM ∈X DOM Is the only one in the DOM tree that originates from x DOM and x are the lowest common ancestor of a fixed node.

[0034] (2) Construction of template perspective prompts and dual perspective prompts

[0035] As described in the paper "Liu P, Yuan W, Fu J, et al. Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processing [J]. 2021.", in prompt learning, the task template By adding a task description to the original text (i.e., a template perspective prompt at the task level), the model is prompted and guided to do what next. With this task-level prompt, the model can quickly retrieve and make full use of the task-related knowledge learned during pre-training, making it easier to solve the task.

[0036] For any variable node x∈N in the web page v , and its text content is represented as Its DOM tree perspective prompt is represented as EDDVPL first designs a task template, and then rewrites x and its DOM tree perspective prompt information simultaneously according to the task template, realizing the fusion of the semantic level DOM tree perspective prompt and the task level template perspective prompt to obtain a dual perspective prompt. In this way, the dual perspective prompt input of the model is x prompt It can be expressed as:

[0037]

[0038] Specifically, the task template designed by EDDVPL is:

[0039]

[0040] The goal of EDDVPL is to prompt After that, the decoder predicts the content of the blank position, which is the vocabulary text corresponding to the attribute type of x.

[0041] (3) Label word mapping

[0042] After obtaining dual-perspective prompts from the DOM tree perspective and the template perspective, the pre-trained language model needs to predict the masked text z in the blank space of the task template (i.e., the mask position). Here, a one-to-one label mapping function φ is required to implement the predefined attribute set and the set of texts to be predicted The conversion mapping is as follows:

[0043]

[0044] The above formula indicates that the function φ can convert any attribute name in the predefined attribute set into Mapped to text consisting of words from the pre-trained language model vocabulary EDDVPL achieves label-word mapping by removing meaningless symbols in attribute names or adding qualifiers to attribute names.

[0045] It is worth noting that when performing classification tasks, the prompt learning based on the autoencoder pre-trained language model needs to mask the label mapping text after mapping in the task template, and then obtain the final result by predicting the token at each mask position. However, when a new data appears, the length of its text to be predicted is unknown. At this time, the model cannot determine the number of masks and cannot classify it.

[0046] In order to solve this problem, the documents "Schick T, H Schütze. Exploiting Cloze Questions for Few Shot Text Classification and Natural Language Inference [J]. 2020." and "Han X, Zhao W, Ding N, et al. Ptr: Prompt tuning with rules for text classification [J]. AI Open, 2022, 3: 182-192." attempt to fix the length of the text after each label mapping. However, this method will result in the loss or disturbance of semantic information. Therefore, the present invention adopts a pre-trained language model based on an encoder-decoder structure to avoid the above problems. After giving a mask as a label placeholder in the task template, the model of this structure can simultaneously learn the content information and length information of the mask position during training, thereby generating prediction results of arbitrary length on the decoder side and solving the problem of inconsistent label length.

[0047] (4) Model training

[0048] The pre-trained language model is represented as Given dual-view prompt input And the predicted target is the label mapping text φ(y). Assuming that the output sequence of the decoder is o, the matching probability between the decoded output and the label mapping text (that is, the masked original label mapping text) is calculated as follows:

[0049]

[0050] Where P represents the matching probability function, o t and φ t (y) represent the tth word of the output sequence o and the label mapping text φ(y), o <t Represents the decoding sequence on the left side of the tth word. The goal is to minimize the negative log-likelihood of all variable nodes. The formula of the loss function is as follows:

[0051]

[0052] in, Represents the loss function, the base of log is e.

[0053] (5) Model inference

[0054] When classifying new data, first obtain the normalized probability output of each position on the decoder side, and then, for each attribute type Calculate the score:

[0055]

[0056] Among them, score y represents the score of each attribute type, P(o t =φ t (y)) is the normalized probability output of the decoder at time t, word φ t (y). When calculating the score, in order to avoid the prediction results being biased towards attribute types with longer texts, the method follows the idea of ​​"Chen Y, Harbecke D, Hennig L. Multilingual Relation Classification via Efficient and Effective Prompting[J].arXiv preprint arXiv:2210.13838,2022." and uses the length of the label mapping text φ(y) to normalize the score (that is, the sum of the probabilities in the above formula is used). Divided by |φ(y)|), the attribute type with the highest score is finally selected as the prediction result.

[0057] This section mainly describes the specific implementation plan of the invention in detail. First, the dataset, evaluation index, comparison method and implementation details used in the experiment are introduced; then, a comparison experiment is conducted on the public dataset SWDE proposed in the document "Hao Q, Rui C, Pang Y, et al. From one tree to a forest: a unified solution for structured web data extraction [C] / / International Acm Sigir Conference on Research & Development in Information Retrieval. ACM, 2011.", and the experimental results are presented; finally, the effectiveness of each part of the proposed method is verified through ablation experiments.

[0058] (1) Dataset Introduction

[0059] The SWDE (Structured Web Data Extraction) public dataset contains 8 vertical fields, each of which consists of 10 websites with 3 to 5 attributes. The specific statistics of the dataset are shown in Table 1.

[0060] Table 1 Statistical data of SWDE dataset

[0061] field Number of websites Number of web pages property auto 10 17923 model,price,engine,fuel economy book 10 20000 title,author,isbn,publisher,publish date camera 10 5258 model,price,manufacturer job 10 20000 title,company,location,date posted movie 10 20000 title,director,genre,mpaa rating NBA Player 10 4405 name, team, height, weight restaurant 10 20000 name,address,phone,cuisine university 10 16705 name,phone,website,type

[0062] When conducting the experiment, EDDVPL re-divided the data set. For each field, this experiment selected k (k can be 10, 50, or 100) pages from each website in the field to construct the training set, and used the remaining pages to construct the test set. The specific data of the training set and test set for each field when k takes different values ​​are shown in Table 2.

[0063] Table 2 Details of training and test data in various fields when k takes different values

[0064]

[0065] (2) Introduction to evaluation indicators

[0066] Following the evaluation indicators of existing research, this experiment calculates the page-level F1 score to evaluate the performance of the proposed method. Specifically, for each attribute, precision refers to the number of pages that correctly extract the target attribute value divided by the number of pages that extract the attribute; recall refers to the number of pages that correctly extract the target attribute value divided by the number of pages that contain the target attribute value (see the document "Hao Q, Rui C, Pang Y, et al. From one tree to a forest: a unified solution for structured web data extraction [C] / / International Acm Sigir Conference on Research & Development in Information Retrieval. ACM, 2011."). The page-level F1 score is the harmonic mean of the above precision and recall.

[0067] (3) Comparison method

[0068] In order to demonstrate the advantages of the method in extracting attribute values ​​in a small sample scenario at the web page level, this experiment selected SimpDOM and DOM2R-Graph as comparison methods. Specifically, SimpDOM uses the underlying DOM tree structure to avoid using rendering-based features. It enhances node representation by retrieving context and capturing discrete features for DOM tree nodes. Since these features are consistent across websites, after training with several seed websites, SimpDOM can be used for extraction on other unseen websites. DOM2R-Graph (reference: Feng J, Cao C, Yuan F, et al. DOM2R-Graph: A Web Attribute Extraction Architecture with Relation-Aware Heterogeneous Graph Transformer [C] / / Neural Information Processing: 29th International Conference, ICONIP 2022, Virtual Event, November 22–26, 2022, Proceedings, Part I. Cham: Springer International Publishing, 2023: 468-479.) simplifies the web page DOM tree and models it as a heterogeneous graph. By capturing the impact of contextual structural relationships on semantic interactions in the graph, a fine-grained representation of nodes is obtained to improve the extraction effect. Since text semantics and contextual structural relationships are generalizable features between websites, DOM2R-Graph can perform cross-website attribute value extraction well.

[0069] (4) Implementation details

[0070] In the data preprocessing stage, EDDVPL first uses the LXML library to parse the HTML source code of the web page to obtain the DOM tree structure of the web page. Then, based on the heuristic algorithm of the literature "Lin BY, Sheng Y, Vo N, et al. FreeDOM: A Transferable Neural Architecture for Structured Information Extraction on WebDocuments[J]. ACM, 2020.", this chapter distinguishes between fixed nodes and variable nodes in the web page. In addition, this chapter sets the maximum distance D between the variable node and its DOM tree perspective hint information to their lowest common ancestor to 2.

[0071] During the model training phase, EDDVPL uses the T5 provided by the Transformers library in Hugging Face. base As a pre-trained language model, the training batch size is set to 16, the learning rate is 0.0002, and the number of training times is 20.

[0072] (5) Comparative experimental results

[0073] In order to fully verify the effectiveness of EDDVPL, this section conducts experimental verification on the SWDE dataset. The comparison results of EDDVPL and the comparison methods on training sets of different sizes are shown in Table 3, where k represents the number of web pages used for training on each website.

[0074] Table 3 Experimental results of EDDVPL and comparison methods on SWDE dataset

[0075]

[0076] From the results in the table, we can see that when k=10, SimpDOM outperforms DOM2R-Graph. This is because when there is very little annotated data, SimpDOM's rich discrete features can provide a certain basis for reasoning compared to DOM2R-Graph, which only focuses on complex features such as semantics and structure. Under this data setting, the effect of the EDDVPL model significantly surpasses all the above methods. This is because SimpDOM and DOM2R-Graph rely on task data to learn complex semantic knowledge or web page structures that are consistent between websites, and very little training data cannot provide them with sufficient learning opportunities. For EDDVPL, the following two aspects determine its superior performance:

[0077] 1) The pre-trained language model contains more comprehensive semantic expressions and rich prior knowledge, which provides a good foundation for the model to infer node attribute types with very little training data.

[0078] 2) EDDVPL quickly guides the pre-trained language model to understand "what needs to be done" by building task templates. It introduces DOM tree perspective prompt information to assist the model in making judgments and stimulate domain-related knowledge at the semantic level, thus achieving an effective combination of the pre-trained language model and task objectives and domain data. Therefore, even with only a small number of training web pages, the model can quickly make full use of limited data.

[0079] As k increases, existing methods can further learn web page-related features that are more domain- and task-specific, so their generalization ability is further improved, and the gap with EDDVPL is gradually narrowing. However, EDDVPL can still achieve comparable or even better results in various fields based on its strong task understanding ability and important DOM tree prompt information.

[0080] (1) Ablation Experiment Results

[0081] In order to verify the effectiveness of the design of each part of EDDVPL, this section conducts an ablation experiment on the public dataset SWDE. Specifically, this section designs two variant models to demonstrate the contribution of different perspective cues. The relevant descriptions of the variant models are as follows:

[0082] 1) Template-view In order to prove the important role of DOM tree perspective hint information at the semantic level, this experiment removed the DOM tree perspective hint information and only used the text of the node itself to fill in the template.

[0083] 2) DOM-view In order to prove the effectiveness of the template perspective hint information at the task level, this experiment removed the task template and input the node's own text and DOM tree perspective hint into the model in a continuous sequence.

[0084] When 10 web pages are taken from each website as the training set (i.e., k = 10), the ablation experiment results in various fields are as follows: Figure 3 As shown. Figure 3 It can be seen that the effects of Template-view and DOM-view are both lower than those of the complete model. This is because when the DOM tree perspective prompt information is removed, although the model understands the task objectives, the relevant knowledge cannot be quickly retrieved due to the lack of domain text information; when the template perspective prompt information at the task level is removed, the model only has relevant semantic knowledge and is relatively vague about the task requirements, so it is difficult to converge quickly. The above experimental results prove that the prompts from both perspectives have a positive guiding effect on the model, and also show that only when the pre-trained language model is closely integrated with the task and domain can the maximum utilization of existing knowledge and limited data be achieved.

[0085] Although the present invention has been disclosed as above by way of embodiments, it is not intended to limit the present invention. Appropriate modifications or equivalent substitutions of the technical solutions of the present invention made by ordinary technicians in the field should all be included in the protection scope of the present invention. The protection scope of the present invention shall be based on what is defined in the claims.

Claims

1. A method for extracting attribute values ​​from semi-structured web pages based on prompt learning, characterized in that: The following steps are involved: For semi-structured web pages, the text nodes in the DOM tree of the web page include fixed nodes and variable nodes. For each variable node, the DOM tree perspective hint at the semantic level is retrieved; Design task templates to add task prompts to the text content of variable nodes to obtain template perspective prompts at the task level; Rewrite the text content of each variable node and its DOM tree perspective prompt through the task template, and mask the label mapping text in the task template to achieve the fusion of the DOM tree perspective prompt and the template perspective prompt to obtain a dual-perspective prompt; Using a pre-trained language model based on an encoder-decoder structure, the dual-view prompt information is input to the encoder, and the decoder predicts the text at the mask position. The text is composed of words in the vocabulary of the pre-trained language model, and the attribute type is determined based on the mapping relationship between the text and the predefined attributes. Training the pre-trained language model, calculating the matching probability between the text output by the decoder and the label mapping text, and calculating the loss function according to the matching probability, and optimizing the loss function; For the semi-structured web pages to be processed, the pre-trained language model is used to predict the attribute types of the variable nodes, and the normalized probability output of each position on the decoder side is obtained. The score of each attribute type is calculated based on the probability, and the attribute type with the highest score is taken as the prediction result.

2. The method according to claim 1, characterized in that For each variable node, the steps of retrieving the semantic hint information from the DOM tree perspective include: First, for all nodes, retrieve their ancestor nodes according to Xpath, and put the node into the collection corresponding to each of its ancestor nodes; Then, for the variable node, backtrack from its nearest ancestor node. If there is only one fixed node in the set corresponding to the ancestor, and the distance between the fixed node and the current variable node meets the requirements, stop backtracking and use it as semantic prompt information from the DOM tree perspective. Otherwise, continue backtracking to higher-level ancestor nodes and repeat the above process.

3. The method according to claim 1, characterized in that When using a pre-trained language model based on an encoder-decoder structure for prediction, a mask is set in advance at a blank position in the task template as a label placeholder, and then the pre-trained language model learns the content information and length information of the mask position through training.

4. The method according to claim 1, characterized in that The formula for calculating the matching probability between the text output by the decoder and the label mapping text is as follows: Where P represents the matching probability function, o t and φ t (y) represents the tth word of the output sequence o and the label mapping text φ(y), y represents the attribute type, o <t represents the decoding sequence on the left side of the t-th word, Represents a task template, Represents the text content of variable node x, A DOM tree view hint representing the variable node x.

5. The method according to claim 1, characterized in that The loss function is a log-likelihood loss function, and optimizing the loss function means minimizing the negative log-likelihood of all variable nodes.

6. The method according to claim 5, characterized in that The loss function is calculated as follows: in, represents the loss function, P represents the matching probability function, o t and φ t (y) represents the tth word of the output sequence o and the label mapping text φ(y), y represents the attribute type, o <t represents the decoding sequence on the left side of the t-th word, the log base is e, Represents a task template, Represents the text content of variable node x, Represents the DOM tree perspective hint of variable node x, N v Represents a collection of variable nodes.

7. The method according to claim 1, characterized in that When calculating the score, the predicted attribute type name is converted to a label and the score is normalized using the length of the label mapping text.

8. The method according to claim 7, characterized in that The formula for calculating the score is as follows: Among them, score y represents the score of each attribute type, P(o t =φ t (y)) represents the normalized probability output of word φ at the decoder end at time t t The probability value of (y), o t and φ t (y) represent the tth word of the output sequence o and the label mapping text φ(y), respectively, and y represents the attribute type.

9. A semi-structured web page attribute value extraction system based on prompt learning, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the program, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Web data extraction method based on visual customization of extraction template

    CN102360368A

  • Knowledge prompt-based concept extraction model

    CN114911947A