Presentation link: https://aaudk-my.sharepoint.com/:v:/g/personal/ev52yu_student_aau_dk/IQBhbanv3sOmR4qpqKzNWJ8LASJjBYmnSK-GsC4yRPtShL8?nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJPbmVEcml2ZUZvckJ1c2luZXNzIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXciLCJyZWZlcnJhbFZpZXciOiJNeUZpbGVzTGlua0NvcHkifX0&e=spnj1M # 🌱 Green Patent Classification using PatentSBERTa ### Silver Supervision + Active Learning + Human-in-the-Loop Fine-Tuning This repository contains a fine-tuned version of **PatentSBERTa** for binary classification of patent claims into: - **0 β€” Non-Green** - **1 β€” Green Technology** We created a balanced dataset of 50,000 claims: - 25,000 Green (silver) - 25,000 Non-Green (silver) Stratified split: - 70% Train - 15% Pool (for active learning) - 15% Evaluation --- # 🧠 Baseline Model (Frozen Embeddings) We computed claim embeddings using: A Logistic Regression classifier was trained on frozen embeddings. ### Silver Evaluation Performance - Accuracy β‰ˆ 77.5% - Balanced precision and recall across classes This confirms that domain-specific embeddings capture sustainability semantics effectively even without fine-tuning. --- # πŸ” Active Learning Strategy To improve labeling efficiency, we selected high-risk examples from the unlabeled pool using uncertainty sampling: Where: - `p_green` is the model’s predicted probability for class 1. - Higher `u` indicates higher classification uncertainty. The top 100 most uncertain examples were selected for expert review. --- # πŸ€– LLM β†’ Human HITL Workflow ## LLM Used qwen2.5:7b-instruct (via Ollama) The LLM provided: - Suggested label (0/1) - Confidence level (low / medium / high) - Short rationale quoting the claim Human reviewers assigned the final gold label. --- # πŸ”„ Human Overrides (Required Reporting) Override defined as: This measures disagreement between the LLM and human expert. ## Example Overrides 1) **LLM 0 β†’ Human 1** Claim: Conversion of biological material into energy. Reason: Biomass-based energy conversion qualifies as renewable energy under green technology criteria. 2) **LLM 0 β†’ Human 1** Claim: Light concentrating optic for photovoltaic device. Reason: The invention directly improves solar energy generation, which is renewable and climate-mitigating. ### Observed Pattern The LLM tends to under-classify cases where renewable energy impact is implied but not explicitly framed as β€œclimate mitigation.” This highlights the importance of human-in-the-loop review for borderline sustainability cases. --- # πŸš€ Final Fine-Tuning We fine-tuned: Training data: - Silver training split - + 100 human-labeled gold examples Training configuration: - Optimizer: AdamW - Learning rate: 2e-5 - Epochs: 1 - Max sequence length: 256 - Batch size: 4 --- # πŸ“ˆ Evaluation The fine-tuned model was evaluated on: - Silver evaluation set - Gold HITL set Fine-tuning improves performance especially on previously uncertain claims. --- # πŸ’» Usage Example ```python from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch model_path = "your-model-path" tokenizer = AutoTokenizer.from_pretrained(model_path) model = AutoModelForSequenceClassification.from_pretrained(model_path) text = "A system for converting biomass into renewable energy." inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=256) with torch.no_grad(): outputs = model(**inputs) prediction = torch.argmax(outputs.logits, dim=-1).item() print("Green" if prediction == 1 else "Non-Green")