A lightweight Python project that demonstrates how multiple labeling functions can generate training labels without manually annotating every example.
- Rule-based labeling functions
- Positive, negative, and abstain labels
- Majority-vote label aggregation
- Coverage and label-distribution metrics
- JSON report generation
- Automated Pytest test suite
- Docker support
- GitHub Actions continuous integration
The project applies several independent labeling functions to each text example.
Each labeling function returns one of these values:
POSITIVENEGATIVEABSTAIN
The votes are combined using majority voting. A tie produces an abstain result.
.
├── .github/
│ └── workflows/
│ └── ci.yml
├── tests/
│ └── test_labeling.py
├── .gitignore
├── Dockerfile
├── labeling.py
├── README.md
├── requirements.txt
└── train.py
Create a virtual environment:
python -m venv venvActivate it:
.\venv\Scripts\Activate.ps1Install dependencies:
python -m pip install -r requirements.txtpython -m pytest -qExpected result:
11 passed
python train.pyThis creates:
weak_supervision_report.json
Create a file with one example per line:
I love this product.
This is terrible.
The package arrived today.
Run:
python train.py --input examples.txtExample:
[
{"text": "This product is amazing."},
{"text": "I want a refund."}
]Run:
python train.py --input examples.jsonBuild the image:
docker build -t weak-supervision-demo .Run it:
docker run --rm weak-supervision-demo- Python 3.11
- Weak supervision
- Rule-based labeling
- Pytest
- Docker
- GitHub Actions
MIT