Feature Extraction
sentence-transformers
Safetensors
English
Portuguese
lexical_embedding
custom_code
Instructions to use cnmoro/LexicalEmbed-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use cnmoro/LexicalEmbed-Base with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("cnmoro/LexicalEmbed-Base", 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
Upload 5 files
Browse files- lexical_model.py +2 -0
- model.safetensors +1 -1
lexical_model.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import torch
|
| 2 |
import torch.nn as nn
|
| 3 |
from transformers import PreTrainedModel, PretrainedConfig
|
|
@@ -24,6 +25,7 @@ class LexicalHFModel(PreTrainedModel):
|
|
| 24 |
super().__init__(config)
|
| 25 |
self.config = config
|
| 26 |
|
|
|
|
| 27 |
self.embedding = nn.Embedding(
|
| 28 |
config.vocab_size,
|
| 29 |
config.embed_dim,
|
|
|
|
| 1 |
+
# file: lexical_model.py
|
| 2 |
import torch
|
| 3 |
import torch.nn as nn
|
| 4 |
from transformers import PreTrainedModel, PretrainedConfig
|
|
|
|
| 25 |
super().__init__(config)
|
| 26 |
self.config = config
|
| 27 |
|
| 28 |
+
# We use the exact name 'embedding' so it matches your .pth state_dict keys
|
| 29 |
self.embedding = nn.Embedding(
|
| 30 |
config.vocab_size,
|
| 31 |
config.embed_dim,
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 66363520
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ed3741f068bcec9b34e9d299dac8ccca5c55d5df5f5cdb4bc6f39113214c4310
|
| 3 |
size 66363520
|