Gas station customer behavior prediction method and device based on knowledge graph
Through the knowledge graph-based method, the knowledge graph is constructed and the behavior prediction model is combined, the problem that traditional management systems cannot accurately predict customer needs is solved, and more accurate customer behavior prediction and service optimization are achieved.
Patent Information
- Application Number
- CN202510309637.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2045-03-17
AI Technical Summary
The traditional gas station management system lacks in-depth analysis of customer behavior data, which leads to the inability to accurately predict customers' potential needs and thus fail to provide better services.
Using a knowledge graph-based method, the historical customer data of the gas station is extracted and processed, semantic vectors and part-of-speech vectors are generated, and the triple is extracted after the fusion process is used to build the knowledge graph, and in-depth analysis is carried out in combination with the preset behavior prediction model to predict customer behavior.
It achieves more accurate customer behavior prediction results, can accurately adjust oil inventory, optimize capital flow, meet customers' potential needs and improve service quality.
Smart Images

Figure CN119831114A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the fields of natural language processing and Internet application technology, and in particular to a method and device for predicting customer behavior at a gas station based on a knowledge graph. Background Art
[0002] With the diversity of customer behavior and the rapid changes in the market, in order to provide customers with better services, it is particularly important to predict customer behavior. Traditional gas station management systems rely on basic membership management and manual services. These systems often lack analysis of customer behavior data, resulting in the inability to accurately predict customers' potential needs and, in turn, the inability to provide better services. For example, the formulation of promotional and preferential policies often lacks pertinence and flexibility.
[0003] However, existing solutions that can predict customer behavior mostly use simple prediction methods based on historical purchase data, and do not combine other customer behavior data for in-depth analysis from the overall perspective, which limits the accuracy and effectiveness of customer behavior predictions. Summary of the invention
[0004] In order to solve the above-mentioned problem of poor prediction effect of gas station customer behavior, the embodiment of the present application provides a gas station customer behavior prediction method and device based on knowledge graph, and its technical solution is as follows: In a first aspect, the present application embodiment provides a method for predicting customer behavior at a gas station based on a knowledge graph, comprising: Perform information extraction on historical customer data at gas stations to obtain semantic vectors and part-of-speech vectors; The semantic vector and the part-of-speech vector are fused to obtain a fused vector; Extract at least two triplets from the fused vector and construct a knowledge graph based on all the triplets; Based on the knowledge graph and the preset behavior prediction model, the prediction results are obtained.
[0005] In an optional solution of the first aspect, information extraction is performed on historical customer data in a gas station to obtain a semantic vector and a part-of-speech vector, including: Inputting historical customer data of the gas station into a pre-trained language model to obtain a semantic vector; wherein the pre-trained language model is trained by the sample data and the sample semantic vector corresponding to the sample data; Split the historical customer data to obtain at least two segmented words; Obtaining a part-of-speech tag corresponding to each participle based on a preset part-of-speech table; wherein the preset part-of-speech table includes at least two participles and part-of-speech tags corresponding to the participles; According to all the participles and the part-of-speech tags corresponding to the participles, the part-of-speech vectors are obtained.
[0006] In another optional solution of the first aspect, the semantic vector and the part-of-speech vector are fused to obtain a fused vector, including: Inputting the part-of-speech vector into a preset convolutional model to obtain a node vector; wherein the preset convolutional model is trained by the sample part-of-speech vector and the node vector corresponding to the sample part-of-speech vector; The semantic vector and node vector are fused through the cross attention algorithm to obtain a fused vector.
[0007] In yet another optional solution of the first aspect, extracting at least two triplets from the fused vector includes: Performing entity recognition processing on the fusion vector through a preset neural network model to obtain an entity result; wherein the preset neural network model is trained by the sample fusion vector and the sample entity result corresponding to the sample fusion vector; Performing relationship extraction processing on the fusion vector through a preset deep learning model to obtain a relationship result; wherein the preset deep learning model is trained by the sample fusion vector and the sample relationship result corresponding to the sample fusion vector; Construct triples based on entity results and relationship results.
[0008] In yet another optional solution of the first aspect, constructing a triple based on the entity result and the relationship result includes: Determine a first entity set and a second entity set based on entity types in the entity results; wherein the entity results include at least two entities and an entity type corresponding to each entity; Determine an initial relationship set according to the first entity set and the second entity set; wherein the initial relationship set includes at least two relationship words; The initial relationship set is screened based on the relationship result to obtain a target relationship set; wherein the relationship result includes at least two relationship words, and the target relationship set includes the relationship words common to the relationship result and the initial relationship set; A triple is constructed based on the first entity set, the second entity set, and the target relationship set.
[0009] In another optional solution of the first aspect, a prediction result is obtained based on the knowledge graph and a preset behavior prediction model, including: Obtain the refueling time data and oil type data corresponding to the data to be predicted in the knowledge graph, and serialize the refueling time data and oil type data; Inputting the serialized refueling time data into a preset behavior prediction model to obtain a refueling time series; wherein the preset behavior prediction model is obtained by training the sample serialized data and the sample series; Inputting the serialized oil type data into a preset behavior prediction model to obtain an oil type sequence; Based on the refueling time series and the oil type series, the prediction results are obtained.
[0010] In another optional solution of the first aspect, the prediction result includes a predicted oil type, a predicted refueling amount corresponding to the predicted oil type, and a predicted refueling time; After obtaining the prediction results based on the knowledge graph and the preset behavior prediction model, it also includes: Obtaining the current inventory corresponding to the predicted oil type, and determining the expected inventory based on the current inventory and the predicted refueling volume corresponding to the predicted oil type; The inventory corresponding to the predicted oil type is adjusted based on the predicted refueling time so that the current inventory level is consistent with the expected inventory level before the predicted refueling time.
[0011] In a second aspect, the embodiment of the present application provides a gas station customer behavior prediction device based on a knowledge graph, comprising: The first processing module is used to extract information from the historical customer data of the gas station to obtain semantic vectors and part-of-speech vectors; The second processing module is used to fuse the semantic vector and the part-of-speech vector to obtain a fused vector; A third processing module is used to extract at least two triples from the fusion vector and construct a knowledge graph based on all the triples; The fourth processing module is used to obtain prediction results based on the knowledge graph and a preset behavior prediction model.
[0012] In a third aspect, the embodiment of the present application further provides a gas station customer behavior prediction device based on a knowledge graph, including a processor and a memory; The processor is connected to the memory; A memory for storing executable program codes; The processor runs the program corresponding to the executable program code by reading the executable program code stored in the memory, so as to implement the gas station customer behavior prediction method based on the knowledge graph provided by the first aspect of the embodiment of the present application or any one of the implementation methods of the first aspect.
[0013] In a fourth aspect, an embodiment of the present application provides a computer storage medium, which stores a computer program. The computer program includes program instructions. When the program instructions are executed by a processor, the gas station customer behavior prediction method based on the knowledge graph provided by the first aspect of the embodiment of the present application or any one of the implementation methods of the first aspect can be implemented.
[0014] The beneficial effects brought by the technical solutions provided by some embodiments of this specification include at least: In the process of predicting customer behavior at gas stations based on knowledge graphs, semantic vectors and part-of-speech vectors are extracted from historical customer data and then fused together to fully consider the semantic information and part-of-speech information in the historical customer data. As a result, triplets for constructing the knowledge graph can be extracted based on the fused vectors obtained through the fusion process. In-depth analysis is then performed in combination with the knowledge graph and the preset behavior prediction model to obtain more accurate customer behavior prediction results. Based on the prediction results, oil inventory can be accurately adjusted to optimize cash flow, meet customers' potential needs, and improve service quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0016] Figure 1 An overall flow chart of a gas station customer behavior prediction method based on a knowledge graph provided in an embodiment of the present application; Figure 2 An overall flow chart of a method for constructing a knowledge graph provided in an embodiment of the present application; Figure 3 A schematic diagram of the structure of a gas station customer behavior prediction device based on a knowledge graph provided in an embodiment of the present application; Figure 4 A schematic diagram of the structure of another gas station customer behavior prediction device based on a knowledge graph provided in an embodiment of the present application. DETAILED DESCRIPTION
[0017] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0018] In the following introduction, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance. The following introduction provides multiple embodiments of the present application, and different embodiments can be replaced or combined, so the present application can also be considered to include all possible combinations of the same and / or different embodiments recorded. Therefore, if one embodiment includes features A, B, and C, and another embodiment includes features B and D, then the present application should also be considered to include embodiments containing one or more of all other possible combinations of A, B, C, and D, although the embodiment may not be clearly recorded in the following text.
[0019] The following description provides examples and does not limit the scope, applicability or examples set forth in the claims. Changes may be made to the functions and arrangements of the elements described without departing from the scope of the present application. Various processes or components may be appropriately omitted, substituted or added to each example. For example, the described method may be performed in an order different from the order described, and various steps may be added, omitted or combined. In addition, features described in some examples may be combined in other examples.
[0020] See also Figure 1 , Figure 1 An overall flow chart of a method for predicting customer behavior at a gas station based on a knowledge graph provided in an embodiment of the present application is shown.
[0021] like Figure 1 As shown, the gas station customer behavior prediction method based on knowledge graph can at least include the following steps: Step 101: extract information from historical customer data in a gas station to obtain semantic vectors and part-of-speech vectors.
[0022] In the embodiment of the present application, the gas station customer behavior prediction method based on the knowledge graph can be applied to, but is not limited to, mobile terminals, servers or cloud platforms. In the gas station customer behavior prediction process based on the knowledge graph, semantic vectors and part-of-speech vectors are extracted from historical customer data, and then these two vectors are fused to fully consider the semantic information and part-of-speech information in the historical customer data, so that the triples used to construct the knowledge graph can be extracted based on the fusion vectors obtained by the fusion process, and the knowledge graph and the preset behavior prediction model are combined for in-depth analysis to obtain more accurate customer behavior prediction results, and then the oil inventory can be accurately adjusted according to the prediction results to optimize the cash flow, meet the potential needs of customers and improve service quality.
[0023] Specifically, in the process of predicting customer behavior at a gas station based on a knowledge graph, the historical customer data of the gas station obtained can be first subjected to information extraction processing, the purpose of which is to extract semantic vectors containing semantic information in the historical customer data and part-of-speech vectors containing part-of-speech information in the historical customer data from the historical customer data. The implementation process can be but is not limited to the following four steps: (1) Use word segmentation tools (such as Jieba) to split text data into words or phrases; (2) Use part-of-speech tagging tools or libraries (such as NLTK, spaCy, jieba, HanLP, etc.) to tag each word after segmentation, that is, assign a label to each word that indicates its grammatical role, such as noun (NN), verb (VB), adjective (JJ), etc.; (3) Generate part-of-speech vectors using a pre-calculated part-of-speech co-occurrence matrix. The part-of-speech co-occurrence matrix is a statistical method used to represent the frequency or probability of co-occurrence of different parts of speech in a text. It can reveal the distribution pattern of parts of speech in a text and their correlation. It is a tool for studying language structure, performing grammatical analysis, or assisting other natural language processing tasks. (4) Use pre-trained word embedding models (such as Word2Vec model, GloVe model, etc.) or more advanced context-sensitive models (such as BERT model, RoBERTa model, etc.) to generate semantic vectors for words. These models can capture the contextual meaning of words and provide richer semantic representations.
[0024] Understandably, historical customer data mainly consists of text data such as customer feedback, evaluations, and purchase records, which can be obtained through the gas station's point of sale (POS) system, membership system, online questionnaires, and social media platforms.
[0025] It is worth noting that jieba is a popular Chinese word segmentation library, which can not only perform word segmentation on Chinese text, but also support part-of-speech tagging. Word segmentation refers to dividing continuous text into words one by one, while part-of-speech tagging assigns a specific part-of-speech tag to each word segmentation result, such as noun (n), verb (v), adjective (a), etc.
[0026] As an option of the embodiment of the present application, information extraction is performed on the historical customer data of the gas station to obtain semantic vectors and part-of-speech vectors, including: Inputting historical customer data of the gas station into a pre-trained language model to obtain a semantic vector; wherein the pre-trained language model is trained by the sample data and the sample semantic vector corresponding to the sample data; Split the historical customer data to obtain at least two segmented words; Obtaining a part-of-speech tag corresponding to each participle based on a preset part-of-speech table; wherein the preset part-of-speech table includes at least two participles and part-of-speech tags corresponding to the participles; According to all the participles and the part-of-speech tags corresponding to the participles, the part-of-speech vectors are obtained.
[0027] Specifically, in the process of obtaining semantic vectors and part-of-speech vectors through historical customer data, the historical customer data of the gas station can be first input into a pre-trained language model (such as the RoBERTa-WWM model), and then the corresponding semantic vector can be obtained, wherein the pre-trained language model is trained by sample data and sample semantic vectors corresponding to the sample data.
[0028] Next, the historical customer data may be split and processed, and the implementation method may be but is not limited to splitting the historical customer data through the maximum matching method or the minimum segmentation method to obtain segmented words (i.e., words or phrases), or splitting the historical customer data through segmentation tools such as jieba, THULAC, HanLP, etc. to obtain segmented words.
[0029] Thereafter, the part-of-speech tag corresponding to each participle can be queried and obtained from the preset part-of-speech table, wherein the preset part-of-speech table includes at least two participles and the part-of-speech tag corresponding to each participle. For example, when the historical customer data is "Good service attitude, reasonable price.", the participle results are: "service", "attitude", "good", "," "price", "reasonable" ".", and the part-of-speech tags are: "noun", "noun", "adjective", "punctuation", "noun", "adjective", "punctuation" respectively.
[0030] After obtaining all the word segments and the part-of-speech tags corresponding to each word segment, a One-Hot encoding vector (i.e., a word vector and a label vector) can be created for each word and each part-of-speech tag. Then, as needed, the word vector and the label vector can be simply concatenated or other combinations can be used to form a composite vector, which is the part-of-speech vector.
[0031] It should be noted that One-Hot encoding is a method of converting categorical variables into numerical features that can be understood by machine learning models. For part-of-speech tags in part-of-speech tagging tasks, the basic idea of One-Hot encoding is to create a vector for each unique part-of-speech category. The length of the vector is equal to the total number of part-of-speech categories, and each position in the vector represents a part-of-speech category. In such a vector, only one position has a value of 1, indicating which category the current word belongs to, and the values of the remaining positions are all 0. Taking the common part-of-speech tag set as an example, if there are 5 basic part-of-speech categories: noun (Noun, N), verb (Verb, V), adjective (Adjective, Adj), adverb (Adverb, Adv), preposition (Preposition, P). A simple One-Hot encoding method can be: Noun (N): [1, 0, 0, 0, 0], Verb (V): [0, 1, 0, 0, 0], Adjective (Adj): [0, 0, 1, 0, 0], Adverb (Adv): [0, 0, 0, 1, 0], Preposition (P): [0, 0, 0, 0, 1]. If a word is marked as "adjective", then its part of speech One-Hot encoding vector is [0, 0, 1, 0, 0]. Similarly, One-Hot encoding can also be used to encode words to form word vectors.
[0032] Step 102: Fuse the semantic vector and the part-of-speech vector to obtain a fused vector.
[0033] Specifically, after obtaining the semantic vector and the part-of-speech vector, the semantic vector and the part-of-speech vector can be weighted and summed up by a pre-set weight value, thereby obtaining a fusion vector, and the calculation formula is: x*A+y*B=C, wherein A is the semantic vector, B is the part-of-speech vector, C is the fusion vector, x is the weight value of the semantic vector, and y is the weight value of the part-of-speech vector.
[0034] It can be understood that the fused vector contains not only the semantic information in the historical customer data but also the part-of-speech information.
[0035] As another option of the embodiment of the present application, the semantic vector and the part-of-speech vector are fused to obtain a fused vector, including: Inputting the part-of-speech vector into a preset convolutional model to obtain a node vector; wherein the preset convolutional model is trained by the sample part-of-speech vector and the node vector corresponding to the sample part-of-speech vector; The semantic vector and node vector are fused through the cross attention algorithm to obtain a fused vector.
[0036] Specifically, in the process of fusing the semantic vector and the part-of-speech vector, the part-of-speech vector can be first input into a preset convolutional model (such as the convolutional network model GCN in the figure) to obtain a node vector, wherein the preset convolutional model is trained by sample part-of-speech vectors and node vectors corresponding to the sample part-of-speech vectors.
[0037] Then, the semantic vector and the node vector can be fused through the cross-attention algorithm to obtain a fused vector. The cross-attention algorithm is mainly used to process the interaction between two different sequences or feature sets (which can be represented by vectors), that is, the elements of one sequence allocate attention to the elements of another sequence to extract relevant information. This process can be understood as: based on the elements in X, calculate which parts of Y are most relevant to X, and generate a new representation Z based on these relevance weights. In this solution, the semantic vector is X, the part-of-speech vector is Y, and the fused vector is Z.
[0038] Step 103: extract at least two triplets from the fusion vector and construct a knowledge graph based on all the triplets.
[0039] Specifically, after obtaining the fused vector, the triplets can be extracted from the fused vector through the following three steps: (1) Entity recognition: First, the named entity recognition (NER) model (such as the BiLSTM-CRF model and the BERT-CRF model) can be used to identify the entities in the text data represented by the fusion vector. The named entity recognition model can identify entities such as names, places, and organizations from the vector formed by the text data and label their categories. (2) Relation Extraction: Next, the relationship between entities can be determined through a relation extraction (RE) model, where the relation extraction model can extract the relationship type between entities from the vector formed by a sentence containing two or more entities; (3) Constructing triples: Finally, the identified entities and relations are combined into triples. The combination can be: (entity 1, relationship, entity 2). For example, when there is a historical customer data such as "I am willing to refuel only when the oil price does not exceed 6 yuan / liter", the entities that can be identified from its corresponding fusion vector are: customer (identified by the pronoun "I"), oil price, 6 yuan / liter. The extractable relationship is: customer → willing to refuel → when the oil price does not exceed 6 yuan / liter. Therefore, the triple can be constructed as: (customer, willingness to refuel condition, oil price does not exceed 6 yuan / liter).
[0040] It should be noted that in this triplet, "customer" is the subject, expressing a willingness or behavioral tendency; "conditions for willingness to refuel" is a relationship, describing the conditions under which the customer will perform specific behaviors; "oil price does not exceed 6 yuan / liter" is the object, pointing out the specific content of this condition.
[0041] Understandably, such triples help to understand customers’ sensitivity to oil prices and its impact on refueling decisions. Such information is very valuable for gas stations or policymakers, as it can help them formulate pricing strategies or promotional activities that are more in line with market demand.
[0042] Furthermore, after the triples are determined, a knowledge graph can be constructed based on all the triples, wherein the construction method can be but is not limited to: firstly establish a connection with the graph database Neo4j through the Py2neo library, and import all triples into the Neo4j database for storage, and then use the graph.create() function in the Py2neo library to create the basic structure of the knowledge graph: nodes and edges, wherein nodes represent entities and edges represent relationships.
[0043] For example, if you want the node attributes to include the basic information of the customer, the edge attributes to include the transaction amount and frequency, and use graph reasoning technology to discover potential associations and patterns between entities (such as the relationship between the customer's age and the transaction amount), you can first create a node with the label Customer (this label indicates that the subject of the node is a customer), and pass the customer information as an attribute to the node. Then, you can create an edge TRANSACTION representing the transaction, and use the transaction amount and frequency as the attributes of the edge. Then, you can use the MATCH clause of the Cypher language to find customer nodes and transaction edges that meet the conditions (such as the total transaction amount of all customers over 25 years old), and then use the RETURN clause to return the customer name and total transaction amount.
[0044] Through the above method, the py2neo library and the Neo4j database can be used to build and query complex knowledge graphs, thereby achieving in-depth analysis and reasoning of historical customer data to improve the accuracy of predictions of potential needs of gas station customers.
[0045] As another option of the embodiment of the present application, at least two triplets are extracted from the fusion vector, including: Performing entity recognition processing on the fusion vector through a preset neural network model to obtain an entity result; wherein the preset neural network model is trained by the sample fusion vector and the sample entity result corresponding to the sample fusion vector; Performing relationship extraction processing on the fusion vector through a preset deep learning model to obtain a relationship result; wherein the preset deep learning model is trained by the sample fusion vector and the sample relationship result corresponding to the sample fusion vector; Construct triples based on entity results and relationship results.
[0046] Specifically, after obtaining the fusion vector, the fusion vector can be input as input data into a preset neural network model (such as a BERT model), thereby obtaining the implementation result of the above-mentioned entity recognition step, that is, the entity result.
[0047] Then, the fused vector can be used as input data of a preset deep learning model (such as a Transformer model) to obtain the corresponding output data of the model, that is, the relationship result.
[0048] It should be noted that the preset neural network model is trained by the sample fusion vector and the sample entity results corresponding to the sample fusion vector; the preset deep learning model is trained by the sample fusion vector and the sample relationship results corresponding to the sample fusion vector.
[0049] Afterwards, the entities and relations that can form triples can be determined from the obtained entity results and relationship results, and triples can be constructed in the combination of (entity 1, relationship, entity 2).
[0050] As another option of the embodiment of the present application, a triple is constructed based on the entity result and the relationship result, including: Determine a first entity set and a second entity set based on entity types in the entity results; wherein the entity results include at least two entities and an entity type corresponding to each entity; Determine an initial relationship set according to the first entity set and the second entity set; wherein the initial relationship set includes at least two relationship words; The initial relationship set is screened based on the relationship result to obtain a target relationship set; wherein the relationship result includes at least two relationship words, and the target relationship set includes the relationship words common to the relationship result and the initial relationship set; A triple is constructed based on the first entity set, the second entity set, and the target relationship set.
[0051] Specifically, in the process of constructing triples based on entity results and relationship results, a first entity set and a second entity set can be selected from the entity results based on entity types in the entity results, wherein the entity results include at least two entities and an entity type corresponding to each entity.
[0052] It is understandable that the entity type indicates the type of role played by the entity in the text data, that is, subject or object. The entities in the first entity set are all entities that serve as subjects or subjects in the historical customer data, and the entities in the second entity set are all entities that serve as objects or subjects in the historical customer data. For example, in the above historical customer data example "I am willing to go to the gas station only when the oil price does not exceed 6 yuan / liter.", "I" is the subject (that is, the first entity), and "the oil price does not exceed 6 yuan / liter" is the object (that is, the second entity).
[0053] It is worth noting that when the sentence structure is relatively simple, the subject in the sentence is the first entity and the object is the second entity; when the sentence structure is relatively complex (such as when there is an adverbial phrase "when..." as mentioned above), the subject or object does not necessarily correspond to the first entity or the second entity. The method of distinguishing the first entity from the second entity is mainly based on the entity type to which each entity belongs in the data, and the entity type is calculated by the model and included in the entity result.
[0054] Next, after determining the first entity and the second entity, the relationship corresponding to the first entity and the second entity can be determined according to the first entity set and the second entity set, and an initial relationship set can be formed, wherein the initial relationship set includes at least two relationship words. For example, if there are a first entity A, a second entity B, and a second entity C, there is a relationship 1 between A and B, whose relationship word is X, and there is a relationship 2 between A and C, whose relationship word is Y, then the initial relationship set is {X, Y}.
[0055] Afterwards, the initial relationship set can be screened according to the relationship results, and the relationship words in the relationship results that are common to the initial relationship set can be used as elements in the target relationship set, thereby obtaining the target relationship set to ensure that the relationship words in the target relationship set are all obtained by relationship extraction based on historical customer data, and all have corresponding entities in the first entity set or the second entity set.
[0056] After obtaining the target relationship set, triples can be constructed based on the first entity set, the second entity set and the target relationship set. The construction method can be but is not limited to: taking the entities in the first entity set as entity 1, taking the entities in the second entity set as entity 2, taking the relationship words in the target relationship set as relationships, and constructing triples in the combination method of (entity 1, relationship, entity 2).
[0057] It is worth noting that the relative words here can be but are not limited to single Chinese characters, words or phrases.
[0058] Step 104: Obtain prediction results based on the knowledge graph and the preset behavior prediction model.
[0059] Specifically, after constructing the knowledge graph, data related to the object to be predicted (such as a certain customer A) (such as nodes, edges, attributes or weights on edges, etc.) can be obtained from the knowledge graph, and the data can be input into the preset behavior prediction model (such as the BiLSTM-CRF model), and then the output data of the model, that is, the prediction result, can be obtained. For example, the data such as the node of customer A and the edges related to the node (such as transaction amount, oil type, etc.), the attributes of the node (such as age, gender, vehicle information, etc.) are input into the BiLSTM-CRF model, and then the model analyzes the purchase behavior pattern of customer A (such as the highest frequency of refueling on Fridays, and the most frequent times of refueling with No. 92 oil), and predicts the time of refueling in the future (such as next Friday) and the type of oil (such as No. 92 oil), and then uses it as the prediction result.
[0060] As another option of the embodiment of the present application, based on the knowledge graph and the preset behavior prediction model, the prediction result is obtained, including: Obtain the refueling time data and oil type data corresponding to the data to be predicted in the knowledge graph, and serialize the refueling time data and oil type data; Inputting the serialized refueling time data into a preset behavior prediction model to obtain a refueling time series; wherein the preset behavior prediction model is obtained by training the sample serialized data and the sample series; Inputting the serialized oil type data into a preset behavior prediction model to obtain an oil type sequence; Based on the refueling time series and the oil type series, the prediction results are obtained.
[0061] Specifically, in the process of obtaining prediction results based on the knowledge graph and the preset behavior prediction model, the refueling time data (such as the historical refueling time data of a customer) and the oil type data (such as all the types of oils that a customer has added and the corresponding number of refuelings) corresponding to the data to be predicted (such as a customer) can be obtained from the knowledge graph first, and then the refueling time data and oil type data can be serialized.
[0062] It can be understood that data serialization is the process of converting data structures (such as the data structures of nodes and edges in knowledge graphs) or object states into a format that can be stored or transmitted. It can be but is not limited to using several commonly used data serialization methods such as JSON serialization method, XML serialization method and MessagePack in Python. The specific method selected depends on the purpose of the data and the required compatibility.
[0063] Next, the serialized refueling time data and oil type data can be input into the preset behavior prediction model (such as the BiLSTM-CRF model) in sequence to obtain the corresponding refueling time series and oil type series, wherein the preset behavior prediction model is trained by the sample serialization data and the sample sequence.
[0064] After that, the prediction results can be obtained based on the obtained refueling time series and oil type series. For example, when the data obtained through the knowledge graph shows that the probability distribution of a customer's refueling time in a week is: Monday: 0.2; Tuesday: 0.1; Wednesday: 0.9; Thursday: 0.1; Friday: 0.4; Saturday: 0.3; Sunday: 0.2, then the refueling time series can be [0.2, 0.1, 0.9, 0.1, 0.4, 0.3, 0.2]. Similarly, the oil type series can be [10, 0, 0], where 10 represents 10 times of refueling with No. 92 oil in a certain period of time, and the remaining two 0s represent 0 times of refueling with No. 95 oil and No. 98 oil. The corresponding prediction result of this example can be: the customer tends to refuel with No. 92 oil on Wednesdays.
[0065] It should be noted that the probability distribution of refueling time within a week can be obtained by statistics of refueling time data within multiple weeks. For example, if a customer refuels on Tuesdays and Fridays for three consecutive weeks, the corresponding refueling time series can be [0, 0.5, 0, 0, 0.5, 0, 0].
[0066] As another option of the embodiment of the present application, the prediction result includes a predicted oil type, a predicted refueling amount corresponding to the predicted oil type, and a predicted refueling time; After obtaining the prediction results based on the knowledge graph and the preset behavior prediction model, it also includes: Obtaining the current inventory corresponding to the predicted oil type, and determining the expected inventory based on the current inventory and the predicted refueling volume corresponding to the predicted oil type; The inventory corresponding to the predicted oil type is adjusted based on the predicted refueling time so that the current inventory level is consistent with the expected inventory level before the predicted refueling time.
[0067] Specifically, the prediction results may include the customer's predicted fuel type, the predicted refueling quantity corresponding to the predicted fuel type, and the predicted refueling time, etc., and after obtaining the prediction results based on the knowledge graph and the preset behavior prediction model, the current inventory corresponding to the predicted fuel type can be obtained first, and the expected inventory can be calculated based on the current inventory and the predicted refueling quantity, and then the inventory corresponding to the predicted fuel type can be adjusted according to the predicted refueling time, so that the current inventory and the expected inventory are consistent before the predicted refueling time, thereby ensuring that the gas station has enough fuel to provide to customers before the predicted refueling time.
[0068] It is understandable that if the prediction result is that two customers' predicted fuel type is No. 92 oil, the predicted refueling volume is 40 liters and 50 liters respectively, the predicted refueling time is Wednesday, the current day is Monday, and the current inventory is 20 liters, then the expected inventory is at least 90 liters, and at least 70 liters of No. 92 oil needs to be added before Wednesday to make the inventory reach 90 liters or more, so as to ensure that these two customers can refuel smoothly on Wednesday and provide customers with satisfactory service.
[0069] In addition, exclusive refueling discount coupons can be pushed to customers on the eve of the predicted refueling time to encourage customers to refuel at the predicted refueling time, thereby improving customer experience and the operating efficiency of the gas station.
[0070] It is worth noting that the data of the knowledge graph is not static. It can, but is not limited to, obtain new customer data at fixed intervals and build a new knowledge graph or update the old knowledge graph based on the new customer data. By using the real-time transaction data and feedback information of customers, the knowledge graph is dynamically adjusted to reflect the latest changes in customer behavior and the evolution of the market environment, thereby improving the accuracy and practicality of the knowledge graph.
[0071] See also Figure 2 , Figure 2 An overall flow chart of a method for constructing a knowledge graph provided in an embodiment of the present application is shown.
[0072] like Figure 2 As shown in Figure 1, the method for constructing the knowledge graph includes at least the following five steps: (1) Obtaining data from various systems: The point-of-sale (POS) system of a gas station can be used to obtain customer transaction records, including purchase time, fuel type, purchase quantity, price, and other information. The membership system of a gas station can be used to obtain customer personal information, such as age, gender, and vehicle information. Customer feedback and evaluation information can be obtained through online questionnaires and social media platforms.
[0073] (2) Preprocess the data: Integrate the data obtained in step (1) and store it in the relational database MongoDB, and use the primary key to associate the customer's transaction records in the POS system with the personal information in the member management system to provide a basis for subsequent analysis. After that, the data collected in (1) needs to be cleaned, such as using regular expressions to remove duplicate records, correct error information, and process missing values. Next, the data can be formatted to convert unstructured data into structured data for subsequent analysis. The processed data presents standardized characteristics, which can ensure the consistency of information in different data sources, such as date format, oil product code, etc. In addition, the acquired text data needs to be segmented and stop words removed; (3) Entity recognition and relationship extraction on preprocessed data: The preprocessed data is fused with features by combining the RoBERTa-WWM model with a graph convolutional network (GCN) to achieve entity recognition and relationship extraction; (4) Construct triples through the identified entities and extracted relationships: Based on the identified entities, determine entity 1 as the subject and entity 2 as the object, and find the extracted relationship corresponding to entity 1 and entity 2. The three can form a triple of the form (entity 1, relationship, entity 2); (5) Construct a knowledge graph based on triples: Use the Py2neo library and the graph database Neo4j to create nodes and edges corresponding to triples to construct a knowledge graph, and add attributes to the nodes and edges in the knowledge graph. The attributes of the nodes can include the basic information of the customer, and the attributes of the edges can include the transaction amount and frequency, etc.
[0074] Figure 3 A schematic diagram of the structure of a gas station customer behavior prediction device based on a knowledge graph provided in an embodiment of the present application.
[0075] like Figure 3 As shown, the gas station customer behavior prediction device based on knowledge graph may include at least a first processing module 301, a second processing module 302, a third processing module 303 and a fourth processing module 304, wherein: The first processing module 301 is used to extract information from historical customer data in the gas station to obtain semantic vectors and part-of-speech vectors; The second processing module 302 is used to fuse the semantic vector and the part-of-speech vector to obtain a fused vector; The third processing module 303 is used to extract at least two triples from the fusion vector and construct a knowledge graph based on all triples; The fourth processing module 304 is used to obtain prediction results based on the knowledge graph and a preset behavior prediction model.
[0076] In some possible embodiments, information extraction is performed on historical customer data in a gas station to obtain semantic vectors and part-of-speech vectors, including: The first processing module 301 is specifically used for: Inputting historical customer data of the gas station into a pre-trained language model to obtain a semantic vector; wherein the pre-trained language model is trained by the sample data and the sample semantic vector corresponding to the sample data; Split the historical customer data to obtain at least two segmented words; Obtaining a part-of-speech tag corresponding to each participle based on a preset part-of-speech table; wherein the preset part-of-speech table includes at least two participles and part-of-speech tags corresponding to the participles; According to all the participles and the part-of-speech tags corresponding to the participles, the part-of-speech vectors are obtained.
[0077] In some possible embodiments, the semantic vector and the part-of-speech vector are fused to obtain a fused vector, including: The second processing module 302 is specifically used for: Inputting the part-of-speech vector into a preset convolutional model to obtain a node vector; wherein the preset convolutional model is trained by the sample part-of-speech vector and the node vector corresponding to the sample part-of-speech vector; The semantic vector and node vector are fused through the cross attention algorithm to obtain a fused vector.
[0078] In some possible embodiments, extracting at least two triplets from the fusion vector includes: The third processing module 303 is specifically used for: Performing entity recognition processing on the fusion vector through a preset neural network model to obtain an entity result; wherein the preset neural network model is trained by the sample fusion vector and the sample entity result corresponding to the sample fusion vector; Performing relationship extraction processing on the fusion vector through a preset deep learning model to obtain a relationship result; wherein the preset deep learning model is trained by the sample fusion vector and the sample relationship result corresponding to the sample fusion vector; Construct triples based on entity results and relationship results.
[0079] In some possible embodiments, triples are constructed based on entity results and relationship results, including: The third processing module 303 is specifically used for: Determine a first entity set and a second entity set based on entity types in the entity results; wherein the entity results include at least two entities and an entity type corresponding to each entity; Determine an initial relationship set according to the first entity set and the second entity set; wherein the initial relationship set includes at least two relationship words; The initial relationship set is screened based on the relationship result to obtain a target relationship set; wherein the relationship result includes at least two relationship words, and the target relationship set includes the relationship words common to the relationship result and the initial relationship set; A triple is constructed based on the first entity set, the second entity set, and the target relationship set.
[0080] In some possible embodiments, based on the knowledge graph and the preset behavior prediction model, the prediction results are obtained, including: The fourth processing module 304 is specifically used for: Obtain the refueling time data and oil type data corresponding to the data to be predicted in the knowledge graph, and serialize the refueling time data and oil type data; Inputting the serialized refueling time data into a preset behavior prediction model to obtain a refueling time series; wherein the preset behavior prediction model is obtained by training the sample serialized data and the sample series; Inputting the serialized oil type data into a preset behavior prediction model to obtain an oil type sequence; Based on the refueling time series and the oil type series, the prediction results are obtained.
[0081] In some possible embodiments, the prediction result includes a predicted oil type, a predicted refueling amount corresponding to the predicted oil type, and a predicted refueling time; After obtaining the prediction results based on the knowledge graph and the preset behavior prediction model, it also includes: The fourth processing module 304 is specifically used for: Obtaining the current inventory corresponding to the predicted oil type, and determining the expected inventory based on the current inventory and the predicted refueling volume corresponding to the predicted oil type; The inventory corresponding to the predicted oil type is adjusted based on the predicted refueling time so that the current inventory level is consistent with the expected inventory level before the predicted refueling time.
[0082] See also Figure 4 , Figure 4 A structural schematic diagram of another gas station customer behavior prediction device based on knowledge graph provided in an embodiment of the present application is shown.
[0083] like Figure 4 As shown, the knowledge graph-based gas station customer behavior prediction device 400 may include at least one processor 401 , at least one network interface 404 , a user interface 403 , a memory 405 , and at least one communication bus 402 .
[0084] The communication bus 402 may be used to realize the connection and communication among the above-mentioned components.
[0085] The user interface 403 may include buttons, and the optional user interface may also include a standard wired interface or a wireless interface.
[0086] The network interface 404 may include, but is not limited to, a Bluetooth module, an NFC module, a Wi-Fi module, etc.
[0087] Among them, the processor 401 may include one or more processing cores. The processor 401 uses various interfaces and lines to connect the various parts of the entire knowledge graph-based gas station customer behavior prediction device 400, and executes various functions and processes data of the knowledge graph-based gas station customer behavior prediction device 400 by running or executing instructions, programs, code sets or instruction sets stored in the memory 405, and calling data stored in the memory 405. Optionally, the processor 401 can be implemented in at least one hardware form of DSP, FPGA, and PLA. The processor 401 can integrate one or a combination of CPU, GPU, modem, etc. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 401, and it can be implemented by a single chip.
[0088] The memory 405 may include a RAM or a ROM. Optionally, the memory 405 includes a non-transitory computer-readable medium. The memory 405 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 405 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 405 may optionally be at least one storage device located away from the aforementioned processor 401. As Figure 4 As shown, the memory 405 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a knowledge graph-based gas station customer behavior prediction application.
[0089] Specifically, the processor 401 may be used to call the knowledge graph-based gas station customer behavior prediction application stored in the memory 405, and specifically perform the following operations: Perform information extraction on historical customer data at gas stations to obtain semantic vectors and part-of-speech vectors; The semantic vector and the part-of-speech vector are fused to obtain a fused vector; Extract at least two triplets from the fused vector and construct a knowledge graph based on all the triplets; Based on the knowledge graph and the preset behavior prediction model, the prediction results are obtained.
[0090] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the above method are implemented. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a micro drive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), or any type of medium or device suitable for storing instructions and / or data.
[0091] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0092] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0093] In the several embodiments provided in the present application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which 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 service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0094] The units described 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.
[0095] 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.
[0096] 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 memory. 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. The computer software product is stored in a memory, including a number of 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 various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, disk or optical disk and other media that can store program codes.
[0097] A person skilled in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by entering a program to instruct related hardware, and the program may be stored in a computer-readable memory, which may include a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0098] The above are only exemplary embodiments of the present disclosure and cannot be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the specification and practicing the disclosure here, those skilled in the art will easily think of the implementation scheme of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field that are not recorded in the present disclosure. The description and examples are only regarded as exemplary, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. A gas station customer behavior prediction method based on knowledge graph, characterized in that: include: Perform information extraction on historical customer data at gas stations to obtain semantic vectors and part-of-speech vectors; Fusing the semantic vector and the part-of-speech vector to obtain a fused vector; Extracting at least two triplets from the fusion vector, and constructing a knowledge graph based on all the triplets; Based on the knowledge graph and the preset behavior prediction model, a prediction result is obtained.
2. The method according to claim 1, characterized in that The information extraction process of the historical customer data in the gas station to obtain the semantic vector and the part-of-speech vector includes: Inputting historical customer data of the gas station into a pre-trained language model to obtain a semantic vector; wherein the pre-trained language model is trained by sample data and a sample semantic vector corresponding to the sample data; Splitting the historical customer data to obtain at least two segmented words; Acquire a part-of-speech tag corresponding to each of the participles based on a preset part-of-speech table; wherein the preset part-of-speech table includes at least two of the participles and the part-of-speech tags corresponding to the participles; A part-of-speech vector is obtained according to all the participles and the part-of-speech tags corresponding to the participles.
3. The method according to claim 1, characterized in that The fusing the semantic vector and the part-of-speech vector to obtain a fused vector includes: Inputting the part-of-speech vector into a preset convolutional model to obtain a node vector; wherein the preset convolutional model is trained by a sample part-of-speech vector and a node vector corresponding to the sample part-of-speech vector; The semantic vector and the node vector are fused by a cross attention algorithm to obtain a fused vector.
4. The method according to claim 1, characterized in that The extracting at least two triplets from the fused vector comprises: Performing entity recognition processing on the fusion vector through a preset neural network model to obtain an entity result; wherein the preset neural network model is trained by a sample fusion vector and a sample entity result corresponding to the sample fusion vector; Performing relationship extraction processing on the fusion vector through a preset deep learning model to obtain a relationship result; wherein the preset deep learning model is trained by the sample fusion vector and the sample relationship result corresponding to the sample fusion vector; A triple is constructed based on the entity result and the relationship result.
5. The method according to claim 4, characterized in that The constructing a triple based on the entity result and the relationship result includes: Determine a first entity set and a second entity set based on entity types in the entity results; wherein the entity results include at least two entities and an entity type corresponding to each of the entities; Determine an initial relationship set according to the first entity set and the second entity set; wherein the initial relationship set includes at least two relationship words; The initial relationship set is screened based on the relationship result to obtain a target relationship set; wherein the relationship result includes at least two relationship words, and the target relationship set includes the relationship words common to the relationship result and the initial relationship set; The triple is constructed based on the first entity set, the second entity set, and the target relationship set.
6. The method according to claim 1, characterized in that The prediction result is obtained based on the knowledge graph and the preset behavior prediction model, including: Obtaining refueling time data and oil type data corresponding to the data to be predicted in the knowledge graph, and serializing the refueling time data and the oil type data; Inputting the serialized refueling time data into a preset behavior prediction model to obtain a refueling time sequence; wherein the preset behavior prediction model is obtained by training the sample serialized data and the sample sequence; Inputting the serialized oil type data into the preset behavior prediction model to obtain an oil type sequence; Based on the refueling time series and the oil type series, a prediction result is obtained.
7. The method according to claim 1, characterized in that The prediction result includes a predicted oil type, a predicted refueling amount corresponding to the predicted oil type, and a predicted refueling time; After obtaining the prediction result based on the knowledge graph and the preset behavior prediction model, the method further includes: Acquire the current inventory corresponding to the predicted oil type, and determine the expected inventory according to the current inventory and the predicted refueling quantity corresponding to the predicted oil type; The inventory corresponding to the predicted oil type is adjusted based on the predicted refueling time so that the current inventory amount is consistent with the expected inventory amount before the predicted refueling time.
8. A gas station customer behavior prediction device based on knowledge graph, characterized in that: include: The first processing module is used to extract information from the historical customer data of the gas station to obtain semantic vectors and part-of-speech vectors; A second processing module is used to fuse the semantic vector and the part-of-speech vector to obtain a fused vector; A third processing module, configured to extract at least two triples from the fusion vector and construct a knowledge graph based on all the triples; The fourth processing module is used to obtain prediction results based on the knowledge graph and a preset behavior prediction model.
9. A gas station customer behavior prediction device based on knowledge graph, characterized in that: including a processor and a memory; The processor is connected to the memory; The memory is used to store executable program code; The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a computer or a processor, the computer or the processor executes the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Chinese word sense disambiguation method based on fusion of graph convolutional neural network and support vector machine
CN114186560A
Associated information fused program language recognition system and method
CN114330338A
Customer loss risk prediction method and device
CN116702977A
Method and system for processing multi-source information in construction process of underground powerhouse of pumped storage power station
CN116975256A
Electric power knowledge semantic analysis system and method
CN117273012A