New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can we create a graph model for all of our contextual data and then use the same graph to train all our downstream models? #428
Comments
Do you mean that the graph construction component should be disentangled from the pipeline such that it can be used for other applications? Eg, after we trained the classification app with the dependency graph, we can use the same graph to train another app without constructing the graphs again? |
Yes exactly. |
OK. Currently, the processed graph data can be reused. You can just copy it to another project and load it to train another app. Do you encounter some problems? |
For our use case, Constructed Graph using the approach provided in Text_Classification application; I am able to construct the graph. Our Idea is as mentioned in the earlier comments, to try to use the obtained graph for further applications like KG_Completion in this scenario. I have modified wrangle_KG.py accordingly to create the entities and relation files. (e1rel_to_e2_full.json, e1rel_to_e2_ranking_dev.json, e1rel_to_e2_ranking_test.json, e1rel_to_e2_train.json), and modified the below code snippet for the same
Currently I am not able to use the graph as I am getting AttributeError: 'StreamBatcher' object has no attribute 'loaders'. I need help in steps/process to re-use the already constructed graph in KG Completion. |
@sandeepKondaveeti Hi, the graph used in KG Completion is a single |
@Nicoleqwerty , Please let us know if there is a way to covert the dict object to a single graph4nlp.pytorch.data.dataGraphData. We want to use the same graph for multiple applications. |
The dict is in the form of {'train': list of DataItems, 'test': list of DataItems, ...}. You can use DataItem.graph to access |
@Nicoleqwerty Even we try to access GraphData for all the values in the dict DataItem.graph, we will be having multiple graphs, my query is how can we combine all of the dataitems to single graph. |
@Nicoleqwerty Another query is can we do a vice-versa of constructing the Graph using KG-Completion and use the same graph data for Text-Classification, Since there are multiple dependency files like data.pt, local.pt and vocab.pt for |
@sandeepKondaveeti Hi, you can use to_batch() to combine a list of GraphData objects to a single graph. |
Do you mean that you want to do a KG node classification task? In our examples, the graph construction of KG Completion builds a single KG graph directly. The graph construction of text classification builds a dependency or constituency graph for each text. If you want to merge these text graphs as a graph, you can use to_batch() mentioned above. |
@Nicoleqwerty @AlanSwift |
@dbanka Hi, you can check the example codes of KG completion and text classification. They are two completely different tasks with different inputs. For KG completion, the input is a single KG and the goal of KG completion is to predict the missing links between entity nodes. For text classification, each input is a (text, label) pair. A text classification dataset has lots of pairs. Unlike KG, there are usually no relation between texts in text classification. So we construct separate graph for each text. As for whether the constructed graph can be reused, I think take KG completion and KG node classification as a pair of examples is more suitable. Both tasks may take the same KG as input. You can certainly do KG completion or node classification on the same graph. |
@Nicoleqwerty What my point was that can we do Graph construction for all of our data? Then in future if we have to train any classification model or any other model, we can just get the graph embedding of the inputs required for that model and train a deep neural network model for classification using those embedding as input. In doing so, we will have a graph model for all our data and then we can use the graph embedding from that model to train any model we want. |
@dbanka The processed graph data can be reused. Since KG completion and text classification are two completely different tasks, you cannot directly apply the graphs built in text classification to KG completion example codes. You can merge the graphs built in text classification using to_batch(). |
Close this issue due to inactivity from the user. Please reopen it when necessary. |
In the examples mentioned in the demo, we saw that graph construction was done while training the specific use case like classification. Is there a way, we can construct graph on whole of our contextual data and then use that graph for our downstream applications like classification, knowledge graph completion etc.?
The text was updated successfully, but these errors were encountered: