Guide · spaCy

Custom NER in spaCy, without training data

Updated 26 November 2026, by Jungroo AI Labs, the makers of ReDefiNER

spaCy's trained pipelines find general types: people, organisations, places, dates. For your own types, such as product models, error codes or order numbers, the usual route is to label examples and train a NER model, or to write EntityRuler patterns. The spacy-redefiner component adds a third route: describe each type in a plain-English rulebook and a 0.8B model, ReDefiNER, finds them, with no training data. It runs on a CPU and is free under Apache 2.0. We make ReDefiNER and the plugin; every output on this page is real.

The short answer

  • Train a spaCy NER model when you have hundreds of labelled examples for each type and need speed: a trained pipeline answers in milliseconds.
  • Write EntityRuler patterns for fixed formats such as emails and ID numbers. Patterns and rulebooks compared.
  • Use spacy-redefiner when you have no labelled data, when a type needs explaining, or when the definitions change often: edit the rulebook, and there is nothing to retrain.

What en_core_web_sm finds in your own types

Three support messages, run through spaCy's small English pipeline. It knows its general types, so it puts your terms into the nearest one:

import spacy

nlp = spacy.load("en_core_web_sm")
for doc in nlp.pipe(texts):
    print([(ent.text, ent.label_) for ent in doc.ents])
Texten_core_web_sm
My Nimbus X200 router shows error E-4012 after updating to firmware 2.3.1.Nimbus ORG
X200 PRODUCT
E-4012 ORG
2.3.1 CARDINAL
Order #A-77120 arrived on 3 May, but the Nimbus X300 inside was the wrong colour.A-77120 ORG
3 May DATE
Nimbus ORG
X300 PRODUCT
Acme support said E-4012 means the fan has failed.E-4012 ORG

The error code and the order number come back as organisations, and each product name is split in two. That is expected: these types are not in its training data. Labelled examples and training would fix it.

The same texts with a rulebook

Three types, each with a one-line description and an example of a different value. One rule keeps the company name out of PRODUCT:

[TYPE] PRODUCT
[DESCRIPTION] A product model name, such as Orbit Z5.
PR1 A company name on its own, such as "Acme", is not a product.

[TYPE] ERROR_CODE
[DESCRIPTION] A device error code, such as E-1001.

[TYPE] ORDER_ID
[DESCRIPTION] A customer's order reference, such as #B-10234.
pip install spacy-redefiner
import spacy

# RULEBOOK is the rulebook above; texts are the three messages
nlp = spacy.blank("en")
nlp.add_pipe("redefiner", config={"rulebook": RULEBOOK})
for doc in nlp.pipe(texts):
    print([(ent.text, ent.label_, ent._.redefiner_confidence)
           for ent in doc.ents])
Textspacy-redefiner (confidence)
My Nimbus X200 router shows error E-4012 after updating to firmware 2.3.1.Nimbus X200 PRODUCT (0.72)
E-4012 ERROR_CODE (0.99)
Order #A-77120 arrived on 3 May, but the Nimbus X300 inside was the wrong colour.#A-77120 ORDER_ID (0.49)
Nimbus X300 PRODUCT (0.98)
Acme support said E-4012 means the fan has failed.E-4012 ERROR_CODE (0.98)

All three types were found with whole spans, and “Acme” was left out as the rule says. The order number's confidence, 0.49, is low: set a minimum confidence that suits your data after checking 20 to 50 of your own texts. Settings include min_confidence.

Add a type with one more paragraph

Append this to the rulebook and run the same three texts again:

[TYPE] FIRMWARE_VERSION
[DESCRIPTION] A firmware or software version number, such as 1.0.4.

The first message now also returns 2.3.1 as FIRMWARE_VERSION (confidence 0.98), and the other spans are the same as before. No labelling and no training step.

With a trained spaCy pipeline

The component works after a pipeline such as en_core_web_sm. How it shares doc.ents decides what you get, and on these texts the choice matters:

SetupWhat you getOn the three texts
exclude=["ner"]spaCy's tagger, parser and lemmatizer, with entities from the rulebookThe rulebook's entities, as above
spans_key="custom"spaCy's entities in doc.ents, the rulebook's in doc.spans["custom"]Both, side by side: E-4012 is ORG in one and ERROR_CODE in the other
overwrite_ents=FalsespaCy's entities, plus only rulebook spans that don't overlap themNothing added: spaCy's wrong labels covered every span the rulebook found
# spaCy's tagger, parser and lemmatizer; entities from the rulebook
nlp = spacy.load("en_core_web_sm", exclude=["ner"])
nlp.add_pipe("redefiner", config={"rulebook": RULEBOOK})
# spaCy's entities stay in doc.ents; the rulebook's go to doc.spans
nlp = spacy.load("en_core_web_sm")
nlp.add_pipe("redefiner",
             config={"rulebook": RULEBOOK, "spans_key": "custom"})

In a spaCy config file:

[components.redefiner]
factory = "redefiner"
rulebook = "rules/support.txt"
spans_key = "custom"

Speed and limits

  • Speed. On the Apple M2 laptop that ran these examples, en_core_web_sm took about 2 milliseconds per text and the redefiner component about 0.2 seconds, once the rulebook was loaded: roughly 100 times slower. For millions of texts a day, a trained model costs far less to run.
  • Memory. About 2 to 2.6 GB at peak on a CPU. It also runs on an NVIDIA GPU.
  • English only, and spans of up to 16 model tokens by default; raise max_span_tokens for long IDs or URLs.
  • Rules that fight a strong prior are mostly ignored, such as labelling a person's name as something other than a person. When a type's condition isn't clearly met, it tends to label anyway.
  • More on rules: How to write rules that work.

Questions

Frequently asked.

How do I add a custom entity type to spaCy without training?

Install spacy-redefiner, write the type as a [TYPE] line with a one-line [DESCRIPTION], and add the redefiner component to your pipeline. The model finds the type from its description; there is no training step.

Should I train a spaCy NER model instead?

If you have hundreds of labelled examples for each type and need millisecond speed, yes: a trained spaCy model is far faster. spacy-redefiner suits types you have no labelled data for, types that need explaining, and definitions that change often.

Can I keep spaCy's own entities?

Yes. Set spans_key so the rulebook's spans go to doc.spans and doc.ents stays spaCy's. Setting overwrite_ents to false also keeps spaCy's entities, but adds only rulebook spans that don't overlap them.

Does it work with spaCy's EntityRuler?

Yes. Put the entity_ruler before the redefiner component and set overwrite_ents to false: the patterns keep their matches and the rulebook adds the rest.

Is it free, and does it need a GPU?

The plugin, the code and the 0.8B model are free under Apache 2.0, including commercial use. It runs on an ordinary CPU; a GPU makes it faster.

Try it on your own text

Test ReDefiNER on 20 of your sentences.

It runs on a laptop CPU. Install it with pip, edit a rule and see the output change, or write to us and we will test a rulebook on your data.

Contact

Tell us what you need.

We partner with a limited number of enterprises at a time, so every engagement gets senior attention. Tell us what you want to build, and our leadership will reply.

We use these details only to reply to you. What you type is saved as you go, so we can still reply if you leave before pressing Send. Privacy

General enquiries

Jungroo AI Labs

Partnerships, projects and products

Leadership

Sethuraman T A

Chief Executive Officer

Engineering

Cibe Hariharan

Chief Technology Officer