hankcs/HanLP · error · ValueError
If no `decoder_input_ids` or `decoder_inputs_embeds` are pas
Error message
If no `decoder_input_ids` or `decoder_inputs_embeds` are passed, `input_ids` cannot be `None`. Please pass either `input_ids` or `decoder_input_ids` or `decoder_inputs_embeds`.
What it means
SmatchEval for AMR evaluation downloads version-specific official utility scripts; only AMR corpus versions '1.0', '2.0' and '3.0' are supported. Any other amr_version string raises ValueError from get_amr_utils, which is called during __init__ and post_process.
Source
Thrown at hanlp/components/amr/amrbart/model_interface/modeling_bart.py:1204
decoder_attention_mask: Optional[torch.LongTensor] = None,
head_mask: Optional[torch.Tensor] = None,
decoder_head_mask: Optional[torch.Tensor] = None,
cross_attn_head_mask: Optional[torch.Tensor] = None,
encoder_outputs: Optional[List[torch.FloatTensor]] = None,
past_key_values: Optional[List[torch.FloatTensor]] = None,
inputs_embeds: Optional[torch.FloatTensor] = None,
decoder_inputs_embeds: Optional[torch.FloatTensor] = None,
use_cache: Optional[bool] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Optional[bool] = None,
) -> Union[Tuple, Seq2SeqModelOutput]:
# different to other models, Bart automatically creates decoder_input_ids from
# input_ids if no decoder_input_ids are provided
if decoder_input_ids is None and decoder_inputs_embeds is None:
if input_ids is None:
raise ValueError(
"If no `decoder_input_ids` or `decoder_inputs_embeds` are "
"passed, `input_ids` cannot be `None`. Please pass either "
"`input_ids` or `decoder_input_ids` or `decoder_inputs_embeds`."
)
decoder_input_ids = shift_tokens_right(
input_ids, self.config.pad_token_id, self.config.decoder_start_token_id
)
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
output_hidden_states = (
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
)
use_cache = use_cache if use_cache is not None else self.config.use_cache
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
if encoder_outputs is None:
encoder_outputs = self.encoder(View on GitHub (pinned to ddb1299bdd)
Solutions
- Use one of '1.0', '2.0', '3.0' exactly
- Map your corpus to the closest supported version (e.g. AMR 2.0 utilities for AMR 2.5 data, if structurally compatible)
- Upgrade HanLP to a version supporting your AMR version
Example fix
# before eval = SmatchEval(amr_version='2.5') # after eval = SmatchEval(amr_version='2.0')
Defensive patterns
Strategy: validation
Validate before calling
assert amr_version in ('1.0', '2.0', '3.0'), f'unsupported AMR version {amr_version!r}' Type guard
def supported_amr_version(v: str) -> bool:
return v in ('1.0', '2.0', '3.0') Try / catch
try:
ev = SmatchEval(amr_version=amr_version)
except ValueError:
amr_version = '2.0'
ev = SmatchEval(amr_version=amr_version) Prevention
- Normalize version strings before constructing SmatchEval
- Pin the AMR corpus version in experiment configs
- Upgrade HanLP when new AMR corpus versions are released
When it happens
Trigger: Constructing SmatchEval(amr_version='2.5') or any string other than 1.0/2.0/3.0, including forms like 'v2' or 'AMR2.0'.
Common situations: New AMR corpus releases not yet supported by this HanLP version; typo'd or unnormalized version strings in configs; passing the corpus name instead of its version.
Related errors
- Failed to parse results from smatch: {line}
- Unsupported argument length: {item}
- error
- output ({}) must be of type bool or str
- Call fit or load before evaluate.
AI-assisted analysis of hankcs/HanLP@ddb1299bdd (2026-08-27).
Data as JSON: /api/errors/83172f13b1c0d4d6.
Report an issue: GitHub.