danielhjerresen commited on
Commit
d09965d
·
verified ·
1 Parent(s): aca8c90

Upload README_hf_model.md

Browse files
Files changed (1) hide show
  1. README_hf_model.md +158 -0
README_hf_model.md ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ pipeline_tag: text-classification
7
+ tags:
8
+ - patents
9
+ - climate-tech
10
+ - green-patents
11
+ - patentsberta
12
+ - classification
13
+ - academic-project
14
+ ---
15
+
16
+ # PatentSBERTa Green Patent Classifier (Silver + Gold + MAS + HITL)
17
+
18
+ This repository contains the **final fine-tuned PatentSBERTa model** developed for the *Advanced Agentic Workflow with QLoRA* final project.
19
+
20
+ The model classifies **patent claims as green vs non-green technologies**, focusing on climate mitigation technologies aligned with **CPC Y02 classifications**.
21
+
22
+ The training pipeline combines **silver labels, agent debate labeling, and targeted human review** to improve classification quality on difficult claims.
23
+
24
+ ---
25
+
26
+ ## Model Overview
27
+
28
+ **Base model:** `AI-Growth-Lab/PatentSBERTa`
29
+ **Task:** Binary classification
30
+ **Labels:**
31
+
32
+ | Label | Meaning |
33
+ | --- | --- |
34
+ | 0 | Non-green technology |
35
+ | 1 | Green technology (climate mitigation related) |
36
+
37
+ The model is fine-tuned using HuggingFace `AutoModelForSequenceClassification`.
38
+
39
+ ---
40
+
41
+ ## Training Data
42
+
43
+ The training dataset is based on a **balanced 50k patent claim dataset** derived from:
44
+
45
+ `AI-Growth-Lab/patents_claims_1.5m_train_test`
46
+
47
+ Dataset composition:
48
+
49
+ | Source | Description |
50
+ | --- | --- |
51
+ | Silver Labels | Automatically derived from CPC Y02 indicators |
52
+ | Gold Labels | 100 high-uncertainty claims reviewed using MAS + Human-in-the-Loop |
53
+
54
+ Final training set:
55
+
56
+ `train_silver + gold_100`
57
+
58
+ The **gold dataset overrides the silver labels** for those claims to improve supervision on ambiguous cases.
59
+
60
+ ---
61
+
62
+ ## Pipeline Architecture
63
+
64
+ The full system used in the project consists of several stages:
65
+
66
+ 1. **Baseline Model**
67
+ - Frozen PatentSBERTa embeddings
68
+ - Logistic Regression classifier
69
+
70
+ 2. **Uncertainty Sampling**
71
+ - Identifies 100 claims with highest prediction uncertainty
72
+
73
+ 3. **QLoRA Domain Adaptation**
74
+ - LLM fine-tuned to better understand patent language
75
+
76
+ 4. **Multi-Agent System (MAS)**
77
+ - Advocate agent: argues claim is green
78
+ - Skeptic agent: argues claim is not green
79
+ - Judge agent: decides final classification
80
+
81
+ 5. **Targeted Human Review**
82
+ - Human only reviews cases where MAS confidence is low or agents disagree
83
+
84
+ 6. **Final Model Training**
85
+ - PatentSBERTa fine-tuned on silver data + gold labels
86
+
87
+ ---
88
+
89
+ ## Evaluation
90
+
91
+ The model is evaluated on the **eval_silver split** of the dataset.
92
+
93
+ Primary metric:
94
+
95
+ **F1 score**
96
+
97
+ Additional metrics reported:
98
+
99
+ - Precision
100
+ - Recall
101
+ - Accuracy
102
+ - Confusion Matrix
103
+
104
+ The evaluation script also exports prediction probabilities for analysis.
105
+
106
+ ---
107
+
108
+ ## Usage
109
+
110
+ Example inference using HuggingFace Transformers:
111
+
112
+ ```python
113
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
114
+ import torch
115
+
116
+ model_name = "YOUR_USERNAME/BDS_M4_exam_final_model"
117
+
118
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
119
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
120
+
121
+ text = "A system for capturing carbon emissions using advanced filtration..."
122
+
123
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
124
+
125
+ with torch.no_grad():
126
+ outputs = model(**inputs)
127
+
128
+ prob_green = torch.softmax(outputs.logits, dim=-1)[0,1].item()
129
+
130
+ print("Probability green:", prob_green)
131
+ ```
132
+
133
+ ## Limitations
134
+
135
+ - Silver labels are derived from CPC Y02 classifications and may contain noise.
136
+ - Only 100 claims were manually reviewed, meaning supervision improvements are limited to high-uncertainty cases.
137
+ - Patent claims can be extremely technical and ambiguous, which may impact classification accuracy.
138
+
139
+ ## Project Context
140
+
141
+ This model was developed as part of the M4 Advanced AI Systems final assignment.
142
+ The project explores agentic workflows for data labeling, combining:
143
+
144
+ - QLoRA fine-tuning
145
+ - Multi-Agent Systems
146
+ - Human-in-the-Loop review
147
+ - Transformer fine-tuning
148
+
149
+ ## Citation
150
+
151
+ If referencing this model in academic work:
152
+
153
+ **Green Patent Detection with Agentic Workflows.**
154
+ **M4 Advanced AI Systems Final Project.**
155
+
156
+ ## Authors
157
+
158
+ Student project submission by Daniel Hjerresen.