greenleaf-law-embed-tiny / configuration.py
sakasurya's picture
judicialmind/greenleaf-law-embed-tiny: initial release
bff06c9
Raw
History Blame Contribute Delete
1.11 kB
"""GreenLeaf Law Embed — model configuration.
A bidirectional transformer encoder built on the Qwen3 backbone,
specialized for legal-domain dense retrieval and text embedding.
"""
from transformers.models.qwen3.configuration_qwen3 import Qwen3Config
class GreenLeafEmbedConfig(Qwen3Config):
"""Configuration class for GreenLeaf law embedding models.
Inherits the Qwen3 architecture and applies the following
modifications for dense embedding tasks:
- All transformer layers use bidirectional (non-causal) attention
- KV caching is disabled (embedding models don't need it)
- Sliding window is disabled — every token attends to every token
"""
model_type = "greenleaf_embed"
def __init__(
self,
use_bidirectional_attention: bool = True,
use_cache: bool = False,
use_sliding_window: bool = False,
**kwargs,
):
kwargs["use_bidirectional_attention"] = use_bidirectional_attention
kwargs["use_cache"] = use_cache
kwargs["use_sliding_window"] = use_sliding_window
super().__init__(**kwargs)