CoolFace
Modelpublic

dleemiller/sts-bert-hash-pico

sourceHugging Facemitupdated 1y agoView on Hugging Face
1likes20downloads
Model Card

BERT Hash Cross-Encoder: Semantic Similarity (STS)

Cross encoders are high performing encoder models that compare two texts and output a 0-1 score. I've found the cross-encoders/roberta-large-stsb model to be very useful in creating evaluators for LLM outputs. They're simple to use, fast and very accurate.

The BERT hash uses a bucketing technique with projection to decrease the size of the embedding parameters (all <1M parameters). These models are very small and good for inference at the edge.


Features

  • —Performance: Achieves Pearson: 0.7595 and Spearman: 0.7474 on the STS-Benchmark test set.
  • —Efficient architecture: Based on the BERT Hash model architecture, offering lightweight models.
  • —Extended context length: Processes sequences up to 8192 tokens, great for LLM output evals.
  • —Diversified training: Pretrained on dleemiller/wiki-sim and fine-tuned on sentence-transformers/stsb.

Performance

ModelSTS-B Test PearsonSTS-B Test SpearmanContext LengthParametersSpeed
dleemiller/ModernCE-large-sts0.92560.92158192395MMedium
dleemiller/CrossGemma-sts-300m0.91750.91352048303MMedium
dleemiller/ModernCE-base-sts0.91620.91228192149MFast
cross-encoder/stsb-roberta-large0.9147-512355MSlow
dleemiller/EttinX-sts-m0.91430.91028192149MFast
dleemiller/NeoCE-sts0.91240.90874096250MFast
dleemiller/EttinX-sts-s0.90040.8926819268MVery Fast
cross-encoder/stsb-distilroberta-base0.8792-51282MFast
dleemiller/EttinX-sts-xs0.87630.8689819232MVery Fast
dleemiller/EttinX-sts-xxs0.84140.8311819217MVery Fast
dleemiller/sts-bert-hash-nano0.79040.774381920.97MVery Fast
dleemiller/sts-bert-hash-pico0.75950.747481920.45MVery Fast

Usage

To use sts-bert-hash for semantic similarity tasks, you can load the model with the Hugging Face sentence-transformers library:

python
from sentence_transformers import CrossEncoder

# Load CrossEncoder model
model = CrossEncoder("dleemiller/sts-bert-hash-nano", trust_remote_code=True)

# Predict similarity scores for sentence pairs
sentence_pairs = [
    ("It's a wonderful day outside.", "It's so sunny today!"),
    ("It's a wonderful day outside.", "He drove to work earlier."),
]
scores = model.predict(sentence_pairs)

print(scores)  # Outputs: array([0.9184, 0.0123], dtype=float32)

Output

The model returns similarity scores in the range [0, 1], where higher scores indicate stronger semantic similarity.


Training Details

Pretraining

The model was pretrained on the pair-score-sampled subset of the `dleemiller/wiki-sim` dataset. This dataset provides diverse sentence pairs with semantic similarity scores, helping the model build a robust understanding of relationships between sentences.

  • —Classifier Dropout: a somewhat large classifier dropout of 0.15, to reduce overreliance on teacher scores.
  • —Objective: STS-B scores from dleemiller/MocernCE-large-sts.

Fine-Tuning

Fine-tuning was performed on the `sentence-transformers/stsb` dataset.

Validation Results

The model achieved the following test set performance after fine-tuning:

  • —Pearson Correlation: 0.7595
  • —Spearman Correlation: 0.7474

Model Card

  • —Architecture: bert-hash-nano
  • —Tokenizer: Custom tokenizer trained with modern techniques for long-context handling.
  • —Pretraining Data: dleemiller/wiki-sim (pair-score-sampled)
  • —Fine-Tuning Data: sentence-transformers/stsb

Thank You

Thanks to the NeuML team for providing the BERT Hash models, and the Sentence Transformers team for their leadership in transformer encoder models.


Citation

If you use this model in your research, please cite:

bibtex
@misc{stsnano2025,
  author = {Miller, D. Lee},
  title = {Bert Hash STS: An STS cross encoder model},
  year = {2025},
  publisher = {Hugging Face Hub},
  url = {https://huggingface.co/dleemiller/sts-bert-hash-pico},
}

License

This model is licensed under the MIT License.