Automatic Speech Recognition
PEFT
Safetensors
Transformers
Nepali
English
whisper
nepali
english
code-switching
lora
Instructions to use DontHash/neptrans-v4-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use DontHash/neptrans-v4-lora with PEFT:
Task type is invalid.
- Transformers
How to use DontHash/neptrans-v4-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="DontHash/neptrans-v4-lora")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("DontHash/neptrans-v4-lora", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download evaluation/protocol.py from DontHash/neptrans-v4-lora: direct link, hf CLI and curl.
- Browser
- Download file 2.17 kB
-
https://huggingface.co/DontHash/neptrans-v4-lora/resolve/main/evaluation/protocol.py
- Command line
-
hf download hf://DontHash/neptrans-v4-lora/evaluation/protocol.py
-
curl -L -o protocol.py https://huggingface.co/DontHash/neptrans-v4-lora/resolve/main/evaluation/protocol.py
2.17 kB
| # SPDX-License-Identifier: MIT | |
| """Verbatim scoring function and reference generation snippet from the saved v4 recipe. | |
| This documents the protocol; it does not bundle a benchmark dataset. | |
| """ | |
| from jiwer import wer, cer | |
| def score_predictions(references: list[dict], predictions: list[dict]) -> dict: | |
| ref_by_id = {r["item_id"]: r for r in references} | |
| by_id = {p["item_id"]: p["hypothesis"] for p in predictions} | |
| metrics = {} | |
| for bucket in ["mixed", "nepali", "english"]: | |
| rows = [r for r in references if r.get("language_bucket") == bucket] | |
| if not rows: | |
| continue | |
| refs = [r["text"] for r in rows] | |
| hyps = [by_id.get(r["item_id"], "") for r in rows] | |
| w = wer(refs, hyps) * 100.0 | |
| c = cer(refs, hyps) * 100.0 | |
| metrics[bucket] = {"wer": round(w, 2), "cer": round(c, 2), "clips": len(rows)} | |
| all_refs = [r["text"] for r in references] | |
| all_hyps = [by_id.get(r["item_id"], "") for r in references] | |
| overall_w = wer(all_refs, all_hyps) * 100.0 | |
| overall_c = cer(all_refs, all_hyps) * 100.0 | |
| metrics["overall"] = {"wer": round(overall_w, 2), "cer": round(overall_c, 2), "clips": len(references)} | |
| # Target weighted WER (60% mixed, 20% nepali, 20% english if present, else overall) | |
| if "mixed" in metrics and "nepali" in metrics: | |
| mix_w = metrics["mixed"]["wer"] | |
| nep_w = metrics["nepali"]["wer"] | |
| en_w = metrics.get("english", {}).get("wer", mix_w) | |
| metrics["target_weighted_wer"] = round(0.6 * mix_w + 0.2 * nep_w + 0.2 * en_w, 2) | |
| else: | |
| metrics["target_weighted_wer"] = round(overall_w, 2) | |
| return metrics | |
| REFERENCE_GENERATION_SNIPPET = ' tokens = base.generate(\n input_features=inputs["input_features"],\n attention_mask=inputs.get("attention_mask"),\n language=None,\n task="transcribe",\n return_timestamps=False,\n max_length=self.args.generation_max_length,\n num_beams=1,\n use_cache=True,\n )\n' | |