Downloads · 30 days
5
8% of all-time downloads
Signe22/patentsberta-green-hitl-final
patentsberta-green-hitl-final is a text classification model from Signe22. Use it when you need a label for a piece of text. It is set up for transformers.
Video: https://aaudk-my.sharepoint.com/personal/de63svstudentaaudk/layouts/15/stream.aspx?id=%2Fpersonal%2Fde63sv%5Fstudent%5Faau%5Fdk%2FDocuments%2FOptagelser%2FM%C3%B8de%20med%20Signe%20S%C3%B8ndergaard%20Dahl%2D202…
Downloads · 30 days
5
8% of all-time downloads
All-time downloads
61
Public
Parameters
109M
438 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors438 MB · 100%
From the Hugging Face model README
Model: https://huggingface.co/Signe22/patentsberta-green-hitl-final
Dataset: https://huggingface.co/datasets/Signe22/patents-50k-green-hitl-final
The fine-tuning was done in AI-Lab, the code is displayed below (for reference only, NOT to be run).
To specialize a large language model for green patent classification, I fine-tuned Mistral-7B-Instruct-v0.2 using QLoRA (Quantized Low-Rank Adaptation). This approach enables efficient domain adaptation while significantly reducing GPU memory requirements.
Noteable QLoRA parameters:
QLoRA allows training only a small set of injected low-rank matrices while keeping the base model frozen in 4-bit precision. This reduces resource requirements while maintaining strong adaptation capability.
Training was performed using the train_silver split from patents_50k_green.parquet.
Training Configuration:
Training loss decreased steadily and stabilized, indicating successful convergence of the LoRA adapter.
Only the LoRA adapter weights were saved, meaning I have created a lightweight domain-adapted classifier while keeping the base model unchanged.
This time I chose to do the classification using agentic setup in AI-Lab as well due to computational resource needs.
The script shown below implements a green patent classification pipeline using a QLoRA-adapted Mistral model within an agentic setup.
The base model (Mistral-7B-Instruct-v0.2) is loaded in 4-bit quantized form using bitsandbytes to reduce memory usage. A LoRA adapter trained on green patent classification is then loaded using:
judge_model = PeftModel.from_pretrained(base_model, ADAPTER_LOCAL)
Only the Judge agent uses the QLoRA adapter. The Advocate and Skeptic agents use the base quantized model without adapters. This isolates domain specialization to the final decision step.
Intermediate results are checkpointed periodically to prevent data loss.
For each patent claim:
Because the agents are generative models, strict JSON output could not be guaranteed by prompting alone. Several safeguards are implemented:
These steps ensure that even if the agents sometimes generate free text, the final stored output is reliable and structured.
I had the advocate and skeptic output their stance (their 'vote') for each claim, where they were told to choose between 0 and 1. Out of 100 claims total, the agents disagreed on 60. This is a high level of disagreement, but it is relevant to note that theses patents are specifically chosen due to their uncertainty.
I will now load the gold_100 dataset, which was classified by my agentic setup (prior to the HITL step) in this run. For a combined implementation of an agentic setup and HITL within the same pipeline, I refer to my Assignment 3 work using CrewAI and LangChain.
This run uses an exception-based HITL approach, meaning I do not manually review all 100 claims. Instead, I focus human review on:
However, the Judge flagged 45 claims as low-confidence (likely due to it being high uncertainty claims), which indicates that substantial human review is still required with the current setup.
The model was fine-tuned for one epoch using a maximum sequence length of 256 tokens and a learning rate of 2e-5, following the recommended settings to keep computation reasonable. Tokenization was performed using the PatentSBERTa tokenizer prior to training.
Model performance was evaluated on the held-out eval_silver split and gold_100 subset so evaluate performance, which will be used for a comparative analysis between baseline model, A2 model, A3 model and this final model.
The table below compares model performance across the four stages of the project using the same silver evaluation set.
| Model Version | Training Data Source | F1 Score (Eval Set) |
|---|---|---|
| Baseline | Frozen PatentSBERTa embeddings (no fine-tuning) | 0.7719 |
| Assignment 2 Model | Fine-tuned on Silver + Gold (Simple LLM labels + HITL) | 0.8030 |
| Assignment 3 Model | Fine-tuned on Silver + Gold (Agentic LLM + HITL) | 0.8051 |
| Final Assignment Model | Fine-tuned on Silver + Gold (QLoRA-Powered MAS + Targeted HITL) | 0.8041 |
The final QLoRA-powered Multi-Agent System (MAS) model achieved an F1 score of 0.8041 on the independent evaluation set, which is marginally lower than the Assignment 3 model (0.8051) but higher than earlier versions. The difference (0.001) is small, suggesting that the fine-tuned models perform at a comparable level on unseen data.
Although the final model achieved the highest F1 score on the Gold 100 subset, this dataset was also included during fine-tuning and therefore cannot be considered an independent evaluation benchmark. While the improved performance likely indicates stronger alignment with the high-quality gold annotations, it may also partially reflect closer fitting to examples seen during training. As such, results on this subset should be interpreted as evidence of improved calibration and label alignment rather than definitive proof of improved generalization.
Overall, the results indicate that the QLoRA-powered MAS with targeted HITL improved alignment with human judgments while maintaining stable performance on the broader evaluation set.