Downloads · 30 days
14
6% of all-time downloads
metga97/Modern-EgyBert-Embedding
Modern-EgyBert-Embedding is a feature extraction model from metga97. Use it when you need embeddings to search or compare text. It is set up for transformers.
- Developed by: Mohammad Essam (metga97) - Model type: BERT-style encoder - Language(s): Arabic (MSA + Egyptian dialect) - License: MIT - Finetuned from model: metga97/Modern-EgyBert-Base
Downloads · 30 days
14
6% of all-time downloads
All-time downloads
226
Public
Parameters
159M
638 MB on disk
Likes
4
Public
Click a slice to open those files.
.safetensors638 MB · 99%
From the Hugging Face model README
metga97/Modern-EgyBert-BaseThis model is intended to be used for generating sentence embeddings for downstream tasks:
Use the code below to get started with the model.
from transformers import AutoTokenizer, AutoModel
import torch
tokenizer = AutoTokenizer.from_pretrained("metga97/Modern-EgyBert-Embedding")
model = AutoModel.from_pretrained("metga97/Modern-EgyBert-Embedding")
text = ["الجو النهارده جميل"]
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
with torch.no_grad():
outputs = model(**inputs)
last_hidden = outputs.last_hidden_state
# Mean Pooling
attention_mask = inputs["attention_mask"]
input_mask_expanded = attention_mask.unsqueeze(-1).expand(last_hidden.size()).float()
sum_embeddings = torch.sum(last_hidden * input_mask_expanded, dim=1)
sum_mask = torch.clamp(input_mask_expanded.sum(1), min=1e-9)
sentence_embedding = sum_embeddings / sum_mask
print(sentence_embedding.shape) # torch.Size([1, 768])