Skip to content

Commit

Permalink
👍 changed the import source of models and added comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
hppRC committed Dec 9, 2024
1 parent 6428c19 commit f177e60
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/jmteb/embedders/data_parallel_sbert_embedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import torch
from accelerate.utils import find_executable_batch_size
from loguru import logger
from sentence_transformers import SentenceTransformer, models
from sentence_transformers import SentenceTransformer
from sentence_transformers.models import Pooling
from sentence_transformers.quantization import quantize_embeddings
from sentence_transformers.util import truncate_embeddings
from torch import Tensor
Expand Down Expand Up @@ -166,9 +167,11 @@ def encode(

return all_embeddings

# Sentence Transformersの`include_prompt`判定メソッドを参考に実装
# ref: https://github.com/UKPLab/sentence-transformers/blob/679ab5d38e4cf9cd73d4dcf1cda25ba2ef1ad837/sentence_transformers/trainer.py#L931
def include_prompt_for_pooling(self) -> bool:
for module in self:
if isinstance(module, models.Pooling):
if isinstance(module, Pooling):
return module.include_prompt
return True

Expand Down

0 comments on commit f177e60

Please sign in to comment.