Token Classification
Transformers
ONNX
Safetensors
English
Japanese
Chinese
bert
anime
filename-parsing
Eval Results (legacy)
Run this model with HF Jobs
Run ModerRAS/AniFileBERT on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/ModerRAS/AniFileBERT. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/ModerRAS/AniFileBERT on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use ModerRAS/AniFileBERT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ModerRAS/AniFileBERT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="ModerRAS/AniFileBERT")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("ModerRAS/AniFileBERT") model = AutoModelForTokenClassification.from_pretrained("ModerRAS/AniFileBERT", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Tighten DMHY low-frequency special cases
Browse files200 unmodified lines2012022032042052062072082091977 unmodified lines21872188218921902191219221932 unmodified lines2196219721982199220022014 unmodified lines220622072208220922102211174 unmodified lines238623872388238923902391113 unmodified lines250525062507250825092510251119 unmodified lines253125322533253425352536253725382539184 unmodified lines27242725272627272728272927302731273227332734163 unmodified lines2898289929002901290229032904290529062907290843 unmodified lines29522953295429552956295724 unmodified lines298229832984298529862987717 unmodified lines37053706370737083709200 unmodified linesstatic CJK_SEASON_EMBEDDED_RE: Lazy<Regex> = Lazy::new(|| {Regex::new(r"^(.+?)(第[一二三四五六七八九十\d]+[季期部])(.{0,12})$").unwrap()});static SEASON_VALUE_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"(?i)^S(\d{1,2})$").unwrap());static SPECIAL_RE: Lazy<Regex> = Lazy::new(|| {Regex::new(r"(?i)^(?:(?:NCOP|NCED|OP|ED|PV|CM)(?:[\s_.-]?(?:\d{1,4}|v\d{1,3}|[A-Z]))?|SP(?:[\s_.-]?\d{0,4})?|(?:OVA|OAD|IV)(?:[\s_.-]?\d{0,4})?|(?:Menu|Intro|Preview|Trailer|Teaser|Animatics?)(?:[\s_.-]?(?:\d{0,4}|Ep\d{1,4}|[A-Z]))?)$").unwrap()});static VOLUME_RE: Lazy<Regex> =Lazy::new(|| Regex::new(r"(?i)^(?:Vol(?:ume)?\.?|Disc|CD|BD|DVD|D)\s*\d{1,3}$").unwrap());1977 unmodified lines| "THEATER GREETING EVENT"| "TOKUTEN"| "TRAILER"| "WORLD PREMIERE"| "番宣"| "宣番"| "映像特典"2 unmodified lines|| normalized.contains("特典映像")|| normalized.contains("番宣")|| normalized.contains("宣番")|| SPECIAL_TITLE_PHRASE_RE.is_match(text)}4 unmodified lines&["Zom", "100"],&["Kamisama", "Hajimemashita", "2"],&["Phantasy", "Star", "Online", "2", "Episode", "Oracle"],&["Lupin The Thrid Jigen Daisuke no Bohyou"],&["Lupin The Third Jigen Daisuke no Bohyou"],];174 unmodified linesif output[index] == "O" && groups[index].class_name.contains("SXE") {output[index] = "EPISODE".to_string();}if roles[index].starts_with("EPISODE") && YEAR_RANGE_RE.is_match(&text) {output[index] = "O".to_string();continue;113 unmodified lines}}if roles[index].starts_with("EPISODE")&& text.chars().all(|ch| ch.is_ascii_digit())&& output[..index].iter().any(|role| role == "SPECIAL")&& !output[..index].iter().any(|role| role.starts_with("EPISODE")){19 unmodified lines&& groups[index - 1].class_name == "SEP"{let previous_text = group_text(tokens, &groups[index - 2]);if previous_text.chars().any(|ch| ch.is_ascii_digit() || matches!(ch, '.' | '-' | '_' | '.')){output[index] = "RESOLUTION".to_string();continue;184 unmodified lines|| previous_text.contains("下午")|| previous_text.contains('年')|| previous_text.contains('月')|| next_text.contains('点')|| next_text.contains('點')|| next_text.contains('半')|| next_text.contains('月')|| next_text.contains('日'){output[index] = "O".to_string();}163 unmodified lineslabels.push("O".to_string());continue;}if CJK_SEASON_TOKEN_RE.is_match(&piece) {output_pieces.push(piece);labels.push("B-SEASON".to_string());continue;}if let Some(caps) = CJK_SEASON_EMBEDDED_RE.captures(&piece) {let before = caps.get(1).map(|m| m.as_str()).unwrap_or_default();let season = caps.get(2).map(|m| m.as_str()).unwrap_or_default();43 unmodified lines.is_some_and(|ch| ch.is_whitespace() || !ch.is_alphanumeric())}fn project_refined_tokens(tokens: &[String],groups: &[Group],24 unmodified linescontinue;}}if matches!(role, "EPISODE" | "EPISODE_VERSION" | "EPISODE_RANGE") {if let Some((pieces, labels)) = split_sxe_token(&strip_wrapper(token)) {output_tokens.extend(pieces);717 unmodified linesassert!(doremi_bonus.contains(&("おジャ魔女どれみナ".to_string(), "B-TITLE".to_string())));assert!(doremi_bonus.contains(&("07".to_string(), "B-SPECIAL".to_string())));assert!(!doremi_bonus.contains(&("07".to_string(), "B-EPISODE".to_string())));}}200 unmodified lines2012022032042052062072082092102112122131977 unmodified lines2191219221932194219521962197219821992 unmodified lines220222032204220522062207220822094 unmodified lines2214221522162217221822192220174 unmodified lines239523962397239823992400240124022403240424052406240724082409241024112412113 unmodified lines2526252725282529253025312532253325342535253619 unmodified lines2556255725582559256025612562256325642565256625672568184 unmodified lines2753275427552756275727582759276027612762276327642765163 unmodified lines292929302931293229332934293529362937293829392940294129422943294429452946294729482949295043 unmodified lines2994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301624 unmodified lines3041304230433044304530463047304830493050305130523053717 unmodified lines377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812200 unmodified linesstatic CJK_SEASON_EMBEDDED_RE: Lazy<Regex> = Lazy::new(|| {Regex::new(r"^(.+?)(第[一二三四五六七八九十\d]+[季期部])(.{0,12})$").unwrap()});static ASCII_SEASON_SUFFIX_RE: Lazy<Regex> =Lazy::new(|| Regex::new(r"(?i)^(.+?)[\s_.-]+(S\d{1,2})$").unwrap());static CJK_TITLE_LANG_PREFIX_RE: Lazy<Regex> =Lazy::new(|| Regex::new(r"^(.+?)(国日双语|國日雙語|日语版|日語版|国语版|國語版|双语|雙語)(第?)$").unwrap());static SEASON_VALUE_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"(?i)^S(\d{1,2})$").unwrap());static SPECIAL_RE: Lazy<Regex> = Lazy::new(|| {Regex::new(r"(?i)^(?:(?:NCOP|NCED|OP|ED|PV|CM)(?:[\s_.-]?(?:\d{1,4}|v\d{1,3}|[A-Z]))?|SP(?:[\s_.-]?\d{0,4})?|(?:OVA|OAD|IV)(?:[\s_.-]?\d{0,4})?|(?:BD)?Menu(?:[\s_.-]?(?:\d{0,4}|Ep\d{1,4}|[A-Z]))?|(?:Intro|Preview|Trailer|Teaser|Animatics?)(?:[\s_.-]?(?:\d{0,4}|Ep\d{1,4}|[A-Z]))?)$").unwrap()});static VOLUME_RE: Lazy<Regex> =Lazy::new(|| Regex::new(r"(?i)^(?:Vol(?:ume)?\.?|Disc|CD|BD|DVD|D)\s*\d{1,3}$").unwrap());1977 unmodified lines| "THEATER GREETING EVENT"| "TOKUTEN"| "TRAILER"| "TV SPOT"| "WORLD PREMIERE"| "予告"| "番宣"| "宣番"| "映像特典"2 unmodified lines|| normalized.contains("特典映像")|| normalized.contains("番宣")|| normalized.contains("宣番")|| normalized.contains("TV SPOT")|| text.contains("予告")|| SPECIAL_TITLE_PHRASE_RE.is_match(text)}4 unmodified lines&["Zom", "100"],&["Kamisama", "Hajimemashita", "2"],&["Phantasy", "Star", "Online", "2", "Episode", "Oracle"],&["Ghiblies", "Episode", "2"],&["Lupin The Thrid Jigen Daisuke no Bohyou"],&["Lupin The Third Jigen Daisuke no Bohyou"],];174 unmodified linesif output[index] == "O" && groups[index].class_name.contains("SXE") {output[index] = "EPISODE".to_string();}if text.eq_ignore_ascii_case("TV") {let next_text = (index + 1..roles.len()).find(|&cursor| groups[cursor].class_name != "SEP").map(|cursor| (cursor, group_text(tokens, &groups[cursor])));if let Some((spot_index, spot_text)) = next_text {if spot_text.eq_ignore_ascii_case("Spot") {output[index] = "SPECIAL".to_string();output[spot_index] = "SPECIAL".to_string();continue;}}}if roles[index].starts_with("EPISODE") && YEAR_RANGE_RE.is_match(&text) {output[index] = "O".to_string();continue;113 unmodified lines}}if roles[index].starts_with("EPISODE")&& (text.chars().all(|ch| ch.is_ascii_digit())|| matches!(classify_atom(&text).as_str(),"EPISODE" | "EPISODE_VERSION"))&& output[..index].iter().any(|role| role == "SPECIAL")&& !output[..index].iter().any(|role| role.starts_with("EPISODE")){19 unmodified lines&& groups[index - 1].class_name == "SEP"{let previous_text = group_text(tokens, &groups[index - 2]);let next_sourceish = (index + 1..roles.len()).find(|&cursor| groups[cursor].class_name != "SEP").is_some_and(|cursor| matches!(roles[cursor].as_str(), "SOURCE" | "RESOLUTION"));if previous_text.chars().any(|ch| ch.is_ascii_digit() || matches!(ch, '.' | '-' | '_' | '.'))|| next_sourceish{output[index] = "RESOLUTION".to_string();continue;184 unmodified lines|| previous_text.contains("下午")|| previous_text.contains('年')|| previous_text.contains('月')|| previous_text.contains('秒')|| next_text.contains('点')|| next_text.contains('點')|| next_text.contains('半')|| next_text.contains('月')|| next_text.contains('日')|| next_text.contains('秒'){output[index] = "O".to_string();}163 unmodified lineslabels.push("O".to_string());continue;}if CJK_SEASON_TOKEN_RE.is_match(&piece) || SEASON_RE.is_match(&piece) {output_pieces.push(piece);labels.push("B-SEASON".to_string());continue;}if let Some(caps) = ASCII_SEASON_SUFFIX_RE.captures(&piece) {let before = caps.get(1).map(|m| m.as_str()).unwrap_or_default();let season = caps.get(2).map(|m| m.as_str()).unwrap_or_default();if !before.is_empty() {output_pieces.push(before.to_string());labels.push("B-TITLE".to_string());}output_pieces.push(season.to_string());labels.push("B-SEASON".to_string());continue;}if let Some(caps) = CJK_SEASON_EMBEDDED_RE.captures(&piece) {let before = caps.get(1).map(|m| m.as_str()).unwrap_or_default();let season = caps.get(2).map(|m| m.as_str()).unwrap_or_default();43 unmodified lines.is_some_and(|ch| ch.is_whitespace() || !ch.is_alphanumeric())}fn split_cjk_title_lang_prefix(token: &str) -> Option<(Vec<String>, Vec<String>)> {let caps = CJK_TITLE_LANG_PREFIX_RE.captures(token)?;let title = caps.get(1)?.as_str();let lang = caps.get(2)?.as_str();let marker = caps.get(3).map(|m| m.as_str()).unwrap_or_default();if title.chars().count() < 2 {return None;}let mut pieces = vec![title.to_string(), lang.to_string()];let mut labels = vec!["B-TITLE".to_string(), "B-SOURCE".to_string()];if !marker.is_empty() {pieces.push(marker.to_string());labels.push("O".to_string());}Some((pieces, labels))}fn project_refined_tokens(tokens: &[String],groups: &[Group],24 unmodified linescontinue;}}if role == "SOURCE" {if let Some((pieces, labels)) = split_cjk_title_lang_prefix(token) {output_tokens.extend(pieces);output_labels.extend(labels);continue;}}if matches!(role, "EPISODE" | "EPISODE_VERSION" | "EPISODE_RANGE") {if let Some((pieces, labels)) = split_sxe_token(&strip_wrapper(token)) {output_tokens.extend(pieces);717 unmodified linesassert!(doremi_bonus.contains(&("おジャ魔女どれみナ".to_string(), "B-TITLE".to_string())));assert!(doremi_bonus.contains(&("07".to_string(), "B-SPECIAL".to_string())));assert!(!doremi_bonus.contains(&("07".to_string(), "B-EPISODE".to_string())));let bd_menu =labels_for("[HYSUB]Kuusen Madoushi Kouhosei no Kyoukan[BDMenu][01v1][MP4][1280X720]");assert!(bd_menu.contains(&("BDMenu".to_string(), "B-SPECIAL".to_string())));assert!(bd_menu.contains(&("01v1".to_string(), "B-SPECIAL".to_string())));assert!(!bd_menu.contains(&("BDMenu".to_string(), "B-TITLE".to_string())));let ura_on = labels_for("K-ON !! (TV S2 2010). URA-ON !! 01; 1080_h264_flac");assert!(ura_on.contains(&("K".to_string(), "B-TITLE".to_string())));assert!(ura_on.contains(&("01".to_string(), "B-EPISODE".to_string())));assert!(ura_on.contains(&("1080".to_string(), "B-RESOLUTION".to_string())));assert!(!ura_on.contains(&("1080".to_string(), "B-EPISODE".to_string())));let machikado = labels_for("[KTXP][Machikado_Mazoku_S2][Mini][01][GB][1080p][BDrip][HEVC]");assert!(machikado.contains(&("Machikado".to_string(), "B-TITLE".to_string())));assert!(machikado.contains(&("S2".to_string(), "B-SEASON".to_string())));assert!(machikado.contains(&("01".to_string(), "B-EPISODE".to_string())));let ronin = labels_for("【蓝色狂想】魔神坛斗士国日双语第01集");assert!(ronin.contains(&("魔神坛斗士".to_string(), "B-TITLE".to_string())));assert!(ronin.contains(&("国日双语".to_string(), "B-SOURCE".to_string())));assert!(ronin.contains(&("01".to_string(), "B-EPISODE".to_string())));let ghiblies = labels_for("Ghiblies - Episode 2 op");assert!(ghiblies.contains(&("Ghiblies".to_string(), "B-TITLE".to_string())));assert!(ghiblies.contains(&("2".to_string(), "B-TITLE".to_string())));assert!(!ghiblies.contains(&("2".to_string(), "B-EPISODE".to_string())));let tv_spot = labels_for("[RUELL-Next] Fruits Basket TV Spot 1 (DVD 768x576 x264 AAC) [49531416]");assert!(tv_spot.contains(&("TV".to_string(), "B-SPECIAL".to_string())));assert!(tv_spot.contains(&("1".to_string(), "B-SPECIAL".to_string())));assert!(!tv_spot.contains(&("1".to_string(), "B-EPISODE".to_string())));let preview_seconds =labels_for("[DVD] 鋼鉄天使くるみ 予告 第03話 30秒バージョン (640x480 WMV9)");assert!(preview_seconds.contains(&("03".to_string(), "B-EPISODE".to_string())));assert!(!preview_seconds.contains(&("30".to_string(), "B-EPISODE".to_string())));}}
tools/rust_dmhy_template_apply/src/main.rs+106-3