DEV Community

Cover image for Three tasks where you don't need AI: when a script or a regex is enough
Slava Kotenev
Slava Kotenev

Posted on

Three tasks where you don't need AI: when a script or a regex is enough

"Add AI to it" is a fine idea only when AI is the cheapest way to hit the target. Often it isn't. Here are three kinds of tasks where a plain script, a regex or a lookup table is the better answer, and a quick test to tell which side your task is on.

The test: three questions

  1. Are the rules stable and writable? If you can explain the decision to a new colleague in ten lines, you can code it in ten lines.
  2. Is the volume small? A task done 20 times a week does not justify building, evaluating and monitoring a model.
  3. Is an error expensive? If one wrong answer costs more than a month of manual work, you want deterministic behaviour you can fully test.

If all three answers are "yes", "yes" and "yes", skip the model.

1. Fixed-format extraction

Order numbers, dates in a known template, IBANs, tracking codes. A regex plus a checksum does this with 100% repeatability and costs nothing per call:

import re
ORDER = re.compile(r"\bORD-(\d{6})\b")
def order_ids(text: str) -> list[str]:
    return ORDER.findall(text)
Enter fullscreen mode Exit fullscreen mode

A model might get 98% on the same input, and you will spend weeks finding the 2%.

2. Routing by explicit signals

If tickets already carry a form field, a sender domain or a keyword that decides the queue, route on that. A lookup table is auditable: when someone asks "why did this go to billing?", the answer is one line, not a probability.

Documents moving through a fixed set of rules

3. Small, rarely changing volumes

Thirty invoices a month from five suppliers? A template per supplier beats any general model. The break-even point depends on volume and on how often formats change, so count both before deciding.

When a model does earn its place

Free-form text with many phrasings, formats that keep changing, and tolerance for a measured error rate with a human catching the doubtful cases. In my ticket-triage demo (public Banking77 data, test numbers) a plain TF-IDF model handled about 76% of tickets automatically at 97.7% accuracy, because 77 intents phrased in free text are not something you write rules for.

Note the demo uses no large language model either: the ladder is rules first, then classic ML, then an LLM, and you climb only when the step below fails your measured target.

Takeaway

Write the target as a number, try the cheapest tool that could meet it, and add AI where the measurement says the cheaper tool falls short.

Portfolio and contacts: @Kotenev01_bot.


I write about practical, measurable AI adoption for business: demos on test data, no invented case studies. Telegram channel: @kotenev01_en

Top comments (0)