bibr 0.7.3__tar.gz → 0.7.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bibr-0.7.3 → bibr-0.7.4}/PKG-INFO +9 -2
- {bibr-0.7.3 → bibr-0.7.4}/README.md +8 -1
- {bibr-0.7.3 → bibr-0.7.4}/bibr/api.py +4 -4
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/resolver.py +141 -5
- {bibr-0.7.3 → bibr-0.7.4}/bibr/config.py +102 -15
- {bibr-0.7.3 → bibr-0.7.4}/bibr/demo/server.py +1 -1
- {bibr-0.7.3 → bibr-0.7.4}/bibr/enrich/references.py +6 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/citations.py +68 -18
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/integrity_statements.py +27 -1
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/ref_extractor.py +12 -6
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/ref_field_repair.py +1 -1
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/ref_locator.py +56 -22
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/statement_scan.py +7 -2
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/docx_native.py +352 -13
- bibr-0.7.4/bibr/input/heading_cues.py +168 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/html_native.py +276 -10
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/cli/dry_run.py +3 -1
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/cli/parser.py +5 -4
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/cli/run_config.py +1 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/ocr_cloud.py +45 -2
- {bibr-0.7.3 → bibr-0.7.4}/bibr/mcp_server.py +4 -4
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ner/model.py +15 -2
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ner/parser.py +69 -4
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ner/parser_onnx.py +1 -1
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ner/runtime.py +7 -1
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/ref_patterns.py +3 -2
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/artifacts.py +1 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/setup_wizard.py +11 -9
- {bibr-0.7.3 → bibr-0.7.4}/pyproject.toml +13 -4
- {bibr-0.7.3 → bibr-0.7.4}/.gitignore +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/LICENSE.md +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/batch/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/batch/ledger.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/batch/manifest.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/batch/remote.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/batch/report.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/batch/runner.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/cache.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/base.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/batch.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/crossref.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/llm.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/llm_cache.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/llm_protocol.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/nuextract.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/nuextract_schema.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/pointer_outputs.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/prompts.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/providers/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/providers/anthropic.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/providers/base.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/providers/google.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/providers/groq.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/providers/ollama.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/providers/openai.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/ref_llm.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/response_cache.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/ror.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/structured.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/clients/structured_json.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/config_cli.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/config_introspect.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/data/sample_paper.pdf +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/demo/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/demo/local_app.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/document/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/document/destinations.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/document/harvest.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/document/ids.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/document/links.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/document/model.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/document/outline.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/document/outline_guard.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/document/rebuild.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/document/serialize.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/document/structure.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/document/views.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/enrich/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/enrich/check.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/enrich/consolidate.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/enrich/organizations.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/enrich/schemas.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/enrich/verify.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/env_utils.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/evaluation/segmenter_capture.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/exceptions.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/geometry.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/json_export.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/models.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/names.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/normalize.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/qualification_provenance.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/schema_artifact.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/spans.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/structure_ids.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/tables.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/usage.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/export/validation.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/anchor_snap.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/archive_cover.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/author_email_harvester.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/core_metadata.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/doi_identity.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/equation_extractor.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/extractor.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/field_decisions.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/footnote_citations.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/front_matter.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/front_role.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/front_role_features.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/geom_adjacent_features.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/geom_features.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/geom_segmenter.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/merge_split.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/metadata_precision.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/pdf_doi_evidence.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/ref_line_stream.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/ref_review.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/region_seg.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/research_integrity.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/segment_filter.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/title_candidates.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/title_marks.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/title_subtitle.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/extract/training_capture.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/field_states.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/consolidate_text.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/docx_footnotes.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/docx_omml.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/epub_native.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/file.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/jats_native.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/mathml_whitespace.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/pdf_metadata.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/pdf_outline.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/supported_files.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/validate.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/xml_entities.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/input/zip_limits.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/layout/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/layout/registry.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/layout_base.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/layout_onnx.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/layout_utils.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/_vllm_mlx_server.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/artifacts.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/cli/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/cli/__main__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/cli/batch.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/cli/doctor.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/cli/inputs.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/cli/presets.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/cli/process.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/cli/references.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/cli/tables.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/cli/ui.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/http_runtime.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/inspect.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/layout.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/llama_cpp.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/llm.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/llm_models.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/llmster.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/manifest.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/mlx_vlm_ocr.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/ocr.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/ocr_transport.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/pipeline.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/rapid_mlx.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/ref_model.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/segmenter.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/vllm_llm.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/vllm_mlx_runtime.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/local/vllm_ocr.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/models.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ner/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ner/checkpoint.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ner/crf_numpy.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ner/decode.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ner/segmenter.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ner/tags.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/backend.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/http_security.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/image_processing.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/image_utils.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/layout.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/native_text.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/normalization.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/otsl.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/pdf_inspection.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/pdf_links.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/postprocess.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/profiles.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/ref_geometry.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/registry.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/table_recovery.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/types.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/ocr/utils.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/paper.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/paper_contents.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/classifier_resources.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/context.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/enrich_prefetch.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/enricher.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/identity.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/inference_batcher.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/ocr_cache.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/pipeline.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/plans.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/progress.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/resources.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stage.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/classifiers.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/core_checkpoint.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/docx.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/enrich.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/export.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/html.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/identity.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/jats.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/layout.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/llm_server.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/native_text.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/ocr.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/parse_segment.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/post_parse.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/render_ocr.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/stages/validate.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/pipeline/state.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/presets.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/processing_warnings.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/py.typed +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/scan/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/scan/articles.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/scan/consensus.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/scan/page_kind.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/schemas.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/segmenter/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/segmenter/registry.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/segmenter_base.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/admission.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/app.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/auth.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/batching.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/deployments/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/deployments/layout.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/deployments/pipeline.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/deployments/segmenter.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/ingress.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/jobs.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/jobs_redis.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/logsetup.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/mcp.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/ocr_backend.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/paths.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/serve/pipeline.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/_paper_classifier_arch.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/_section_minilm_arch.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/assembler.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/caption_continuations.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/caption_matcher.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/carry_over_manager.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/citation_linker.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/citation_matcher.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/float_images.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/float_labels.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/floats_normalize.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/footnote_buffer.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/html_table.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/implicit_sections.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/paper_classifier.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/paper_classifier_common.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/paper_classifier_model.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/paper_classifier_onnx.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/parse_headings.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/parse_media.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/parse_text.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/pdf_parser.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/reference_boundaries.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/section_classifier.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/section_classifier_common.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/section_classifier_model.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/section_classifier_onnx.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/section_tree.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/text_quality.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/text_repair.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/structure/xref_utils.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/__init__.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/async_tasks.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/circuit_breaker.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/constants.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/device.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/hf_cache.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/hosts.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/json_salvage.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/locks.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/metadata.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/ml_extra.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/ml_runtime.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/onnx_providers.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/onnx_tokenizer.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/pages.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/rate_limiter.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/redact.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/safe_fetch.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/safe_pickle.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/secure_temp.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/semaphore.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/text.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/tokenizer_safety.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/utils/transient.py +0 -0
- {bibr-0.7.3 → bibr-0.7.4}/bibr/validation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: bibr
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.4
|
|
4
4
|
Summary: Scientific paper extraction to structured JSON: metadata, text, references, tables, figures, and equations from PDF, DOCX, JATS XML, HTML, and ePub.
|
|
5
5
|
Project-URL: Homepage, https://bibr.org
|
|
6
6
|
Project-URL: Documentation, https://bibr.org
|
|
@@ -114,12 +114,15 @@ Description-Content-Type: text/markdown
|
|
|
114
114
|
- Extracts metadata, references, full text, tables, figures, and equations into a
|
|
115
115
|
[versioned JSON format](https://bibr.org/reference/schema/), and writes whole corpora
|
|
116
116
|
as Parquet tables for pandas, polars, DuckDB, or R.
|
|
117
|
+
- Exports reference lists as BibTeX, RIS, or CSL-JSON for Zotero and other reference managers.
|
|
117
118
|
- Includes sentence and page references to help check extractions against the source.
|
|
118
119
|
- Works through the CLI, Python, an HTTP API, a web demo, or MCP.
|
|
119
120
|
- Lets you choose local or cloud models, limit page ranges, and skip extraction stages.
|
|
120
121
|
|
|
121
122
|
> **Alpha:** Expect bugs and uneven extraction quality. Current evaluation is strongest
|
|
122
123
|
> for English-language social science papers. See [where bibr is strong and where it isn't](https://bibr.org/limitations/).
|
|
124
|
+
> The [JATS benchmark](https://github.com/scienceverse/bibr-jats-eval) behind the whole-paper result, bibr against GROBID on
|
|
125
|
+
> 300 open-access papers, is public with its papers, answer key and scores.
|
|
123
126
|
|
|
124
127
|
## Get started
|
|
125
128
|
|
|
@@ -158,6 +161,7 @@ for development setup.
|
|
|
158
161
|
uv run bibr chew papers/ -o results/ # Process a directory
|
|
159
162
|
uv run bibr batch papers/ --out corpus/ # Resumable corpus run, plus Parquet tables
|
|
160
163
|
uv run bibr tables results/ --out tables/ # JSON exports → one Parquet file per table
|
|
164
|
+
uv run bibr references results/ -o refs.bib # Reference lists → BibTeX (.ris, CSL-JSON .json)
|
|
161
165
|
uv run bibr chew paper.pdf --dry-run # Preview the processing plan
|
|
162
166
|
uv add 'bibr[demo]' # Add the optional web demo
|
|
163
167
|
uv run bibr demo # Open it locally
|
|
@@ -183,6 +187,7 @@ references = result.references.df # pandas DataFrame
|
|
|
183
187
|
result.save("result.json")
|
|
184
188
|
|
|
185
189
|
bibr.write_tables(bibr.chew("papers/"), "tables/") # corpus → Parquet, keyed by paper_id
|
|
190
|
+
bibr.write_references(result, "refs.bib") # reference list → BibTeX, RIS, or CSL-JSON
|
|
186
191
|
```
|
|
187
192
|
|
|
188
193
|
See the [Python guide](https://bibr.org/guides/library/) for batch processing and
|
|
@@ -192,7 +197,8 @@ reusing loaded models with `bibr.Chewer`.
|
|
|
192
197
|
|
|
193
198
|
bibr uses LLMs selectively for tasks such as front-page metadata. `bibr setup`
|
|
194
199
|
recommends a model for your hardware: bibr's fine-tuned Qwen3.5 4B or 2B model
|
|
195
|
-
on an NVIDIA GPU
|
|
200
|
+
on an NVIDIA GPU (vLLM on Linux, llama.cpp on Windows), the same models as MLX
|
|
201
|
+
builds on Apple Silicon, or Claude Haiku 5.5 as a hosted model
|
|
196
202
|
([how they compare](https://bibr.org/guides/extraction-models/)). You can disable downstream LLM extraction
|
|
197
203
|
with `--no-llm`, which returns structural output; PDF OCR may still use a
|
|
198
204
|
vision-language model. The [LLM use note](https://bibr.org/llm-use/) covers these choices
|
|
@@ -239,6 +245,7 @@ We are grateful to the open-source projects that bibr builds on:
|
|
|
239
245
|
|
|
240
246
|
- [PaddleOCR-VL-1.6](https://huggingface.co/PaddlePaddle/PaddleOCR-VL-1.6) (PaddlePaddle) — default OCR recognizer
|
|
241
247
|
- [GLM-OCR](https://huggingface.co/zai-org/GLM-OCR) (Z.ai / Tsinghua University) — explicit compatibility backend and fallback
|
|
248
|
+
- [Qwen3.5](https://huggingface.co/Qwen) (Alibaba Qwen) — base of bibr's fine-tuned extraction models
|
|
242
249
|
- [GROBID](https://github.com/kermitt2/grobid) — a major source of inspiration for structured scientific document parsing
|
|
243
250
|
- [LitServe](https://lightning.ai/docs/litserve/home) (Lightning AI) — serving infrastructure
|
|
244
251
|
- [PP-DocLayoutV3](https://github.com/PaddlePaddle/PaddleOCR) (PaddlePaddle) — document layout analysis
|
|
@@ -15,12 +15,15 @@
|
|
|
15
15
|
- Extracts metadata, references, full text, tables, figures, and equations into a
|
|
16
16
|
[versioned JSON format](https://bibr.org/reference/schema/), and writes whole corpora
|
|
17
17
|
as Parquet tables for pandas, polars, DuckDB, or R.
|
|
18
|
+
- Exports reference lists as BibTeX, RIS, or CSL-JSON for Zotero and other reference managers.
|
|
18
19
|
- Includes sentence and page references to help check extractions against the source.
|
|
19
20
|
- Works through the CLI, Python, an HTTP API, a web demo, or MCP.
|
|
20
21
|
- Lets you choose local or cloud models, limit page ranges, and skip extraction stages.
|
|
21
22
|
|
|
22
23
|
> **Alpha:** Expect bugs and uneven extraction quality. Current evaluation is strongest
|
|
23
24
|
> for English-language social science papers. See [where bibr is strong and where it isn't](https://bibr.org/limitations/).
|
|
25
|
+
> The [JATS benchmark](https://github.com/scienceverse/bibr-jats-eval) behind the whole-paper result, bibr against GROBID on
|
|
26
|
+
> 300 open-access papers, is public with its papers, answer key and scores.
|
|
24
27
|
|
|
25
28
|
## Get started
|
|
26
29
|
|
|
@@ -59,6 +62,7 @@ for development setup.
|
|
|
59
62
|
uv run bibr chew papers/ -o results/ # Process a directory
|
|
60
63
|
uv run bibr batch papers/ --out corpus/ # Resumable corpus run, plus Parquet tables
|
|
61
64
|
uv run bibr tables results/ --out tables/ # JSON exports → one Parquet file per table
|
|
65
|
+
uv run bibr references results/ -o refs.bib # Reference lists → BibTeX (.ris, CSL-JSON .json)
|
|
62
66
|
uv run bibr chew paper.pdf --dry-run # Preview the processing plan
|
|
63
67
|
uv add 'bibr[demo]' # Add the optional web demo
|
|
64
68
|
uv run bibr demo # Open it locally
|
|
@@ -84,6 +88,7 @@ references = result.references.df # pandas DataFrame
|
|
|
84
88
|
result.save("result.json")
|
|
85
89
|
|
|
86
90
|
bibr.write_tables(bibr.chew("papers/"), "tables/") # corpus → Parquet, keyed by paper_id
|
|
91
|
+
bibr.write_references(result, "refs.bib") # reference list → BibTeX, RIS, or CSL-JSON
|
|
87
92
|
```
|
|
88
93
|
|
|
89
94
|
See the [Python guide](https://bibr.org/guides/library/) for batch processing and
|
|
@@ -93,7 +98,8 @@ reusing loaded models with `bibr.Chewer`.
|
|
|
93
98
|
|
|
94
99
|
bibr uses LLMs selectively for tasks such as front-page metadata. `bibr setup`
|
|
95
100
|
recommends a model for your hardware: bibr's fine-tuned Qwen3.5 4B or 2B model
|
|
96
|
-
on an NVIDIA GPU
|
|
101
|
+
on an NVIDIA GPU (vLLM on Linux, llama.cpp on Windows), the same models as MLX
|
|
102
|
+
builds on Apple Silicon, or Claude Haiku 5.5 as a hosted model
|
|
97
103
|
([how they compare](https://bibr.org/guides/extraction-models/)). You can disable downstream LLM extraction
|
|
98
104
|
with `--no-llm`, which returns structural output; PDF OCR may still use a
|
|
99
105
|
vision-language model. The [LLM use note](https://bibr.org/llm-use/) covers these choices
|
|
@@ -140,6 +146,7 @@ We are grateful to the open-source projects that bibr builds on:
|
|
|
140
146
|
|
|
141
147
|
- [PaddleOCR-VL-1.6](https://huggingface.co/PaddlePaddle/PaddleOCR-VL-1.6) (PaddlePaddle) — default OCR recognizer
|
|
142
148
|
- [GLM-OCR](https://huggingface.co/zai-org/GLM-OCR) (Z.ai / Tsinghua University) — explicit compatibility backend and fallback
|
|
149
|
+
- [Qwen3.5](https://huggingface.co/Qwen) (Alibaba Qwen) — base of bibr's fine-tuned extraction models
|
|
143
150
|
- [GROBID](https://github.com/kermitt2/grobid) — a major source of inspiration for structured scientific document parsing
|
|
144
151
|
- [LitServe](https://lightning.ai/docs/litserve/home) (Lightning AI) — serving infrastructure
|
|
145
152
|
- [PP-DocLayoutV3](https://github.com/PaddlePaddle/PaddleOCR) (PaddlePaddle) — document layout analysis
|
|
@@ -306,10 +306,10 @@ class Result:
|
|
|
306
306
|
) -> list[dict[str, Any]]:
|
|
307
307
|
"""The references as CSL-JSON items, for Zotero, Mendeley or Pandoc.
|
|
308
308
|
|
|
309
|
-
Values are as printed
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
309
|
+
Values are as printed; a field a reference does not print stays
|
|
310
|
+
empty. ``prefer="record"`` (opt-in) takes a matched record's values
|
|
311
|
+
over the printed ones and fills the gaps from it, noting which values
|
|
312
|
+
came from the record. ``check_note`` adds a note saying when the check found a
|
|
313
313
|
difference, an unregistered DOI, no record, or a retraction. See
|
|
314
314
|
:mod:`bibr.export.citations`; ``bibr.write_references()`` writes a file.
|
|
315
315
|
"""
|
|
@@ -3,10 +3,18 @@
|
|
|
3
3
|
Thin wrapper over the resolver's ``/search`` and ``/works/{doi}`` endpoints. Every
|
|
4
4
|
call degrades gracefully — any HTTP/parse error returns an empty result so the
|
|
5
5
|
caller falls through to CrossRef; the resolver never fails enrichment.
|
|
6
|
+
|
|
7
|
+
A busy resolver is retried, not given up on: a 429/502/503/504 answer, a timeout
|
|
8
|
+
or a dropped connection is tried again after an exponential backoff. Every client
|
|
9
|
+
in the process that talks to the same resolver also shares one cap on requests in
|
|
10
|
+
flight, so a batch with many papers open at once can't flood it.
|
|
6
11
|
"""
|
|
7
12
|
|
|
8
13
|
import asyncio
|
|
14
|
+
import contextlib
|
|
9
15
|
import logging
|
|
16
|
+
import random
|
|
17
|
+
import threading
|
|
10
18
|
from urllib.parse import quote
|
|
11
19
|
|
|
12
20
|
import httpx
|
|
@@ -15,16 +23,87 @@ from bibr.utils.text import is_url_safe_doi
|
|
|
15
23
|
|
|
16
24
|
logger = logging.getLogger(__name__)
|
|
17
25
|
|
|
26
|
+
# What a busy or briefly unreachable resolver answers. bibr-resolver says 503
|
|
27
|
+
# ("resolver backend unavailable") when its search backend runs out of capacity;
|
|
28
|
+
# a proxy in front of it may say 502/504 or 429.
|
|
29
|
+
_RETRY_STATUSES = frozenset({429, 502, 503, 504})
|
|
30
|
+
|
|
31
|
+
# A request the resolver did not finish: a timeout (including waiting for a
|
|
32
|
+
# pooled connection) or a connection it dropped. A refused connection is left
|
|
33
|
+
# out on purpose: that resolver is down, not busy, and the health probe should
|
|
34
|
+
# say so at once rather than after the whole backoff.
|
|
35
|
+
_RETRY_ERRORS: tuple[type[Exception], ...] = (
|
|
36
|
+
httpx.TimeoutException,
|
|
37
|
+
httpx.RemoteProtocolError,
|
|
38
|
+
httpx.ReadError,
|
|
39
|
+
httpx.WriteError,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# No single backoff wait is longer than this, whatever Retry-After says.
|
|
43
|
+
_MAX_RETRY_DELAY = 30.0
|
|
44
|
+
|
|
45
|
+
# A timed-out request is retried once at most, within the retry budget. The
|
|
46
|
+
# resolver may still be running the search it gave up waiting for, so every
|
|
47
|
+
# retry of a timeout adds load to a resolver that is already behind, and four
|
|
48
|
+
# 30 s attempts would outlast the paper's whole enrichment budget.
|
|
49
|
+
_TIMEOUT_RETRIES = 1
|
|
50
|
+
|
|
51
|
+
# The health probe decides whether a paper uses the resolver at all, and it runs
|
|
52
|
+
# inside the paper's enrichment budget: a resolver that accepts the connection
|
|
53
|
+
# but never answers must cost seconds here, not the full search timeout.
|
|
54
|
+
_HEALTH_TIMEOUT = 10.0
|
|
55
|
+
|
|
56
|
+
# One in-flight cap per (event loop, resolver URL, limit). Papers each build
|
|
57
|
+
# their own ResolverClient, so a per-client cap would multiply by the papers in
|
|
58
|
+
# flight; this one is shared. An asyncio.Semaphore belongs to one loop, hence
|
|
59
|
+
# the loop in the key; gates of closed loops are dropped as new ones are made.
|
|
60
|
+
_GATES: dict[tuple[asyncio.AbstractEventLoop, str, int], asyncio.Semaphore] = {}
|
|
61
|
+
_GATES_LOCK = threading.Lock()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _shared_gate(base_url: str, limit: int) -> asyncio.Semaphore:
|
|
65
|
+
loop = asyncio.get_running_loop()
|
|
66
|
+
key = (loop, base_url, limit)
|
|
67
|
+
with _GATES_LOCK:
|
|
68
|
+
gate = _GATES.get(key)
|
|
69
|
+
if gate is None:
|
|
70
|
+
for stale in [k for k in _GATES if k[0].is_closed()]:
|
|
71
|
+
del _GATES[stale]
|
|
72
|
+
gate = _GATES[key] = asyncio.Semaphore(limit)
|
|
73
|
+
return gate
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _retry_after(headers: httpx.Headers) -> float | None:
|
|
77
|
+
"""A numeric ``Retry-After`` in seconds; the HTTP-date form and garbage are None."""
|
|
78
|
+
try:
|
|
79
|
+
secs = float(headers.get("retry-after", ""))
|
|
80
|
+
except ValueError:
|
|
81
|
+
return None
|
|
82
|
+
return secs if secs >= 0 else None
|
|
83
|
+
|
|
18
84
|
|
|
19
85
|
class ResolverClient:
|
|
20
86
|
def __init__(
|
|
21
87
|
self,
|
|
22
88
|
base_url: str,
|
|
23
89
|
*,
|
|
24
|
-
timeout: float =
|
|
90
|
+
timeout: float = 30.0,
|
|
25
91
|
client: httpx.AsyncClient | None = None,
|
|
92
|
+
retries: int = 3,
|
|
93
|
+
retry_backoff: float = 1.0,
|
|
94
|
+
max_concurrency: int = 8,
|
|
26
95
|
) -> None:
|
|
96
|
+
"""``retries`` is how many times a busy answer, a timeout (once at most) or
|
|
97
|
+
a dropped connection is tried again, after ``retry_backoff`` seconds
|
|
98
|
+
doubled per attempt (with jitter, and never less than the resolver's
|
|
99
|
+
Retry-After). ``max_concurrency`` caps requests in
|
|
100
|
+
flight across every client in this process that uses the same resolver
|
|
101
|
+
URL; 0 means no cap."""
|
|
27
102
|
self.base_url = base_url.rstrip("/")
|
|
103
|
+
self._timeout = timeout
|
|
104
|
+
self._retries = max(0, retries)
|
|
105
|
+
self._retry_backoff = max(0.0, retry_backoff)
|
|
106
|
+
self._max_concurrency = max(0, max_concurrency)
|
|
28
107
|
self._client = client or httpx.AsyncClient(
|
|
29
108
|
base_url=self.base_url,
|
|
30
109
|
timeout=httpx.Timeout(timeout),
|
|
@@ -36,6 +115,61 @@ class ResolverClient:
|
|
|
36
115
|
if not self._client.is_closed:
|
|
37
116
|
await self._client.aclose()
|
|
38
117
|
|
|
118
|
+
def _slot(self) -> "asyncio.Semaphore | contextlib.nullcontext[None]":
|
|
119
|
+
if not self._max_concurrency:
|
|
120
|
+
return contextlib.nullcontext()
|
|
121
|
+
return _shared_gate(self.base_url, self._max_concurrency)
|
|
122
|
+
|
|
123
|
+
def _backoff(self, attempt: int, retry_after: float | None) -> float:
|
|
124
|
+
# Jittered so the requests a busy spell turned away don't all come back
|
|
125
|
+
# in the same instant and make it busy again.
|
|
126
|
+
delay = self._retry_backoff * (2**attempt) * random.uniform(0.5, 1.0) # noqa: S311
|
|
127
|
+
if retry_after is not None:
|
|
128
|
+
delay = max(delay, retry_after)
|
|
129
|
+
return min(delay, _MAX_RETRY_DELAY)
|
|
130
|
+
|
|
131
|
+
async def _request(
|
|
132
|
+
self, method: str, path: str, *, timeout_retries: int = _TIMEOUT_RETRIES, **kwargs
|
|
133
|
+
) -> httpx.Response:
|
|
134
|
+
"""Send one request, retrying a busy answer or an unfinished request.
|
|
135
|
+
|
|
136
|
+
Returns the last response, whatever its status, for the caller to judge;
|
|
137
|
+
raises the last transport error once the retries are spent. At most
|
|
138
|
+
``timeout_retries`` of the retries may follow a timeout. The backoff
|
|
139
|
+
wait happens outside the in-flight cap, so a request that is waiting
|
|
140
|
+
frees its slot for one that can run."""
|
|
141
|
+
attempt = 0
|
|
142
|
+
timeouts = 0
|
|
143
|
+
while True:
|
|
144
|
+
try:
|
|
145
|
+
async with self._slot():
|
|
146
|
+
resp = await self._client.request(method, path, **kwargs)
|
|
147
|
+
except _RETRY_ERRORS as e:
|
|
148
|
+
if isinstance(e, httpx.TimeoutException):
|
|
149
|
+
timeouts += 1
|
|
150
|
+
if timeouts > timeout_retries:
|
|
151
|
+
raise
|
|
152
|
+
if attempt >= self._retries:
|
|
153
|
+
raise
|
|
154
|
+
reason: object = e
|
|
155
|
+
delay = self._backoff(attempt, None)
|
|
156
|
+
else:
|
|
157
|
+
if resp.status_code not in _RETRY_STATUSES or attempt >= self._retries:
|
|
158
|
+
return resp
|
|
159
|
+
reason = f"HTTP {resp.status_code}"
|
|
160
|
+
delay = self._backoff(attempt, _retry_after(resp.headers))
|
|
161
|
+
attempt += 1
|
|
162
|
+
logger.debug(
|
|
163
|
+
"resolver %s %s: %s; retry %d/%d in %.1fs",
|
|
164
|
+
method,
|
|
165
|
+
path[:80],
|
|
166
|
+
reason,
|
|
167
|
+
attempt,
|
|
168
|
+
self._retries,
|
|
169
|
+
delay,
|
|
170
|
+
)
|
|
171
|
+
await asyncio.sleep(delay)
|
|
172
|
+
|
|
39
173
|
async def healthy(self) -> bool:
|
|
40
174
|
"""Probe GET /health once and cache the verdict for this client's lifetime.
|
|
41
175
|
|
|
@@ -50,7 +184,9 @@ class ResolverClient:
|
|
|
50
184
|
|
|
51
185
|
async def _probe_health(self) -> bool:
|
|
52
186
|
try:
|
|
53
|
-
resp = await self.
|
|
187
|
+
resp = await self._request(
|
|
188
|
+
"GET", "/health", timeout_retries=0, timeout=min(self._timeout, _HEALTH_TIMEOUT)
|
|
189
|
+
)
|
|
54
190
|
resp.raise_for_status()
|
|
55
191
|
payload = resp.json()
|
|
56
192
|
# A proxy or another service answering /health may return any JSON
|
|
@@ -82,7 +218,7 @@ class ResolverClient:
|
|
|
82
218
|
if sources:
|
|
83
219
|
body["sources"] = list(sources)
|
|
84
220
|
try:
|
|
85
|
-
resp = await self.
|
|
221
|
+
resp = await self._request("POST", "/search", json=body)
|
|
86
222
|
resp.raise_for_status()
|
|
87
223
|
payload = resp.json()
|
|
88
224
|
# A body of ``{"candidates": null}`` makes ``.get(..., [])`` return
|
|
@@ -104,7 +240,7 @@ class ResolverClient:
|
|
|
104
240
|
self,
|
|
105
241
|
queries: list[dict],
|
|
106
242
|
*,
|
|
107
|
-
concurrency: int =
|
|
243
|
+
concurrency: int = 4,
|
|
108
244
|
sources: list[str] | None = None,
|
|
109
245
|
raise_on_error: bool = False,
|
|
110
246
|
) -> list[list[dict] | Exception]:
|
|
@@ -150,7 +286,7 @@ class ResolverClient:
|
|
|
150
286
|
return None
|
|
151
287
|
path = quote(doi, safe="/")
|
|
152
288
|
try:
|
|
153
|
-
resp = await self.
|
|
289
|
+
resp = await self._request("GET", f"/works/{path}")
|
|
154
290
|
if resp.status_code == 404:
|
|
155
291
|
return None
|
|
156
292
|
resp.raise_for_status()
|
|
@@ -468,6 +468,21 @@ class _BibrSettings(BaseSettings):
|
|
|
468
468
|
return (init_settings, env_settings, no_interp, file_secret_settings)
|
|
469
469
|
|
|
470
470
|
|
|
471
|
+
# Model each provider gets when ``LLM_PROVIDER`` is set without ``LLM_MODEL``.
|
|
472
|
+
# ``bibr setup`` writes the same model (``setup_wizard.LLM_DEFAULTS``). Without
|
|
473
|
+
# this, a hand-set provider kept the Gemini default and the provider answered
|
|
474
|
+
# 404 for a model it does not serve.
|
|
475
|
+
DEFAULT_LLM_MODELS: dict[str, str] = {
|
|
476
|
+
"google": "gemini-3.5-flash-lite",
|
|
477
|
+
"openai": "gpt-5-nano",
|
|
478
|
+
# Haiku 5.5 is the recommended hosted extraction model
|
|
479
|
+
# (docs/guides/extraction-models.md).
|
|
480
|
+
"anthropic": "claude-haiku-5-5",
|
|
481
|
+
"groq": "llama-3.3-70b-versatile",
|
|
482
|
+
"ollama": "gpt-oss:20b",
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
|
|
471
486
|
class LlmOptions(_BibrSettings):
|
|
472
487
|
"""LLM client settings. Env: ``LLM_PROVIDER``, ``LLM_MODEL``, ``LLM_API_KEY``, ..."""
|
|
473
488
|
|
|
@@ -479,7 +494,13 @@ class LlmOptions(_BibrSettings):
|
|
|
479
494
|
"Custom adapters added through bibr.clients.providers.register cannot be named here; "
|
|
480
495
|
"set them on the settings object in code instead.",
|
|
481
496
|
)
|
|
482
|
-
model: str = Field(
|
|
497
|
+
model: str = Field(
|
|
498
|
+
DEFAULT_LLM_MODELS["google"],
|
|
499
|
+
description="Model name for the selected provider. Unset, it follows LLM_PROVIDER: "
|
|
500
|
+
+ ", ".join(f"{name} uses {model}" for name, model in DEFAULT_LLM_MODELS.items())
|
|
501
|
+
+ ". An openai provider with LLM_BASE_URL keeps this default, so name the served "
|
|
502
|
+
"model there.",
|
|
503
|
+
)
|
|
483
504
|
model_revision: str | None = Field(
|
|
484
505
|
None,
|
|
485
506
|
description="Exact model revision/commit deployed (surfaced in qualification_provenance; "
|
|
@@ -840,6 +861,29 @@ class LlmOptions(_BibrSettings):
|
|
|
840
861
|
return v
|
|
841
862
|
return v
|
|
842
863
|
|
|
864
|
+
@model_validator(mode="after")
|
|
865
|
+
def _default_model_for_provider(self) -> "LlmOptions":
|
|
866
|
+
self.apply_provider_default_model()
|
|
867
|
+
return self
|
|
868
|
+
|
|
869
|
+
def apply_provider_default_model(self) -> None:
|
|
870
|
+
"""Give an unset ``model`` the default of the current ``provider``.
|
|
871
|
+
|
|
872
|
+
Runs when the settings are built and again after ``--llm-provider``
|
|
873
|
+
swaps the provider in place. The default stays out of
|
|
874
|
+
``model_fields_set``, so a later provider change still counts it as
|
|
875
|
+
unset. An openai provider with ``base_url`` points at a self-hosted
|
|
876
|
+
server whose model name bibr cannot guess, so it is left alone.
|
|
877
|
+
"""
|
|
878
|
+
if "model" in self.model_fields_set:
|
|
879
|
+
return
|
|
880
|
+
if self.provider == "openai" and self.base_url:
|
|
881
|
+
return
|
|
882
|
+
default = DEFAULT_LLM_MODELS.get(self.provider)
|
|
883
|
+
if default is not None and default != self.model:
|
|
884
|
+
self.model = default
|
|
885
|
+
self.model_fields_set.discard("model")
|
|
886
|
+
|
|
843
887
|
|
|
844
888
|
class OcrOptions(_BibrSettings):
|
|
845
889
|
"""OCR service settings. Env: ``OCR_BACKEND``, ``OCR_BASE_URL``, ..."""
|
|
@@ -1510,8 +1554,8 @@ class ResolverOptions(_BibrSettings):
|
|
|
1510
1554
|
"""Optional external bibr-resolver candidate-search service (tier 3 in the
|
|
1511
1555
|
enrichment chain). Default-off: when ``url`` is unset, bibr behaves exactly
|
|
1512
1556
|
as today. Env: ``BIBR_RESOLVER_URL``, ``BIBR_RESOLVER_ENRICH``,
|
|
1513
|
-
``BIBR_RESOLVER_TIMEOUT``, ``
|
|
1514
|
-
``BIBR_RESOLVER_FALLBACK_SOURCES``."""
|
|
1557
|
+
``BIBR_RESOLVER_TIMEOUT``, ``BIBR_RESOLVER_RETRIES``, ``BIBR_RESOLVER_MAX_CONCURRENCY``,
|
|
1558
|
+
``BIBR_RESOLVER_LIMIT``, ``BIBR_RESOLVER_FALLBACK_SOURCES``."""
|
|
1515
1559
|
|
|
1516
1560
|
model_config = _section("BIBR_RESOLVER_")
|
|
1517
1561
|
|
|
@@ -1526,18 +1570,45 @@ class ResolverOptions(_BibrSettings):
|
|
|
1526
1570
|
description="Master gate for the resolver; when false the resolver is skipped even if url is set.",
|
|
1527
1571
|
)
|
|
1528
1572
|
# Per-request timeout (seconds) for single resolver calls (/search, /works, /health).
|
|
1573
|
+
# 30, not 10: a resolver under batch load queues searches behind its own
|
|
1574
|
+
# concurrency limit, and at 10 s many of them timed out and left the
|
|
1575
|
+
# reference unmatched. A healthy resolver answers in well under a second, so
|
|
1576
|
+
# this only matters when it is busy, where waiting beats giving up.
|
|
1529
1577
|
timeout: float = Field(
|
|
1530
|
-
|
|
1578
|
+
30.0,
|
|
1531
1579
|
gt=0,
|
|
1532
1580
|
description="Per-request timeout in seconds for resolver calls (/search, /works, /health).",
|
|
1533
1581
|
)
|
|
1582
|
+
# A busy resolver answers 503; bibr used to take that as a failed search.
|
|
1583
|
+
retries: int = Field(
|
|
1584
|
+
3,
|
|
1585
|
+
ge=0,
|
|
1586
|
+
description="Times a resolver call is tried again after a busy answer (429/502/503/504), "
|
|
1587
|
+
"a timeout (once at most) or a dropped connection. 0 disables retries.",
|
|
1588
|
+
)
|
|
1589
|
+
retry_backoff: float = Field(
|
|
1590
|
+
1.0,
|
|
1591
|
+
ge=0,
|
|
1592
|
+
description="First wait in seconds before retrying a resolver call; it doubles on each "
|
|
1593
|
+
"retry (with jitter, capped at 30 s) and is never shorter than the resolver's Retry-After.",
|
|
1594
|
+
)
|
|
1595
|
+
# Each paper builds its own resolver client, so the per-paper limits below
|
|
1596
|
+
# multiply by the papers in flight: 12 papers x 8 searches flooded a
|
|
1597
|
+
# resolver that runs 16 searches at once. This cap is shared by every paper
|
|
1598
|
+
# in the process.
|
|
1599
|
+
max_concurrency: int = Field(
|
|
1600
|
+
8,
|
|
1601
|
+
ge=0,
|
|
1602
|
+
description="Max resolver requests in flight across all papers in this process (per "
|
|
1603
|
+
"resolver URL). 0 = no cap.",
|
|
1604
|
+
)
|
|
1534
1605
|
# Max candidates to request from the resolver /search endpoint.
|
|
1535
1606
|
limit: int = Field(
|
|
1536
1607
|
20, ge=1, description="Max candidates to request from the resolver /search endpoint."
|
|
1537
1608
|
)
|
|
1538
1609
|
# Max concurrent /search calls when prefetching a reference list's title searches.
|
|
1539
1610
|
search_concurrency: int = Field(
|
|
1540
|
-
|
|
1611
|
+
4,
|
|
1541
1612
|
ge=1,
|
|
1542
1613
|
description="Max concurrent /search calls when prefetching a reference list's title searches.",
|
|
1543
1614
|
)
|
|
@@ -2476,7 +2547,7 @@ class GlobalSettings(_BibrSettings):
|
|
|
2476
2547
|
# Reference extraction strategy — DECOUPLED segmentation + parsing axes
|
|
2477
2548
|
# (resolved in bibr.extract.ref_extractor._resolve_ref_strategies; per-run
|
|
2478
2549
|
# overrides ride RunConfig via chew(refs=...) / CLI --refs/--ref-seg).
|
|
2479
|
-
# The local
|
|
2550
|
+
# The local encoder-CRF parser ("ner") is the default: reference parsing
|
|
2480
2551
|
# is the bulk of bibr's LLM tokens, so doing it locally cuts most of the
|
|
2481
2552
|
# per-paper cost. To use LLM field parsing instead, set parse=llm (CLI
|
|
2482
2553
|
# `--refs llm`). Segmentation defaults to the local geometry GBM ("geom"),
|
|
@@ -2494,7 +2565,7 @@ class GlobalSettings(_BibrSettings):
|
|
|
2494
2565
|
)
|
|
2495
2566
|
REF_PARSE_STRATEGY: Literal["llm", "ner", "llm-chunked", "ref-llm", "off"] | None = Field(
|
|
2496
2567
|
"ner",
|
|
2497
|
-
description='Reference-parsing strategy: "ner" (default; local
|
|
2568
|
+
description='Reference-parsing strategy: "ner" (default; local encoder-CRF parser, no '
|
|
2498
2569
|
'per-reference LLM cost), "ref-llm" (dedicated fine-tuned reference model), "llm" (batched LLM), "llm-chunked" (chunk-tolerant '
|
|
2499
2570
|
'LLM parse over region-aligned chunks), or "off" (disable reference extraction entirely).',
|
|
2500
2571
|
)
|
|
@@ -2674,13 +2745,15 @@ class GlobalSettings(_BibrSettings):
|
|
|
2674
2745
|
description="Local path or HF Hub repo id for the NER reference-segmenter checkpoint "
|
|
2675
2746
|
"(optionally suffixed :filename.pt).",
|
|
2676
2747
|
)
|
|
2677
|
-
# Parser default is
|
|
2678
|
-
#
|
|
2679
|
-
#
|
|
2680
|
-
#
|
|
2681
|
-
#
|
|
2748
|
+
# Parser default is v5.1: UltraBERT-150M + feature-gated CRF trained on the
|
|
2749
|
+
# reference markup of CC BY / CC0 JATS papers, LinkedBooks and the v4.5 gold
|
|
2750
|
+
# rows (refsets sealed test ref_exact 0.75 vs 0.42 for v4.5, RenoBench 0.73
|
|
2751
|
+
# vs 0.56, v4.5 gold val entity F1 0.975 vs 0.966). The repo carries the encoder's config, modeling code and
|
|
2752
|
+
# tokenizer, so they load from it at NER_PARSER_REVISION. The parser path
|
|
2753
|
+
# (RefParser → FeatureGatedEncoderCRF, add_special_tokens=False) requires a
|
|
2754
|
+
# v4-format checkpoint; the legacy v1 parser is no longer loadable here.
|
|
2682
2755
|
NER_PARSER_CKPT: str = Field(
|
|
2683
|
-
"scienceverse/bibr-parser-
|
|
2756
|
+
"scienceverse/bibr-parser-v5-1-ultrabert",
|
|
2684
2757
|
description="Local path or HF Hub repo id for the NER reference-parser checkpoint "
|
|
2685
2758
|
"(optionally suffixed :filename.pt). Requires a v4-format checkpoint.",
|
|
2686
2759
|
)
|
|
@@ -2694,9 +2767,23 @@ class GlobalSettings(_BibrSettings):
|
|
|
2694
2767
|
"track the latest revision instead.",
|
|
2695
2768
|
)
|
|
2696
2769
|
NER_PARSER_REVISION: str = Field(
|
|
2697
|
-
"
|
|
2770
|
+
"97b06cc7dd6511bdd53f8855c93a29020231d215",
|
|
2698
2771
|
description='Pinned commit revision for the NER parser checkpoint. Set to "main" to track '
|
|
2699
|
-
"the latest revision instead
|
|
2772
|
+
"the latest revision instead; a parser repo that ships its own encoder code (v5) loads "
|
|
2773
|
+
"only from a commit SHA or a local directory.",
|
|
2774
|
+
)
|
|
2775
|
+
# Unset, the encoder comes from the checkpoint (bibr.ner.parser.resolve_encoder):
|
|
2776
|
+
# the parser repo itself when it ships a config.json, else ModernBERT-base.
|
|
2777
|
+
NER_PARSER_ENCODER: str | None = Field(
|
|
2778
|
+
None,
|
|
2779
|
+
description="Encoder (HF Hub repo id or local directory) whose config, modeling code and "
|
|
2780
|
+
"tokenizer the torch NER parser loads. Unset: the checkpoint's own (a parser repo with a "
|
|
2781
|
+
"config.json, at NER_PARSER_REVISION), else answerdotai/ModernBERT-base.",
|
|
2782
|
+
)
|
|
2783
|
+
NER_PARSER_ENCODER_REVISION: str | None = Field(
|
|
2784
|
+
None,
|
|
2785
|
+
description="Revision of NER_PARSER_ENCODER. An encoder with its own modeling code runs it "
|
|
2786
|
+
"only from a local directory or a commit SHA revision.",
|
|
2700
2787
|
)
|
|
2701
2788
|
NER_DEVICE: str | None = Field(
|
|
2702
2789
|
None, description="Device for NER checkpoints: cpu, cuda, or mps (auto-detected if unset)."
|
|
@@ -59,7 +59,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
59
59
|
default=None,
|
|
60
60
|
help=(
|
|
61
61
|
"Reference extraction strategy: 'ner' (default) parses each reference "
|
|
62
|
-
"with the local
|
|
62
|
+
"with the local encoder-CRF model (no per-reference LLM cost); 'llm' "
|
|
63
63
|
"parses the bibliography with the configured LLM. "
|
|
64
64
|
"Overrides REF_PARSE_STRATEGY for the demo."
|
|
65
65
|
),
|
|
@@ -217,6 +217,9 @@ async def prefetch_enrichment(
|
|
|
217
217
|
resolver_client = ResolverClient(
|
|
218
218
|
effective.resolver.url,
|
|
219
219
|
timeout=effective.resolver.timeout,
|
|
220
|
+
retries=effective.resolver.retries,
|
|
221
|
+
retry_backoff=effective.resolver.retry_backoff,
|
|
222
|
+
max_concurrency=effective.resolver.max_concurrency,
|
|
220
223
|
)
|
|
221
224
|
owns_resolver = True
|
|
222
225
|
prefetch.resolver_client = resolver_client
|
|
@@ -496,6 +499,9 @@ async def enrich_paper_identity(
|
|
|
496
499
|
resolver_client = ResolverClient(
|
|
497
500
|
effective.resolver.url,
|
|
498
501
|
timeout=effective.resolver.timeout,
|
|
502
|
+
retries=effective.resolver.retries,
|
|
503
|
+
retry_backoff=effective.resolver.retry_backoff,
|
|
504
|
+
max_concurrency=effective.resolver.max_concurrency,
|
|
499
505
|
)
|
|
500
506
|
owns_resolver = True
|
|
501
507
|
if resolver_client is not None and not await resolver_client.healthy():
|