Downloads · 30 days
29
15% of all-time downloads
PulseNet-Labs/spiking-sentence-embedder
spiking-sentence-embedder is a feature extraction model from PulseNet-Labs. Use it when you need embeddings to search or compare text. The card lists the license as apache-2.0.
This is the official PyTorch/HuggingFace implementation of the Spiking Sentence Embedder featuring Sparse Coincidence-Based Semantic Attention. The model was originally implemented in Rust to simulate true neuromorphi…
Downloads · 30 days
29
15% of all-time downloads
All-time downloads
189
Public
Parameters
12.9M
51.5 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors51.5 MB · 96%
From the Hugging Face model README
This is the official PyTorch/HuggingFace implementation of the Spiking Sentence Embedder featuring Sparse Coincidence-Based Semantic Attention. The model was originally implemented in Rust to simulate true neuromorphic hardware constraints and has been carefully ported to PyTorch to guarantee 100% mathematical bit-exact parity for seamless deployment.
This model requires custom architecture code (modeling_spiking.py) to run. You must set trust_remote_code=True when loading the model.
import torch
import torch.nn.functional as F
from transformers import AutoTokenizer, AutoModel
# 1. Load Tokenizer and Spiking Model
tokenizer = AutoTokenizer.from_pretrained("PulseNet-Labs/spiking-sentence-embedder", trust_remote_code=True)
model = AutoModel.from_pretrained("PulseNet-Labs/spiking-sentence-embedder", trust_remote_code=True)
model.eval()
# 2. Input sentences
sentences = [
"Sistem neuromorfik ini sangat hemat energi.",
"Jaringan saraf spiking mengonsumsi daya yang rendah."
]
# 3. Tokenize
inputs = tokenizer(sentences, padding="max_length", max_length=128, truncation=True, return_tensors="pt")
# Convert PAD tokens to 0 to align with SNN initialization behavior
inputs.input_ids[inputs.input_ids == tokenizer.pad_token_id] = 0
# 4. Forward Pass (Temporal SNN Simulation)
with torch.no_grad():
embeddings = model(**inputs)
# 5. Compute Pearson/Cosine Similarity
# Note: For strict SNN metric space validation, mean-centering is recommended
emb_centered = embeddings - embeddings.mean(dim=-1, keepdim=True)
similarity = F.cosine_similarity(emb_centered[0].unsqueeze(0), emb_centered[1].unsqueeze(0))
print(f"Semantic Similarity: {similarity.item():.4f}")
Tested on the bilingual STS-B dataset:
If you use this model in your research, please refer to our DOI manuscript: https://doi.org/10.5281/zenodo.20739462. Organization: PulseNet-Labs