(self, model_name, model_path, max_length, use_fp16, instruction)
| 102 | """ |
| 103 | |
| 104 | def __init__(self, model_name, model_path, max_length, use_fp16, instruction): |
| 105 | import torch |
| 106 | from sentence_transformers import SentenceTransformer |
| 107 | |
| 108 | self.model_name = model_name |
| 109 | self.model_path = model_path |
| 110 | self.max_length = max_length |
| 111 | self.use_fp16 = use_fp16 |
| 112 | self.instruction = instruction |
| 113 | self.model = SentenceTransformer( |
| 114 | model_path, trust_remote_code=True, model_kwargs={"torch_dtype": torch.float16 if use_fp16 else torch.float} |
| 115 | ) |
| 116 | |
| 117 | @torch.inference_mode() |
| 118 | def encode(self, query_list: Union[List[str], str], batch_size=64, is_query=True) -> np.ndarray: |
nothing calls this directly
no outgoing calls
no test coverage detected