Update level_classifier_tool_2.py
Browse files- level_classifier_tool_2.py +1 -15
level_classifier_tool_2.py
CHANGED
|
@@ -53,21 +53,7 @@ class HFEmbeddingBackend:
|
|
| 53 |
# Load tokenizer/model with eager attention
|
| 54 |
self.TOK = AutoTokenizer.from_pretrained(self.model_name)
|
| 55 |
self.MODEL = AutoModel.from_pretrained(self.model_name, attn_implementation="eager")
|
| 56 |
-
|
| 57 |
-
# Keep eager; DO NOT set sliding_window=None (Gemma-3 expects an int in mask math)
|
| 58 |
-
try:
|
| 59 |
-
self.MODEL.config.attn_implementation = "eager"
|
| 60 |
-
|
| 61 |
-
# If you want to effectively disable sliding attention, make it 0 (int), not None
|
| 62 |
-
if hasattr(self.MODEL.config, "sliding_window"):
|
| 63 |
-
self.MODEL.config.sliding_window = 0
|
| 64 |
-
|
| 65 |
-
gen_cfg = getattr(self.MODEL, "generation_config", None)
|
| 66 |
-
if gen_cfg is not None and hasattr(gen_cfg, "sliding_window"):
|
| 67 |
-
gen_cfg.sliding_window = 0
|
| 68 |
-
except Exception:
|
| 69 |
-
pass
|
| 70 |
-
|
| 71 |
self.MODEL.to(self.device).eval()
|
| 72 |
|
| 73 |
def encode(self, texts: Iterable[str], batch_size: int = 32) -> "Tuple[torch.Tensor, List[str]]":
|
|
|
|
| 53 |
# Load tokenizer/model with eager attention
|
| 54 |
self.TOK = AutoTokenizer.from_pretrained(self.model_name)
|
| 55 |
self.MODEL = AutoModel.from_pretrained(self.model_name, attn_implementation="eager")
|
| 56 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
self.MODEL.to(self.device).eval()
|
| 58 |
|
| 59 |
def encode(self, texts: Iterable[str], batch_size: int = 32) -> "Tuple[torch.Tensor, List[str]]":
|