Posted in

How to choose features for a CRF model?

If you’re here, you probably know how critical feature selection is if you’re working with CRF models—whether you’re building for NLP, bioinformatics, computer vision, or even custom industrial tagging (think the kind of work our CRF machines are built to support). As a CRF machine supplier, I talk to teams every week who either overcomplicate feature lists or skip key steps that make their models either garbage or impossible to deploy. Today I’m breaking down how to pick features that actually move the needle, no fancy math jargon required. Crf Machine

First, let’s get one thing straight: a CRF model is only as good as its features. It’s not like a deep learning model that can “learn” raw patterns from pixel data or text on its own (at least, not the standard CRF setups most people use in production). CRFs work by calculating the probability of a sequence of labels based on the features you feed them, so if your features are irrelevant or noisy, your labels will be too. I’ve seen teams spend weeks tweaking model architectures only to fix 2% accuracy, when they could’ve thrown out half their features and doubled that gain in a day.

Let’s start with the basics: what even counts as a good feature for CRFs? It’s not just “any piece of data about a token or a state.” Good features are binary or categorical (though you can adjust for continuous, but start simple) and tell the model something consistent about how a label should behave. For example, if you’re tagging named entities (like “Apple” as a company, not a fruit), a feature like “current token is capitalized” is good—most company names start with capitals, but not all. A bad feature would be “current token has 5 letters”—that’s way too vague, and you’ll end up with false positives for words like “Table” that aren’t entities.

Now, how do you narrow down your list? Let’s walk through the process step by step, with examples from actual projects we’ve supported with our CRF machines.

First, map your label schema first before picking a single feature. You can’t pick features if you don’t know what you’re trying to label. If your project is labeling parts of speech, your labels are things like NN (noun), VB (verb), JJ (adjective). If you’re doing invoice line-item tagging, labels might be “Item Description,” “Quantity,” “Price,” “Tax.” For each label, write down what information would tell you that a token belongs to it. For “Quantity” in invoices, common clues are numbers, words like “each,” “dozen,” “#,” or symbols like “@.” That’s your starting feature list—don’t skip this step. I had a customer last month who tried to build an invoice tagger, and they started picking features without defining their labels clearly. They ended up with 17 features that had nothing to do with their labels, and their model was tagging 40% of “12” as “Item Description” instead of “Quantity.” They fixed that in a day once they mapped labels to clues.

Next, separate “local” vs. “contextual” features. This is a common mistake. Local features are about the token itself—its text, its formatting, its length, its type (number, letter, symbol). Contextual features are about neighboring tokens: the previous token, the next token, a combination of nearby tokens. CRFs are great at using context, but that doesn’t mean you need 20 different contextual features. For example, in part-of-speech tagging, a local feature is “current token ends with ‘ing’” (which usually means a verb), and a contextual feature is “previous token is a determiner like ‘the’” (which often precedes a noun). The key here: don’t overdo contextual features. I’ve seen teams add features like “the token two before is an adjective and the token two after is a noun” which just adds noise and makes your model run way slower. Our CRF machines are fast, but even fast machines hate unnecessary features—they bloat training time and don’t improve accuracy.

Once you have your initial list, filter out redundant features. How? Let’s say you have two features: “current token is capitalized” and “current token starts with a capital letter.” Those are basically the same thing—using both won’t give you extra info, it’ll just make the model work harder. Another example: if you’re tagging emails, “current token is an @ symbol” and “current token is part of an email domain” are redundant. Test for this: if you remove a feature and your model’s accuracy doesn’t drop, or if the feature has a correlation of more than 0.8 with another feature, cut it. Our team usually recommends using a simple correlation matrix for this (even a basic Excel sheet works, no fancy tools needed). I’ve had a customer who cut 12 redundant features from their 30-feature list, and their training time went down by 40% with no accuracy loss—big win.

Then, test for feature utility. Not all features will help. The easiest way to check if a feature is worth keeping is to train a small test CRF model with and without it, and see how accuracy changes. If removing the feature only changes accuracy by 1% or less, cut it. I know, I know—it’s tedious, but it’s way better than wasting time on useless features. For example, a customer building a product attribute tagger had a feature for “current token has an exclamation mark.” When they removed it, accuracy stayed the same. Why? Because product descriptions almost never use exclamation marks, so that feature never triggered a useful label. They cut it, no harm done.

