Registry / ai-ml / snorkel

snorkel

JSON →
library0.10.0pypypi✓ verified 89d ago

A system for quickly generating training data with weak supervision. Uses labeling functions and probabilistic models to create noisy labels. Current version 0.10.0, supports Python >=3.11. Releases are infrequent; maintenance updates only.

pip install snorkel
INSTALL
IMPORT
SIG · SNORKEL
S
snorkel
ai-mlpythonv0.10.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LabelModel
✓ from snorkel.labeling.model import LabelModel
✗ from snorkel.labeling import LabelModel
LabelModel was moved to snorkel.labeling.model in v0.9.4, but still accessible via old path for backward compatibility.
LFAnalysis
✓ from snorkel.labeling import LFAnalysis
✗ from snorkel.labeling import LabelingFunction
LFAnalysis is in snorkel.labeling, not other submodules.
SnorkelClassifier
✓ from snorkel.classification import SnorkelClassifier
✗ from snorkel import SnorkelClassifier
Must import from snorkel.classification.

Basic Snorkel flow: define labeling functions, generate label matrix, train LabelModel.

from snorkel.labeling import labeling_function, LFAnalysis from snorkel.labeling.model import LabelModel import numpy as np @labeling_function() def lf_keyword(x): # Return 1 if 'keyword' in text else 0 return 1 if 'keyword' in x else 0 # Example data data = ['text with keyword', 'no match'] # Apply LFs (simulate L matrix) L = np.array([[1, 0], [0, 0]) # Train LabelModel label_model = LabelModel(cardinality=2, verbose=True) label_model.fit(L_train=L, n_epochs=500, log_freq=100, seed=123) predictions = label_model.predict(L=L)
Debug
Known issues
breakingSnorkel 0.10.0 dropped support for Python <3.11. If your environment uses Python 3.10 or earlier, you must downgrade to snorkel <=0.9.9 or upgrade Python.
fix
Use Python >=3.11, or install snorkel==0.9.9 if locked to older Python.
affects: >=0.10.0
gotchaLabelModel.fit() requires n_epochs to be explicitly set; default is None and will raise error. Many users forget to set n_epochs.
fix
Always specify n_epochs (e.g., 500) when calling fit().
affects: >=0.9.1
deprecatedLabelModel renamed from 'LabelModel' to 'LabelModel' (still same) but old path snorkel.labeling.LabelModel still works but discouraged.
fix
Use from snorkel.labeling.model import LabelModel.
affects: >=0.9.4
Errors
Common errors & fixes
ValueError: Label model must be fit before calling predict.
Calling predict() without first calling fit() on LabelModel.
fix
Call label_model.fit(...) before predict().
ModuleNotFoundError: No module named 'snorkel.labeling.model'
Installed snorkel version <0.9.4 where the model submodule did not exist.
fix
Upgrade snorkel: pip install --upgrade snorkel. Or import from snorkel.labeling import LabelModel if using older version.
Upgrade
Version history
0.10.0latest on PyPI · released Feb 27, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
1
Resources
snorkel — pip install snorkel · libregistry