2
$\begingroup$

I'm looking to use ML to read in a blob of text, and extract a name from that text blob. (The blob is from an OCR result from an iPhone)

The text blob varies in size, but the name is always present in the text. The resulting model needs to be able to run on an iPhone.

I've used Apple's CreateML, but it only seems to assign labels that it has seen in training. Is there a tool that will allow me to do this?

$\endgroup$

1 Answer 1

1
$\begingroup$

Unfortunately, it is not possible to do a classifier with “unlimited labels”. In general, your best bet is to use a transformer model adapted to certain tasks:

  • Text generation: GPT, Llama
  • Named Entity Recognition Models: BERT w/ additional layers
  • Question Answering: BERT for question answering

For example, you can prompt a text generation model:

“Extract the names out of this phrase: ”

A named entity recognition would tag a text with some entities it recognizes.

Question answering is similar to text generation. Just prompt it by asking:

“What are the names in this text? ”

Unfortunately, you’d have to do some serious quantizing and re-serialization to get this to a point where it fits into an embedded system.

No matter the route you take, if you’re doing a custom trained model, make sure to quantize your models (change the floating point precision of your model’s weights to reduce memory of the model parameters) and serialize appropriately (i.e. tf-lite is a serialization format to optimize space and inference speed of tensorflow models in an embedded system).

Otherwise, look on huggingface or tensorflow model garden to see if you can find any mobile-optimized NLP models (Mobile-BERT: https://huggingface.co/docs/transformers/en/model_doc/mobilebert)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.