🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Information Extraction: Relations, Events, and Knowledge

Natural Language ProcessingInformation Extraction: Relations, Events, and KnowledgeđŸŸĸ Free Lesson

Information Extraction: Relations, Events, and Knowledge

What You'll Learn

  • 1Label entities with a token classification head and decode BIO sequences
  • 2Score relations between two spans and handle the dominant no relation class
  • 3Compute micro and macro F1 for imbalanced extraction tasks
  • 4Embed triples so that a knowledge graph score measures plausibility

Information extraction converts unstructured text into structured records: entity mentions with types, relations between pairs, and events with participants. Downstream systems then query tables instead of prose, which is why extraction quality directly bounds every analytics or search feature built on top. This lesson walks the three extraction stages, the imbalance traps in their metrics, and the graph embeddings that turn triples into distances.

Named Entity Recognition

A sequence labeler assigns a tag to every token, and the BIO scheme marks whether a token begins an entity, continues one, or is outside:

A transformer encoder produces one state per token and a linear head scores the tag set, so NER is per sequence with a small constant. CoNLL-2003 defines the classic four type setup of person, organization, location, and miscellaneous, and modern benchmarks add nested entities, discontinuous spans, and fine grained types that require span classification instead of per token tags.

Real systems fail in predictable ways: coordinated entities such as "Paris and Berlin" get one span, aliases like "IBM" and "Big Blue" resolve to one entity only after linking, and rare surnames split across lines break offset alignment. Normalization, splitting, and coreference each address a different one of those.

Relation and Event Extraction

Relation extraction scores an ordered pair of spans against a fixed label set, usually with a classifier over the concatenated head, relation, and tail representations:

TACRED defines 41 relation types plus a dominant no relation class, so accuracy alone is misleading: a model that always predicts no relation scores above 80 percent while extracting nothing. FewRel pushes to 700 fine grained types, which is the low resource regime where the model must learn from very few examples per type.

DatasetScaleStructureWhat it tests
TACRED100,000 plus sentencestyped entity pairsnoise and class imbalance
FewRel700 relation typesone per sentencefew shot classification
DocRED132,978 relations, 5,053 docscross sentencedocument level reasoning
ACE 20058 types, 33 subtypestriggers and argumentsevent structure

Event extraction is two headed: a trigger classifier picks the verb or noun that fires the event, and argument roles fill in who did what to whom. Because triggers are rare compared to background verbs, class weights and hard negative mining matter more than architecture choice.

Scoring Extraction Systems

Micro pooling counts every mention before computing scores, so frequent classes dominate. Macro averages per class F1, so a rare relation type moves the number:

Exact match scoring means an entity predicted as two overlapping spans counts as one false positive and one false negative, which is why offset bugs dominate error analyses. Report both metrics: micro F1 tracks production volume, macro F1 catches a collapsed rare class.

Knowledge Graph Embeddings

Once triples are extracted, embedding models score whether a fact is plausible. TransE places entities and relations in one vector space and treats a relation as a translation:

ModelScore functionCost per triple
TransE
RotatE
ComplEx

Training corrupts the tail with a random entity and pushes the true triple's score above the corrupted one with a margin or logistic loss. That objective scores plausibility, not truth, so a link predictor proposes candidates that a human or a source document must confirm.

Worked Examples

Worked Code

python
"""Named entity recognition with offsets preserved."""
from transformers import pipeline

ner = pipeline("ner", model="dslim/bert-base-NER", aggregation_strategy="simple")
text = "Ada Lovelace worked in London for Charles Babbage."
for ent in ner(text):
    print(ent["entity_group"], ent["word"], ent["start"], ent["end"],
          round(ent["score"], 3))
python
"""Exact match scoring for extracted spans and relations."""
from collections import Counter


def span_f1(pred, gold):
    tp = len(set(pred) & set(gold))
    fp, fn = len(set(pred) - set(gold)), len(set(gold) - set(pred))
    precision = tp / (tp + fp) if tp + fp else 0.0
    recall = tp / (tp + fn) if tp + fn else 0.0
    f1 = 2 * precision * recall / (precision + recall) if precision + recall else 0.0
    return round(precision, 3), round(recall, 3), round(f1, 3)


pred = [("Paris", "LOC"), ("Ada Lovelace", "PER"), ("London", "LOC")]
gold = [("Paris", "LOC"), ("Ada Lovelace", "PER"), ("Charles Babbage", "PER")]
print(span_f1(pred, gold))
print(Counter(label for _, label in gold))

Real-World Applications

  • Financial screening - Analysts extract company, regulator, and event relations from filings to populate risk dashboards.
  • Clinical notes - Discontinuous entity tagging pulls dosage, drug, and condition mentions into trial matching tools.
  • Search indexing - Entity linking turns queries into graph lookups so results include the entity page, not just keyword hits.
  • Fraud graphs - Account, address, and phone relations from messages feed link analysis before any model runs.

💡Publish the metric and the class distribution

Extraction sets are dominated by negative classes, so a headline F1 without the label distribution hides whether the model learned anything. Always report micro and macro F1 together.

Common Mistakes

Using accuracy on relation data

Fix: No relation dominates, so report macro F1 over the real relation types instead.

Evaluating on token tags with different offsets

Fix: Convert predictions to character offsets before scoring, otherwise split tokens inflate false negatives.

Dropping rare event types

Fix: Weight classes or mine hard negatives, because rare triggers are exactly the ones worth catching.

Best Practices

  • Score at character offsets with exact match before any soft overlap metric
  • Report micro and macro F1 with the label histogram
  • Separate extraction quality from link prediction quality when evaluating a graph pipeline

Key Takeaways

  • BIO decoding makes NER a linear cost token classification problem
  • TACRED adds 41 relation types plus a dominant no relation class, so accuracy misleads
  • Micro F1 pools mentions while macro F1 averages per class F1
  • TransE scores a triple as the distance between h plus r and t, and training corrupts tails

Frequently Asked Questions

Why not just use accuracy for extraction?

Because a system predicting no relation everywhere already scores high. F1 over the positive classes measures whether extraction happened at all.

When does span classification beat BIO tagging?

With nested or discontinuous entities, where one token legitimately belongs to two spans. The cost is quadratic candidate generation and a more complex decoder.

Does a high embedding score mean the fact is true?

No. It means the triple fits the geometry learned from the graph, so predictions need verification against a source document before they reach users.

Interview Questions

Q1: How do you evaluate a relation extractor on TACRED?

Macro F1 over the relation types with no relation treated as one class, plus micro F1, because accuracy is dominated by no relation and hides collapsed rare types.

Q2: A tagger scores 96 percent token accuracy but weak span F1. What is wrong?

Outside tokens dominate the token count, so accuracy looks strong while boundary errors split spans, which exact match scoring counts as a miss and a false positive.

CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-07

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert NLP Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement