Transformer-Based Search Intent Classification with BART Zero-Shot & SERP Signals (Colab Notebook)
Three-signal hybrid pipeline that fuses rule-based regex patterns, SERP feature percentage breakdowns (70+ features mapped), and Facebook BART-large-MNLI zero-shot transformer classification into one final intent label
Production-grade engineering: batched inference, lazy model loading, automatic GPU detection via PyTorch, precompiled regex patterns, and Hugging Face transformers pipeline integration
Full transparency in the output—every row shows the rule-based label, SERP percentages per intent category, the combined transformer input, and the final classification, so you can audit exactly why each query got its label
When rule-based classifiers hit their ceiling and entity-based methods need an extra layer of nuance, transformers step in. This Google Colab notebook by Lazarina Stoy, part of the Semantic ML-enabled Keyword Research Course, builds a hybrid search intent classifier that fuses three signals—rule-based keyword patterns, SERP feature distributions, and zero-shot transformer inference—into a single, robust intent prediction for each query.
The notebook is built around a SearchIntentClassifier class powered by Facebook’s BART-large-MNLI model running zero-shot classification through the Hugging Face transformers pipeline. For each keyword, the script first runs precompiled regex patterns against the query text to generate a rule-based label across Informational, Transactional, Commercial, and Navigational categories. It then processes the associated SERP features, mapping over 70 features (AI Overview, Featured Snippet, Shopping Results, Local Pack, Carousel, Knowledge Graph, Reviews, Top Ads, and many more) to intent categories and computing percentage breakdowns. All three signals—the original query, the rule-based label, and the SERP percentage breakdown—are fused into a single combined input string that’s passed to the transformer for the final classification. The script is built for scale: batch processing, lazy model loading, automatic GPU detection via PyTorch, and efficient regex precompilation. It outputs a CSV with the final intent, rule-based label, SERP percentage columns for every category, and the combined transformer input, plus pie and bar chart visualizations of the intent distribution.
Use this for:
‧ Classifying search intent with state-of-the-art transformer accuracy without training a model from scratch
‧ Combining heuristic, statistical, and deep learning signals into one classification pipeline that’s more accurate than any single method alone
‧ Processing large keyword sets efficiently with batched inference, GPU acceleration, and lazy model loading
‧ Getting both a final intent label and full transparency into the rule-based and SERP-feature signals that informed it
‧ Building advanced SEO classification systems that go beyond keyword matching to incorporate live SERP intelligence
This is perfect for technical SEO professionals, ML-curious marketers, and data scientists working on search who want a production-ready hybrid classification pipeline that combines the speed of rules, the realism of SERP signals, and the contextual intelligence of transformer models—no model training required.
What’s Included
- Three-signal hybrid pipeline that fuses rule-based regex patterns, SERP feature percentage breakdowns (70+ features mapped), and Facebook BART-large-MNLI zero-shot transformer classification into one final intent label
- Production-grade engineering: batched inference, lazy model loading, automatic GPU detection via PyTorch, precompiled regex patterns, and Hugging Face transformers pipeline integration
- Full transparency in the output—every row shows the rule-based label, SERP percentages per intent category, the combined transformer input, and the final classification, so you can audit exactly why each query got its label
Created by
Semantic ML-enabled Keyword Research
This resource is part of a comprehensive course. Access the full curriculum and learning path.
View Full CourseGet Instant Access
Enter your email and we’ll send you the download link immediately.
