Views
No views yet
sdg-scibert-zo_up)transformers Trainer APIAutoModelForSequenceClassificationpipeline:1from transformers import pipeline
2
3classifier = pipeline(
4 "text-classification",
5 model="simon-clmtd/sdg-scibert-zo_up",
6 tokenizer="simon-clmtd/sdg-scibert-zo_up",
7 truncation=True,
8 padding=True,
9 max_length=512,
10 return_all_scores=True,
11 device=0 # or -1 for CPU
12)
13
14text = "Ensure access to affordable, reliable, sustainable and modern energy for all"
15print(classifier(text))sdg-predict1git clone https://huggingface.co/simon-clmtd/sdg-scibert-zo_up
2cd sdg-scibert-zo_up
3pip install -e .sdg-predict..jsonl file (one JSON object per line). You must specify the key containing the text to classify:input.jsonl):1{"id": 1, "text": "Ensure access to affordable, reliable, sustainable and modern energy for all"}
2{"id": 2, "text": "Atmospheric warming is profoundly affecting high-mountain regions"}sdg-predict input.jsonl --key text --top1 --output preds.jsonlsdg-predict input.jsonl --key text --output preds_all.jsonlsdg-predict input.jsonl --key text --batch_size 16prediction key:--top1:1{
2 "id": 1,
3 "text": "...",
4 "prediction": {
5 "label": "7",
6 "score": 0.9124
7 }
8}--top1:1{
2 "id": 1,
3 "text": "...",
4 "prediction": [
5 {"label": "1", "score": 0.0021},
6 {"label": "2", "score": 0.0005},
7 ...
8 {"label": "7", "score": 0.9124}
9 ]
10}modeling.py: Optional class wrapper if extending the base model.inference.py: Reusable batch inference logic for Python scripts.cli_predict.py: CLI tool using the inference logic.requirements.txt: Runtime dependencies.setup.py: Installation and entry point for the CLI.