UnKR
A Python Library for Uncertain Knowledge Graph Reasoning
Install / Use
/learn @seucoin/UnKRREADME
unKR: A Python Library for Uncertain Knowledge Graph Reasoning by Representation Learning
<p align="center"> <a href="https://pypi.org/project/unKR/"> <img alt="Pypi" src="https://img.shields.io/pypi/v/unKR"> </a> <a href="https://github.com/seucoin/unKR/blob/main/LICENSE"> <img alt="Pypi" src="https://img.shields.io/badge/license-Apache--2.0-yellowgreen"> </a> <!-- <a href=""> <img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-brightgreen"> </a> --> <a href="https://seucoin.github.io/unKR/"> <img alt="Documentation" src="https://img.shields.io/badge/Doc-online-blue"> </a> </p>unKR is an python library for uncertain Knowledge graph (UKG) Reasoning based on the PyTorch Lightning. It provides a unifying workflow to implement a variety of uncertain knowledge graph representation learning models to complete UKG reasoning. unKR consists of five modules: 1) Data Processor handles low-level dataset parsing and negative sampling, then generates mini-batches of data; 2) Model Hub implements the model algorithms, containing the scoring function and loss function; 3) Trainer conducts iterative training and validation; 4) Evaluator provides confidence prediction and link prediction tasks to evaluate models' performance; 5) Controller controls the training worklow, allowing for early stopping and model saving. These modules are decoupled and independent, making unKR highly modularized and extensible. Detailed documentation of the unKR is available at here.
unKR core development team will provide long-term technical support, and developers are welcome to discuss the work and initiate questions using issue.
What's New
- [May, 2024] We perform instruction tuning with LLaMA-2-7B for UKG reasoning and achieve stronger performance in several UKG resoning tasks. We have relesed the implementation source code and tuned checkpoints.
- [Mar, 2024] Our paper "unKR: A Python Library for Uncertain Knowledge Graph Reasoning by Representation Learning" is accepted by SIGIR2024 Demonstration Track.
- [Feb, 2024] We have relesed this repo that includes the source code and documentation of unKR.
Demo
This is a demo shows the training and testing process of PASSLEAF model with unKR.
<!--  --> <img src="pics/demo.gif"> <!-- <img src="pics/demo.gif" width="900" height="500" align=center> -->Datasets
unKR provides three public UKG datasets including CN15K, NL27K, and PPI5K. The following table shows the source, the number of entities, relations, and facts of each dataset.
| Dataset | Source | #Entity | #Relation | #Fact | |:-------:|:----------:|:---------:|:---------:|:-----------:| | CN15K | ConceptNet | 15000 | 36 | 241158 | | NL27K | NELL | 27221 | 404 | 175412 | | PPI5K | STRING | 4999 | 7 | 271666 |
Models
Now, nine uncertain knowledge graph representation learning models are available and they can be divided to two types: normal and few-shot models.
| Type | Model | |:--------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | Normal | BEURrE, FocusE, GTransE, PASSLEAF, UKGE, UKGsE, UPGAT | | Few-shot | GMUC, GMUC+ |
Reproduced Results
unKR determines two tasks, confidence prediction and link prediction, to evaluate models' ability of UKG reasoning. For confidence prediction task, MSE (Mean Squared Error) and MAE (Mean Absolute Error) are reported. For link prediction task, Hits@k(k=1,3,10), MRR (Mean Reciprocal Rank), MR (Mean Rank) under both raw and filterd settings are reported. In addition, we choose high-confidence (>0.7) triples as the test data for link prediction.
Here are the reproduce results of nine models on NL27K dataset with unKR. See more results at here.
Confidence prediction
<table> <thead> <tr> <th>Type</th> <th>Model</th> <th>MSE</th> <th>MAE </th> </tr> </thead> <tbody align="center" valign="center"> <tr> <td rowspan="8">Normal</td> <td>BEUrRE</td> <td>0.08920 </td> <td>0.22194 </td> </tr> <tr> <td>PASSLEAF(ComplEx)</td> <td>0.02434 </td> <td>0.05176 </td> </tr> <tr> <td>PASSLEAF(DistMult)</td> <td>0.02309 </td> <td>0.05107 </td> </tr> <tr> <td>PASSLEAF(RotatE)</td> <td>0.01949 </td> <td>0.06253 </td> </tr> <tr> <td>UKGE_logi</td> <td>0.02868 </td> <td>0.05966 </td> </tr> <tr> <td>UKGE_rect</td> <td>0.03326 </td> <td>0.07015 </td> </tr> <tr> <td>UKGsE</td> <td>0.12202 </td> <td>0.27065 </td> </tr> <tr> <td>UPGAT</td> <td>0.02922 </td> <td>0.10107 </td> </tr> <tr> <td rowspan="2">Few-shot</td> <td>GMUC</td> <td>0.01300 </td> <td>0.08200 </td> </tr> <tr> <td>GMUC+</td> <td>0.01300 </td> <td>0.08600 </td> </tr> </tbody> </table>Link prediction
<table> <thead> <tr> <th>Type</th> <th>Model</th> <th>Hits@1</th> <th>Hits@3</th> <th>Hits@10</th> <th>MRR</th> <th>MR</th> </tr> </thead> <tbody align="center" valign="center"> <tr> <td rowspan="10">Normal</td> <td>BEUrRE</td> <td>0.156 </td> <td>0.385 </td> <td>0.543 </td> <td>0.299 </td> <td>488.051 </td> </tr> <tr> <td>FocusE</td> <td>0.814 </td> <td>0.918 </td> <td>0.957 </td> <td>0.870 </td> <td>384.471 </td> </tr> <tr> <td>GTransE</td> <td>0.222 </td> <td>0.366 </td> <td>0.493 </td> <td>0.316 </td> <td>1377.564 </td> </tr> <tr> <td>PASSLEAF(ComplEx)</td> <td>0.669 </td> <td>0.786 </td> <td>0.876 </td> <td>0.741 </td> <td>138.808 </td> </tr> <tr> <td>PASSLEAF(DistMult)</td> <td>0.627 </td> <td>0.754 </td> <td>0.856 </td> <td>0.707 </td> <td>138.781 </td> </tr> <tr> <td>PASSLEAF(RotatE)</td> <td>0.687 </td> <td>0.816 </td> <td>0.884 </td> <td>0.762 </td> <td>50.776 </td> </tr> <tr> <td>UKGE_logi</td> <td>0.525 </td> <td>0.673 </td> <td>0.812 </td> <td>0.623 </td> <td>168.029 </td> </tr> <tr> <td>UKGE_rect</td> <td>0.500 </td> <td>0.647 </td> <td>0.800 </td> <td>0.599 </td> <td>125.233 </td> </tr> <tr> <td>UKGsE</td> <td>0.038 </td> <td>0.073 </td> <td>0.130 </td> <td>0.069 </td> <td>2329.501 </td> </tr> <tr> <td>UPGAT</td> <td>0.618 </td> <td>0.751 </td> <td>0.862 </td> <td>0.701 </td> <td>69.120 </td> </tr> <tr> <td rowspan="2">Few-shot</td> <td>GMUC</td> <td>0.3Related Skills
node-connect
352.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
