Skip to content

Commit

Permalink
[rust] Fix bert model classifier loading
Browse files Browse the repository at this point in the history
  • Loading branch information
xyang16 committed Aug 26, 2024
1 parent 94bce4a commit d5929c0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion extensions/tokenizers/rust/src/models/bert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,17 @@ impl BertClassificationHead {
Ok(layer) => Some(layer),
Err(_) => None,
};
let output = Linear::load(vb.pp("classifier"), config.hidden_size, n_classes, None)?;
let output = match (Linear::load(vb.pp("classifier"), config.hidden_size, n_classes, None))
{
Ok(output) => output,
Err(err) => {
if let Ok(output) = (Linear::load(vb, config.hidden_size, n_classes, None)) {
output
} else {
return Err(err);
}
}
};

Ok(Self {
pooler,
Expand Down

0 comments on commit d5929c0

Please sign in to comment.