fletxcher's picture
graph_subgraph_embedding v1
ad59ea5 verified
|
Raw History Blame Contribute Delete
2.44 kB
---
license: other
library_name: khaos
tags:
- khaos
- graph
- subgraph-embedding
- graph-transformer
pipeline_tag: feature-extraction
---
# Khaos Subgraph Embedding
A graph transformer that maps a whole subgraph to one 128-dimensional vector, trained contrastively on augmented views of subgraphs (dropped edges and masked features), with a small network-type objective.
`graph_subgraph_embedding` **v1**, from Khaos (a local-first library of pre-trained models for domain-specific tasks). This is the first release of the artifact.
## Model
- Architecture: GraphTransformerEncoder: 4 transformer blocks (dim 128, 4 heads) with a learned attention bias on edges and mean pooling
- Parameters: 801,665
- Format: ONNX (`model.onnx`) plus PyTorch weights (`model.pt`) and `manifest.json`
- Training data: [fletxcher/khaos-graph_subgraph_embedding](https://huggingface.co/datasets/fletxcher/khaos-graph_subgraph_embedding)
## Results
Measured on the held-out test split of the training dataset.
| Metric | Value |
| --- | ---: |
| test_domain_accuracy | 0.9950 |
| test_baseline_structure_accuracy | 0.8375 |
| test_unseen_graph_domain_accuracy | 0.7833 |
| test_unseen_graph_baseline_structure_accuracy | 0.6867 |
| chance_accuracy | 0.3333 |
### Domain classification from the embedding
A logistic regression on the 128-dimensional subgraph embedding, versus a baseline on simple statistics (size, mean degree, density, feature mean and spread).
| Split | Subgraphs | Embedding | Baseline |
| --- | ---: | ---: | ---: |
| test | 400 | 0.995 | 0.838 |
| test_unseen_graph | 300 | 0.783 | 0.687 |
## Training
```json
{
"epochs": 30,
"batch": 16,
"lr": 0.0005,
"architecture": "GraphTransformerEncoder"
}
```
Best epoch 4, trained in 349.5 minutes on a single consumer GPU (RTX 3050 8 GB).
## Intended use
Comparing and retrieving subgraphs and communities. Input is a subgraph of at most about 64 nodes.
## Limitations
- Trained with a coarse pretext task (network type), so it captures global structure more than fine semantics.
- Attention is all-pairs: cost grows quadratically with subgraph size.
## Usage
```bash
pip install khaos
khaos serve ./graph_subgraph_embedding
```
## License
This model was trained on graph data with research-only, share-alike or mixed terms (see the training dataset card for each source). Treat it as research use and check the upstream data licenses before any commercial use.