Views
No views yet
final-data-new-anonymized-grok4-filtered.jsonl)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2import torch
3
4# Load the model
5# trust_remote_code=True is required for Qwen-based models
6model = SentenceTransformer(
7 "Mira190/Euler-Legal-Embedding-V1",
8 trust_remote_code=True,
9 model_kwargs={
10 "torch_dtype": torch.bfloat16,
11 "attn_implementation": "flash_attention_2", # Optional, requires flash-attn installed
12 },
13)
14
15model.max_seq_length = 1536
16
17sentences = [
18 "The plaintiff filed a motion for summary judgment.",
19 "The court granted the motion based on lack of genuine dispute of material fact."
20]
21
22# No specific prompt is required for this version
23embeddings = model.encode(
24 sentences,
25 normalize_embeddings=True,
26 batch_size=16,
27 show_progress_bar=True,
28)
29
30print(embeddings.shape)
31# Output: (2, 4096)transformers library:1import torch
2from transformers import AutoModel, AutoTokenizer
3
4model_id = "Mira190/Euler-Legal-Embedding-V1"
5
6# Load tokenizer and model
7tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
8model = AutoModel.from_pretrained(
9 model_id,
10 trust_remote_code=True,
11 torch_dtype=torch.bfloat16,
12 device_map="auto"
13)
14
15sentences = ["This is a legal document.", "This is another legal document."]
16
17# Tokenize sentences
18inputs = tokenizer(
19 sentences,
20 return_tensors="pt",
21 padding=True,
22 truncation=True,
23 max_length=1536
24)
25
26# Move inputs to the same device as the model
27inputs = {k: v.to(model.device) for k, v in inputs.items()}
28
29with torch.no_grad():
30 outputs = model(**inputs)
31 # Last token pooling (Standard for Qwen-Embedding)
32 # Note: Qwen embeddings typically use the last hidden state of the last token (EOS or specific token)
33 embeddings = outputs.last_hidden_state[:, -1]
34
35 # Normalize embeddings
36 embeddings = torch.nn.functional.normalize(embeddings, p=2, dim=1)
37
38print(embeddings.shape)
39# Output: (2, 4096)1@misc{euler2025legal,
2 title={Euler-Legal-Embedding: Advanced Legal Representation Learning},
3 author={LawRank Team},
4 year={2025},
5 publisher={Hugging Face}
6}