hankcs/HanLP · warning
The main dependency conflicts with 2nd dependency at ID={i},
Error message
The main dependency conflicts with 2nd dependency at ID={i}, which means joint mode might not be suitable. The sample is
{sample_str} What it means
When merging main and second-order dependencies for SemEval-15 joint parsing, if the 2nd-best graph already has a different label for the head chosen by the main parser, the labels conflict and joint mode may be inconsistent; the full CoNLL sample is printed in the warning.
Source
Thrown at hanlp/datasets/parsing/semeval15.py:56
return sample
def append_bos_to_form_pos(sample, pos_key='CPOS'):
sample['token'] = [ROOT] + sample['FORM']
if pos_key in sample:
sample['pos'] = [ROOT] + sample[pos_key]
return sample
def merge_head_deprel_with_2nd(sample: dict):
if 'arc' in sample:
arc_2nd = sample['arc_2nd']
rel_2nd = sample['rel_2nd']
for i, (arc, rel) in enumerate(zip(sample['arc'], sample['rel'])):
if i:
if arc_2nd[i][arc] and rel_2nd[i][arc] != rel:
sample_str = CoNLLSentence.from_dict(sample, conllu=True).to_markdown()
warnings.warn(f'The main dependency conflicts with 2nd dependency at ID={i}, ' \
'which means joint mode might not be suitable. ' \
f'The sample is\n{sample_str}')
arc_2nd[i][arc] = True
rel_2nd[i][arc] = rel
return sample
View on GitHub (pinned to ddb1299bdd)
Solutions
- Check the printed sample at the flagged ID to see which deprel is intended
- If labels disagree, prefer non-joint (separate) decoding for that data or fix the source annotation
- Ignore if occasional disagreement is acceptable for your training setup
Defensive patterns
Strategy: try-catch
Validate before calling
for i, (arc, rel) in enumerate(zip(sample['arc'], sample['rel'])):
if i and sample['arc_2nd'][i][arc] and sample['rel_2nd'][i][arc] != rel:
conflicts.append(i) # inspect before joint mode Try / catch
with warnings.catch_warnings():
warnings.filterwarnings('ignore', message='.*joint mode might not be suitable.*')
merged = merge_head_deprel_with_2nd(sample) Prevention
- Audit SemEval-15 samples for head/label conflicts before joint training
- Fall back to non-joint parsing when conflicts are frequent
When it happens
Trigger: Calling merge_head_deprel_with_2nd on a SemEval-15 sample where arc_2nd[i][arc] is True but rel_2nd[i][arc] != rel — i.e. both graphs pick the same head with different deprel labels.
Common situations: Preparing SemEval-15 data for joint dependency parsing; mismatched main/2nd annotations in the corpus or preprocessed files.
Related errors
- Chinese Treebank 9.0 is a copyright dataset owned by LDC whi
- Not supported.
- Not supported.
- Prediction file {pred_file.name} does not end a sentence at
- Expect X to be 2 or 3 elements but got {repr(X)}
AI-assisted analysis of hankcs/HanLP@ddb1299bdd (2026-08-27).
Data as JSON: /api/errors/159ba71814201716.
Report an issue: GitHub.