Downloads · 30 days
4
6% of all-time downloads
mehta7408/assig._2_green_patent_sberta
assig._2_green_patent_sberta is a machine learning model from mehta7408. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This project builds a binary classifier that identifies green technology patents (climate-change mitigation, renewable energy, pollution reduction) from patent claim text using a Human-in-the-Loop (HITL) active learni…
Downloads · 30 days
4
6% of all-time downloads
All-time downloads
67
Public
Parameters
109M
592 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors438 MB · 74%
From the Hugging Face model README
This project builds a binary classifier that identifies green technology patents (climate-change mitigation, renewable energy, pollution reduction) from patent claim text using a Human-in-the-Loop (HITL) active learning pipeline.
┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Part A │ │ Part B │ │ Part C │ │ Part D │ │ Upload │
│ Baseline │────▶│ Uncertainty │────▶│ LLM + Human │────▶│ Fine-Tune │────▶│ HF Hub │
│ (Frozen) │ │ Sampling │ │ HITL Labels │ │ PatentSBERTa│ │ │
└──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘
| Property | Value |
|---|---|
| Source | AI-Growth-Lab/patents_claims_1.5m_traim_test |
| Balanced subset | 50,000 patents (25k green + 25k non-green) |
| Train split | 40,000 rows (80%) |
| Eval split | 5,000 rows (10%) |
| Pool split | 5,000 rows (10%) |
| Silver labels | CPC Y02* codes (auto-assigned) |
| Gold labels | 100 human-verified via HITL pipeline |
| Property | Value |
|---|---|
| Base model | AI-Growth-Lab/PatentSBERTa |
| Architecture | BERT + classification head (2 labels) |
| Max sequence length | 256 tokens |
| Fine-tuning epochs | 1 |
| Learning rate | 2e-5 |
| Batch size | 16 |
green-patent-detector/
├── create_dataset.py # Build balanced 50k dataset
├── baseline_model.py # Frozen embeddings + LogisticRegression
├── uncertainty_sampling.py # Select 100 most uncertain examples
├── hitl_pipeline.py # LLM labeling + human review
├── finetune_model.py # Fine-tune PatentSBERTa
├── upload_to_huggingface.py # Upload model + dataset to HF Hub
├── requirements.txt
├── README.md
└── .env # API key (not committed to git)
pip install -r requirements.txt
python Part_A.py
python Part_A.py
python Part_B.py
echo "GROQ_API_KEY=your_key_here" > .env
python Part_C.py
# → Fill in is_green_human in hitl_green_100_gold.csv
python Part_C.py
python Part_D.py
huggingface-cli login
python upload_to_huggingface.py
Evaluated on eval_silver (5,000 examples):
| Class | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| Non-Green (0) | 0.76 | 0.78 | 0.77 | 2,500 |
| Green (1) | 0.78 | 0.76 | 0.77 | 2,500 |
| Accuracy | 0.77 | 5,000 | ||
| Macro Avg | 0.77 | 0.77 | 0.77 | 5,000 |
| Weighted Avg | 0.77 | 0.77 | 0.77 | 5,000 |
Summary: Precision = 0.7787, Recall = 0.7588, F1 = 0.7686
| Metric | Value |
|---|---|
| Loss | 0.4154 |
| Accuracy | 0.8082 |
| Precision | 0.8086 |
| Recall | 0.8076 |
| F1 | 0.8081 |
| Metric | Value |
|---|---|
| Loss | 0.6888 |
| Accuracy | 0.6300 |
| Precision | 0.0513 |
| Recall | 1.0000 |
| F1 | 0.0976 |
Classification report (gold_100):
| Class | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| Non-Green | 1.00 | 0.62 | 0.77 | 98 |
| Green | 0.05 | 1.00 | 0.10 | 2 |
| Accuracy | 0.63 | 100 | ||
| Macro Avg | 0.53 | 0.81 | 0.43 | 100 |
| Weighted Avg | 0.98 | 0.63 | 0.75 | 100 |
| Metric | Baseline (LogReg) | Fine-Tuned | Improvement |
|---|---|---|---|
| Precision | 0.7787 | 0.8086 | +0.0299 |
| Recall | 0.7588 | 0.8076 | +0.0488 |
| F1 | 0.7686 | 0.8081 | +0.0395 |
Key findings:
The gold_100 evaluation set contains only 2 green and 98 non-green examples out of 100. This heavy imbalance occurred because most of the uncertain patents near the decision boundary turned out to be non-green after human review. With only 2 positive examples, the per-class metrics for "Green" are statistically unreliable. The eval_silver results (5,000 balanced examples) are a more trustworthy measure of model quality.
I examined all 100 examples that were pre-labeled by the LLM (LLaMA 3.1 8B). The LLM saw only the claim text — no CPC codes or metadata.
| Metric | Value |
|---|---|
| Total examples labeled | 100 |
| Human agrees with LLM | 97 |
| Human overrides LLM | 3 |
Example 1 (doc_id: 46226)
Example 2 (doc_id: 46852)
Example 3 (doc_id: 49570)
u = 1 - 2 * |p - 0.5| where 1.0 = maximum uncertaintyfrom transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model
model_name = "your-username/green-patent-sberta"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
model.eval()
# Classify a patent claim
claim = "A solar panel system comprising photovoltaic cells arranged to maximize energy capture..."
inputs = tokenizer(claim, return_tensors="pt", truncation=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")