图神经网络预训练(1) - Strategies for Pre-training Graph Neural Networks 简介

本文介绍了斯坦福大学在2019年发表的一篇关于图神经网络预训练方法的研究,该方法通过节点和图级别的预训练提升模型在IC50等分子性质预测任务上的性能。研究指出,有效的预训练应兼顾节点和图层面的学习,避免负迁移。文章探讨了结构预测和属性掩蔽两种预训练策略,并展示了预训练对模型性能的提升。尽管提升有限,但这种方法为解决数据稀缺问题提供了新思路。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在项目中,做IC50等分子性质预测,但是自有的数据很少,往往只有几百,甚至几十。即使有类似任务的数据,例如从专利或者文献去收集,合并在一起也不多,最多上千。数量上完全不能从头训练一个深度学习模型。这时候就要考虑到迁移学习和预训练,减少模型对数据的需求。

我们这次要复制的文献是一篇非常经典的关于图神经网络预训练策略的文章,是斯坦福大学的工作,发表于2019年。

参考文献

Weihua Hu*, Bowen Liu*, Joseph Gomes, Marinka Zitnik, Percy Liang, Vijay Pande, Jure Leskovec. Strategies for Pre-training Graph Neural Networks. ICLR 2020

他们开发了一种自监督学习的预训练方法,单个节点以及整个图的级别上预训练一个富有表现力的 GNN,以便 GNN 可以同时学习有用的局部和全局表示。

一、背景

成功的迁移学习不仅仅是增加与下游任务来自同一域数据集上的预训练。同时,它需要大量的领域专业知识来仔细选择与感兴趣的下游任务相关的示例和目标标签。 否则,知识从相关的预训练任务转移到新的下游任务可能会损害泛化能力,这被称为负迁移(negative transfer),并显著限制了预训练模型的适用性和可靠性。

文章中解释道:

如图,

(a.i) 当仅使用节点层面预训练时,可以很好地分离不同形状的节点(语义不同的节点),但是,节点嵌入是不可通过组合、池化节点级嵌入产生图的嵌入(由它们的类表示,+ 和 - ) ,因为节点层面的嵌入是不可分离的,放到图层面是没有意义。

(a.ii) 仅使用图层面预训练,图嵌入可以很好地分离,但是单个节点的嵌入不一定能捕获其特定领域的语义。也就是说,图层面训练过程中,节点的特征X,没有特定的意义。

(a.iii) 高质量的节点嵌入使得不同类型的节点可以很好地分离,同时嵌入空间也是可组合的。这允许对整个图进行准确和稳健的表示,并能够将预训练模型稳健地转移到各种下游任务。也就是说,一个好的预训练,既可以得到图层面的特征,也可以得到节点层面的特征,在图层面和节点层面均有意义。

(b) GNN 预训练方法的分类。文章提出的方法,即结构预测(Context Prediction)、属性掩蔽(Attribute Masking)和图级监督预训练(Supervised Attribute Prediction)支持节点层面和图层面预训练。

二、节点层面预训练:Context 和 Attribute Prediction

2.1  结构预测 Context Prediction

在 Context Prediction 中,子图是围绕选定中心节点(红色标记)的 K-hop 邻域,其中 K 是 GNN 层数,在图中设置为 2。 上下文定义为从中心节点开始的 r1- 和 r2-hop 之间的周围图结构,我们在图中使用 r1 = 1 和 r2 = 4。GNN学习的目标是判断哪些节点属于中心节点的周围结构范围 

2.2 属性掩蔽 Attribute Masking

如上图(b) 在属性掩蔽中,输入节点/边缘属性(例如,分子图中的原子类型)被随机掩蔽,并要求 GNN 预测它们

这里仅仅是简单的介绍一下文章中两种节点层面的预训练方法,在代码实现层面上,还涉及到如何设置节点掩码,如何负采样,如何判断是不是一个周围子节点等。这些留到后面的内容中。

三、结果与性能

 

从上面两张图的结果来看,经过预训练,模型的性能是由明显提高的,虽然提高的并不大。

四、总体评价:

正如文章所言,节点层面和图层面的任务在训练过程中,模型中间层输出的向量是没有意义的,因为模型是照着任务损失的梯度下降方向进行优化的,针对标签相同的结构完全不同的两个分子,他们原子节点特征几乎是相同的。所以,这按文章确实提供一个很好的解决方案,既可以有节点层面的有效特征,又可以由此延申生成图层面特征/任务。

文章源码:GitHub - snap-stanford/pretrain-gnns: Strategies for Pre-training Graph Neural Networkshttps://github.com/snap-stanford/pretrain-gnns

但是由于版本的问题,代码并不能直接运行。

接下来,将解析代码,同时,发布可以运行的版本。

### GraphRAG with Docker Deployment or Integration Issues GraphRAG is an advanced framework designed for handling graph-based retrieval-augmented generation tasks. When integrating or deploying such frameworks within a Dockerized environment, several considerations must be taken into account to ensure smooth operation and scalability. #### Key Considerations for Deploying GraphRAG Using Docker 1. **Network Configuration**: Similar to how Docker Compose handles networking by creating dedicated networks for applications, ensuring proper network settings is crucial when running multiple containers involved in the GraphRAG stack[^3]. Each component of the system should reside on the same virtual network so they can communicate seamlessly via their respective container names. 2. **Service Management**: The `docker.service` file plays a pivotal role in managing Docker daemon behavior at startup. Modifying it might involve setting appropriate resource limits or enabling certain features required by complex workloads like those encountered while working with large-scale machine learning models used in GraphRAG deployments[^1]. 3. **Continuous Integration/Deployment Pipelines**: Leveraging CI/CD pipelines facilitates automated testing and deployment processes which are essential especially during iterative development phases where frequent updates occur regularly. Tools provided through platforms such as Google Cloud Platform's offerings could streamline these operations significantly[^2]. 4. **Volume Handling**: Persistent storage management becomes critical since training data sets along with pre-trained model weights need persistent locations outside ephemeral container filesystems. Properly defining volumes ensures consistency across different runs without losing important information due to accidental deletions upon stopping/removing containers. 5. **Environment Variables & Secrets Management**: Secure passing down sensitive credentials necessary for accessing external APIs or databases connected indirectly from inside your docker-compose setup requires careful planning around secrets' protection mechanisms available natively under modern DevOps practices today including but not limited to HashiCorp Vault integrations etc.. ```bash # Example command showing basic usage pattern involving both local files alongside remote registry pulls. $ docker run --name mygraphragapp \ -v $(pwd)/data:/var/graphrag/data \ -e API_KEY="your_api_key_here" \ gcr.io/myprojectid/graphrag:latest python app.py start ``` Above script demonstrates launching custom built image tagged 'gcr.io/myprojectid/graphrag:latest', mapping current directory’s subfolder named “data” onto path `/var/graphrag/data`, injecting environmental variable called `API_KEY`. Finally executing entrypoint defined within target image specifying action ‘start’. --- §§Related Questions§§ 1. How does one optimize memory allocation parameters specifically tailored towards deep neural networks execution environments encapsulated entirely over isolated Linux namespaces? 2. What strategies exist regarding failover scenarios concerning multi-container setups utilizing shared resources yet maintaining high availability standards expected out enterprise grade solutions nowadays ? 3. Can you elaborate further about potential pitfalls associated with improper configuration leading up degraded performance metrics observed post-production rollouts ? 4. Are there any recommended best practice guidelines published anywhere covering end-to-end lifecycle management aspects related specifically toward AI/ML serving layers deployed atop container orchestration clusters?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

DrugAutoPilot

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值