Another thing to watch out for: sparse features. These are features that only fire for 1% or less of your training data. For example, if you’re tagging medical records, a feature like “current token is ‘COVID-19 variant Omicron’” might be super important, but if it only appears 20 times in your 10,000-token dataset, it’ll lead to overfitting. Our CRF machines handle sparse data, but too many sparse features can make your model perform badly on new data it hasn’t seen. The fix? Either combine sparse features with more general ones (like “current token mentions a variant”) or drop them if they don’t contribute enough. One of our long-term users adjusted a set of medical tags by merging 5 sparse variant features into one, and their model’s out-of-sample accuracy went up 5%—that’s a huge jump.

Wait, but what about continuous features? A lot of people struggle with these because CRFs work best with discrete (binary/categorical) features. If you have a continuous feature like “token length” (number of characters), don’t just plug it in as is. Bin it! For example, turn “length=5” into a feature like “token length is short (1-5 chars)” vs. “medium (6-10)” vs. “long (11+).” That’s way easier for the model to use. I’ve seen teams try to use raw continuous data, and their model would assign weird weights—like giving more importance to a token that’s 7 characters than one that’s 5, even if it’s not meaningful. Binning fixes that.

Now, let’s talk about a common scenario that most of our customers face: custom CRF setups for industrial or domain-specific work, not just NLP. If you’re using a CRF machine for things like assembly line defect tagging, sensor data sequence labeling, or even document processing for legal/financial work, the same rules apply, but the features change. For defect tagging on a conveyor belt, local features might be “pixel is red” or “pixel edge is sharp,” and contextual features might be “previous pixel is part of a circle.” For legal document clause tagging, local features might be “token is ‘indemnify’” and contextual might be “previous token is ‘the undersigned’.” The process is the same, just the feature data is different.

A quick pro tip from our team: start small. Don’t build a 50-feature list on day one. Start with 10-15 features that map directly to your labels, filter out the redundant ones, test for utility, and build from there. You can always add more features later if you need to tweak accuracy. We’ve had customers who tried to go from 0 to 50 features in a week, and their model was so bloated it took 10x longer to train on our machines, and accuracy was worse. Slow and steady wins here.

Now, what if you’re stuck? If you’ve gone through all these steps and your model still isn’t performing, don’t just add more features—go back to your labels. Are your labels too vague? If you’re tagging “product” but your labels include both “laptop” and “laptop charger” that are easy to mix up, your features will never work. Refine your labels, then rework your feature list. That’s a fix I see all the time.

At the end of the day, choosing features for a CRF model is about being intentional, not exhaustive. It’s quality over quantity. If you pick the right features, your model will be fast, accurate, and easy to deploy on our CRF machines—no overengineering required.

If you’re currently building a CRF model and hit a wall with feature selection, or you’re looking to upgrade your setup to a CRF machine that can handle even complex, high-volume sequence labeling, reach out to our team to chat through your needs. We’ve supported teams in retail, manufacturing, healthcare, and more, and we can help you align your feature choices with the right tools to make your project a success.

Stacker References

  1. Lafferty, J., McCallum, A., & Pereira, F. (2001). Conditional random fields: Probabilistic models for segmenting and labeling sequence data. Proceedings of the 18th International Conference on Machine Learning.
  2. Sha, F., & Pereira, F. (2003). Shallow parsing with conditional random fields. Proceedings of the 2003 Conference of the North American Chapter of the Association for Computational Linguistics on Human Language Technology.
  3. Kudo, T., & Matsumoto, Y. (2001). Chunking with support vector machines. Proceedings of the 2nd Meeting of the North American Chapter of the Association for Computational Linguistics.
  4. McCallum, A. (2002). Mallet: A machine learning for language toolkit. Technical Report, University of Massachusetts Amherst.

Wuxi Yuanding Machinery Manufacturing Co., Ltd.
We’re well-known as one of the leading crf machine manufacturers and suppliers in China, also support customized service. Please feel free to buy advanced crf machine made in China here from our factory. For pricelist, contact us now.
Address: Yaguang Industrial Park, No.88 Chaoyang South Road, Xishan District, Wuxi City, Jiangsu Province
E-mail: 13861798466@163.com
WebSite: https://www.wxyuanding.com/