Semi-structured webpage attribute value extraction method based on prompt learning, and electronic device and storage medium
By using a combination of dual-view prompt information and pre-trained language models in semi-structured web pages, the problem of limited model learning ability caused by the scarcity of domain annotation data is solved, and the efficient extraction of semi-structured web page attribute values and model performance improvement are achieved. .
Patent Information
- Application Number
- PCT/CN2023/099808
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-26
- Filing Date
- 2023-06-13
- Publication Date
- 2024-10-31
AI Technical Summary
Existing semi-structured web page attribute value extraction methods have limited model learning capabilities when domain annotation data is scarce, making it difficult to effectively extract attribute information of semi-structured web pages.
Using a prompt-based learning method, through dual-perspective prompt information from the DOM tree perspective and the task template perspective, combined with the encoder-decoder structure of the pre-trained language model, prediction of attribute types and loss function optimization are performed to improve the model's domain knowledge retrieval and task Comprehension.
In scenarios where domain annotation data is scarce, it achieves efficient extraction of semi-structured web page attribute values, improves the model's generalization ability and performance, and reduces dependence on a large amount of annotated data.
Smart Images

Figure CN2023099808_31102024_PF_FP_ABST
Abstract
Description
A method for extracting attribute values from semi-structured web pages based on prompt learning, an electronic device, and a storage medium Technical Field
[0001] The present invention relates to the field of the Internet, and in particular to a method for extracting attribute values from semi-structured web pages based on prompt learning, as well as electronic equipment and storage media applicable to the method. 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 performance of downstream tasks. However, due to the large scale of semi-structured web pages, the complex content and varied layout of the web pages, extracting structured attribute information from semi-structured web pages is a very challenging task. At present, the attribute value extraction methods of semi-structured web pages are mainly divided into the following three categories:
[0003] One is a wrapper-based semi-structured web page attribute value extraction method, which is a method that constructs extraction rules or templates based on the shallow regularities of the target data in the web page. For each website, the web pages within the site usually have the same or similar layout structure. This feature makes the data in the web page have certain presentation regularities. Therefore, formulating rules based on the relevant regularities found can achieve the extraction of target data. The literature "Hammer J, Mchugh JG, Garcia-Molin H. Semistructured data: the TSIMMIS experience. British Computer Society, 1997." First, by analyzing the source code of the web page, the regularities of the target data's HTML tags, XPath paths and other features are discovered. Then, based on these regularities, a series of sequentially executed instructions are designed to achieve accurate extraction of the target data. The literature "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 construct 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 approach involves extracting attribute values from semi-structured web pages based on visual features. These methods, based on the characteristics of web page layout, consider visual features such as the size, proportion, and layout relevance of text blocks within the web page. To facilitate quick comprehension and navigation of web page content, web pages typically divide and arrange information based on visual structure. Therefore, analyzing and understanding web page content based on visual features is a crucial approach. The paper "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" proposes a method based on rendering features. This method uses visual features such as the size and position of text blocks within the DOM tree to explore the distances between web page blocks, which are then used to extract attribute values from the web page. The paper "Kumar A, Morabia K, Wang J, et al. CoVA: Context-aware Visual Attention for Webpage Information Extraction[J].arXiv e-prints, 2021" proposes a neural network model for encoding visual features called CoVA. This model consists of a representation network consisting of a CNN, a pooling layer, and a positional encoder, and a graph attention neural network. The model first uses the representation network to learn visual features such as the size and spatial position of each node content block in a webpage screenshot. Then, the graph attention neural network is applied to transfer and aggregate the visual features of the nodes, enhancing their visual representation.
[0005] The third approach involves extracting attribute values from semi-structured web pages based on DOM tree features. This approach focuses on relevant features within the underlying DOM tree of a web page, such as node XPath, node HTML tags, node text content, and node associations. The presentation of a web page is closely related to the way the HTML source code is written. The web page DOM tree is a parsed representation of the HTML document, so leveraging underlying DOM tree features to locate or understand web page content is a crucial approach. The paper "Lin BY, Sheng Y, Vo N, et al. FreeDOM: A Transferable Neural Architecture for Structured Information Extraction on Web Documents[J]. ACM, 2020" constructs a two-stage model, FreeDOM, to infer attribute types from DOM tree nodes. In the first stage of learning, the model primarily extracts local node features to achieve node classification, including node text features, semantic features of the preceding context, and discrete features such as node HTML tags and node content format. In the second stage of learning, the model constructs node pairs to learn dependencies between nodes, thereby correcting the classification results from the first stage. SimpDOM, proposed in the paper "Zhou Y, Sheng Y, Vo N, et al. Simplified DOM Trees for Transferable Attribute Extraction from the Web[J]. 2021," simplifies FreeDOM's two-stage model and constructs a holistic attribute value extraction model. After retrieving the current node context based on 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's semantics. At the same time, the 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] While early wrapper-based approaches only required a small number of labeled web pages per website, building and regularly updating templates for each site resulted in significant labor and time costs, making them less practical. Feature-based learning approaches, instead of relying on templates, leverage a small number of seed websites to generalize the model to other websites in the same domain. However, each seed website requires thousands of labeled web pages, which necessitates extensive web-level data collection and labeling. Otherwise, the scarcity of labeled data would limit the model's learning capabilities.
[0007] Summary of the Invention
[0008] The purpose of this invention is to propose a method for extracting attribute values from 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.
[0009] The present invention also provides an electronic device and a storage medium applicable to the above method.
[0010] To achieve the above object, the present invention adopts the following technical solutions:
[0011] A method for extracting attribute values from semi-structured web pages based on prompt learning includes the following steps:
[0012] 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;
[0013] Design task templates to add task prompts to the text content of variable nodes to obtain template perspective prompts at the task level;
[0014] 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;
[0015] Using a pre-trained language model based on an encoder-decoder structure, the dual-view prompt information is input to the encoder side, and the decoder side 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 predefined attributes.
[0016] 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 based on the matching probability, and optimizing the loss function;
[0017] 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 used as the prediction result.
[0018] Furthermore, for each variable node, the step of retrieving its semantic hint information from the DOM tree perspective includes:
[0019] 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;
[0020] 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, then stop backtracking and use it as semantic hint information from the DOM tree perspective. Otherwise, continue backtracking to the higher-level ancestor node and repeat the above process.
[0021] 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 the content information and length information of the mask position through training.
[0022] 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.
[0023] 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.
[0024] The electronic device of the present invention includes a memory and a processor. A computer program is stored in the memory. When the processor executes the program, the steps of the above-mentioned method for extracting attribute values of semi-structured web pages based on prompt learning are realized.
[0025] The computer-readable storage medium of the present invention stores computer program instructions, which, when executed by a processor, implement the steps of the above-mentioned method for extracting attribute values of semi-structured web pages based on prompt learning.
[0026] The advantages of the present invention are as follows:
[0027] 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 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 the 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 from two perspectives, integrates the dual-perspective prompt information through template filling, and jointly guides the pre-trained language model to perform task learning at the semantic level and the task level through prompt learning, thereby realizing the effective combination of the pre-trained language model and the attribute value extraction task, and achieving superior model performance in scenarios where domain annotation data is scarce. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] FIG1 is a framework diagram of a method for extracting attribute values from semi-structured web pages based on prompt learning proposed by the present invention.
[0029] Figure 2 is a schematic diagram of the general process of extracting attribute values from semi-structured web pages.
[0030] FIG3 is a graph showing 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
[0031] In order to make the various technical features and advantages or technical effects of 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.
[0032] As described in the paper “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 the encoder-decoder structure and adopts a prompt learning paradigm to achieve an effective combination of the model and the attribute value extraction task. The present invention first retrieves the semantic level DOM tree perspective prompts of the variable nodes according to the DOM tree simplification algorithm, then designs a task template containing the task description to obtain the template perspective prompts at the task level, and finally integrates the dual perspective prompt information by filling the template, jointly guiding the pre-trained language model to perform task learning at the semantic level and the task level, thereby improving 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.
[0033] Figure 1 shows the proposed method and system for extracting attribute values from semi-structured web pages based on prompt learning (hereinafter referred to as EDDVPL). EDDVPL consists of five components: constructing DOM tree perspective prompts, constructing template perspective prompts and dual-perspective prompts, label-word mapping, model training, and model inference. Each component will be described in detail below.
[0034] (1) Construction of DOM tree perspective prompts.
[0035] In semi-structured web pages, the contexts corresponding to different structural relationships can provide different clues for the classification of variable nodes, and this characteristic is generalizable across different semi-structured web pages. The descriptive context of a variable node explicitly and intuitively indicates the type of information contained in the current node at a semantic level, thus providing important reference value. For example, in Figure 2, when the variable node corresponds to "Vicky Jenson," its descriptive context "Director" can indicate 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 a hint based on the DOM tree perspective.
[0036] 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 often changes. 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 composed 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, the set satisfies x DOM ∈X DOM Is the only one in the DOM tree that originates from x DOM and x are the fixed nodes of the lowest common ancestor.
[0037] (2) Construction of template perspective prompts and dual perspective prompts
[0038] As described in the literature "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 on what to do next. With this task-level prompt, the model can quickly retrieve and fully utilize the task-related knowledge learned during pre-training, making it easier to solve the task.
[0039] 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:
[0040] Specifically, the task template designed by EDDVPL is:
[0041] The goal of EDDVPL is to prompt Finally, the decoder predicts the content of the blank position, which is the vocabulary text corresponding to the attribute type of x.
[0042] (3) Label word mapping
[0043] 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 text set to be predicted The conversion mapping is as follows:
[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's worth noting that when performing classification tasks, prompt learning based on an autoencoder pre-trained language model requires masking the label-mapped text in the task template and then predicting the token at each masked position to obtain the final result. However, when new data is presented, the length of the text to be predicted is unknown. In this case, the model cannot determine the number of masks and, therefore, cannot classify it.
[0046] In order to solve this problem, the literature "Schick T, H Schütze. Exploiting Cloze Questions for Few Shot Text Classification and Natural Language Inference[J]. 2020." and the literature "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 the 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, 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] Among them, 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), o <t Represents the decoding sequence on the left side of the t-th word. The goal is to minimize the negative log-likelihood of all variable nodes. The loss function formula is as follows:
[0050] in, Represents the loss function, the base of log is e.
[0051] (5) Model inference
[0052] 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:
[0053] 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) probability value. 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). Divide by |φ(y)|), and finally select the attribute type with the highest score as the prediction result.
[0054] This section describes the specific implementation of the invention in detail. First, we introduce the datasets, evaluation metrics, comparison methods, and implementation details used in the experiments. We then conduct comparative experiments on the public dataset SWDE, presented in the paper "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 present the experimental results. Finally, we conduct ablation experiments to verify the effectiveness of each component of the proposed method.
[0055] (1) Dataset Introduction
[0056] The SWDE (Structured Web Data Extraction) public dataset contains eight vertical domains, each consisting of 10 websites with 3 to 5 attributes. The specific statistics of the dataset are shown in Table 1.
[0057] Table 1 SWDE dataset statistics
[0058] During the experiment, EDDVPL repartitioned the dataset. For each domain, this experiment selected k (k can be 10, 50, or 100) pages from each website within that domain to construct the training set, and the remaining pages to construct the test set. Table 2 shows the specific data for the training and test sets for each domain when k is used for different values.
[0059] Table 2 Details of training and test data in various fields when k takes different values
[0060] (2) Introduction to evaluation indicators
[0061] Following the evaluation metrics 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 total 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 reference "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.
[0062] (3) Comparison method
[0063] To demonstrate the advantages of our method for extracting attribute values from a small sample size of web pages, this experiment compared SimpDOM and DOM2R-Graph. Specifically, SimpDOM leverages the underlying DOM tree structure to avoid using rendering-based features. It enhances node representation by retrieving context for DOM tree nodes and capturing discrete features. Because these features are consistent across websites, SimpDOM, after training on a few seed websites, can extract attributes from other unseen websites. DOM2R-Graph (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 webpage DOM tree and models it as a heterogeneous graph. By capturing the influence of contextual structural relationships on semantic interactions within the graph, it obtains a fine-grained representation of nodes to improve extraction performance. Because textual semantics and contextual structural relationships are generalizable features across websites, DOM2R-Graph can effectively extract attribute values across websites.
[0064] (4) Implementation details
[0065] During the data preprocessing phase, EDDVPL first uses the LXML library to parse the HTML source code of a webpage to obtain the webpage's DOM tree structure. This chapter then uses a heuristic algorithm based on the paper "Lin BY, Sheng Y, Vo N, et al. FreeDOM: A Transferable Neural Architecture for Structured Information Extraction on Web Documents[J]. ACM, 2020." to distinguish between fixed and variable nodes in the webpage. Furthermore, this chapter sets the maximum distance D between a variable node and its DOM tree perspective information and its lowest common ancestor to 2.
[0066] 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.
[0067] (5) Comparative experimental results
[0068] To fully verify the effectiveness of EDDVPL, this section conducts experimental verification on the SWDE dataset. The comparison results of EDDVPL and 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.
[0069] Table 3 Experimental results of EDDVPL and comparison methods on SWDE dataset
[0070] The results in the table show that when k = 10, SimpDOM outperforms DOM2R-Graph. This is because, given minimal labeled data, SimpDOM's rich discrete features provide a basis for reasoning, compared to DOM2R-Graph, which focuses solely on complex features such as semantics and structure. Under this data setting, the EDDVPL model significantly outperforms all of the aforementioned methods. This is because SimpDOM and DOM2R-Graph rely on task data to learn complex semantic knowledge or web page structure that is consistent across websites, and the limited training data does not provide sufficient learning opportunities. EDDVPL's superior performance is driven by the following two factors:
[0071] 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.
[0072] 2) EDDVPL rapidly guides pre-trained language models to understand "what needs to be done" by constructing task templates. By introducing DOM tree-perspective prompts, it assists the model in making decisions at the semantic level and stimulates domain-related knowledge. This effectively integrates the pre-trained language model with task objectives and domain data. As a result, even with only a small number of training web pages, the model can quickly and fully utilize the limited data.
[0073] As k increases, existing methods can further learn domain- and task-specific web page features, thus further improving their generalization capabilities and gradually narrowing the gap with EDDVPL. However, EDDVPL, due to its stronger task understanding and important DOM tree hints, can still achieve comparable or even better results in various fields.
[0074] (1) Ablation experiment results
[0075] To verify the effectiveness of the design of each part of EDDVPL, this section conducts ablation experiments on the public dataset SWDE. Specifically, this section designs two variant models to demonstrate the contribution of different viewpoint cues. The relevant descriptions of the variant models are as follows:
[0076] 1) Template-view In order to demonstrate the importance of semantic-level DOM tree perspective hint information, this experiment removed the DOM tree perspective hint information and only used the node's own text to fill in the template.
[0077] 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.
[0078] 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 shown in Figure 3. As can be seen from Figure 3, the effects of Template-view and DOM-view are both reduced compared to the complete model. This is because when the DOM tree perspective prompt information is removed, although the model understands the task objectives, due to the lack of domain text information, the relevant knowledge cannot be quickly retrieved; 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, making it difficult to converge quickly. The above experimental results prove that 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.
[0079] Although the present invention has been disclosed as above by way of embodiments, they are not intended to limit the present invention. Any appropriate modification or equivalent substitution of the technical solution of the present invention by a person skilled in the art should be included in the protection scope of the present invention. The protection scope of the present invention shall be based on that defined in the claims.
Claims
1. A method for extracting attribute values from semi-structured web pages based on prompt learning, comprising the following steps: For the semi-structured web page to be processed, for each variable node of the text node in the DOM tree of the web page, retrieve the DOM tree perspective hint at the semantic level; 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; Use the trained pre-trained language model to predict the attribute type of the variable node, obtain the normalized probability output of each position on the decoder side, calculate the score of each attribute type based on the probability, and extract the attribute type with the highest score as the attribute value of the semi-structured web page.
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 showing 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, with the log base being 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. An electronic device, 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.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Method and system for extracting object attribution value information from webpage
CN102650999A
Web information extraction method and system based on HTML source code and webpage snapshot
CN113312568A
Webpage data extraction method and device, computer equipment and storage medium
CN114491325A
Knowledge prompt-based concept extraction model
CN114911947A
Methods for information extraction, search, and structured representation of text data
US10146751B1
Cited By
Web page information extraction method and device based on attribute perception
CN119166927A
Intelligent decision-making system evaluation scene set construction method and device based on case constraint large model
CN119337151A
Mass spectrum structure analysis method and device, storage medium and program product
CN119517179A
Vertical website information extraction method and device based on large model, equipment and medium
CN119598050A
Universal two-stage webpage information extraction method and system based on multi-dimensional features
CN119646331A
