torch_geometric.nn.models.MoleculeGPT
- class MoleculeGPT(llm: LLM, graph_encoder: Module, smiles_encoder: Module, mlp_out_channels: int = 32, max_tokens: Optional[int] = 20)[source]
Bases:
Module来自“MoleculeGPT: Instruction Following Large Language Models for Molecular Property Prediction”论文的MoleculeGPT模型。
- Parameters:
llm (LLM) – 要使用的LLM。
graph_encoder (torch.nn.Module) – 编码二维分子图。
smiles_encoder (torch.nn.Module) – 编码1D SMILES。
mlp_out_channels (int, optional) – qformer编码后每个嵌入的大小。(默认:
32)max_tokens (int, optional) – 1D/2D编码器的最大输出标记数。 (default:
20)
警告
该模块已使用以下HuggingFace模型进行测试
llm_to_use="lmsys/vicuna-7b-v1.5"
并且可能不适用于其他模型。请查看HuggingFace Models上的其他模型,如果您遇到任何问题,请告知我们。
注意
有关使用
MoleculeGPT的示例,请参见 examples/llm/molecule_gpt.py。- forward(x: Tensor, edge_index: Tensor, batch: Tensor, edge_attr: Optional[Tensor], smiles: List[str], instructions: List[str], label: List[str], additional_text_context: Optional[List[str]] = None)[source]
定义每次调用时执行的计算。
应该由所有子类覆盖。
注意
尽管前向传递的配方需要在此函数内定义,但之后应该调用
Module实例而不是这个,因为前者负责运行已注册的钩子,而后者则默默地忽略它们。