Upload pasita.py with huggingface_hub
Browse files
pasita.py
CHANGED
|
@@ -1041,24 +1041,25 @@ def convert_to_markdown(
|
|
| 1041 |
) -> dict[str, Any]:
|
| 1042 |
if kind == "generic":
|
| 1043 |
kind = infer_kind(text)
|
| 1044 |
-
|
| 1045 |
-
|
| 1046 |
-
|
| 1047 |
-
|
| 1048 |
-
|
| 1049 |
-
|
| 1050 |
-
|
| 1051 |
-
|
| 1052 |
-
|
| 1053 |
-
|
| 1054 |
-
|
| 1055 |
-
|
| 1056 |
-
|
| 1057 |
-
|
| 1058 |
-
|
| 1059 |
-
|
| 1060 |
-
|
| 1061 |
-
|
|
|
|
| 1062 |
result = generate_candidates(model, tokenizer, text, **gen_kwargs)
|
| 1063 |
candidates = list(result.candidates)
|
| 1064 |
fallback_start = len(candidates)
|
|
|
|
| 1041 |
) -> dict[str, Any]:
|
| 1042 |
if kind == "generic":
|
| 1043 |
kind = infer_kind(text)
|
| 1044 |
+
if skip_model_for_structured and structured_fallback and kind in ("html", "data"):
|
| 1045 |
+
candidates = [postprocess(c, text) for c in structured_candidates(text)]
|
| 1046 |
+
if not candidates:
|
| 1047 |
+
candidates = [postprocess(text, text)]
|
| 1048 |
+
best, metrics = rerank_candidates(text, candidates, must, kind)
|
| 1049 |
+
return {
|
| 1050 |
+
"markdown": candidates[best],
|
| 1051 |
+
"candidate_index": best,
|
| 1052 |
+
"fallback_used": True,
|
| 1053 |
+
"route": "structured",
|
| 1054 |
+
"metrics": metrics[best],
|
| 1055 |
+
"candidate_metrics": metrics,
|
| 1056 |
+
"candidates": candidates,
|
| 1057 |
+
"raw_candidates": [],
|
| 1058 |
+
"prompt_tokens": 0,
|
| 1059 |
+
"max_new_tokens": 0,
|
| 1060 |
+
"seconds": 0.0,
|
| 1061 |
+
"strategy": {"mode": "structured", "best_index": best, "structured_fallback": True, "route": "structured"},
|
| 1062 |
+
}
|
| 1063 |
result = generate_candidates(model, tokenizer, text, **gen_kwargs)
|
| 1064 |
candidates = list(result.candidates)
|
| 1065 |
fallback_start = len(candidates)
|