Downloads · 30 days
18
0% of all-time downloads
novelcore/gem-modernbert
gem-modernbert is a fill-mask model from novelcore. Use it when you need the model to fill a missing word. It is set up for transformers. The card lists the license as apache-2.0.
GEM-ModernBERT HQ Legal is a ModernBERT-base model pre-trained from scratch on a strategically curated 21GB corpus of Greek legal, parliamentary, and governmental text. This model leverages ModernBERT's cutting-edge a…
Downloads · 30 days
18
0% of all-time downloads
All-time downloads
57.2K
Public
Parameters
150M
599 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors599 MB · 98%
From the Hugging Face model README
GEM-ModernBERT HQ Legal is a ModernBERT-base model pre-trained from scratch on a strategically curated 21GB corpus of Greek legal, parliamentary, and governmental text. This model leverages ModernBERT's cutting-edge architectural innovations including Flash Attention 2, StableAdamW optimizer, 1024-token context length, and advanced memory optimization techniques to deliver superior performance on Greek legal document understanding tasks.
Building upon our proven quality-based data repetition strategy, this model incorporates ModernBERT's state-of-the-art training methodology with 30% masking probability, trapezoidal learning rate scheduling, and optimized batch sizing for enhanced convergence and performance. The model is specifically designed to handle longer legal documents with its extended 1024-token context window while maintaining computational efficiency through advanced optimization techniques.
This model represents the culmination of our Greek legal language modeling research, combining domain expertise with the latest architectural advances in transformer-based language models. It has been optimized for downstream tasks such as Named Entity Recognition (NER), Text Classification, and Question Answering within the complex legal domain.
You can use this model directly with the fill-mask pipeline:
from transformers import pipeline
# Load the model
fill_mask = pipeline(
"fill-mask",
model="novelcore/gem-modernbert-hq-legal",
tokenizer="novelcore/gem-modernbert-hq-legal"
)
# Example from a legal context with longer sequence support
text = "Σύμφωνα με το άρθρο 15 του Συντάγματος, η <mask> των δικαιωμάτων του ανθρώπου αποτελεί βασική υποχρέωση του κράτους στο πλαίσιο της δημοκρατικής πολιτείας."
# Get predictions
predictions = fill_mask(text)
print(predictions)
For downstream tasks:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
# For legal document classification with extended context
tokenizer = AutoTokenizer.from_pretrained("novelcore/gem-modernbert-hq-legal")
model = AutoModelForSequenceClassification.from_pretrained("novelcore/gem-modernbert-hq-legal")
# The model supports up to 1024 tokens for longer legal documents
The model was pre-trained on the same comprehensive corpus of Greek text used in our previous models, employing our proven quality-based data repetition strategy that increases exposure to higher-quality legal content. The original 16.75GB corpus was expanded to 21.12GB through strategic repetition, now processed with 1024-token sequences for enhanced context understanding.
| Dataset | Original Size (GB) | Quality Level | Repetition Factor | Effective Size (GB) |
|---|---|---|---|---|
| Raptarchis Legal Dictionary | 0.35 | Best | 4x | 1.40 |
| Political Reports of the Supreme Court | 1.20 | Medium-Best | 3x | 3.60 |
| Eur-Lex (Greek Content) | 0.92 | Medium | 2x | 1.84 |
| FEK - Greek Government Gazette | 11.00 | Low | 1x | 11.00 |
| Greek Parliament Proceedings | 2.90 | Low-Medium | 1x | 2.90 |
| Europarl (Greek Content) | 0.38 | Low | 1x | 0.38 |
| TOTAL | 16.75 GB | - | - | 21.12 GB |
With 1024-token sequences, this model can process:
The model uses the ModernBERT-base architecture with the following configuration:
ModernBERT's innovations provide significant benefits for legal text processing:
The text was processed into 1024-token chunks using ModernBERT's tokenizer (vocabulary: 50,373 tokens), providing excellent coverage of Greek legal terminology while maintaining compatibility with the base architecture.
Higher-quality sources were strategically repeated during the data preparation phase, with sequences now capturing much more context per training example.
The model was pre-trained from scratch for 150,000 steps on 8x NVIDIA H100 80GB GPUs, using BFloat16 (bf16) mixed-precision with advanced optimization techniques. The training took approximately 97 hours and 9 minutes to complete.
Batch Size Optimization:
StableAdamW Configuration:
Advanced Learning Rate Schedule:
ModernBERT Specifications:
The model achieved excellent performance metrics:
The model was trained with cutting-edge optimizations:
Flash Attention 2 Optimizations:
FLASH_ATTENTION_FORCE_FP16: "0" # Use bfloat16
FLASH_ATTENTION_SKIP_RESHAPE: "1" # Skip unnecessary reshapes
FLASH_ATTENTION_CAUSAL: "0" # Non-causal for BERT
FORCE_FLASH_ATTENTION: "1" # Force Flash Attention usage
Memory Optimization:
PYTORCH_CUDA_ALLOC_CONF: "max_split_size_mb:256,roundup_power2_divisions:16,expandable_segments:True,garbage_collection_threshold:0.8"
Distributed Training:
Consistent with our previous models: