35 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from lnp_ml.modeling.encoders.rdkit_encoder import CachedRDKitEncoder
from lnp_ml.modeling.encoders.mpnn_encoder import CachedMPNNEncoder
# ============ LLM / 分子编码器(可选) ============
# 这些 encoder 在使用 use_llm=True 时才会被实例化。
# 为避免在未安装对应依赖(如 torch_geometric、selfies时导入即报错
# 采用惰性导入:实际类在 build_llm_encoder() 内按需 import。
__all__ = [
"CachedRDKitEncoder",
"CachedMPNNEncoder",
# LLM encoders按需惰性导入见 models.build_llm_encoder
"LLMEncoder",
"MolT5Encoder",
"MoleculeSTMEncoder",
"SELFIESTEDEncoder",
]
def __getattr__(name):
"""惰性导入 LLM encoder 类,避免未装可选依赖时 import 失败。"""
if name == "LLMEncoder":
from lnp_ml.modeling.encoders.llm_encoder import LLMEncoder
return LLMEncoder
if name == "MolT5Encoder":
from lnp_ml.modeling.encoders.molt5_encoder import MolT5Encoder
return MolT5Encoder
if name == "MoleculeSTMEncoder":
from lnp_ml.modeling.encoders.moleculestm_encoder import MoleculeSTMEncoder
return MoleculeSTMEncoder
if name == "SELFIESTEDEncoder":
from lnp_ml.modeling.encoders.selfiested_encoder import SELFIESTEDEncoder
return SELFIESTEDEncoder
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")