Fill-Mask
Transformers
Safetensors
Ancient Greek (to 1453)
char_bert
ancient-greek
classical-philology
character-level
masked-diffusion
custom_code
Instructions to use Ericu950/CharDiff-grc-doc_clean with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Ericu950/CharDiff-grc-doc_clean with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="Ericu950/CharDiff-grc-doc_clean", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Ericu950/CharDiff-grc-doc_clean", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Fix: RoPE inv buffer could fail to materialize under some transformers meta-device loading paths, corrupting all attention output (see repo history for full diagnosis)
Browse files- modeling_char_bert.py +10 -3
modeling_char_bert.py
CHANGED
|
@@ -34,11 +34,18 @@ class RMSNorm(nn.Module):
|
|
| 34 |
class RoPE(nn.Module):
|
| 35 |
def __init__(self, dim, base=10000.0):
|
| 36 |
super().__init__()
|
| 37 |
-
|
| 38 |
-
self.
|
| 39 |
|
| 40 |
def cos_sin(self, pos):
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
emb = torch.cat([f, f], -1)
|
| 43 |
return emb.cos(), emb.sin()
|
| 44 |
|
|
|
|
| 34 |
class RoPE(nn.Module):
|
| 35 |
def __init__(self, dim, base=10000.0):
|
| 36 |
super().__init__()
|
| 37 |
+
self.dim = dim
|
| 38 |
+
self.base = base
|
| 39 |
|
| 40 |
def cos_sin(self, pos):
|
| 41 |
+
# Recomputed on every call rather than cached in a registered buffer: a
|
| 42 |
+
# persistent=False buffer is never covered by the checkpoint's state dict,
|
| 43 |
+
# so it depends entirely on __init__-time materialization -- which some
|
| 44 |
+
# transformers versions' meta-device/low_cpu_mem_usage loading path can
|
| 45 |
+
# skip, silently leaving this tensor uninitialized. Recomputing here is
|
| 46 |
+
# immune to that regardless of how the model was constructed/loaded.
|
| 47 |
+
inv = 1.0 / (self.base ** (torch.arange(0, self.dim, 2, device=pos.device).float() / self.dim))
|
| 48 |
+
f = torch.outer(pos.float(), inv)
|
| 49 |
emb = torch.cat([f, f], -1)
|
| 50 |
return emb.cos(), emb.sin()
|
| 51 |
|