Model Card for youtube-audiobook-title-parser

youtube-audiobook-title-parser is a lightweight model fine-tuned from Qwen/Qwen2.5-0.5B-Instruct designed to parse noisy YouTube and audiobook track titles into structured JSON containing the book title, author, and channel or show name.

It reliably separates entities across multi-delimiter titles (|, -, :), handles channel-first and franchise prefix variations (e.g., เฆฎเฆฟเฆธเฆฟเฆฐ เฆ†เฆฒเฆฟ, เฆซเง‡เฆฒเงเฆฆเฆพ, เฆฌเงเฆฏเง‹เฆฎเฆ•เง‡เฆถ), strips episode noise (1/2, เงงเฆฎ เฆชเฆฐเงเฆฌ, Part 1), and preserves original Bengali script without unwanted translation or phonetic transliteration.


Available Model Formats

File Format Size Best For
model.safetensors FP16 ~980 MB Transformers, PyTorch, HF Serverless API, GPU inference
model-q4_k_m.gguf Q4_K_M ~380 MB llama.cpp, fast CPU inference, mobile/desktop local apps

How to Get Started

Option 1: Using Transformers (GPU / Serverless)

import json
import re
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

MODEL_ID = "Salahin/youtube-audiobook-title-parser"

tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(
    MODEL_ID,
    torch_dtype=torch.float16,
    device_map="auto"
)
model.eval()

def parse_title(title: str) -> dict:
    messages = [
        {
            "role": "system",
            "content": "Extract book title, author, and channel as JSON. Keep Bengali in Bengali script."
        },
        {"role": "user", "content": title}
    ]
    prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
    inputs = tokenizer([prompt], return_tensors="pt").to(model.device)

    with torch.no_grad():
        outputs = model.generate(
            **inputs,
            max_new_tokens=80,
            do_sample=False,
            eos_token_id=tokenizer.convert_tokens_to_ids("<|im_end|>")
        )

    text = tokenizer.decode(outputs[0][len(inputs.input_ids[0]):], skip_special_tokens=True).strip()
    match = re.search(r'\{.*?\}', text, re.DOTALL)
    return json.loads(match.group(0)) if match else {"raw": text}

# Example
print(parse_title("เฆนเฆฟเฆฎเงเฆฐ เฆนเฆพเฆคเง‡ เฆ•เฆฏเฆผเง‡เฆ•เฆŸเฆฟ เฆจเง€เฆฒเฆชเฆฆเงเฆฎ 1/2 | Humayun Ahmed | Golpokothon"))
# Output: {'book_title': 'เฆนเฆฟเฆฎเงเฆฐ เฆนเฆพเฆคเง‡ เฆ•เฆฏเฆผเง‡เฆ•เฆŸเฆฟ เฆจเง€เฆฒเฆชเฆฆเงเฆฎ', 'author': 'Humayun Ahmed', 'channel': 'Golpokothon'}

Option 2: Using GGUF on CPU (Ultra-Fast & Low Memory)

Install llama-cpp-python:

pip install llama-cpp-python huggingface-hub
import json
import re
from huggingface_hub import hf_hub_download
from llama_cpp import Llama

# Download quantized GGUF binary (~380 MB)
model_path = hf_hub_download(
    repo_id="Salahin/youtube-audiobook-title-parser",
    filename="model-q4_k_m.gguf"
)

llm = Llama(
    model_path=model_path,
    n_ctx=512,
    n_threads=4,  # Adjust to your CPU core count
    verbose=False
)

def parse_title_cpu(title: str) -> dict:
    prompt = (
        "<|im_start|>system\n"
        "Extract book title, author, and channel as JSON. Keep Bengali in Bengali script.<|im_end|>\n"
        f"<|im_start|>user\n{title}<|im_end|>\n"
        "<|im_start|>assistant\n"
    )
    output = llm(
        prompt,
        max_tokens=80,
        stop=["}", "<|im_end|>"],
        temperature=0.0
    )
    raw = output["choices"][0]["text"].strip()
    if not raw.endswith("}"):
        raw += "}"
    match = re.search(r'\{.*?\}', raw, re.DOTALL)
    return json.loads(match.group(0)) if match else {"raw": raw}

# Example
print(parse_title_cpu("Golpokothon Presents | เฆนเฆฟเฆฎเงเฆฐ เฆนเฆพเฆคเง‡ เฆ•เฆฏเฆผเง‡เฆ•เฆŸเฆฟ เฆจเง€เฆฒเฆชเฆฆเงเฆฎ | เฆนเงเฆฎเฆพเฆฏเฆผเง‚เฆจ เฆ†เฆนเฆฎเง‡เฆฆ"))

Training Details

Training Data

The training data is available directly in this repository: dataset.jsonl.

It comprises 600 synthetic and curated title variations addressing real-world edge cases:

  • Multi-delimiter patterns (|, -, :, /)
  • Leading channel markers (Channel Presents | Title | Author)
  • Bengali franchise patterns (เฆฎเฆฟเฆธเฆฟเฆฐ เฆ†เฆฒเฆฟ, เฆนเฆฟเฆฎเง, เฆฌเงเฆฏเง‹เฆฎเฆ•เง‡เฆถ, เฆซเง‡เฆฒเงเฆฆเฆพ)
  • Missing metadata fields (titles without channels or authors)
  • Undelimited radio show titles (Sunday Suspense, Midnight Horror Station)
  • Noise tokens (1/2, เงงเฆฎ เฆชเฆฐเงเฆฌ, [HD], Full Audiobook)

Training Procedure

  • Base Model: Qwen/Qwen2.5-0.5B-Instruct
  • Method: LoRA (Low-Rank Adaptation) with standard sequence-to-sequence loss masking (loss calculated solely on assistant response tokens and EOS)
  • Hyperparameters:
  • r: 16
  • lora_alpha: 32
  • target_modules: ["q_proj", "k_proj", "v_proj", "o_proj"]
  • lora_dropout: 0.05
  • learning_rate: 3e-4 (Cosine schedule)
  • epochs: 3
  • optimizer: adamw_torch

Bias, Risks, and Limitations

  • Specifically tuned for South Asian / Bengali literature naming conventions and formats.
  • Strings that diverge significantly from standard book or audiobook naming structures may produce incomplete metadata fields.
Downloads last month
542
Safetensors
Model size
0.5B params
Tensor type
F16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Salahin/youtube-audiobook-title-parser

Quantized
(388)
this model

Space using Salahin/youtube-audiobook-title-parser 1