← all repositories
eagle705/pytorch-bert-crf-ner

Korean NER with BERT's brains and CRF's discipline

A PyTorch implementation that bolts a Conditional Random Field onto KoBERT so Korean named-entity recognition stops hallucating invalid tag sequences.

505 stars Jupyter Notebook Language ModelsML Frameworks
pytorch-bert-crf-ner
Velocity · 7d
+0.2
★ / day
Trend
steady
star history

What it does

This is a Korean named-entity recognizer built from SKTBrain’s KoBERT with a CRF layer strapped on top. It tags entities like people (PER), locations (LOC), dates (DAT), organizations (ORG), and various proper nouns (POH) in Korean text. The repo includes training code, inference examples, and attention visualizations — all in Jupyter notebooks running PyTorch 1.2+.

The interesting bit

The CRF is the quiet hero here. BERT spits out per-token probabilities, but those don’t know that an I-PER can’t follow a B-LOC. The CRF layer enforces those structural constraints at decode time, which matters for Korean where morpheme-level tokenization can fragment entities unpredictably.

Key highlights

  • Built on KoBERT, not multilingual BERT — uses SKTBrain’s Korean-specific pretrained weights
  • CRF layer for globally consistent BIO tag decoding
  • Attention visualization included (the 11-layer GIF shows where the model looks)
  • Handles tricky cases: movie titles with mixed scripts, URLs tagged as POH, nested parentheses
  • Training accuracy/loss and confusion matrix plots provided

Caveats

  • README warns that tokenization can outgrow entities, causing extraction failures — the subword tokenizer may split a single entity into more tokens than the entity itself contains
  • PyTorch 1.2 is specified; modern environments will need version bumps
  • Code is notebook-centric, not a packaged library

Verdict

Worth a look if you’re doing Korean NER and want a solid, explained baseline with the CRF guardrail. Skip if you need production-grade packaging or multilingual support — this is a research reference implementation, not a framework.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.