Feature Extraction
sentence-transformers
Safetensors
GGUF
English
Chinese
multilingual
qwen3_5
multimodal
embeddings
retrieval
quantization
mixed-precision
w4a8
fp8
int4
svd
mrl
text-embeddings
image-embedding
video-embedding
cross-modal
custom_code
Eval Results (legacy)
Instructions to use ewin-reg/WeMM-Embedding-2B-Quantized with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use ewin-reg/WeMM-Embedding-2B-Quantized with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("ewin-reg/WeMM-Embedding-2B-Quantized", trust_remote_code=True) sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
feat: remote code support for Hybrid FP8 Attn/GDN + INT4-g16 MLP
Browse files
modeling_wemm_embedding.py
CHANGED
|
@@ -34,7 +34,7 @@ class FlatQuantFP8Linear(nn.Module):
|
|
| 34 |
return F.linear(x, w_deq, self.bias.to(x.dtype) if self.bias is not None else None)
|
| 35 |
|
| 36 |
class FlatQuantW4A8Linear(nn.Module):
|
| 37 |
-
def __init__(self, in_features, out_features, bias=False, group_size=
|
| 38 |
super().__init__()
|
| 39 |
self.in_features = in_features
|
| 40 |
self.out_features = out_features
|
|
@@ -60,8 +60,6 @@ class FlatQuantW4A8Linear(nn.Module):
|
|
| 60 |
class WeMMEmbedding(Qwen3_5ForConditionalGeneration):
|
| 61 |
def __init__(self, config):
|
| 62 |
super().__init__(config)
|
| 63 |
-
full_attn_layers = {3, 7, 11, 15, 19, 23}
|
| 64 |
-
pas_layers = {2, 6, 10, 14, 18, 22}
|
| 65 |
for name, mod in list(self.model.named_modules()):
|
| 66 |
if name.endswith("embed_tokens") and isinstance(mod, nn.Embedding):
|
| 67 |
parent = self.model.get_submodule(name.rsplit(".", 1)[0]) if "." in name else self.model
|
|
@@ -70,13 +68,12 @@ class WeMMEmbedding(Qwen3_5ForConditionalGeneration):
|
|
| 70 |
elif isinstance(mod, nn.Linear):
|
| 71 |
parent = self.model.get_submodule(name.rsplit(".", 1)[0]) if "." in name else self.model
|
| 72 |
child = name.rsplit(".", 1)[-1]
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
if is_full or is_pas_kv or is_down_proj_outer:
|
| 77 |
setattr(parent, child, FlatQuantFP8Linear(mod.in_features, mod.out_features, bias=mod.bias is not None))
|
| 78 |
else:
|
| 79 |
-
setattr(parent, child, FlatQuantW4A8Linear(mod.in_features, mod.out_features, bias=mod.bias is not None, group_size=
|
| 80 |
|
| 81 |
def embedding(self, input_ids=None, attention_mask=None, **kwargs):
|
| 82 |
self.model.rope_deltas = None
|
|
|
|
| 34 |
return F.linear(x, w_deq, self.bias.to(x.dtype) if self.bias is not None else None)
|
| 35 |
|
| 36 |
class FlatQuantW4A8Linear(nn.Module):
|
| 37 |
+
def __init__(self, in_features, out_features, bias=False, group_size=16):
|
| 38 |
super().__init__()
|
| 39 |
self.in_features = in_features
|
| 40 |
self.out_features = out_features
|
|
|
|
| 60 |
class WeMMEmbedding(Qwen3_5ForConditionalGeneration):
|
| 61 |
def __init__(self, config):
|
| 62 |
super().__init__(config)
|
|
|
|
|
|
|
| 63 |
for name, mod in list(self.model.named_modules()):
|
| 64 |
if name.endswith("embed_tokens") and isinstance(mod, nn.Embedding):
|
| 65 |
parent = self.model.get_submodule(name.rsplit(".", 1)[0]) if "." in name else self.model
|
|
|
|
| 68 |
elif isinstance(mod, nn.Linear):
|
| 69 |
parent = self.model.get_submodule(name.rsplit(".", 1)[0]) if "." in name else self.model
|
| 70 |
child = name.rsplit(".", 1)[-1]
|
| 71 |
+
is_attn = ("self_attn" in name) or ("linear_attn" in name)
|
| 72 |
+
is_down = "down_proj" in name
|
| 73 |
+
if is_attn or is_down:
|
|
|
|
| 74 |
setattr(parent, child, FlatQuantFP8Linear(mod.in_features, mod.out_features, bias=mod.bias is not None))
|
| 75 |
else:
|
| 76 |
+
setattr(parent, child, FlatQuantW4A8Linear(mod.in_features, mod.out_features, bias=mod.bias is not None, group_size=16))
|
| 77 |
|
| 78 |
def embedding(self, input_ids=None, attention_mask=None, **kwargs):
|
| 79 |
self.model.rope_deltas = None
|