Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files176 unmodified lines17717817918018118218318418538 unmodified lines224225226227228229230231232233234235236237238239240241242176 unmodified linesreturn text, hit_cap, limit.fired and not hit_capdef _is_degenerate(text: str, hit_cap: bool, timed_out: bool) -> bool:"""inference_config.yaml's runaway-output rule (token limit or repetition)."""if hit_cap or timed_out:return Trueif len(text.encode("utf-8")) > DEGENERATE_MIN_BYTES:if _gzip_ratio(text) < DEGENERATE_GZIP_RATIO:38 unmodified linestext, hit_cap, timed_out = _generate(page, 0.0, cap, deadline)note = ""if _is_degenerate(text, hit_cap, timed_out):if time.time() < deadline - RETRY_MIN_REMAINING_S:# Authors' runaway-output policy, bounded to a single retry so the# reservation still covers it: regenerate at the lowest documented# retry temperature and keep the shorter result.note = "repeat-prone pass -- retried at temperature 0.1"retry, retry_cap, retry_timeout = _generate(page, RETRY_TEMPERATURE, cap, deadline)if retry and not (retry_cap or retry_timeout) and len(retry) < len(text):text, hit_cap, timed_out = retry, retry_cap, retry_timeoutelse:note = "repeat-prone pass -- no time left for the retry"seconds = time.time() - startedreport = f"Transcribed in {seconds:.1f}s - {len(text)} characters."176 unmodified lines17717817918018118218318418538 unmodified lines224225226227228229230231232233234235236237238239240241242243244245176 unmodified linesreturn text, hit_cap, limit.fired and not hit_capdef _is_degenerate(text: str, hit_cap: bool) -> bool:"""inference_config.yaml's runaway-output rule (token limit or repetition)."""if hit_cap:return Trueif len(text.encode("utf-8")) > DEGENERATE_MIN_BYTES:if _gzip_ratio(text) < DEGENERATE_GZIP_RATIO:38 unmodified linestext, hit_cap, timed_out = _generate(page, 0.0, cap, deadline)note = ""if timed_out:# Ran out of GPU budget: there is no room left for the retry pass.passelif _is_degenerate(text, hit_cap):if time.time() < deadline - RETRY_MIN_REMAINING_S:# Authors' runaway-output policy, bounded to a single retry so the# reservation still covers it: regenerate at the lowest documented# retry temperature and keep the shorter result.note = "repeat-prone output -- retried at a higher temperature"retry, retry_cap, retry_timeout = _generate(page, RETRY_TEMPERATURE, cap, deadline)if retry and not (retry_cap or retry_timeout) and len(retry) < len(text):text, hit_cap = retry, retry_capelse:note = "repeat-prone output -- too little time left to retry"seconds = time.time() - startedreport = f"Transcribed in {seconds:.1f}s - {len(text)} characters."
app.py+9-6