CoreML Text Classifier in Message Filter

Hi all,

I'm trying to build a scam detection in Message Filter powered by CoreML. I find the predictions of ML reliable and the solution for text frauds and scams are sorely needed.

I was able to create a trained MLModel and deploy it in the app. It works on my container app, but when I try to use and initialise the model in the Message Filter extension, I get an error;

initialization of text classifier model with model data failed

I have tried putting the model in the container app, extension, even made a shared framework for container and extension but to no avail. Every time I invoke the codes to init my model from the extension, I am met with the same error.

Here's my code for initializing the model

do {
    let model = try Ace_v24_6(configuration: .init())
    let output = try model.prediction(text: text)
    
    guard !output.label.isEmpty else {
        return nil
    }
    
    return MessagePrediction(rawValue: output.label)
} catch {
    return nil
}

My question is: Is it impossible to use CoreML in MessageFilters?

Cheers

CoreML Text Classifier in Message Filter
 
 
Q