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JhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJPbmVEcml2ZUZvckJ1c2luZXNzIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXciLCJyZWZlcnJhbFZpZXciOiJNeUZpbGVzTGlua0NvcHkifX0&e=spnj1M
|
| 2 |
+
|
| 3 |
+
# 🌱 Green Patent Classification using PatentSBERTa
|
| 4 |
+
### Silver Supervision + Active Learning + Human-in-the-Loop Fine-Tuning
|
| 5 |
+
|
| 6 |
+
This repository contains a fine-tuned version of **PatentSBERTa** for binary classification of patent claims into:
|
| 7 |
+
|
| 8 |
+
- **0 — Non-Green**
|
| 9 |
+
- **1 — Green Technology**
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
We created a balanced dataset of 50,000 claims:
|
| 13 |
+
|
| 14 |
+
- 25,000 Green (silver)
|
| 15 |
+
- 25,000 Non-Green (silver)
|
| 16 |
+
|
| 17 |
+
Stratified split:
|
| 18 |
+
|
| 19 |
+
- 70% Train
|
| 20 |
+
- 15% Pool (for active learning)
|
| 21 |
+
- 15% Evaluation
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
# 🧠 Baseline Model (Frozen Embeddings)
|
| 26 |
+
|
| 27 |
+
We computed claim embeddings using:
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
A Logistic Regression classifier was trained on frozen embeddings.
|
| 31 |
+
|
| 32 |
+
### Silver Evaluation Performance
|
| 33 |
+
|
| 34 |
+
- Accuracy ≈ 77.5%
|
| 35 |
+
- Balanced precision and recall across classes
|
| 36 |
+
|
| 37 |
+
This confirms that domain-specific embeddings capture sustainability semantics effectively even without fine-tuning.
|
| 38 |
+
|
| 39 |
+
---
|
| 40 |
+
|
| 41 |
+
# 🔍 Active Learning Strategy
|
| 42 |
+
|
| 43 |
+
To improve labeling efficiency, we selected high-risk examples from the unlabeled pool using uncertainty sampling:
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
Where:
|
| 47 |
+
- `p_green` is the model’s predicted probability for class 1.
|
| 48 |
+
- Higher `u` indicates higher classification uncertainty.
|
| 49 |
+
|
| 50 |
+
The top 100 most uncertain examples were selected for expert review.
|
| 51 |
+
|
| 52 |
+
---
|
| 53 |
+
|
| 54 |
+
# 🤖 LLM → Human HITL Workflow
|
| 55 |
+
|
| 56 |
+
## LLM Used
|
| 57 |
+
|
| 58 |
+
qwen2.5:7b-instruct (via Ollama)
|
| 59 |
+
|
| 60 |
+
The LLM provided:
|
| 61 |
+
- Suggested label (0/1)
|
| 62 |
+
- Confidence level (low / medium / high)
|
| 63 |
+
- Short rationale quoting the claim
|
| 64 |
+
|
| 65 |
+
Human reviewers assigned the final gold label.
|
| 66 |
+
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
# 🔄 Human Overrides (Required Reporting)
|
| 70 |
+
|
| 71 |
+
Override defined as:
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
This measures disagreement between the LLM and human expert.
|
| 75 |
+
|
| 76 |
+
## Example Overrides
|
| 77 |
+
|
| 78 |
+
1) **LLM 0 → Human 1**
|
| 79 |
+
Claim: Conversion of biological material into energy.
|
| 80 |
+
Reason: Biomass-based energy conversion qualifies as renewable energy under green technology criteria.
|
| 81 |
+
|
| 82 |
+
2) **LLM 0 → Human 1**
|
| 83 |
+
Claim: Light concentrating optic for photovoltaic device.
|
| 84 |
+
Reason: The invention directly improves solar energy generation, which is renewable and climate-mitigating.
|
| 85 |
+
|
| 86 |
+
### Observed Pattern
|
| 87 |
+
|
| 88 |
+
The LLM tends to under-classify cases where renewable energy impact is implied but not explicitly framed as “climate mitigation.”
|
| 89 |
+
|
| 90 |
+
This highlights the importance of human-in-the-loop review for borderline sustainability cases.
|
| 91 |
+
|
| 92 |
+
---
|
| 93 |
+
|
| 94 |
+
# 🚀 Final Fine-Tuning
|
| 95 |
+
|
| 96 |
+
We fine-tuned:
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
Training data:
|
| 100 |
+
- Silver training split
|
| 101 |
+
- + 100 human-labeled gold examples
|
| 102 |
+
|
| 103 |
+
Training configuration:
|
| 104 |
+
|
| 105 |
+
- Optimizer: AdamW
|
| 106 |
+
- Learning rate: 2e-5
|
| 107 |
+
- Epochs: 1
|
| 108 |
+
- Max sequence length: 256
|
| 109 |
+
- Batch size: 4
|
| 110 |
+
|
| 111 |
+
---
|
| 112 |
+
|
| 113 |
+
# 📈 Evaluation
|
| 114 |
+
|
| 115 |
+
The fine-tuned model was evaluated on:
|
| 116 |
+
|
| 117 |
+
- Silver evaluation set
|
| 118 |
+
- Gold HITL set
|
| 119 |
+
|
| 120 |
+
Fine-tuning improves performance especially on previously uncertain claims.
|
| 121 |
+
|
| 122 |
+
---
|
| 123 |
+
|
| 124 |
+
# 💻 Usage Example
|
| 125 |
+
|
| 126 |
+
```python
|
| 127 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 128 |
+
import torch
|
| 129 |
+
|
| 130 |
+
model_path = "your-model-path"
|
| 131 |
+
|
| 132 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 133 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_path)
|
| 134 |
+
|
| 135 |
+
text = "A system for converting biomass into renewable energy."
|
| 136 |
+
|
| 137 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=256)
|
| 138 |
+
|
| 139 |
+
with torch.no_grad():
|
| 140 |
+
outputs = model(**inputs)
|
| 141 |
+
|
| 142 |
+
prediction = torch.argmax(outputs.logits, dim=-1).item()
|
| 143 |
+
|
| 144 |
+
print("Green" if prediction == 1 else "Non-Green")
|