Instructions to use spywarex/retake-pair-scorer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use spywarex/retake-pair-scorer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="spywarex/retake-pair-scorer")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("spywarex/retake-pair-scorer", device_map="auto") - Notebooks
- Google Colab
- Kaggle
retake-pair-scorer
The pair scorer of the ReTake pipeline (github.com/spywareXd/re-take). Given two spoken sentences from a video transcript, it says whether the second one is a retake of the first: the speaker said the same thing again after stumbling, correcting themselves or restarting. The pipeline groups the sentences that are retakes of each other; a separate model then decides which take to keep (spywarex/retake-keeper-qwen3-4b).
It scores pairs. It does not generate text and it does not edit video.
How to use it (no other code needed)
This repo includes retake_pair_scorer.py, one self-contained file with the text normalisation, the lexical scores, the loader and the decision rules. It does not need the ReTake repository.
pip install torch transformers sentence-transformers huggingface_hub numpy
huggingface-cli download spywarex/retake-pair-scorer retake_pair_scorer.py --local-dir .
from retake_pair_scorer import RetakePairScorer
scorer = RetakePairScorer.from_pretrained("spywarex/retake-pair-scorer") # downloads about 270 MB once
r = scorer.score_pair("So the main idea is", "So the main idea is that it works.")
print(r["decision"], round(r["p"], 3), round(r["ce_prob"], 3)) # retake | not_retake | ambiguous
score(pairs)takes a list of(earlier sentence, later sentence)tuples and returns one dict per pair. Put the earlier sentence first: the model was trained that way.- Each result has
decision(retake,not_retakeorambiguous),resolved_by,p,ce_probandstage2. ambiguousmeans the model is not sure. The ReTake editor asks the user about these pairs. If you cannot ask, treat them asnot_retake: nothing is cut by mistake.- The scores are not calibrated probabilities. Do not show them as percentages.
- Needs a GPU only for speed; CPU works. The first call also downloads
sentence-transformers/all-MiniLM-L6-v2.
What is inside
Scoring follows the ReTake pipeline exactly:
- Stage 2 score = 0.50 x semantic + 0.30 x lexical + 0.20 x containment. Semantic is the all-MiniLM-L6-v2 cosine mapped to [0, 1]. Lexical is the weighted sequence ratio, Jaccard, containment and bigram overlap of the normalised tokens (contractions expanded, punctuation removed), raised to the exact or near-exact match score when that is higher.
- Cross-encoder:
cross-encoder/ms-marco-MiniLM-L-6-v2fine-tuned on labelled sentence pairs (ce_seed0,ce_seed1,ce_seed2: three seeds, probabilities averaged). Input is the two raw sentences, max 128 tokens. - Stacker: a logistic regression on (Stage 2, logit of the cross-encoder probability), in
thresholds.json.p >= 0.866is a retake,p < 0.171is not. In between the cross-encoder decides: probability>= 0.969retake,<= 0.32not a retake, otherwiseambiguous. The lower edge of the unsure band (0.32) was raised by hand from the fitted value 0.0035 so that fewer questions are asked; this is recorded inthresholds.json.
| file | what |
|---|---|
retake_pair_scorer.py |
the loader and scoring code |
ce_seed0/, ce_seed1/, ce_seed2/ |
fine-tuned cross-encoder weights (22M parameters each) |
thresholds.json |
stacker coefficients, thresholds, versions |
Training data and evaluation
Trained on 3,562 labelled sentence pairs (340 retakes) from English-language videos, plus synthetic pairs. The natural recordings and their labels are private and are not published; only the synthetic part is in the ReTake repository, so the training data is not complete and you cannot reproduce this exact model from the public repository alone.
Evaluation used four held-out folds, with thresholds chosen on the other folds (out-of-fold, pooled). The stacker's retake tier reached precision 0.90 and recall 0.84, and 10.5% of pairs were left ambiguous. Treat these as indicative: the data covers few speakers and the weakest fold had precision 0.75 in the retake tier.
Limitations
- English only. Trained on a small number of speakers and topics; expect lower accuracy on other speaking styles.
- It compares two sentences. It does not know the surrounding audio, pauses or video, and it does not choose which take to keep.
- A pair of identical sentences that were meant to be said twice (a refrain) will look like a retake.
- Scores are not probabilities. Choose thresholds for your own data if you can label some.
License
Apache-2.0. Built on cross-encoder/ms-marco-MiniLM-L-6-v2 and sentence-transformers/all-MiniLM-L6-v2, both Apache-2.0.
Links
- Pipeline, editor and training scripts: github.com/spywareXd/re-take
- Keeper model: spywarex/retake-keeper-qwen3-4b
Model tree for spywarex/retake-pair-scorer
Base model
microsoft/MiniLM-L12-H384-uncased