SSCModel (Sequential Semantic Classification Model) is a machine learning model designed to assist in Polkadot governance by identifying referendums that contain explicit requests to vote "NAY." By analyzing referendum titles, this model helps automate governance actions such as triggering automated votes or alerting human moderators for review.
- Classifies referendum titles into two categories:
0: Active referendum (default)1: Referendum requesting a "vote nay"
- Uses a TensorFlow/Keras-based neural network for text classification.
- Implements custom loss functions and weighting to handle class imbalances.
- Can be used for both real-time inference and batch processing.
The model is a sequential neural network with the following layers:
| Layer (type) | Output Shape | Param # |
|---|---|---|
| TextVectorization | (None, 128) | 0 |
| Embedding | (None, 128, 32) | 320,000 |
| Conv1D | (None, 126, 32) | 3,104 |
| GlobalMaxPooling1D | (None, 32) | 0 |
| Dense | (None, 16) | 528 |
| Dropout | (None, 16) | 0 |
| Dense (Output Layer) | (None, 2) | 34 |
Total Parameters: 323,666 (~1.23MB)
Trainable Parameters: 323,666
Non-trainable Parameters: 0
Ensure you have the following dependencies installed:
pip install tensorflow numpy scikit-learn requestsgit clone git@github.com:stake-plus/SSCModel.git
cd SSCModelTo train the model, ensure that data.csv is correctly labeled, then run:
python3 train.pyThis will train and save the model as model.keras.
To classify a single referendum title, run:
python3 inference.py "YOUR REFERENDUM TITLE HERE"Example output:
Model prediction: This title indicates a 'vote nay' request.To manually label referendum titles:
python3 data_labeling.pyThis script iterates through referendum titles and asks for a 0 or 1 label.
To validate and correct existing labels:
python3 data_validate.pyTo retrieve recent referendum titles for labeling:
python3 download_titles.pyThis fetches titles from multiple Polkadot ecosystem networks and saves them in titles_data/.
To integrate the trained model into another Python project, use:
import tensorflow as tf
import numpy as np
# Load the trained model
model = tf.keras.models.load_model("model.keras", compile=False)
# Preprocess the input title
def preprocess_text(title):
return np.array([[title]])
# Predict referendum classification
input_title = "Please vote nay"
logits = model.predict(preprocess_text(input_title), verbose=0)
probs = tf.nn.softmax(logits, axis=1).numpy()
# Output result
if np.argmax(probs[0]) == 1:
print("This title indicates a 'vote nay' request.")
else:
print("This title does NOT indicate a 'vote nay' request.")Example predictions from the test dataset:
Title: Please vote nay
Prob(class0)=0.0021, Prob(class1)=0.9979 => Prediction=1 | Expected=1, PASS
...
Title: Treasury Proposal by 727.ventures: Polkadot Wink
Prob(class0)=0.9842, Prob(class1)=0.0158 => Prediction=0 | Expected=0, PASS
...
The model has demonstrated high accuracy in correctly identifying referendums that request a "vote nay."
If you’d like to improve the model, contribute new training data, or refine the inference pipeline, feel free to submit a pull request or create an issue on GitHub.
This project is open-source and provided under the MIT License.
Stake Plus - 2025