Missing Mapping Dictionaries in Saved Model (CSV Training)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- machine-learning
Research direction
Start by reproducing the CSV training and save_model()/restore_model() flow, then inspect how ScoringBasedEmbeddingModel.get_invalid_keys() obtains its mappings. Done means a restored model can access entity_to_idx and relation_to_idx and invalid-key filtering works for inference with new triples.
Written by the indexing model from the issue text.
Description
Description:
I am encountering an issue during inference with a model trained using a CSV file. The saved model does not include the necessary mapping dictionaries (entity_to_idx and relation_to_idx), which are typically stored in a DB file. This absence leads to a large number of triples being skipped during inference due to invalid keys.
Steps to Reproduce:
- Train an Ampligraph model (e.g.,
ComplEx,TransE) using data loaded from a CSV file. - Save the trained model using
ampligraph.utils.save_model(). - Load the saved model using
ampligraph.utils.restore_model(). - Attempt to perform inference using the loaded model on a new set of triples.
- Observe a significant number of triples being skipped due to "invalid keys".
- Attempt to use
ScoringBasedEmbeddingModel.get_invalid_keys()for filtering. Note that this function does not operate correctly without the mapping dictionaries.
Expected Behavior:
The saved model should include the mapping dictionaries (entity_to_idx and relation_to_idx) either within the model file itself or in a separate associated file (e.g., a DB file) to ensure proper inference on new data. Functions like get_invalid_keys() should be able to effectively identify and filter triples with unknown entities or relations using these saved mappings.
Actual Behavior:
The saved model does not contain the mapping dictionaries. Consequently, during inference, a large number of triples are flagged as containing invalid keys and skipped. The get_invalid_keys() function is ineffective in this scenario.
Additional Information:
- Ampligraph Version: 2.1.0 (latest)
- Training Data Format: CSV file
- The
ampligraph.utils.save_model()function does not appear to have a parameter to explicitly save the mapping dictionaries when training from CSV data.
Questions:
- What is the recommended way to ensure that the entity and relation mapping dictionaries are saved along with the model when training with CSV data?
- Is there a specific procedure or parameter that needs to be used during training or saving to include these mappings?
- If the DB file is not automatically saved, how can we manually save or access these dictionaries after training so they can be used for inference with the saved model?
Thank you for your time and assistance with this issue.
Reported by: Javier Martínez
- Dominant language
- Python
- Stars
- 2.2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Accenture/AmpliGraph
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Accenture/AmpliGraph#290 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Accenture/AmpliGraph#287 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
Accenture/AmpliGraph#284 ·
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
Accenture/AmpliGraph#275 ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
Accenture/AmpliGraph#271 ·
All issues in Accenture/AmpliGraph
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
daniel-ospina/tortoise#15308 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
difficulty:easy prio:low type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NatronGitHub/Natron#2405 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Jstar269/nakagawa-recomp#3746 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day