Add model card for GovRelBERT
#1
by nielsr HF Staff - opened
README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pipeline_tag: text-ranking
|
| 3 |
+
library_name: transformers
|
| 4 |
+
license: other
|
| 5 |
+
tags:
|
| 6 |
+
- bert
|
| 7 |
+
- modernbert
|
| 8 |
+
- government
|
| 9 |
+
- relevance
|
| 10 |
+
- text-relevance
|
| 11 |
+
- govrelbench
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# GovRelBERT: A Model for Government Domain Relevance
|
| 15 |
+
|
| 16 |
+
**GovRelBERT** is a specialized model designed for evaluating the core capabilities of Large Language Models (LLMs) in the government domain, particularly focusing on text relevance. It was introduced as part of the [GovRelBench: A Benchmark for Government Domain Relevance](https://huggingface.co/papers/2507.21419) paper.
|
| 17 |
+
|
| 18 |
+
Built upon the **ModernBERT** architecture, GovRelBERT is trained using the **SoftGovScore** method. This innovative method converts hard labels into soft scores, enabling the model to accurately compute a text's government domain relevance score. GovRelBERT serves as a dedicated evaluation tool within the GovRelBench framework, aiming to improve the assessment of LLMs in government-related research and practical applications.
|
| 19 |
+
|
| 20 |
+
The code and dataset are available as part of the GovRelBench project on GitHub: [https://github.com/pansysy/GovRelBench](https://github.com/pansysy/GovRelBench).
|
| 21 |
+
|
| 22 |
+
## How to use
|
| 23 |
+
|
| 24 |
+
You can use `GovRelBERT` with the Hugging Face `transformers` library to compute a government domain relevance score for a given text.
|
| 25 |
+
|
| 26 |
+
```python
|
| 27 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 28 |
+
import torch
|
| 29 |
+
|
| 30 |
+
model_name = "pansysy/GovRelBERT"
|
| 31 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 32 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 33 |
+
|
| 34 |
+
# Example 1: Text highly relevant to the government domain
|
| 35 |
+
text_relevant = "The new policy initiative aims to streamline public services for citizens."
|
| 36 |
+
inputs_relevant = tokenizer(text_relevant, return_tensors="pt")
|
| 37 |
+
|
| 38 |
+
with torch.no_grad():
|
| 39 |
+
outputs_relevant = model(**inputs_relevant)
|
| 40 |
+
relevance_score_relevant = outputs_relevant.logits.item()
|
| 41 |
+
|
| 42 |
+
print(f"Text: '{text_relevant}'")
|
| 43 |
+
print(f"Government relevance score: {relevance_score_relevant:.4f}")
|
| 44 |
+
|
| 45 |
+
print("-" * 50)
|
| 46 |
+
|
| 47 |
+
# Example 2: Text less relevant to the government domain
|
| 48 |
+
text_less_relevant = "How to train your pet dog to fetch a ball."
|
| 49 |
+
inputs_less_relevant = tokenizer(text_less_relevant, return_tensors="pt")
|
| 50 |
+
|
| 51 |
+
with torch.no_grad():
|
| 52 |
+
outputs_less_relevant = model(**inputs_less_relevant)
|
| 53 |
+
relevance_score_less_relevant = outputs_less_relevant.logits.item()
|
| 54 |
+
|
| 55 |
+
print(f"Text: '{text_less_relevant}'")
|
| 56 |
+
print(f"Government relevance score: {relevance_score_less_relevant:.4f}")
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## Citation
|
| 60 |
+
|
| 61 |
+
If you find this work helpful, please cite the original paper:
|
| 62 |
+
|
| 63 |
+
```bibtex
|
| 64 |
+
@misc{liu2025govrelbench,
|
| 65 |
+
title={GovRelBench:A Benchmark for Government Domain Relevance},
|
| 66 |
+
author={Yizhuo Liu and Siyi Pan and Ruohong Han and Yu Hong and Bojin Wang and Mingyang Li and Jianxun Tang},
|
| 67 |
+
year={2025},
|
| 68 |
+
eprint={2507.21419},
|
| 69 |
+
archivePrefix={arXiv},
|
| 70 |
+
primaryClass={cs.CL},
|
| 71 |
+
url={https://arxiv.org/abs/2507.21419},
|
| 72 |
+
}
|
| 73 |
+
```
|