Views
No views yet
sentence-transformers/all-MiniLM-L6-v2 base encoder + cosine similarity matching headsentence-transformers/all-MiniLM-L6-v2 base encoder + cosine similarity matching headsentence-transformers/all-MiniLM-L6-v2cos_sim)1from sentence_transformers import SentenceTransformer
2import torch
3
4# Load Model B (Block2Answer, block_size=256)
5model_dir = "./matching_head_BlockToAnswer/256/train_all-MiniLM-L6-v2_mixed_pos_merged_4_domain_0.5_hard_easy_mixed_neg_4_domain_limit0_cos_sim_focal_freeze"
6embedding_model = SentenceTransformer(f"{model_dir}/embedding_model", trust_remote_code=True)
7
8# Load matching head
9from heads import get_matching_head
10embedding_dim = embedding_model.get_sentence_embedding_dimension()
11matching_head = get_matching_head("cos_sim", embedding_dim)
12matching_head.load_state_dict(torch.load(f"{model_dir}/matching_head.pt"))
13matching_head.eval()
14
15# Score a (reasoning_block, answer) pair
16emb_block = embedding_model.encode("The derivative of x^2 is 2x...", convert_to_tensor=True)
17emb_answer = embedding_model.encode("The answer is 2x.", convert_to_tensor=True)
18
19features = {"embedding_a": emb_block.unsqueeze(0), "embedding_b": emb_answer.unsqueeze(0)}
20with torch.no_grad():
21 logits = matching_head(features)["logits"]
22 score = torch.sigmoid(logits).item()
23print(f"Match score: {score:.4f}")CoIn-Matching-Head/
├── matching_head_TokensToBlock/ # Model A
│ └── {256,512,1024}/ # Block size variants
│ └── train_.../
│ ├── embedding_model/ # Sentence-transformers model
│ ├── matching_head.pt # Matching head weights
│ └── tokenid_embedding_cache.pt
├── matching_head_BlockToAnswer/ # Model B
│ └── {256,512,1024}/
│ └── train_.../
│ ├── embedding_model/
│ └── matching_head.pt
└── learned_verifier/
├── DeepSet/
│ ├── deepset_weight.pt # DeepSet verifier weights
│ └── model_cfg.py # Model config
└── RNN/ # RNN verifier variant1@article{sun2025coin,
2 title={Coin: Counting the invisible reasoning tokens in commercial opaque llm apis},
3 author={Sun, Guoheng and Wang, Ziyao and Tian, Bowei and Liu, Meng and Shen, Zheyu and He, Shwai and He, Yexiao and Ye, Wanghao and Wang, Yiting and Li, Ang},
4 journal={arXiv preprint arXiv:2505.13778},
5 year={2025}
6}