Sentence Similarity
sentence-transformers
Safetensors
greenleaf_embed
embeddings
legal
retrieval
feature-extraction
mteb
mleb
legal-tech
case-law
contracts
judicialmind
custom_code
Instructions to use judicialmind/greenleaf-law-embed-tiny with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use judicialmind/greenleaf-law-embed-tiny with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("judicialmind/greenleaf-law-embed-tiny", trust_remote_code=True) sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
| """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) | |