mirror of
https://github.com/elastic/eland.git
synced 2025-07-11 00:02:14 +08:00
[NLP] Prevent TypeError with None check (#525)
This commit is contained in:
parent
cebee6406f
commit
8e0d897171
@ -393,11 +393,13 @@ class _DPREncoderWrapper(nn.Module): # type: ignore
|
|||||||
|
|
||||||
def is_compatible() -> bool:
|
def is_compatible() -> bool:
|
||||||
is_dpr_model = config.model_type == "dpr"
|
is_dpr_model = config.model_type == "dpr"
|
||||||
has_architectures = len(config.architectures) == 1
|
has_architectures = (
|
||||||
is_supported_architecture = (
|
config.architectures is not None and len(config.architectures) == 1
|
||||||
|
)
|
||||||
|
is_supported_architecture = has_architectures and (
|
||||||
config.architectures[0] in _DPREncoderWrapper._SUPPORTED_MODELS_NAMES
|
config.architectures[0] in _DPREncoderWrapper._SUPPORTED_MODELS_NAMES
|
||||||
)
|
)
|
||||||
return is_dpr_model and has_architectures and is_supported_architecture
|
return is_dpr_model and is_supported_architecture
|
||||||
|
|
||||||
if is_compatible():
|
if is_compatible():
|
||||||
model = getattr(transformers, config.architectures[0]).from_pretrained(
|
model = getattr(transformers, config.architectures[0]).from_pretrained(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user