Skip to content

How do I resolve this error "ValueError: The number of parallel adapters and the number of active heads must match."? #701

Answered by calpt
charliezuo asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @charliezuo, the error message you mentioned might occur if not all loaded adapters have corresponding heads added to the model correctly. Usually, this should automatically happen with load_adapter() if a head is available in the checkpoint. You can check if this is the case like this after loading the adapters:

assert NER_adapter in model.heads
assert ph_adapters in model.heads

There's one minor error in your code: it should be active_head instead of active_heads to explicitly activate loaded heads, i.e.:

model.active_head = ac.Parallel(NER_adapter, ph_adapters)

This line is also not necessary as set_active_adapters() will automatically also activate the heads if available.

Hope thi…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@charliezuo
Comment options

Answer selected by calpt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants