mirror of
https://github.com/modelscope/modelscope.git
synced 2025-12-25 12:39:25 +01:00
[to #42322933] without setting in config, textranking's num_labels default as 1
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/11629915 * without setting, textranking's num_labels default as 1
This commit is contained in:
committed by
mulin.lyh
parent
5770476881
commit
f761140a97
@@ -35,7 +35,9 @@ class ModelForTextRanking(EncoderModel):
|
||||
label2id = parse_label_mapping(model_dir)
|
||||
if label2id is not None and len(label2id) > 0:
|
||||
num_labels = len(label2id)
|
||||
self.id2label = {id: label for label, id in label2id.items()}
|
||||
self.id2label = {id: label for label, id in label2id.items()}
|
||||
elif label2id is None:
|
||||
num_labels = 1
|
||||
kwargs['num_labels'] = num_labels
|
||||
super().__init__(model_dir, *args, **kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user