Natural language processing parameter extraction techniques turn a sentence like "book a table for four at Nonna's next Friday at 7:30" into fields a program can act on, such as a party size and a timestamp. Four families of technique do this work, and production systems usually combine them. Rules catch the predictable formats while models handle the open-ended ones. A validation layer at the end trusts neither.
Finding the words is the easy half. The hard half is deciding what "next Friday" means on a Thursday, and what to do when the user never mentioned a time at all. This guide walks through each technique with that booking request as the running example.
What parameter extraction means in NLP
Parameter extraction means pulling the values an action needs out of free text. In dialogue systems the action is called an intent and its parameters are called slots, so you will also see the task called slot filling.
Every extraction task starts with a schema, meaning the list of fields, their types and which of them are required. The booking intent needs these:
restaurant: a string, which must match a known venueparty_size: an integer from 1 to 20time: a datetime, resolved against the moment the message was sent
Each field asks a different question of the text. Party size is a number sitting in a predictable spot. The time is a phrase that means nothing until it has been resolved against today's date.
Write the schema before you pick a technique. Most extraction bugs trace back to a field nobody defined, such as whether "a few of us" counts as a party size. Nobody who says "a few of us" has counted yet, and your parser shouldn't pretend it has. The honest value is null, followed by a question.
Rule-based parameter extraction with regex and token patterns
Rules are patterns you write by hand. They are fast and cheap to run, and when one fails you can read exactly why.
A regular expression such as \bfor (\d{1,2})\b catches "for 4" and misses "for four". Token patterns fix that. spaCy's Matcher works on tokens with attributes attached, so a single pattern using LIKE_NUM covers digits and number words alike. Its PhraseMatcher handles the closed sets, so a list of your restaurants becomes a fast exact-match lookup.
The spaCy documentation on rule-based matching gives a sensible test for when rules are enough: a more or less finite set of examples, or a clear structured pattern. Its own examples include IP addresses and URLs among others. The same page recommends rules at the start of a project, to bootstrap the training data a statistical model will need later. Its EntityRuler component lets the two coexist, adding rule matches alongside a trained recogniser's predictions.
We used the same approach for people's names in our guide to name extraction rules in natural language processing, where the rules handle titles and particles that models tend to drop.
Regex is the cockroach of NLP. Every few years someone declares it obsolete, and it carries on in production, quietly parsing phone numbers.
Named entity recognition and transformers for open-ended slots
Some values can't be listed in advance. New restaurants open every week, and people have names you have never seen. For these, you train a model to recognise the value from its context.
Named entity recognition, usually shortened to NER, labels spans of text with a type, such as marking "Nonna's" as a venue. Older recognisers relied on hand-built features. Current ones fine-tune a transformer, the architecture behind modern language models, which reads the whole sentence at once and uses words on both sides of a span to decide what it is. spaCy's guidance puts it well: statistical models shine when there are clues in the local context, such as person or company names.
The cost is labelled data. Someone has to mark up real messages, and the quality of those labels sets the ceiling for the model. A recogniser trained on tidy examples will struggle with "4 ppl @ nonnas fri 730", which is how a real customer types on a phone.
There is a second limit. NER returns a span of text, the literal characters "next Friday". Your booking system needs a timestamp, so one more step is required.
Normalising values: from "next Friday" to a timestamp
Normalisation converts the extracted text into a canonical value, such as an ISO date or an amount with a currency code. Skip it and every downstream system has to guess.
Duckling, the open-source parser from Meta, is the reference design here. Its README shows "the first Tuesday of October" coming back as a timestamp with a grain of "day", which tells you how precise the value is. It covers dimensions such as money and durations among others, so "42€" becomes a value of 42 with the unit EUR, and "3 mins" normalises to 180 seconds.
The detail that matters most is the reference time. "Tomorrow at eight" only resolves once the parser knows when "now" was and which locale the user is in. Store the raw span and the reference time next to every resolved value. When a rule changes, you can re-resolve old messages without guessing.
Dates are where extraction projects go to age. Ask a room of engineers what "next Friday" means on a Thursday and it splits roughly in half, and the half that loses the argument files the bug report. Seasons are worse still, as our piece on season interpretation rules shows.
LLM parameter extraction with function calling and structured outputs
Large language models can do the whole job in one call. You describe the schema, pass in the message and get the fields back as JSON.
Two API features make this dependable. Function calling lets the model choose a tool and fill in its arguments, which is parameter extraction under another name. Structured outputs constrain the response itself to a JSON schema you supply. OpenAI's Structured Outputs guide draws the key line between this and the older JSON mode: both produce valid JSON, and only structured outputs guarantee that the JSON matches your schema.
A schema guarantee covers shape. It says nothing about truth. The same guide warns that the model will always try to fill the schema, which can produce invented values when the input has nothing to do with it, and that structured outputs can still contain mistakes. Your application still has to check the business rules a schema can't express.
Two habits reduce the risk. Make every field the user might omit nullable, so the model has an honest way to say "not given". Then tell it in the prompt to leave a field empty when the text doesn't state it. Designing tool schemas that models fill reliably is a large part of building agents, and Agentic AI Engineering covers tool design and argument handling in depth.
Building a hybrid parameter extraction pipeline
No single technique wins every field, so production systems mix them. Here is how they compare:
| Technique | Best for | Weak spot |
|---|---|---|
| Regex | Fixed formats such as order IDs | Any variation in wording |
| Token patterns and gazetteers | Closed sets such as venue lists | Values outside the list |
| NER and transformers | Open-ended names | Needs labelled data, returns raw spans |
| Value parsers | Dates, amounts and units | Depends on reference time and locale |
| LLM structured outputs | Messy, varied phrasing | Confident invented values |
A sensible order runs cheapest and most certain first:
- Run rules for fixed formats and closed sets.
- Send the remaining fields to an LLM or NER model.
- Normalise dates and amounts with a parser.
- Validate everything against the schema and your business rules.
The validator is the step teams skip. In Python, Pydantic makes it short:
from datetime import datetime
from pydantic import BaseModel, Field, field_validator
VENUES = {"nonna's", "the harbour grill"}
class BookTable(BaseModel):
restaurant: str
party_size: int = Field(ge=1, le=20)
time: datetime | None = None # None when the user never said
@field_validator("restaurant")
@classmethod
def known_venue(cls, v: str) -> str:
if v.lower() not in VENUES:
raise ValueError(f"unknown venue: {v}")
return v
booking = BookTable.model_validate_json(model_output)
When validation fails or a required field comes back null, ask the user a clarifying question and keep the guess out of the booking. A clarifying question costs one turn. A table booked at the wrong Nonna's costs an awkward phone call.
Write the schema first, with types and a rule for every missing value. Then collect fifty real messages and label the fields by hand. Measure accuracy per field, since an overall score hides the one slot that keeps failing. Start with rules for whatever is predictable and add a model for the rest. Keep the validator in place from day one.
If your extraction runs through prompts, the prompt is part of the system and deserves versioning and tests like code. AI Prompt Engineering covers how to build and maintain prompts that way.