File size: 1,109 Bytes
bff06c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""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)