serval-uni-lu/graph-llama-opf

LLMs with GNN encoders for OPF predictions

0

stars

16

commits

Python

primary language

Oct 1, 2025

updated

README

Installation

pip install -r requirements.txt

Usage and graph representation

See run.py:

    # HeteroData dataset:
    dataset = OPFDataset("data/", case_name="pglib_opf_case14_ieee", split="test")
    
    response = model.generate_response([
        {"role": "system", "content": "Describe the graphs provided by the user."},
        {"role": "user", "content": "What are the active and reactive power values for this graph?"},
    ], graph_inputs=[dataset[0]])

Graph Auto-Encoder example usage

from torch_geometric.datasets import OPFDataset
from src.graph.graph_vae import AutoEncoder
from torch_geometric.loader import DataLoader

# loading
dataset = OPFDataset("data/", case_name="pglib_opf_case14_ieee", split="test")
data_loader = DataLoader(dataset, batch_size=8, shuffle=False)
graph_autoencoder = AutoEncoder.from_dataset(dataset)
graph_autoencoder.load_state_dict("checkpoints/autoencoder.pth")
graph_autoencoder.to("cuda").eval()

# inference
with torch.no_grad():
    for batch in data_loader:
        batch = batch.to("cuda")  
        x_recon, _ = graph_autoencoder(batch.x_dict, batch.edge_index_dict)
        loss = 0
        for node_type in node_types:
            loss += F.mse_loss(x_recon[node_type], batch.x_dict[node_type])
        print("batch loss:", loss.item())

Training

readme todo

Contributors

Locust2520

12 commits

dogoulis

2 commits

yamizi

2 commits

serval-uni-lu/graph-llama-opf

LLMs with GNN encoders for OPF predictions

0

stars

16

commits

Python

primary language

Oct 1, 2025

updated

README

Installation

pip install -r requirements.txt

Usage and graph representation

See run.py:

    # HeteroData dataset:
    dataset = OPFDataset("data/", case_name="pglib_opf_case14_ieee", split="test")
    
    response = model.generate_response([
        {"role": "system", "content": "Describe the graphs provided by the user."},
        {"role": "user", "content": "What are the active and reactive power values for this graph?"},
    ], graph_inputs=[dataset[0]])

Graph Auto-Encoder example usage

from torch_geometric.datasets import OPFDataset
from src.graph.graph_vae import AutoEncoder
from torch_geometric.loader import DataLoader

# loading
dataset = OPFDataset("data/", case_name="pglib_opf_case14_ieee", split="test")
data_loader = DataLoader(dataset, batch_size=8, shuffle=False)
graph_autoencoder = AutoEncoder.from_dataset(dataset)
graph_autoencoder.load_state_dict("checkpoints/autoencoder.pth")
graph_autoencoder.to("cuda").eval()

# inference
with torch.no_grad():
    for batch in data_loader:
        batch = batch.to("cuda")  
        x_recon, _ = graph_autoencoder(batch.x_dict, batch.edge_index_dict)
        loss = 0
        for node_type in node_types:
            loss += F.mse_loss(x_recon[node_type], batch.x_dict[node_type])
        print("batch loss:", loss.item())

Training

readme todo

Contributors

Locust2520

12 commits

dogoulis

2 commits

yamizi

2 commits

Languages

Python

59.6%

Jupyter Notebook

40.4%