BGM Tagger BiLSTM
A small character-level bidirectional LSTM sequence tagger for parsing anime release filenames into structured entities. Given a raw filename, it tags every character with a BIO label and reconstructs an XML fragment such as:
[LoliHouse] 婚戒物语 / Kekkon Yubiwa Monogatari - 01 [WebRip 1080p HEVC-10bit AAC][简繁内封字幕]
[<ReleaseGroup>LoliHouse</ReleaseGroup>] <TitleEntity>婚戒物语</TitleEntity> / <TitleEntity>Kekkon Yubiwa Monogatari</TitleEntity> - <Episode>01</Episode> [<SourceEntity>WebRip</SourceEntity> <Resolution>1080p</Resolution> <VideoCodec>HEVC</VideoCodec>-<VideoDepth>10bit</VideoDepth> <AudioCodec>AAC</AudioCodec>][<SubtitleLanguage>简繁</SubtitleLanguage><SubtitleFormat>内封</SubtitleFormat>字幕]
Quick start
uv add bgm-tagger
# or
pip install bgm-tagger
from bgm_tagger import BiLSTM
model = BiLSTM.from_pretrained("jiangzhexin/bgm-tagger-bilstm")
model.eval()
# Move to GPU if available
model.to("cuda")
text = "【喵萌奶茶屋】★01月新番★[迷宫饭 / Dungeon Meshi / Delicious in Dungeon][12][1080p][简日双语][招募翻译时轴]"
# One XML fragment per input filename
print(*model.predict(text), sep="\n")
# Or raw BIO tag sequences
print(*model.predict(text, return_type="bio"), sep="\n")
The output for the example above is:
【<ReleaseGroup>喵萌奶茶屋</ReleaseGroup>】★01月新番★[<TitleEntity>迷宫饭</TitleEntity> / <TitleEntity>Dungeon Meshi</TitleEntity> / <TitleEntity>Delicious in Dungeon</TitleEntity>][<Episode>12</Episode>][<Resolution>1080p</Resolution>][<SubtitleLanguage>简日</SubtitleLanguage>双语][招募翻译时轴]
Model architecture
A character-level sequence tagger with no subword tokenization or pretrained embeddings. Each filename is encoded as a sequence of character ids, processed by a two-layer bidirectional LSTM, and decoded with BIO transition constraints.
| Component | Configuration |
|---|---|
| Tokenizer | Character vocabulary (1,750 chars + <PAD> + <UNK>) |
| Embedding | nn.Embedding(1752, 256), padding_idx=0 |
| Dropout | 0.25 |
| Encoder | 2-layer bidirectional LSTM, hidden size 256, dropout 0.25 |
| Classifier | Linear(512, 25) over the concatenated forward/backward states |
| Decoding | Constrained Viterbi-style decoding with hard BIO transition rules |
| Parameters | ~3.09M (all trainable) |
Labels
The model predicts 25 labels: B-/I- prefixes for 12 entity types plus O.
| Entity | Example |
|---|---|
TitleEntity |
迷宫饭, Dungeon Meshi |
Episode |
01, 01-13 |
Season |
Season 2, S1-S4 |
ReleaseGroup |
LoliHouse, VCB-Studio, 喵萌奶茶屋 |
SourceEntity |
WebRip, BDRip, WEB-DL, Baha |
Resolution |
1080p, 720p |
VideoCodec |
HEVC, AVC |
AudioCodec |
AAC, FLAC |
VideoDepth |
10bit, 8bit |
SubtitleLanguage |
简日, 简繁, CHT |
SubtitleFormat |
内封, ass |
Version |
v2 |
Training procedure
The model was trained on
jiangzhexin/bgm-bio-xml,
a dataset of 10,000 anime release filenames annotated with BIO/XML entities.
| Hyperparameter | Value |
|---|---|
| Train / validation / test split | 7,225 / 1,275 / 1,500 (last 15% held out as test; the rest shuffled 85/15) |
| Optimizer | AdamW (lr=0.001, weight_decay=1e-4) |
| Learning rate scheduler | ReduceLROnPlateau (factor=0.5, patience=2, min_lr=5e-5) |
| Batch size | 128 |
| Max epochs | 40 (early stopping with patience=8, min_delta=1e-4) |
| Seed | 42 |
Training stopped early after 18 epochs. The checkpoint restored for evaluation is the one with the best validation entity micro-F1.
Evaluation
Metrics are computed on the held-out test split (1,500 examples).
| Metric | Value |
|---|---|
| Test loss | 0.0054 |
| Entity micro-F1 | 0.9987 |
| Exact-match accuracy | 0.984 |
- Entity micro-F1 counts exact entity spans (type + boundaries) across all sequences.
- Exact-match accuracy is the fraction of filenames whose predicted entity set matches the gold entity set exactly.
Best validation entity micro-F1 during training: 0.9988 (epoch 17).
Limitations
- The model is trained on
nyaa.sianime release filenames and may not generalize to other naming conventions. - It tags characters, so unusual symbols outside the training vocabulary are
mapped to
<UNK>. - Decoding uses hard BIO constraints rather than a learned CRF, so label transition probabilities are not modeled.
- Downloads last month
- 30