Sentence Similarity
Transformers
Safetensors
Vietnamese
sai_embedding
feature-extraction
embeddings
retrieval
llm2vec
matryoshka
custom-code
custom_code
Instructions to use thongbuind/SAI-Embedding_100M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thongbuind/SAI-Embedding_100M with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("thongbuind/SAI-Embedding_100M", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download DecoderBlock.py from thongbuind/SAI-Embedding_100M: direct link, hf CLI and curl.
- Browser
- Download file 758 Bytes
-
https://huggingface.co/thongbuind/SAI-Embedding_100M/resolve/main/DecoderBlock.py
- Command line
-
hf download hf://thongbuind/SAI-Embedding_100M/DecoderBlock.py
-
curl -L -o DecoderBlock.py https://huggingface.co/thongbuind/SAI-Embedding_100M/resolve/main/DecoderBlock.py
758 Bytes
| import torch.nn as nn | |
| from .SwiGLU import SwiGLU | |
| from .GroupedQueryAttention import GroupedQueryAttention | |
| class DecoderBlock(nn.Module): | |
| def __init__(self, d_model: int, num_heads: int, num_kv_heads: int, ff_dim: int, dropout: float): | |
| super().__init__() | |
| self.gqa = GroupedQueryAttention(d_model, num_heads, num_kv_heads, dropout) | |
| self.ffn = SwiGLU(d_model, ff_dim) | |
| self.norm1 = nn.RMSNorm(d_model, eps=1e-6) | |
| self.norm2 = nn.RMSNorm(d_model, eps=1e-6) | |
| self.drop = nn.Dropout(dropout) | |
| def forward(self, x, cos, sin, attn_mask=None, causal: bool = True): | |
| x = x + self.drop(self.gqa(self.norm1(x), cos, sin, attn_mask, causal)) | |
| x = x + self.drop(self.ffn(self.norm2(x))) | |
| return x | |