Skip to content

Commit

Permalink
[rust] Fix bert model classifier loading (#3441)
Browse files Browse the repository at this point in the history
  • Loading branch information
xyang16 authored Aug 26, 2024
1 parent 94bce4a commit be48ce7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 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,16 @@ 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 be48ce7

Please sign in to comment.