COGNET V1: Concept Routing Graph Neural Network
Project description
COGNET V1
COGNET is a Concept Routing Graph Neural Network designed for complex reasoning over text.
Installation
You can install COGNET as a Python package. From the root directory:
pip install -e .
Requirements
- Python >= 3.10
- PyTorch >= 2.0.0
- PyTorch Geometric >= 2.3.0
- Transformers, spaCy, datasets
You may need to download the spaCy model:
python -m spacy download en_core_web_sm
Running the Pipelines
1. Minimal Working Pipeline (Training Sanity Check)
To test that the full forward and backward pass works on a dummy dataset:
python -m cognet.train --dummy
2. Full Training
To run the full training loop with checkpointing:
python -m cognet.train --train_size 1000 --val_size 200 --epochs 5 --batch_size 16
3. Ablation Experiment
To verify that SCR routing adds value compared to standard pooling:
python -m cognet.experiment --dummy
or on the real dataset:
python -m cognet.experiment --train_size 500 --val_size 100 --epochs 5
Inference API Usage
You can use the generate method for simple yes/no text classification.
from cognet import CognetModel
# Load a trained model
# model = CognetModel.load("./checkpoints/cognet_best.pt")
# Or create a new one
model = CognetModel()
answer = model.generate("Explain gravity")
print(f"Prediction: {answer}")
Lightweight Deployment (FastAPI)
You can serve the model over an HTTP API using the provided FastAPI server.
- Set the environment variable for your model checkpoint (optional):
export COGNET_MODEL_PATH="./checkpoints/cognet_best.pt"
- Start the server:
uvicorn deployment.server:app --host 0.0.0.0 --port 8000
- Make a request:
curl -X POST "http://127.0.0.1:8000/generate" \
-H "Content-Type: application/json" \
-d '{"text": "Is the sky blue?"}'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cognet_generative-0.1.0.tar.gz.
File metadata
- Download URL: cognet_generative-0.1.0.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a4b0880e5eef317e53d416c2cf2788a546f073d9a49be7312bab47667709b92
|
|
| MD5 |
92afa93ed5684fac92daadab6549b30d
|
|
| BLAKE2b-256 |
8af7ad87a36d86db7579c3d0d7d1213e35daab03f0d5c21c0d74e14a6e8ffaf2
|
File details
Details for the file cognet_generative-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cognet_generative-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2a921636b1099dbcdb41176fb0006972ac0c516cb21c2d5f5b2a3ccd9553c0e
|
|
| MD5 |
caae86ff65da3246dbc10be9498cce30
|
|
| BLAKE2b-256 |
afd183a5cb7cb00ca195457b5da82028a2d10a874105c1bdd63bef2a010aa174
|