dejanseo commited on
Commit
e1dcbdf
·
verified ·
1 Parent(s): c56ff7c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +116 -0
README.md CHANGED
@@ -1,5 +1,121 @@
1
  ---
 
 
2
  license: other
3
  license_name: link-attribution
4
  license_link: https://dejanmarketing.com/link-attribution/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - nl
4
  license: other
5
  license_name: link-attribution
6
  license_link: https://dejanmarketing.com/link-attribution/
7
+ library_name: transformers
8
+ tags:
9
+ - token-classification
10
+ - link-prediction
11
+ - seo
12
+ - dutch
13
+ - mdeberta
14
+ base_model: microsoft/mdeberta-v3-base
15
+ datasets:
16
+ - custom
17
+ metrics:
18
+ - f1
19
+ - precision
20
+ - recall
21
+ pipeline_tag: token-classification
22
  ---
23
+
24
+ # LinkjeBERT
25
+
26
+ A Dutch language model that predicts where a human editor would place a hyperlink in plain text. Given a passage, LinkjeBERT3 returns per-token confidence scores indicating how likely each word is to be part of a link anchor.
27
+
28
+ Developed by [DEJAN AI](https://dejan.ai).
29
+
30
+ Read the full write-up: [LinkjeBERT: A Dutch Language Model for Link Prediction](https://dejan.ai/blog/linkjebert/)
31
+
32
+ ## How It Works
33
+
34
+ LinkjeBERT3 is a binary token classifier fine-tuned on `microsoft/mdeberta-v3-base`. Every token is classified as either **O** (not a link) or **LINK** (part of a link anchor). The model outputs probabilities rather than hard labels, enabling heatmap-style visualization and tuneable thresholds for production pipelines.
35
+
36
+ ## Key Innovation: Markdown-Aware Training
37
+
38
+ Unlike its English predecessor [LinkBERT](https://linkbert.com), LinkjeBERT3 is trained on **structure-preserving Markdown** rather than flat text. The training data retains headings (`#`, `##`), bold (`**`), italics (`*`), lists (`-`), and blockquotes (`>`). This gives the model the same structural context a human editor uses when deciding where a link belongs.
39
+
40
+ ## Training Details
41
+
42
+ | Parameter | Value |
43
+ |---|---|
44
+ | Base model | `microsoft/mdeberta-v3-base` |
45
+ | Task | Binary token classification (O / LINK) |
46
+ | Loss function | Focal loss (γ=2.0) |
47
+ | Training tokens | 200M |
48
+ | Training sources | 5 Dutch editorial domains (news, tech, science, business, lifestyle) |
49
+ | Learning rate | 2e-5 with linear warmup (10%) |
50
+ | Batch size | 32 (16 × 2 gradient accumulation) |
51
+ | Epochs | 10 (early stopping, patience 3, monitoring F1) |
52
+ | Precision | bf16 |
53
+ | Max sequence length | 512 |
54
+ | Hardware | NVIDIA RTX 4090 |
55
+
56
+ ## Usage
57
+
58
+ ```python
59
+ from transformers import AutoModelForTokenClassification, AutoTokenizer
60
+ import torch
61
+
62
+ model_id = "dejanseo/LinkjeBERT3"
63
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
64
+ model = AutoModelForTokenClassification.from_pretrained(model_id)
65
+ model.eval()
66
+
67
+ text = "De minister liet weten dat het plan doorgaat."
68
+ inputs = tokenizer(text, return_tensors="pt", return_offsets_mapping=True)
69
+ offsets = inputs.pop("offset_mapping")[0]
70
+
71
+ with torch.no_grad():
72
+ logits = model(**inputs).logits
73
+ probs = torch.softmax(logits, dim=-1)[0, :, 1]
74
+
75
+ for i, (start, end) in enumerate(offsets):
76
+ if start == end:
77
+ continue
78
+ word = text[start:end]
79
+ p = probs[i].item()
80
+ if p > 0.1:
81
+ print(f"{word:20s} {p:.1%}")
82
+ ```
83
+
84
+ ## Long Document Inference
85
+
86
+ For documents exceeding 512 tokens, use a sliding window with overlap:
87
+
88
+ - `MAX_LENGTH = 512`
89
+ - `DOC_STRIDE = 128`
90
+ - Aggregate overlapping token probabilities with `np.maximum`
91
+
92
+ This ensures consistent predictions across article-length text.
93
+
94
+ ## Input Format
95
+
96
+ Feed the model **Markdown-formatted plain text with links stripped**. The model was trained on editorial content where existing `<a>` tags were removed, so it predicts link placement from context alone. Preserve structural markers (`#`, `**`, `-`, `>`) as the model relies on them.
97
+
98
+ ## Labels
99
+
100
+ | ID | Label |
101
+ |---|---|
102
+ | 0 | O |
103
+ | 1 | LINK |
104
+
105
+ ## Intended Use
106
+
107
+ - Anchor text suggestion for internal linking
108
+ - Evaluating naturalness of existing link placements
109
+ - Link placement guidance for content writers
110
+ - Detection of unnatural or spammy link patterns
111
+
112
+ ## Citation
113
+
114
+ ```
115
+ @misc{linkjebert2026,
116
+ title={LinkjeBERT: A Dutch Language Model for Link Prediction},
117
+ author={DEJAN AI},
118
+ year={2026},
119
+ url={https://dejan.ai/blog/linkjebert/}
120
+ }
121
+ ```