SJ-ko embed 400M
A Korean text embedding model (bi-encoder) used for dense retrieval in the SJ-ko harness (github.com/sjmoon0621/sj-ko-harness). The backbone is the author's own 396M-parameter GPT (the base model of sj-ko-400m-v4-gguf), trained from scratch with an own BPE tokenizer and PyTorch code. No Hugging Face Transformers.
Files
| File | Use |
|---|---|
best.pt |
PyTorch checkpoint (fp32): cfg, tokenizer (merges + vocab), model, embed (prefixes and lengths) |
Loading code: src/train_embed.py (load_base, batch_ids, embed) and src/model_v2.py in the harness repo.
The tokenizer is stored inside the checkpoint.
How it works
- Query:
์ง๋ฌธ:+ text, up to 64 tokens. Document:๋ฌธ์:+ text, up to 256 tokens. - Vector: mean of the last hidden states over non-padding tokens, L2-normalized, 1024 dimensions. Score is the dot product.
- Precomputed vectors for 673,097 Korean Wikipedia articles: datasets/sjmoon21/sj-ko-wiki-e400-vectors.
Training
Contrastive training (InfoNCE with in-batch negatives, temperature 0.05) from the 400M base checkpoint on 1,419,409 query-document pairs built from Korean Wikipedia (RAG questions, generated summaries and short-article questions). Batch 256, 400 steps, lr 3e-5, 2x T4, 87.6 minutes. Validation in-batch accuracy 0.622 at step 0, 0.908 at the end.
Evaluation
290 questions with a gold article, searched against all 673,097 articles:
| Retriever | R@1 | R@5 | R@20 | MRR |
|---|---|---|---|---|
| BM25 (harness index) | 54.8% | 66.6% | 77.2% | 0.605 |
| This model, dense only | 60.7% | 80.7% | 90.3% | 0.696 |
| BM25 + this model (RRF, k=60) | 65.2% | 82.1% | 92.4% | 0.729 |
Educational project. Author: Sungjin Moon, Seoul National University, Department of Physics & Astronomy.