Refactor Navigation and KGE Pipeline: Consistent Entity Naming, Enhanced Evaluation, and Robust Config Management#34
Open
HernandezEduin wants to merge 40 commits into
Open
Conversation
Removing query_relation (as it is unused), saving of the triplets from QA (as the benchmark already works), and renaming Query-Entity to Source-Entity for a clearer understanding of the variable.
Modified all the necessary files to that are affected by the renaming of Source-Entity and the removal of Query-Relation Additional Correction for Single Hop Supervised
Update README.md
Forcing found cache to be the cached_metadata_path if the file exists. The function `shift_through_cache_data` returns None regardless of the situation, causing a forced recompute for each new instance.
Modified vector search to be able to take 3D tensors where the 2nd Dim is the rollouts.
Modified code to be able to evaluate the performance in a similar fashion to literature: ranks the rollouts according to their scores (distance to closest entity in this case) Correction
- Correcting the dimension in test_nav due to num_rollouts - Using Path Log Prob to do the ranking of the Rollouts - Adding back Mean Rank (MR) to have a better idea of the performance
Added an additional argument which controls the number of rollouts during the EVALUATION phase. This is necessary for the benchmark metric comparison. Keep at 100.
- Adding Comments of varible expected shape - Changing Metric Variable Name from Distance to Ans Distance for disambiguation with the distance provided by FAISS
- Replaced extracting answer_tensor and instead using the one already calculated by the environment. - Additionally returning tensors of shape (batch size, num_rollouts, steps) from Rollout instead of (batch_size, steps) - Calculating Reinforce Loss in a Separate Function
Added an optional variable in ITLGraphEnvironment for choosing whether to use FAISS to calculate the closest entity and reward the agent if it is the answer vs using episilon distance threshold with the answer embedding. FAISS should provide a correct approach, but it slows down the computation.
- Added Rollouts to the training during Supervised - Added Noise to the current position of the Agent - Modified the Query Rel for the Adapter to be the average relations emb of the supervised path
The configurations (best) and sweeps for the supervised path learning are added and moved to ./configs/supervised_path_learning/ for disambiguation.
Moving KGE training related configs and sweeps into ./configs/embedding_training.
Moving RL Navigation Configs and Sweeps to ./configs/navigation/
Adding indent to make it more presentable
Adding a parameter to allow trainining on the full graph (assumming KGE completion is no longer the task, instead of it the task is navigability).
Before the beginning of training, a pretrained model can be loaded if `--checkpoint_path` is a valid path and contains the dir with the model. Addionally, validation is now optional in the training.
Moving the functions from exogenous/sun_models to utils/convenience for a better location: - calculate_entity_range - calculate_entity_centroid - get_entity_embeddings_from_indices Modifying affected files accordingly: - mlm_training.py - nav_supervised_training.py - nav_training.py - multihopkg/rl/graph_search/pn.py
Moving and renaming the following functions: - save_configs -> save_train_configs - save_model -> save_kge_model - update_best_model -> update_best_kge_model from exogenous/sun_model.py to utils/saving.py Updated the following affected files: - kge_train.py - nav_supervised_training.py
Moving the following functions from exogenous/sun_models to utils/cleaning - clean_up_checkpoints - clean_up_folder Affected files - kge_train.py
Removing unnecessary variables and lines in supervised path learning algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Recent Changes
This pull request brings major refactors, feature enhancements, configuration changes, and bug fixes, particularly around navigation (supervised), KGE, and configuration management.
Highlights
Consistent Data Schema and Naming
source_ent/Source-Entitythroughout, replacingquery_ent/Query-Entityand the use ofquery_rel(relation) where possible. This impacts all data loading, supervision, and environment interfaces.Supervised Path Learning
nav_superviced_training.py→nav_supervised_training.py.Knowledge Graph Embedding (KGE)
Configuration Management
devandtestsplits if present, with fallback to random splits.Reinforcement Learning and Environment
Metrics and Evaluation
Hits@1,Hits@3,Hits@5,Hits@10,Hits@20, and Mean Reciprocal Rank (MRR) with improved rank calculation.General Refactoring
This PR introduces significant backend improvements, enhances reproducibility, and streamlines configuration and training workflows. It lays groundwork for future development and improves maintainability for navigation and embedding tasks.
Major affected files
README.mdmlm_training.pynav_supervised_training.pynav_training.pymultihopkg/data_utils.pymultihopkg/rl/graph_search/pn.pymultihopkg/utils_debug/dump_evals.pymultihopkg/vector_search.pyFor the full commit list and details, see the commit history in the source repository.