unike 3.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- unike/__init__.py +5 -0
- unike/config/HPOTrainer.py +305 -0
- unike/config/Tester.py +385 -0
- unike/config/Trainer.py +519 -0
- unike/config/TrainerAccelerator.py +39 -0
- unike/config/__init__.py +37 -0
- unike/data/BernSampler.py +168 -0
- unike/data/CompGCNSampler.py +140 -0
- unike/data/CompGCNTestSampler.py +84 -0
- unike/data/KGEDataLoader.py +315 -0
- unike/data/KGReader.py +138 -0
- unike/data/RGCNSampler.py +261 -0
- unike/data/RGCNTestSampler.py +208 -0
- unike/data/RevSampler.py +78 -0
- unike/data/TestSampler.py +189 -0
- unike/data/TradSampler.py +122 -0
- unike/data/TradTestSampler.py +87 -0
- unike/data/UniSampler.py +145 -0
- unike/data/__init__.py +47 -0
- unike/module/BaseModule.py +130 -0
- unike/module/__init__.py +20 -0
- unike/module/loss/CompGCNLoss.py +96 -0
- unike/module/loss/Loss.py +26 -0
- unike/module/loss/MarginLoss.py +148 -0
- unike/module/loss/RGCNLoss.py +117 -0
- unike/module/loss/SigmoidLoss.py +145 -0
- unike/module/loss/SoftplusLoss.py +145 -0
- unike/module/loss/__init__.py +35 -0
- unike/module/model/Analogy.py +237 -0
- unike/module/model/CompGCN.py +562 -0
- unike/module/model/ComplEx.py +235 -0
- unike/module/model/DistMult.py +276 -0
- unike/module/model/HolE.py +308 -0
- unike/module/model/Model.py +107 -0
- unike/module/model/RESCAL.py +309 -0
- unike/module/model/RGCN.py +304 -0
- unike/module/model/RotatE.py +303 -0
- unike/module/model/SimplE.py +237 -0
- unike/module/model/TransD.py +458 -0
- unike/module/model/TransE.py +290 -0
- unike/module/model/TransH.py +322 -0
- unike/module/model/TransR.py +402 -0
- unike/module/model/__init__.py +60 -0
- unike/module/strategy/CompGCNSampling.py +140 -0
- unike/module/strategy/NegativeSampling.py +138 -0
- unike/module/strategy/RGCNSampling.py +134 -0
- unike/module/strategy/Strategy.py +26 -0
- unike/module/strategy/__init__.py +29 -0
- unike/utils/EarlyStopping.py +94 -0
- unike/utils/Timer.py +74 -0
- unike/utils/WandbLogger.py +46 -0
- unike/utils/__init__.py +26 -0
- unike/utils/tools.py +118 -0
- unike/version.py +1 -0
- unike-3.0.1.dist-info/METADATA +101 -0
- unike-3.0.1.dist-info/RECORD +59 -0
- unike-3.0.1.dist-info/WHEEL +4 -0
- unike-3.0.1.dist-info/entry_points.txt +2 -0
- unike-3.0.1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: unike
|
3
|
+
Version: 3.0.1
|
4
|
+
Summary: 基于 OpenKE-PyTorch 开发的知识图谱嵌入工具包
|
5
|
+
Author-email: LuYF-Lemon-love <3555028709@qq.com>, wangtao <wangtao.cpu@gmail.com>
|
6
|
+
License-File: LICENSE
|
7
|
+
Requires-Python: >=3.11
|
8
|
+
Requires-Dist: accelerate>=0.20.3
|
9
|
+
Requires-Dist: numpy>=1.21.6
|
10
|
+
Requires-Dist: packaging>=24.0
|
11
|
+
Requires-Dist: pandas>=1.1.5
|
12
|
+
Requires-Dist: torch>=1.13.1
|
13
|
+
Requires-Dist: tqdm>=4.67.1
|
14
|
+
Requires-Dist: wandb>=0.18.7
|
15
|
+
Description-Content-Type: text/markdown
|
16
|
+
|
17
|
+
# UniKE — 知识图谱嵌入工具包
|
18
|
+
|
19
|
+
[](https://unike.readthedocs.io/zh_CN/latest/?badge=latest)
|
20
|
+
|
21
|
+
基于 [OpenKE-PyTorch](https://github.com/thunlp/OpenKE/tree/OpenKE-PyTorch) 开发的知识图谱嵌入工具包,支持跨平台运行,具备自动超参数搜索、高效并行训练以及实验结果记录功能,为研究与应用提供强大助力。
|
22
|
+
|
23
|
+
教程和 API 参考文档可以访问 [unike.readthedocs.io](https://unike.readthedocs.io/zh_CN/latest/)。
|
24
|
+
|
25
|
+
## 项目结构
|
26
|
+
|
27
|
+
- 📁 [`unike/`](https://github.com/CPU-DS/UniKE/tree/main/unike/)
|
28
|
+
UniKE 源代码保存在 `unike/`
|
29
|
+
- 📚 [`docs/`](https://github.com/CPU-DS/UniKE/tree/main/docs/)
|
30
|
+
所有的文档源文件保存在 `docs/`,所有的 `*.rst` 构成了文档中的各个部分
|
31
|
+
- 🌰 [`examples/`](https://github.com/CPU-DS/UniKE/tree/main/examples/)
|
32
|
+
UniKE 的例子保存在 `examples/`,修改自 `OpenKE-PyTorch`
|
33
|
+
- 📍 [`docs/_static/logs/`](https://github.com/CPU-DS/UniKE/tree/main/docs/_static/logs/)
|
34
|
+
UniKE 的例子运行日志保存在 `docs/_static/logs/`
|
35
|
+
- 💡 [`benchmarks/`](https://github.com/CPU-DS/UniKE/tree/main/benchmarks/)
|
36
|
+
常用的知识图谱保存在 `benchmarks/`
|
37
|
+
- 📜 [`README.rst`](https://github.com/CPU-DS/UniKE/tree/main/README.rst)
|
38
|
+
项目主页
|
39
|
+
|
40
|
+
### ⁉️ Questions / comments
|
41
|
+
如果你有任何问题,可以在 [Github issue](https://github.com/CPU-DS/UniKE/issues) 提问。
|
42
|
+
|
43
|
+
## 快速开始
|
44
|
+
|
45
|
+
```bash
|
46
|
+
git clone https://github.com/CPU-DS/UniKE.git
|
47
|
+
cd UniKE
|
48
|
+
uv pip install dgl
|
49
|
+
uv sync
|
50
|
+
```
|
51
|
+
|
52
|
+
## 新特性
|
53
|
+
|
54
|
+
### **易用的**
|
55
|
+
|
56
|
+
- **1.0.0 版本**: 利用 C++ 重写底层数据处理、C++11 的线程库实现并行、[pybind11](https://github.com/pybind/pybind11) 实现 Python 和 C++ 的交互,进而能够做到跨平台 (Windows, Linux)
|
57
|
+
- **2.0.0 版本**: 使用 Python 重写底层数据处理,进而能够做到跨平台 (Windows, Linux)
|
58
|
+
- 增加了文档
|
59
|
+
|
60
|
+
### **正确的**
|
61
|
+
|
62
|
+
- 增加了 `R-GCN`模型
|
63
|
+
- 增加了 `CompGCN`模型
|
64
|
+
- 修复了 [SimplE模型实现的问题](https://github.com/thunlp/OpenKE/issues/151)
|
65
|
+
- 修复了 [HolE](#details_hole) 深度学习框架(pytorch)的版本适配问题
|
66
|
+
|
67
|
+
### **高效的**
|
68
|
+
|
69
|
+
- 使用 `torch.nn.parallel.DistributedDataParallel` 完成数据并行(**2.0.0 版本** 使用 [accelerate](https://github.com/huggingface/accelerate) 实现),使得 `UniKE` 能够利用多个 `GPU` 同时训练
|
70
|
+
- 增加超参数扫描功能(随机搜索、网格搜索和贝叶斯搜索)
|
71
|
+
|
72
|
+
### **扩展的**
|
73
|
+
|
74
|
+
- 在模型训练过程中,能够在验证集上评估模型(模型能够一次评估多个三元组(batch),能够大大加速模型评估)
|
75
|
+
- 增加了学习率调度器
|
76
|
+
- 能够利用 [wandb](https://wandb.ai/) 输出日志
|
77
|
+
- 实现了早停止
|
78
|
+
- 能够自定义 Hits@N
|
79
|
+
|
80
|
+
## 支持的知识图谱嵌入模型
|
81
|
+
|
82
|
+
| 类型 | 模型 |
|
83
|
+
| --- | --- |
|
84
|
+
| 平移模型 | `TransE`, `TransH`, `TransR`, `TransD`, `RotatE` |
|
85
|
+
| 语义匹配模型 | `RESCAL`, `DistMult`, `HolE`, `ComplEx`, `Analogy`, `SimplE`, `ANALOGY` |
|
86
|
+
| 图神经网络模型 | `R-GCN`, `CompGCN` |
|
87
|
+
|
88
|
+
## 如何引用这个项目?
|
89
|
+
|
90
|
+
如果您发现 UniKE 对您的研究有用,请考虑使用以下 BibTeX 模板引用 UniKE:
|
91
|
+
|
92
|
+
```bibtex
|
93
|
+
@misc{UniKE,
|
94
|
+
author = {Lu, Yanfeng and Hou, Fengzhen},
|
95
|
+
year = {2024},
|
96
|
+
note = {https://github.com/CPU-DS/UniKE},
|
97
|
+
title = {UniKE: An Open Source Library for Knowledge Graph Embeddings}
|
98
|
+
}
|
99
|
+
```
|
100
|
+
|
101
|
+
该仓库主要由 [Yanfeng Lu](https://github.com/LuYF-Lemon-love),[Fengzhen Hou](https://github.com/houfz-cpu) 提供(按时间顺序排列)。
|
@@ -0,0 +1,59 @@
|
|
1
|
+
unike/__init__.py,sha256=M0Hqy8CzoiWGfC_p2c3QoMWrgZIJOweYlFbBPPd2i1w,142
|
2
|
+
unike/version.py,sha256=jp6E6uGPeT16TI2dk-7y-LDpYN8b_jTZ6Mp1U6CH9L4,26
|
3
|
+
unike/config/HPOTrainer.py,sha256=K_RS9HmHOhWTHgenY4iioaHb6Cr5JUraPQpQzA4cl2U,9317
|
4
|
+
unike/config/Tester.py,sha256=SIWFjMSRltNIK2LhUGi0qJBcFmSz3K8dnvIvr0UKCew,13055
|
5
|
+
unike/config/Trainer.py,sha256=LgPX4HKXDA82e1NdCSxKkw6PDc3yyx9Zvt11NsOw4-A,15128
|
6
|
+
unike/config/TrainerAccelerator.py,sha256=1hZiHQA4B8R6dst8_ZTMpPIDO4qx16e7GJi8aTORUto,1055
|
7
|
+
unike/config/__init__.py,sha256=8bCqZ3TEc-eo3HZYEwMuE49hvrtVqe4zLRFPeuk5XVc,958
|
8
|
+
unike/data/BernSampler.py,sha256=g1ed496-iYayOKyuoRQPr5BC2OjdR4g5jqnjCcr2sCs,5203
|
9
|
+
unike/data/CompGCNSampler.py,sha256=np0LA8ucgg2fp-8tt_pn-Y4JpVA6_VtuD34HWXjRHHY,4234
|
10
|
+
unike/data/CompGCNTestSampler.py,sha256=ocwHFOZEvwYlf90GlfHMvfVXBJ3MkQ8NTgDgw2XBTTY,2437
|
11
|
+
unike/data/KGEDataLoader.py,sha256=69Un3pJPY91KhOsFAPX7w4PpOwMqTV-iRwpKE0gLXQQ,9415
|
12
|
+
unike/data/KGReader.py,sha256=UwM5H285-ZcNnimHHgbEVFwStxFXfNSp27ZHvE0EXa4,4226
|
13
|
+
unike/data/RGCNSampler.py,sha256=M4IsetGA_5FO67939ChNiNngt1GwzM93HY7nHu773LM,8483
|
14
|
+
unike/data/RGCNTestSampler.py,sha256=JoWYal8qm-YCp8gNe1dLsrqhBL0E0el57WXmEwCIeoY,7534
|
15
|
+
unike/data/RevSampler.py,sha256=AfJkYkRQqWzp0cNmAesmivPX5MK1H6E4qBhqhb019AI,2335
|
16
|
+
unike/data/TestSampler.py,sha256=heymNvW84NSMEf-K6L3PBIDBt4Qtzk6Af-PjMutR62Y,6271
|
17
|
+
unike/data/TradSampler.py,sha256=XD8LMt_P2ci2XW5C3Vdh3b2cMB-JwG8ln3MwWy_EwFo,3753
|
18
|
+
unike/data/TradTestSampler.py,sha256=7NZ6p8W13kRdYED7CIUsAnf_pJCHnZ733Lxcbuk738k,2880
|
19
|
+
unike/data/UniSampler.py,sha256=6hOlXtAfhlAMV9bYdmE7xraOG4NQsBmwnD9g1sY0r8Y,4507
|
20
|
+
unike/data/__init__.py,sha256=2Mop64O3QlF9NxTdnZ6vDdiKFGCLR4qEaBHBTV1LiK4,1203
|
21
|
+
unike/module/BaseModule.py,sha256=dQ1cJk5leUTKU9gsYEQEq0t6VWS-3gJ20yPiSMTxfjc,3278
|
22
|
+
unike/module/__init__.py,sha256=oIi9RORIt7236iuYj7_0DeqZkgeCK9pAfxVUdkUf3mY,473
|
23
|
+
unike/module/loss/CompGCNLoss.py,sha256=NeasyqMsdvhuEp3R4AoVihcUx79uP4jD_CZBi-nfdJo,2368
|
24
|
+
unike/module/loss/Loss.py,sha256=JmZO0g3SrD3v0t1OXWtHLZ73z8jiX_MaNIJ4WbZ3444,554
|
25
|
+
unike/module/loss/MarginLoss.py,sha256=YBYrLeoKnpmecymhkaaDczN4FVww3esNDwWhjim8kB0,3811
|
26
|
+
unike/module/loss/RGCNLoss.py,sha256=bGdMq80ettEN2R7volkYP6hNt2EwGXg2kqZrKfPOfZ4,2855
|
27
|
+
unike/module/loss/SigmoidLoss.py,sha256=YO1Vq_hYoeUdVACsinIpA2zni8FeYWEZtWI7nxYhKe8,3881
|
28
|
+
unike/module/loss/SoftplusLoss.py,sha256=SwRI4IzRLc_1GisC8togL6AphA64jxDNXJkD7jMp09g,3921
|
29
|
+
unike/module/loss/__init__.py,sha256=Yn-71Cuel3aMR5Sg-qXtcmZx_U64qu_xJuewnkbWDHk,1021
|
30
|
+
unike/module/model/Analogy.py,sha256=ObU5qi9ZzplPU3WmHG4BhTGuTH5DoEbkc6fOMB2PnG8,7052
|
31
|
+
unike/module/model/CompGCN.py,sha256=bkDbCaIq3irTioCwhwGKOe7FSYP2EGAMWQx5nasWekc,19643
|
32
|
+
unike/module/model/ComplEx.py,sha256=UInfEXq-bmekMPEtosICWDms0skUHI-87dgxaJesq9o,7548
|
33
|
+
unike/module/model/DistMult.py,sha256=m0pMld9bSGCb7oN9APC8TZ56EjlRg5BrLNXP9RumYQg,7286
|
34
|
+
unike/module/model/HolE.py,sha256=hBx6N9-EygCrGYEbTfF_ZrnkHq9gsYla0haMB9kbfNU,8249
|
35
|
+
unike/module/model/Model.py,sha256=6FGxS54LaR-Hvayb_b5L10F__zjsfwX34Ty0UNxbudk,2882
|
36
|
+
unike/module/model/RESCAL.py,sha256=1H4EW6NLkFCpr48U4xNbKvBmepuqTwDfMCr6iiL9rdk,8029
|
37
|
+
unike/module/model/RGCN.py,sha256=HuCDvstL06IVvhmn4jCVUGa0hbAumBRteChWwEMYN2Y,8752
|
38
|
+
unike/module/model/RotatE.py,sha256=FqURuv45tCUl0cCMensRfk_P1Yb8rMaZy9S5lOeC7_E,8159
|
39
|
+
unike/module/model/SimplE.py,sha256=YdqeLGFHxWXlStKlkZZrZOkUsuwzERDOsuHI-UGVCLI,7518
|
40
|
+
unike/module/model/TransD.py,sha256=9mxd1hiEvz02tcT2ccJjU2RNn2vq5HS7TJ1N3nbGeLo,13378
|
41
|
+
unike/module/model/TransE.py,sha256=xmu6m6udUHNRMtBu6KrjFY6U1LeFQOZcLsNNg6WK7UI,8140
|
42
|
+
unike/module/model/TransH.py,sha256=gi7DbzTCs4f-uX1xTyOI-wcfMSPQW1Onsg9AjVDM6Xo,9251
|
43
|
+
unike/module/model/TransR.py,sha256=11CbkuAI18MDgTRGV7prKlAE0B6CB8EwPKGQ4VP_cco,11713
|
44
|
+
unike/module/model/__init__.py,sha256=NlLlxb4VSkdpU8iNwZHdPmL9KOvT8_tpBvhhslMkUHM,1683
|
45
|
+
unike/module/strategy/CompGCNSampling.py,sha256=Y3Dy0WTwwwXZLUbj7oQZi8qIUitWDLD94VSrCelZr4Q,3609
|
46
|
+
unike/module/strategy/NegativeSampling.py,sha256=9L-eJefkLh9z7X6UyeoxFz6KsCOscNQhv0Q4Qkxpxm8,3455
|
47
|
+
unike/module/strategy/RGCNSampling.py,sha256=bel7m0YM5_xoDxknq3c109MUbQco68IGlZLXKywg12s,3607
|
48
|
+
unike/module/strategy/Strategy.py,sha256=m-zVFXhmNr03cGM8OivSFFdCwM5t44o50rA-w7SoEkg,576
|
49
|
+
unike/module/strategy/__init__.py,sha256=mcMPCk_12BKNwSU4Ef3hOdlUwJDE0Xj66EVMO6My4h0,866
|
50
|
+
unike/utils/EarlyStopping.py,sha256=X7xJ3zgmpDf3qQH9YaTFjIjcyGerTzxByB8P532Z0s0,2848
|
51
|
+
unike/utils/Timer.py,sha256=wVvchC_hamErdnso-JwkpuCV0VKyjUWtMUnxZSEYlOQ,1723
|
52
|
+
unike/utils/WandbLogger.py,sha256=VDny07xm1N0y1zzc39EePDYo_ZFOjRVfDuv6L1KHpzg,1125
|
53
|
+
unike/utils/__init__.py,sha256=SBZbh2CNJm43lde_kWW-rtbkj0KB1bRZIy8rarhZc2c,551
|
54
|
+
unike/utils/tools.py,sha256=4TW0wa5Q5i9aEeSNDv2sIVCAmGrYgout2iWTak_04gY,3361
|
55
|
+
unike-3.0.1.dist-info/METADATA,sha256=bG5K0B5Bg1bbvF4CGVKe5nY0CqYDLeZ9JCz75SlDDPU,4135
|
56
|
+
unike-3.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
57
|
+
unike-3.0.1.dist-info/entry_points.txt,sha256=kLSnRySoUm0e1qV1o2j7fp2DtB61ZSv7jN-3RnJUzkc,37
|
58
|
+
unike-3.0.1.dist-info/licenses/LICENSE,sha256=cCetD3VrUJIPYyIgFNfQVeHIkDNQ5o63gxlz9APxuNU,1063
|
59
|
+
unike-3.0.1.dist-info/RECORD,,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 CPU-DS
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|