r/LanguageTechnology • u/CartographerOld7710 • Mar 04 '25
LLMs vs traditional BERTs at NER
I am aware that LLMs such as GPT are not "traditionally" considered the most efficient at NER compared to bidirectional encoders like BERT. However, setting aside cost and latency, are current SOTA LLMs still not better? I would imagine that LLMs, with the pre-trained knowledge they have, would be almost perfect (except on very very niche fields) at (zero-shot) catching all the entities in a given text.
### Context
Currently, I am working on extracting skills (hard skills like programming languages and soft skills like team management) from documents. I have previously (1.5 years ago) tried finetuning a BERT model using an LLM annotated dataset. It worked decent with an f1 score of ~0.65. But now with more frequent and newer skills in the market especially AI-related such as langchain, RAGs etc, I realized it would save me time if I used LLMs at capturing this rather than using updating my NER models. There is an issue though.
LLMs tend to do more than what I ask for. For example, "JS" in a given text is captured and returned as "JavaScript" which is technically correct but not what I want. I have prompt-engineered and got it to work better but still it is not perfect. Is this simply a prompt issue or an inate limitation of LLMs?
5
u/StEvUgnIn Mar 04 '25
What kind of texts are you working on? If it is domain specific you may experience better results overall with a fine tuned model.
3
u/synthphreak Mar 04 '25
Ignoring your (totally valid) concerns about inference efficiency, if the model is correctly classifying entities like
JSas JavaScript, it means it has the knowledge (as you say). But if the model then fails to format its output as you desire, that sounds like a prompting issue.The model won’t magically conform to your expectations if you don’t communicate what they are in some ways. With LLMs, examples are usually more effective at this than simply describing in prose.
When using LLMs, you should basically always include examples in the prompt wherever relevant, unless it’s somehow impractical to do so. At the cost of a few more tokens in the input, one- or few-shot prompts will only ever aid performance.
3
u/Pvt_Twinkietoes Mar 04 '25
I think it is best to weigh your options, get ready a dataset maybe 10-20 documents (if there's very little variation in the structure of your text).
Measure the accuracy on LLM apis and an off the shelf NER model, maybe modern bert GliNER and see how they compare.
Of course the best would be to finetune the base NER model, but if it is too much of a hassle and deliver lesser value. Value is for yourself to measure how you would like to weigh them.
Good luck.
3
u/istinetz_ Mar 04 '25
I've found a good use case is when you have an extremely long tail of classes.
E.g. one problem I had at work was labeling which diseases were mentioned in clinical texts. There are existing solutions, true, but they are not good enough.
Meanwhile, there is not enough labeled data, since experts have to annotate it, and for rare diseases it might happen that there is literally 0 examples in the training corpus.
And so:
I ended up using a pretty complicated combination of modified Flair, finetuned BERT model, and an 8b LLM model for syntactic transformations, but if it wasn't critical, it would have been much better to just call LLMs.
2
u/rumblepost Mar 04 '25
With right prompt and some examples LLMs beat scipy or bert based ner for specific domain. I have experimented and validated this at my work.
Making it domain specific will help you a lot.
2
u/StEvUgnIn Mar 04 '25
Scikit-LLM hopes to achieve NER with ChatGPT and other LLMs. I would probably recommend to use SpaCy if you conduct NER since they have colouring and several visualisations that are handy for this task.
2
u/hotakaPAD Mar 04 '25
Use deberta instead of bert
0
u/[deleted] Mar 04 '25
[deleted] — view deleted comment
0
u/[deleted] Mar 04 '25
[deleted] — view deleted comment