Prompt
How do I build a page scoring model for AI extractability?
Latest observation
A good page scoring model for AI extractability answers one question:
“How likely is this page to be accurately and usefully extracted by AI systems?”
You can build it as a supervised model if you have labels, or as a heuristic/rule-based scorecard if you don’t. The best approach is usually a hybrid.
1) Define “extractability”
First, be explicit about what “extractable” means for your use case.
Common targets:
- Text extraction quality: Can the main content be identified?
- Semantic completeness: Are key facts, entities, and relationships recoverable?
- Structured extraction: Can AI reliably pull fields like product name, price, author, dates, FAQs?
- Summarization readiness: Is the page easy for an AI to summarize without missing context?
- Grounded QA readiness: Can an AI answer questions from the page with low ambiguity?
You may want one overall score, or separate sub-scores:
- Main content clarity
- Boilerplate noise
- Structural markup quality
- Media/table readability
- Entity/attribute completeness
- Accessibility/semantic signals
2) Choose a scoring strategy
Option A: Heuristic scorecard
Best if you need something fast and explainable.
Score each page from 0–100 using features like:
- Text-to-HTML ratio
- Amount of boilerplate/nav/footer content
- Presence of headings (
h1-h3) - Semantic tags (
article,main,section) - Structured data (
schema.org, JSON-LD) - Readability metrics
- Duplicate content
- Page length / content density
- Table/image dependence
- Language consistency
- Broken or missing metadata
Then combine them with weights.
Example: [ Score = 100 \cdot \sum_i w_i \cdot f_i ] where each ( f_i ) is normalized to 0–1.
Option B: Supervised ML model
Best if you can create training labels from real extraction outcomes.
Labels could be:
- Human rating of extractability
- Success/failure of downstream extraction
- F1 score for fields extracted by a baseline system
- QA accuracy over page-derived questions
- Human judgment of “AI-readable”
Model choices:
- Gradient boosting on engineered features
- Logistic regression for interpretability
- Ranker if comparing pages
- Neural model if you want to use raw DOM/text embeddings
A strong practical choice is:
- LightGBM/XGBoost on page features + text/DOM statistics
3) Collect training data
Build a labeled dataset
Sample pages across:
- Blogs, docs, product pages, news, ecommerce, support pages
- High-quality and low-quality pages
- Different languages and devices
- Pages with JS-rendered content and static content
For each page, store:
- Raw HTML
- Rendered DOM
- Extracted text
- Metadata
- Schema markup
- Screenshot if useful
- Labels
Labeling methods
- Human annotation: “How easy is this to extract?”
- Task-based labels: Ask an extractor to pull fields; measure accuracy
- Proxy labels: Compare against trusted reference text or structured data
A useful label rubric:
- 0 = unusable
- 1 = very poor
- 2 = poor
- 3 = okay
- 4 = good
- 5 = excellent
4) Engineer features that matter
Here are the most useful feature groups.
A. Content density
- Word count
- Sentence count
- Text-to-HTML ratio
- Main content proportion vs boilerplate
- Avg words per paragraph
- Repeated template text percentage
B. Structural quality
- Presence of
main,article,header,footer - Heading hierarchy quality
- Number of sections/subsections
- List/table presence
- DOM depth and clutter
C. Readability and language clarity
- Flesch reading score
- Average sentence length
- Grammar/spelling error rate
- Language detection confidence
- Token repetition rate
D. Semantic markup and metadata
- JSON-LD presence and validity
- OpenGraph/Twitter metadata
- Schema.org type coverage
- Canonical URL, title, description
- Alt text coverage for images
E. Noise and ambiguity
- Ad/script density
- Popup/interstitial presence
- Navigation/link density
- Duplicate content
- Hidden text
- Excessive CSS/JS relative to content
F. Extraction friendliness
- Clear labels/values for fields
- Tables with explicit headers
- FAQs in Q/A structure
- Bullet lists instead of embedded prose
- Stable DOM selectors / predictable structure
G. Media dependence
- Critical information only in images/PDFs
- OCR necessity
- Chart-only or infographic-heavy content
- Video-only content without transcript
5) Normalize and combine features
Convert each feature to a comparable range, usually 0–1.
Examples:
- High text-to-HTML ratio = better
- High ad/script density = worse
- More semantic markup = better
You can use:
- Linear scaling
- Sigmoid transforms
- Quantile normalization
- Threshold-based scoring for categorical signals
Example weighted score:
extractability =
0.20 * content_density +
0.15 * structural_quality +
0.15 * semantic_markup +
0.15 * readability +
0.15 * low_noise +
0.10 * field_clarity +
0.10 * media_accessibility +
0.05 * metadata_completeness
6) Train the model
If using ML:
- Split by site/domain to avoid leakage
- Use cross-validation across domains
- Calibrate scores so they map to intuitive probability/quality bands
- Track feature importance
Good targets:
- Regression: predict 0–5 quality score
- Classification: “extractable” vs “not extractable”
- Ordinal regression: if labels are ordered
Evaluation metrics:
- AUC / accuracy for classification
- RMSE / MAE for regression
- Spearman correlation for ranking
- Calibration error if you want probabilities
7) Validate on real extraction tasks
This is crucial. A page score is only useful if it predicts downstream success.
Run a pipeline like:
- Take a set of pages
- Try extraction with your AI system
- Measure:
- field accuracy
- hallucination rate
- answer correctness
- coverage of required facts
- Check whether higher-scored pages actually do better
If the score doesn’t correlate with extraction quality, revise features/labels.
8) Make the score actionable
Don’t just output a number. Provide:
- Overall score
- Subscores
- Reason codes, e.g.:
- “High script noise”
- “No semantic headings”
- “Critical info embedded in image”
- “Strong JSON-LD present”
- “Main content clearly isolated”
This makes the model useful for:
- Prioritizing crawl/indexing
- Page remediation
- Choosing extraction strategies
- Deciding whether to send page to OCR, HTML parser, or multimodal model
9) Example simple scoring rubric
Here’s a practical starting point:
| Component | Weight | Signal |
|---|---|---|
| Main content clarity | 25% | headings, paragraph structure, low boilerplate |
| Noise suppression | 20% | low nav/ad/script density |
| Semantic markup | 15% | schema.org, article/main tags |
| Text quality | 15% | readability, language consistency |
| Field/relationship clarity | 15% | tables, lists, Q&A patterns |
| Media accessibility | 10% | alt text, OCR need, transcripts |
| Metadata completeness | 5% | title, description, canonical |
Score each 0–1, multiply by weights, scale to 100.
10) Practical architecture
A good production setup:
- Crawler: fetch HTML + rendered DOM
- Feature extractor: compute page signals
- Scorer: heuristic or ML model
- Explainer: output reason codes
- Feedback loop: compare with extraction outcomes and retrain
11) Common pitfalls
- Optimizing for “clean HTML” instead of actual extraction success
- Using only visible text and ignoring structure/semantics
- Not separating site-specific patterns from general quality
- Training on too few domains
- Failing to account for JS-rendered content
- Ignoring images/PDFs/transcripts
- Overweighting metadata that looks good but doesn’t help extraction
12) Best starting point
If you’re starting from scratch:
- Build a heuristic scorecard
- Collect extraction outcomes on a sample set
- Train a LightGBM model on engineered features
- Validate against downstream extraction performance
- Add explanation strings for each score
If you want, I can also help you with one of these:
- a feature list and schema
- a scoring formula
- a Python prototype
- a LightGBM training pipeline
- a labeling rubric for human raters