A fine-tuned sentence embedding model optimized for semantic similarity matching of structured memory documents containing facts, opinions, observations, and experiences that are formatted according to the
Hindsight memory architecture
This model is a fine-tuned version of
sentence-transformers/all-MiniLM-L12-v2, specifically trained to generate embeddings for documents formatted with epistemic type labels and contextual metadata.
The model is trained with Quantization-Aware Training (QAT) and exported to ONNX format with INT8 dynamic activation and INT4 weight quantization for efficient inference.
1import onnxruntime as ort
2import numpy as np
3from tokenizers import Tokenizer
4
5tokenizer = Tokenizer.from_file("tokenizer.json")
6tokenizer.enable_padding(pad_id=0, pad_token='[PAD]')
7tokenizer.enable_truncation(max_length=512)
8
9session = ort.InferenceSession("model.onnx", providers=['CPUExecutionProvider'])
10
11def encode(texts: list[str]) -> np.ndarray:
12 encodings = tokenizer.encode_batch(texts)
13 input_ids = np.array([e.ids for e in encodings], dtype=np.int64)
14 attention_mask = np.array([e.attention_mask for e in encodings], dtype=np.int64)
15
16 outputs = session.run(None, {
17 'input_ids': input_ids,
18 'attention_mask': attention_mask,
19 })
20 return outputs[0]
21
22embeddings = encode(["Your documents here"])
1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("your-username/minilm-l12-v2-memex-ft")
4embeddings = model.encode(["Your documents here"])
Synthetic triplet data for fine-tuning on structured memory documents.
1{
2 "query": "What is our stance on remote work?",
3 "positive": {
4 "text": "I believe remote work requires asynchronous communication discipline to be effective.",
5 "type": "Opinion",
6 "context": "Work Philosophy"
7 },
8 "negative": {
9 "text": "The company policy allows for 3 days of remote work per week.",
10 "type": "World",
11 "context": "HR Policy"
12 }
13}
Uses Multiple Negatives Ranking Loss (MNRL) which treats each positive pair in a batch as a negative for other pairs, effectively creating many negative samples without explicit hard negatives.