-
Notifications
You must be signed in to change notification settings - Fork 179
Open
Labels
Milestone
Description
Is your feature request related to a problem? Please describe.
Currently the text classification is serialized, this blocks the concurrency.
pub extern "C" fn classify_modernbert_text(text: *const c_char) -> ModernBertClassificationResult {
let default_result = ModernBertClassificationResult {
class: -1,
confidence: 0.0,
};
let text = unsafe {
match CStr::from_ptr(text).to_str() {
Ok(s) => s,
Err(_) => return default_result,
}
};
let bert_opt = MODERNBERT_CLASSIFIER.lock().unwrap();
match &*bert_opt {
Some(classifier) => match classifier.classify_text(text) {
Ok((class_idx, confidence)) => ModernBertClassificationResult {
class: class_idx as i32,
confidence,
},
Err(e) => {
eprintln!("Error classifying text with ModernBERT: {e}");
default_result
}
},
None => {
eprintln!("ModernBERT classifier not initialized");
default_result
}
}
}
Describe the solution you'd like
Support concurrent text classification