citeformer 0.3.2__tar.gz → 0.3.3__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.
- {citeformer-0.3.2 → citeformer-0.3.3}/AGENTS.md +2 -2
- {citeformer-0.3.2 → citeformer-0.3.3}/CHANGELOG.md +29 -1
- {citeformer-0.3.2 → citeformer-0.3.3}/CITATION.cff +1 -1
- {citeformer-0.3.2 → citeformer-0.3.3}/CLAUDE.md +5 -2
- {citeformer-0.3.2 → citeformer-0.3.3}/PKG-INFO +12 -12
- {citeformer-0.3.2 → citeformer-0.3.3}/PREPRINT.md +7 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/README.md +11 -11
- citeformer-0.3.3/docs/guarantees.md +62 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/index.md +8 -9
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/reference/architecture.md +12 -10
- {citeformer-0.3.2 → citeformer-0.3.3}/hf-space/app.py +3 -3
- {citeformer-0.3.2 → citeformer-0.3.3}/pyproject.toml +6 -7
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/__init__.py +1 -1
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/_version.py +1 -1
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/backends/__init__.py +11 -11
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/backends/openrouter.py +9 -12
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/backends/together.py +4 -4
- citeformer-0.3.2/docs/guarantees.md +0 -45
- {citeformer-0.3.2 → citeformer-0.3.3}/.claude/agents/contract-reviewer.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.claude/commands/bump.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.claude/commands/contract-check.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.claude/commands/release-check.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.claude/commands/release.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.claude/launch.json +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.claude/skills/add-citation-format/SKILL.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.claude/skills/contract-invariant/SKILL.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.claude/skills/grammar-shape/SKILL.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.claude/skills/piggyback-first/SKILL.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.claude/skills/release-bump/SKILL.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.env.example +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.github/FUNDING.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.github/dependabot.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.github/pull_request_template.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.github/workflows/ci.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.github/workflows/release.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.gitignore +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.pre-commit-config.yaml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/.readthedocs.yaml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/AUTHORS.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/CODE_OF_CONDUCT.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/CONTRIBUTING.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/LICENSE +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/Makefile +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/SECURITY.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/README.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/__init__.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/_common.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/adversarial.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/alce_subset.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/calibration_data.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/demo.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/fetch_fixtures.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/alce-20260424T015354Z.json +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/figures/cover-annotated.png +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/figures/fabrication-structural-vs-empirical.png +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/figures/multiprompt-summary.png +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/figures/nli_calibration_DeBERTa-v3-large-mnli-fever-anli-ling-wanli.png +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/figures/nli_calibration_nli-deberta-v3-base.png +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/figures/premise-comparison.png +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/figures/sweep-summary.png +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/figures/thread-flow.png +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/figures/thread-multi.png +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/figures/thread-render.png +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/figures/thread-verify.png +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/multiprompt-20260423T234641Z.json +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/multiprompt-20260424T020138Z.json +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/nli_calibration_DeBERTa-v3-large-mnli-fever-anli-ling-wanli.json +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/nli_calibration_nli-deberta-v3-base.json +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/sweep-20260423T212115Z.json +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/sweep-20260423T214616Z.json +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/sweep-20260423T215333Z.json +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/sweep-20260423T215926Z.json +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/sweep-20260423T223040Z.json +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/findings/sweep-20260423T223421Z.json +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/fixtures/ai_papers.json +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/generate_cover.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/multiprompt_sweep.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/plot.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/sweep.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/benchmarks/threshold_calibration.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/conf.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/001-gbnf-over-lark.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/002-inline-markers-stay-numeric.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/003-bundle-five-csl-styles.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/004-citeproc-rewrite.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/005-metadata-deps-in-main-install.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/006-vllm-excluded-from-all-extra.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/007-required-policy-progression-gap.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/008-generation-result-schema-v2.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/009-bounded-content-required.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/010-verification-report-schema-v3.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/011-configurable-marker-styles.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/012-generation-result-schema-v3.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/013-citation-rich-attribution.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/014-async-surface.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/015-defer-bedrock-vertex.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/016-defer-fine-grain-windowing.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/017-defer-cost-tables.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/decisions/index.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/development/dev-setup.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/development/releasing.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/getting-started.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/reference/api.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/reference/contracts.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/reference/index.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/spec/v0.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/docs/verification.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/examples/01_quickstart_mock.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/examples/02_rag_with_hf_and_verify.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/examples/03_standalone_rendering.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/examples/04_fetch_and_render.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/examples/05_streaming.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/examples/06_langchain_rag.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/examples/07_llamaindex_rag.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/examples/08_literature_review.ipynb +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/examples/09_bibtex_source.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/examples/README.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/hf-space/README.md +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/hf-space/deploy.sh +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/hf-space/requirements.txt +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/backends/anthropic.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/backends/base.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/backends/fireworks.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/backends/gemini.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/backends/hf.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/backends/llamacpp.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/backends/mistral.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/backends/mock.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/backends/openai.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/backends/vllm.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/citeformer.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/cli/__init__.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/cli/app.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/core.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/csl.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/grammar/__init__.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/grammar/builder.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/integrations/__init__.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/integrations/langchain.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/integrations/llamaindex.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/metadata/__init__.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/metadata/arxiv.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/metadata/bibtex.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/metadata/cache.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/metadata/crossref.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/metadata/pdf.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/metadata/url.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/metadata/zotero.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/prompts.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/py.typed +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/render/__init__.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/render/csl.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/render/formatters/__init__.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/render/formatters/_base.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/render/formatters/apa.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/render/formatters/chicago.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/render/formatters/ieee.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/render/formatters/mla.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/render/formatters/nature.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/render/formatters/vancouver.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/render/styles.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/verify/__init__.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/verify/coverage.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/verify/entailment.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/verify/existence.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/verify/nli.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/verify/report.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/verify/sentences.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/src/citeformer/verify/verifier.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/integration/__init__.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/integration/test_api_backends_live.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/integration/test_env_connectivity.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/integration/test_hf_backend.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/integration/test_integrations_real_libs.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/integration/test_llamacpp_backend.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/integration/test_schemas/test_generation_result_canonical_snapshot.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/integration/test_schemas/test_verification_report_canonical_snapshot.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/integration/test_schemas.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/integration/test_verify_nli.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/integration/test_vllm_backend.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/cassettes/test_extract_url_returns_metadata_and_content.yaml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/cassettes/test_fetch_arxiv_returns_csl_json_with_abstract.yaml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/cassettes/test_fetch_arxiv_strips_version_suffix.yaml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/cassettes/test_fetch_crossref_accepts_url_and_prefixed_forms.yaml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/cassettes/test_fetch_crossref_returns_csl_json.yaml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/cassettes/test_source_from_arxiv_puts_abstract_in_content.yaml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/cassettes/test_source_from_doi_builds_source.yaml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/cassettes/test_source_from_url_builds_source.yaml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_alce_metrics.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_api_backends.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_async_surface.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_backend_conformance.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_backends_mock.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_bibtex_zotero.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_citeformer.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_cli.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_core.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_csl_suite/test_csl_suite_snapshot_apa_7.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_csl_suite/test_csl_suite_snapshot_chicago_author_date.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_csl_suite/test_csl_suite_snapshot_ieee.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_csl_suite/test_csl_suite_snapshot_mla_9.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_csl_suite/test_csl_suite_snapshot_nature.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_csl_suite/test_csl_suite_snapshot_vancouver.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_csl_suite.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_csl_validation.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_dedupe.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_fireworks_together_backends.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_formatters.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_formatters_edge_cases.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_fuzz.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_gemini_mistral_backends.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_grammar_builder/test_grammar_auto_snapshot.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_grammar_builder/test_grammar_quotes_only_snapshot.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_grammar_builder/test_grammar_required_custom_bound_snapshot.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_grammar_builder/test_grammar_required_snapshot.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_grammar_builder/test_grammar_required_unbounded_snapshot.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_grammar_builder/test_grammar_scales_cite_id_with_n_sources.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_grammar_builder.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_integrations.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_marker_styles.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_metadata_cache.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_metadata_fetchers.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_metadata_pdf.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_nli_chunking.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_openrouter_backend.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_pdf_grobid.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_prompts.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_render_csl/test_render_snapshot_apa_7.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_render_csl/test_render_snapshot_chicago_author_date.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_render_csl/test_render_snapshot_ieee.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_render_csl/test_render_snapshot_mla_9.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_render_csl/test_render_snapshot_nature.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_render_csl/test_render_snapshot_vancouver.yml +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_render_csl.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_render_styles.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_streaming.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_verify.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/tests/unit/test_version.py +0 -0
- {citeformer-0.3.2 → citeformer-0.3.3}/uv.lock +0 -0
|
@@ -4,9 +4,9 @@ Canonical agent guide for this repo. Native readers: Cursor, Codex, GitHub Copil
|
|
|
4
4
|
|
|
5
5
|
## What this repo is
|
|
6
6
|
|
|
7
|
-
`citeformer` is a Python OSS library: **
|
|
7
|
+
`citeformer` is a Python OSS library: **verifiably cited text from language models, with citation markers constrained to the sources you supply**. Full pitch: [`README.md`](README.md). Full design: [`docs/reference/architecture.md`](docs/reference/architecture.md). Frozen genesis spec: [`docs/spec/v0.md`](docs/spec/v0.md).
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
It ships **ten backends**: three local (HF transformers, vLLM, llama.cpp) that mask tokens in-process with citeformer's GBNF; Fireworks, which runs the same GBNF provider-side; five JSON-schema API backends (OpenAI, Gemini, Mistral, Together, OpenRouter) where the provider bounds citation ids with an enum; and Anthropic, adapted from its native Citations API. Token-level masking is guaranteed only where a grammar is in play; the per-backend mechanism and its limits are in [`docs/guarantees.md`](docs/guarantees.md) and [`docs/reference/architecture.md`](docs/reference/architecture.md#tiered-enforcement--where-the-masking-runs).
|
|
10
10
|
|
|
11
11
|
## Where to start
|
|
12
12
|
|
|
@@ -6,6 +6,33 @@ Versioning policy: **patch bumps are cheap**. See [docs/development/releasing.md
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.3.3] — 2026-12-06
|
|
10
|
+
|
|
11
|
+
Patch release. Docs and docstrings only, so the PyPI page states per
|
|
12
|
+
backend how citations are enforced. No public API or §10 contract changes.
|
|
13
|
+
|
|
14
|
+
### Changed — per-backend enforcement wording
|
|
15
|
+
|
|
16
|
+
- README, `docs/index.md`, `docs/reference/architecture.md` and backend
|
|
17
|
+
module docstrings said strict structured outputs is "real token-level
|
|
18
|
+
constrained sampling on every modern provider". That overstated it.
|
|
19
|
+
The docs now say per backend how the citation rule is enforced:
|
|
20
|
+
in-process GBNF (HF, vLLM, llama.cpp), provider-side GBNF (Fireworks),
|
|
21
|
+
a provider-enforced JSON-schema enum (OpenAI, Gemini, Mistral,
|
|
22
|
+
Together; OpenAI documents it as constrained decoding, the others are
|
|
23
|
+
not verified by citeformer), forwarded to the routed upstream
|
|
24
|
+
(OpenRouter), or the native Citations API (Anthropic).
|
|
25
|
+
- `docs/guarantees.md` lists all ten backends with their mechanism,
|
|
26
|
+
and notes that the JSON-schema backends bound only the `citations`
|
|
27
|
+
array (segment text is free-form) and that out-of-range ids are
|
|
28
|
+
skipped at render time but not removed from `result.citations`.
|
|
29
|
+
- Stale version facts: `AGENTS.md` ("v0.1 ships seven backends"),
|
|
30
|
+
`CLAUDE.md` (current release), and the architecture phase plan.
|
|
31
|
+
`PREPRINT.md` is kept as a dated v0.1.0 document with a short note
|
|
32
|
+
pointing at current docs.
|
|
33
|
+
- Dropped "bulletproof" from `AGENTS.md`, `CLAUDE.md`, the package
|
|
34
|
+
docstring, the guarantees page and the HF Space demo header.
|
|
35
|
+
|
|
9
36
|
## [0.3.2] — 2026-12-06
|
|
10
37
|
|
|
11
38
|
Patch release. Ships the security dependency refresh (core `pypdf`
|
|
@@ -1302,7 +1329,8 @@ the guarantee on a real (tiny) model — ``gpt2`` via MPS/CPU.
|
|
|
1302
1329
|
- §10.2 CSL metadata: not yet implemented (lands in P3).
|
|
1303
1330
|
- §10.3 output schemas: not yet implemented (lands in P1).
|
|
1304
1331
|
|
|
1305
|
-
[Unreleased]: https://github.com/random-walks/citeformer/compare/v0.3.
|
|
1332
|
+
[Unreleased]: https://github.com/random-walks/citeformer/compare/v0.3.3...HEAD
|
|
1333
|
+
[0.3.3]: https://github.com/random-walks/citeformer/releases/tag/v0.3.3
|
|
1306
1334
|
[0.3.2]: https://github.com/random-walks/citeformer/releases/tag/v0.3.2
|
|
1307
1335
|
[0.3.1]: https://github.com/random-walks/citeformer/releases/tag/v0.3.1
|
|
1308
1336
|
[0.3.0]: https://github.com/random-walks/citeformer/releases/tag/v0.3.0
|
|
@@ -4,7 +4,7 @@ One-screen brief for Claude Code working in this repo. Canonical wider guide is
|
|
|
4
4
|
|
|
5
5
|
## What this is
|
|
6
6
|
|
|
7
|
-
`citeformer` is a Python OSS library:
|
|
7
|
+
`citeformer` is a Python OSS library: verifiably cited text from language models. Citation markers are *structurally impossible to fabricate* at the token level on the grammar backends (HF + XGrammar/llguidance, vLLM, llama.cpp in-process; Fireworks provider-side), bounded by a provider-enforced JSON-schema enum on OpenAI / Gemini / Mistral / Together / OpenRouter, and provider-native on Anthropic (Citations API). Per-backend detail: [`docs/guarantees.md`](docs/guarantees.md). Reference lists are rendered deterministically by six hand-written CSL formatters (APA 7, MLA 9, Chicago author-date, IEEE, Nature, Vancouver — see [ADR-004](docs/decisions/004-citeproc-rewrite.md)). The model never touches the bibliography. The library's point is **composition** — we piggyback on XGrammar, llguidance, transformers, vLLM, llama.cpp, lark, httpx, diskcache, grobid, readability, and DeBERTa-v3-MNLI. Full piggyback map + architecture in [`docs/reference/architecture.md`](docs/reference/architecture.md); **read it before writing grammar / rendering / decoding / verification code**.
|
|
8
8
|
|
|
9
9
|
## Invariants — DO NOT CHANGE SILENTLY
|
|
10
10
|
|
|
@@ -65,7 +65,7 @@ make release-check # preflight for tag push
|
|
|
65
65
|
|
|
66
66
|
## Phase status
|
|
67
67
|
|
|
68
|
-
Current release: **v0.3.
|
|
68
|
+
Current release: **v0.3.3** (PyPI, 2026-12-06; see
|
|
69
69
|
`src/citeformer/_version.py` and `CHANGELOG.md`). Work happens on `main`
|
|
70
70
|
via short-lived feature branches. Phase breakdown in
|
|
71
71
|
[`docs/reference/architecture.md`](docs/reference/architecture.md).
|
|
@@ -85,6 +85,9 @@ via short-lived feature branches. Phase breakdown in
|
|
|
85
85
|
results. ✅
|
|
86
86
|
- **v0.3.1** — PyPI page link fixes, `CITATION.cff`, codecov upload
|
|
87
87
|
reliability. ✅
|
|
88
|
+
- **v0.3.2** — README/PyPI accuracy pass, dependency security refresh. ✅
|
|
89
|
+
- **v0.3.3** — per-backend enforcement wording in README + docs, stale
|
|
90
|
+
version facts. ✅
|
|
88
91
|
- **Next** — scope TBD. Candidates: full-ALCE reproducibility, streaming
|
|
89
92
|
refinements, per-chunk NLI during generation.
|
|
90
93
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: citeformer
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Verifiably cited text from language models: citation markers constrained to supplied sources via grammar-constrained decoding.
|
|
5
5
|
Project-URL: Homepage, https://citeformer.readthedocs.io
|
|
6
6
|
Project-URL: Repository, https://github.com/random-walks/citeformer
|
|
@@ -132,14 +132,14 @@ Description-Content-Type: text/markdown
|
|
|
132
132
|
|
|
133
133
|
### What it does — one paragraph for everyone
|
|
134
134
|
|
|
135
|
-
Language models hallucinate citations. Ask GPT-4, Claude, or an open-source model to cite "source [7]" when you only gave it six sources and it will often invent `[7]`, `[8]`, sometimes `[42]`. citeformer stops that at decode time. Before the model picks its next token, we compile a tiny grammar that only admits citation markers pointing at sources you actually supplied, and we hand that grammar to the decoder. On the local backends, an out-of-scope marker cannot be sampled at all; on the API backends the
|
|
135
|
+
Language models hallucinate citations. Ask GPT-4, Claude, or an open-source model to cite "source [7]" when you only gave it six sources and it will often invent `[7]`, `[8]`, sometimes `[42]`. citeformer stops that at decode time. Before the model picks its next token, we compile a tiny grammar that only admits citation markers pointing at sources you actually supplied, and we hand that grammar to the decoder. On the local backends, an out-of-scope marker cannot be sampled at all; on the API backends the rule is handed to the provider as a grammar, a JSON schema, or (Anthropic) its own Citations API (see [guarantees](https://citeformer.readthedocs.io/en/stable/guarantees.html) for exactly what each tier covers). Bibliographies are rendered deterministically by the library in six academic styles (APA, MLA, Chicago, IEEE, Nature, Vancouver), and every emitted claim can be NLI-verified against its cited source after the fact. Install with `uv add citeformer` (or `pip install citeformer`), or run the [Gradio demo](https://github.com/random-walks/citeformer/tree/main/hf-space) locally.
|
|
136
136
|
|
|
137
137
|
### What makes it interesting — for the applied-AI crowd
|
|
138
138
|
|
|
139
139
|
> If you've read the jsonformer source or thought about logit-layer structured output, skip to [Backends](#backends).
|
|
140
140
|
|
|
141
141
|
- **Logit-masked GBNF.** The `cite-id` terminal is compiled per call to `"[" ("1" | "2" | ... | "N") "]"` and handed to [XGrammar](https://github.com/mlc-ai/xgrammar) (default) or [llguidance](https://github.com/guidance-ai/llguidance). Out-of-scope tokens get masked to zero probability before sampling — the sampler *never sees them*. This is structural, not rejection-sampled.
|
|
142
|
-
- **Ten backends,
|
|
142
|
+
- **Ten backends, one `GenerationResult`, enforcement stated per provider.** HF + vLLM + llama.cpp mask tokens in-process via XGrammar / llguidance / GBNF. **Fireworks** takes citeformer's GBNF *unchanged* through its native `type: grammar` mode, so the same `cite-id` rule masks tokens inside the Fireworks runtime. OpenAI, Gemini, Mistral and Together get a JSON schema whose citation array is an enum of in-scope ids; OpenAI documents strict mode as constrained decoding, while for the others citeformer relies on the provider honouring the schema and can't see how it does so. OpenRouter passes the strict schema to whichever upstream it routes to. Anthropic doesn't use a grammar or schema at all: it's adapted from the native Citations API. Per-backend detail: [guarantees](https://citeformer.readthedocs.io/en/stable/guarantees.html). All collapse to the same typed output for downstream verify / render / streaming.
|
|
143
143
|
- **The model never touches the bibliography.** Six hand-written CSL formatters (~1 kLOC, no citeproc-py dependency — see [ADR-004](https://citeformer.readthedocs.io/en/stable/decisions/004-citeproc-rewrite.html)) render references deterministically. 300 locked snapshots pin the formatter outputs.
|
|
144
144
|
- **Verify is real, not a hit rate.** `result.verify()` runs DeBERTa-v3-large-MNLI over every (source content, cited sentence) pair and returns a typed `VerificationReport` — with a coverage check for uncited-but-entailed sentences. Threshold calibration + the honest bimodal-score finding live in [benchmarks/README.md#finding-4](https://github.com/random-walks/citeformer/blob/main/benchmarks/README.md#finding-4--nli-threshold-calibration-deberta-v3-large-is-bimodal).
|
|
145
145
|
- **0 fabrications in 40 runs.** 4 prompt shapes × 2 models × 5 seeds in [`benchmarks/multiprompt_sweep.py`](https://github.com/random-walks/citeformer/blob/main/benchmarks/multiprompt_sweep.py). On the local backends that is expected by construction: the grammar mask leaves nothing to vary.
|
|
@@ -156,7 +156,7 @@ Language models still cite sources that don't exist, including in RAG setups whe
|
|
|
156
156
|
|
|
157
157
|
It does that in three independent ways:
|
|
158
158
|
|
|
159
|
-
- **Citation markers can't be fabricated.** `[N]` where `N > len(sources)` is token-impossible to sample on local backends
|
|
159
|
+
- **Citation markers can't be fabricated.** `[N]` where `N > len(sources)` is token-impossible to sample on the local backends and on Fireworks's grammar mode. On the JSON-schema API backends the citation ids are enum-bounded by the provider's structured-output mode, and Anthropic's Citations API only references documents you passed in (see [guarantees](https://citeformer.readthedocs.io/en/stable/guarantees.html) for what each covers). Measured on the local HF backend across [40 multi-prompt runs](https://github.com/random-walks/citeformer/blob/main/benchmarks/README.md#finding-5--multi-prompt-sweep-structural-guarantee-is-prompt-invariant): **0% fabrication on every prompt × model × seed triple**.
|
|
160
160
|
- **Bibliographies are rendered by the library, not the model.** Six styles, deterministic output, [300 locked snapshots](https://github.com/random-walks/citeformer/tree/main/tests/unit/test_csl_suite).
|
|
161
161
|
- **Every citation is claim-verifiable.** `result.verify()` runs NLI entailment per cite and returns a structured `VerificationReport` — not just a hit rate.
|
|
162
162
|
|
|
@@ -172,8 +172,8 @@ uv add 'citeformer[hf]' # HuggingFace transformers + XGrammar
|
|
|
172
172
|
uv add 'citeformer[llamacpp]' # llama.cpp native GBNF
|
|
173
173
|
uv add 'citeformer[vllm]' # vLLM guided-decoding (Linux/CUDA only)
|
|
174
174
|
|
|
175
|
-
# API backends —
|
|
176
|
-
#
|
|
175
|
+
# API backends — enforcement happens on the provider side; the mechanism differs
|
|
176
|
+
# per provider (grammar, JSON schema, or Anthropic's Citations API). See docs/guarantees.md.
|
|
177
177
|
uv add 'citeformer[openai]' # Structured Outputs strict=true
|
|
178
178
|
uv add 'citeformer[anthropic]' # Citations API adapter (with prompt-caching on)
|
|
179
179
|
uv add 'citeformer[openrouter]' # Multi-provider routing (anthropic/.., openai/.., google/..)
|
|
@@ -233,18 +233,18 @@ print(f"{report.support_rate:.0%} of cites entailed by their source")
|
|
|
233
233
|
|
|
234
234
|
## Backends
|
|
235
235
|
|
|
236
|
-
Ten backends,
|
|
236
|
+
Ten backends, one `Backend` ABC. The Enforcement column says how the citation rule reaches the model; [guarantees](https://citeformer.readthedocs.io/en/stable/guarantees.html) says what each mechanism does and doesn't cover:
|
|
237
237
|
|
|
238
238
|
| Backend | Extra | Enforcement | Where it lives | Notes |
|
|
239
239
|
|--------------------|--------------|--------------------------------------------|---------------------------------|-------|
|
|
240
240
|
| `HFBackend` | `hf` | In-process (XGrammar) | `citeformer.backends.hf` | Flagship. Grammar-level token masking. |
|
|
241
241
|
| `LlamaCppBackend` | `llamacpp` | In-process (GBNF) | `citeformer.backends.llamacpp` | Native GBNF via `llama-cpp-python`. CPU + Metal + CUDA. |
|
|
242
242
|
| `VLLMBackend` | `vllm` | In-process (XGrammar/llguidance) | `citeformer.backends.vllm` | vLLM guided decoding. Linux/CUDA only. |
|
|
243
|
-
| `FireworksBackend` | `fireworks` | Provider-runtime (**native GBNF**) | `citeformer.backends.fireworks` | Drops citeformer's `cite-id` grammar in unchanged via Fireworks's `response_format={"type":"grammar"}` mode.
|
|
243
|
+
| `FireworksBackend` | `fireworks` | Provider-runtime (**native GBNF**) | `citeformer.backends.fireworks` | Drops citeformer's `cite-id` grammar in unchanged via Fireworks's `response_format={"type":"grammar"}` mode. Token-level masking on a hosted API. |
|
|
244
244
|
| `OpenAIBackend` | `openai` | Provider-runtime (strict JSON) | `citeformer.backends.openai` | OpenAI Structured Outputs — live verified. |
|
|
245
245
|
| `AnthropicBackend` | `anthropic` | Provider-native (Citations API) | `citeformer.backends.anthropic` | Live verified. Prompt-caching on by default; real `messages.stream()` streaming; `cited_text` + `source_span` preserved on every Citation. |
|
|
246
|
-
| `OpenRouterBackend`| `openrouter` | Provider-runtime (per-upstream) | `citeformer.backends.openrouter`| Multi-provider routing on the OpenAI wire format. `provider.require_parameters: true`
|
|
247
|
-
| `TogetherBackend` | `together` | Provider-runtime (strict `json_schema`) | `citeformer.backends.together` |
|
|
246
|
+
| `OpenRouterBackend`| `openrouter` | Provider-runtime (per-upstream) | `citeformer.backends.openrouter`| Multi-provider routing on the OpenAI wire format. `provider.require_parameters: true` (default) only routes to upstreams that accept the strict `response_format`. Reports per-call cost in OR credits. |
|
|
247
|
+
| `TogetherBackend` | `together` | Provider-runtime (strict `json_schema`) | `citeformer.backends.together` | Together's `json_schema` mode on open-weight upstreams (Llama / Qwen / DeepSeek). |
|
|
248
248
|
| `GeminiBackend` | `gemini` | Provider-runtime (`response_schema`) | `citeformer.backends.gemini` | Gemini's OpenAPI-subset structured output. |
|
|
249
249
|
| `MistralBackend` | `mistral` | Provider-runtime (strict JSON) | `citeformer.backends.mistral` | Mistral's `response_format` strict JSON schema. |
|
|
250
250
|
| `MockBackend` | (core) | Scripted | `citeformer.backends.mock` | For tests. Honors policies + marker styles. |
|
|
@@ -272,7 +272,7 @@ cf = Citeformer(backend=OpenAIBackend(model="gpt-4o-mini"),
|
|
|
272
272
|
result = cf.generate(prompt="Describe the opening in one sentence.", sources=sources)
|
|
273
273
|
```
|
|
274
274
|
|
|
275
|
-
|
|
275
|
+
Where enforcement happens: **local** backends mask in-process via XGrammar / llguidance / GBNF, so out-of-scope citations are token-impossible to sample on your hardware. **Fireworks** runs the same GBNF inside its runtime. **OpenAI / Gemini / Mistral / Together** receive a strict JSON schema with the citation ids as an enum; OpenAI documents strict mode as constrained decoding, and for the others citeformer relies on the provider honouring the schema without being able to see the mechanism. The schema bounds the `citations` array only; the segment text is free-form. **OpenRouter** forwards the strict schema and, by default, only routes to upstreams that accept it. **Anthropic** uses its own Citations API, which returns references to the documents you supplied rather than free-form markers. All collapse to the same `GenerationResult` for downstream verify / render. Per-call token usage and (on OpenRouter) per-call cost in OpenRouter credits are exposed on `result.usage`.
|
|
276
276
|
|
|
277
277
|
## Citation policies
|
|
278
278
|
|
|
@@ -327,7 +327,7 @@ for chunk in stream:
|
|
|
327
327
|
result = stream.finalize() # full GenerationResult with parsed citations + refs
|
|
328
328
|
```
|
|
329
329
|
|
|
330
|
-
|
|
330
|
+
On the grammar backends the constraint applies to every chunk. HF and llama.cpp deliver true token-by-token streaming; the API backends chunk on sentence boundaries for UI progression.
|
|
331
331
|
|
|
332
332
|
## Evidence
|
|
333
333
|
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
**Blaise Albis-Burdige · April 2026 · v0.1.0**
|
|
4
4
|
|
|
5
|
+
> **Note (December 2026):** this is a dated write-up of v0.1.0 and is kept
|
|
6
|
+
> as written. Since then citeformer has grown to ten backends (adding
|
|
7
|
+
> Fireworks, OpenRouter and Together) and its docs avoid the word
|
|
8
|
+
> "bulletproof". For current behaviour, and for which backends enforce at
|
|
9
|
+
> the token level, see [CHANGELOG.md](CHANGELOG.md) and
|
|
10
|
+
> [docs/guarantees.md](docs/guarantees.md).
|
|
11
|
+
|
|
5
12
|
**Abstract.** Citation fabrication in retrieval-augmented generation
|
|
6
13
|
(RAG) remains a first-class reliability problem: 2026 surveys place
|
|
7
14
|
fabrication rates between 14 % and 95 % depending on the benchmark and
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
|
|
14
14
|
### What it does — one paragraph for everyone
|
|
15
15
|
|
|
16
|
-
Language models hallucinate citations. Ask GPT-4, Claude, or an open-source model to cite "source [7]" when you only gave it six sources and it will often invent `[7]`, `[8]`, sometimes `[42]`. citeformer stops that at decode time. Before the model picks its next token, we compile a tiny grammar that only admits citation markers pointing at sources you actually supplied, and we hand that grammar to the decoder. On the local backends, an out-of-scope marker cannot be sampled at all; on the API backends the
|
|
16
|
+
Language models hallucinate citations. Ask GPT-4, Claude, or an open-source model to cite "source [7]" when you only gave it six sources and it will often invent `[7]`, `[8]`, sometimes `[42]`. citeformer stops that at decode time. Before the model picks its next token, we compile a tiny grammar that only admits citation markers pointing at sources you actually supplied, and we hand that grammar to the decoder. On the local backends, an out-of-scope marker cannot be sampled at all; on the API backends the rule is handed to the provider as a grammar, a JSON schema, or (Anthropic) its own Citations API (see [guarantees](https://citeformer.readthedocs.io/en/stable/guarantees.html) for exactly what each tier covers). Bibliographies are rendered deterministically by the library in six academic styles (APA, MLA, Chicago, IEEE, Nature, Vancouver), and every emitted claim can be NLI-verified against its cited source after the fact. Install with `uv add citeformer` (or `pip install citeformer`), or run the [Gradio demo](https://github.com/random-walks/citeformer/tree/main/hf-space) locally.
|
|
17
17
|
|
|
18
18
|
### What makes it interesting — for the applied-AI crowd
|
|
19
19
|
|
|
20
20
|
> If you've read the jsonformer source or thought about logit-layer structured output, skip to [Backends](#backends).
|
|
21
21
|
|
|
22
22
|
- **Logit-masked GBNF.** The `cite-id` terminal is compiled per call to `"[" ("1" | "2" | ... | "N") "]"` and handed to [XGrammar](https://github.com/mlc-ai/xgrammar) (default) or [llguidance](https://github.com/guidance-ai/llguidance). Out-of-scope tokens get masked to zero probability before sampling — the sampler *never sees them*. This is structural, not rejection-sampled.
|
|
23
|
-
- **Ten backends,
|
|
23
|
+
- **Ten backends, one `GenerationResult`, enforcement stated per provider.** HF + vLLM + llama.cpp mask tokens in-process via XGrammar / llguidance / GBNF. **Fireworks** takes citeformer's GBNF *unchanged* through its native `type: grammar` mode, so the same `cite-id` rule masks tokens inside the Fireworks runtime. OpenAI, Gemini, Mistral and Together get a JSON schema whose citation array is an enum of in-scope ids; OpenAI documents strict mode as constrained decoding, while for the others citeformer relies on the provider honouring the schema and can't see how it does so. OpenRouter passes the strict schema to whichever upstream it routes to. Anthropic doesn't use a grammar or schema at all: it's adapted from the native Citations API. Per-backend detail: [guarantees](https://citeformer.readthedocs.io/en/stable/guarantees.html). All collapse to the same typed output for downstream verify / render / streaming.
|
|
24
24
|
- **The model never touches the bibliography.** Six hand-written CSL formatters (~1 kLOC, no citeproc-py dependency — see [ADR-004](https://citeformer.readthedocs.io/en/stable/decisions/004-citeproc-rewrite.html)) render references deterministically. 300 locked snapshots pin the formatter outputs.
|
|
25
25
|
- **Verify is real, not a hit rate.** `result.verify()` runs DeBERTa-v3-large-MNLI over every (source content, cited sentence) pair and returns a typed `VerificationReport` — with a coverage check for uncited-but-entailed sentences. Threshold calibration + the honest bimodal-score finding live in [benchmarks/README.md#finding-4](https://github.com/random-walks/citeformer/blob/main/benchmarks/README.md#finding-4--nli-threshold-calibration-deberta-v3-large-is-bimodal).
|
|
26
26
|
- **0 fabrications in 40 runs.** 4 prompt shapes × 2 models × 5 seeds in [`benchmarks/multiprompt_sweep.py`](https://github.com/random-walks/citeformer/blob/main/benchmarks/multiprompt_sweep.py). On the local backends that is expected by construction: the grammar mask leaves nothing to vary.
|
|
@@ -37,7 +37,7 @@ Language models still cite sources that don't exist, including in RAG setups whe
|
|
|
37
37
|
|
|
38
38
|
It does that in three independent ways:
|
|
39
39
|
|
|
40
|
-
- **Citation markers can't be fabricated.** `[N]` where `N > len(sources)` is token-impossible to sample on local backends
|
|
40
|
+
- **Citation markers can't be fabricated.** `[N]` where `N > len(sources)` is token-impossible to sample on the local backends and on Fireworks's grammar mode. On the JSON-schema API backends the citation ids are enum-bounded by the provider's structured-output mode, and Anthropic's Citations API only references documents you passed in (see [guarantees](https://citeformer.readthedocs.io/en/stable/guarantees.html) for what each covers). Measured on the local HF backend across [40 multi-prompt runs](https://github.com/random-walks/citeformer/blob/main/benchmarks/README.md#finding-5--multi-prompt-sweep-structural-guarantee-is-prompt-invariant): **0% fabrication on every prompt × model × seed triple**.
|
|
41
41
|
- **Bibliographies are rendered by the library, not the model.** Six styles, deterministic output, [300 locked snapshots](https://github.com/random-walks/citeformer/tree/main/tests/unit/test_csl_suite).
|
|
42
42
|
- **Every citation is claim-verifiable.** `result.verify()` runs NLI entailment per cite and returns a structured `VerificationReport` — not just a hit rate.
|
|
43
43
|
|
|
@@ -53,8 +53,8 @@ uv add 'citeformer[hf]' # HuggingFace transformers + XGrammar
|
|
|
53
53
|
uv add 'citeformer[llamacpp]' # llama.cpp native GBNF
|
|
54
54
|
uv add 'citeformer[vllm]' # vLLM guided-decoding (Linux/CUDA only)
|
|
55
55
|
|
|
56
|
-
# API backends —
|
|
57
|
-
#
|
|
56
|
+
# API backends — enforcement happens on the provider side; the mechanism differs
|
|
57
|
+
# per provider (grammar, JSON schema, or Anthropic's Citations API). See docs/guarantees.md.
|
|
58
58
|
uv add 'citeformer[openai]' # Structured Outputs strict=true
|
|
59
59
|
uv add 'citeformer[anthropic]' # Citations API adapter (with prompt-caching on)
|
|
60
60
|
uv add 'citeformer[openrouter]' # Multi-provider routing (anthropic/.., openai/.., google/..)
|
|
@@ -114,18 +114,18 @@ print(f"{report.support_rate:.0%} of cites entailed by their source")
|
|
|
114
114
|
|
|
115
115
|
## Backends
|
|
116
116
|
|
|
117
|
-
Ten backends,
|
|
117
|
+
Ten backends, one `Backend` ABC. The Enforcement column says how the citation rule reaches the model; [guarantees](https://citeformer.readthedocs.io/en/stable/guarantees.html) says what each mechanism does and doesn't cover:
|
|
118
118
|
|
|
119
119
|
| Backend | Extra | Enforcement | Where it lives | Notes |
|
|
120
120
|
|--------------------|--------------|--------------------------------------------|---------------------------------|-------|
|
|
121
121
|
| `HFBackend` | `hf` | In-process (XGrammar) | `citeformer.backends.hf` | Flagship. Grammar-level token masking. |
|
|
122
122
|
| `LlamaCppBackend` | `llamacpp` | In-process (GBNF) | `citeformer.backends.llamacpp` | Native GBNF via `llama-cpp-python`. CPU + Metal + CUDA. |
|
|
123
123
|
| `VLLMBackend` | `vllm` | In-process (XGrammar/llguidance) | `citeformer.backends.vllm` | vLLM guided decoding. Linux/CUDA only. |
|
|
124
|
-
| `FireworksBackend` | `fireworks` | Provider-runtime (**native GBNF**) | `citeformer.backends.fireworks` | Drops citeformer's `cite-id` grammar in unchanged via Fireworks's `response_format={"type":"grammar"}` mode.
|
|
124
|
+
| `FireworksBackend` | `fireworks` | Provider-runtime (**native GBNF**) | `citeformer.backends.fireworks` | Drops citeformer's `cite-id` grammar in unchanged via Fireworks's `response_format={"type":"grammar"}` mode. Token-level masking on a hosted API. |
|
|
125
125
|
| `OpenAIBackend` | `openai` | Provider-runtime (strict JSON) | `citeformer.backends.openai` | OpenAI Structured Outputs — live verified. |
|
|
126
126
|
| `AnthropicBackend` | `anthropic` | Provider-native (Citations API) | `citeformer.backends.anthropic` | Live verified. Prompt-caching on by default; real `messages.stream()` streaming; `cited_text` + `source_span` preserved on every Citation. |
|
|
127
|
-
| `OpenRouterBackend`| `openrouter` | Provider-runtime (per-upstream) | `citeformer.backends.openrouter`| Multi-provider routing on the OpenAI wire format. `provider.require_parameters: true`
|
|
128
|
-
| `TogetherBackend` | `together` | Provider-runtime (strict `json_schema`) | `citeformer.backends.together` |
|
|
127
|
+
| `OpenRouterBackend`| `openrouter` | Provider-runtime (per-upstream) | `citeformer.backends.openrouter`| Multi-provider routing on the OpenAI wire format. `provider.require_parameters: true` (default) only routes to upstreams that accept the strict `response_format`. Reports per-call cost in OR credits. |
|
|
128
|
+
| `TogetherBackend` | `together` | Provider-runtime (strict `json_schema`) | `citeformer.backends.together` | Together's `json_schema` mode on open-weight upstreams (Llama / Qwen / DeepSeek). |
|
|
129
129
|
| `GeminiBackend` | `gemini` | Provider-runtime (`response_schema`) | `citeformer.backends.gemini` | Gemini's OpenAPI-subset structured output. |
|
|
130
130
|
| `MistralBackend` | `mistral` | Provider-runtime (strict JSON) | `citeformer.backends.mistral` | Mistral's `response_format` strict JSON schema. |
|
|
131
131
|
| `MockBackend` | (core) | Scripted | `citeformer.backends.mock` | For tests. Honors policies + marker styles. |
|
|
@@ -153,7 +153,7 @@ cf = Citeformer(backend=OpenAIBackend(model="gpt-4o-mini"),
|
|
|
153
153
|
result = cf.generate(prompt="Describe the opening in one sentence.", sources=sources)
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
Where enforcement happens: **local** backends mask in-process via XGrammar / llguidance / GBNF, so out-of-scope citations are token-impossible to sample on your hardware. **Fireworks** runs the same GBNF inside its runtime. **OpenAI / Gemini / Mistral / Together** receive a strict JSON schema with the citation ids as an enum; OpenAI documents strict mode as constrained decoding, and for the others citeformer relies on the provider honouring the schema without being able to see the mechanism. The schema bounds the `citations` array only; the segment text is free-form. **OpenRouter** forwards the strict schema and, by default, only routes to upstreams that accept it. **Anthropic** uses its own Citations API, which returns references to the documents you supplied rather than free-form markers. All collapse to the same `GenerationResult` for downstream verify / render. Per-call token usage and (on OpenRouter) per-call cost in OpenRouter credits are exposed on `result.usage`.
|
|
157
157
|
|
|
158
158
|
## Citation policies
|
|
159
159
|
|
|
@@ -208,7 +208,7 @@ for chunk in stream:
|
|
|
208
208
|
result = stream.finalize() # full GenerationResult with parsed citations + refs
|
|
209
209
|
```
|
|
210
210
|
|
|
211
|
-
|
|
211
|
+
On the grammar backends the constraint applies to every chunk. HF and llama.cpp deliver true token-by-token streaming; the API backends chunk on sentence boundaries for UI progression.
|
|
212
212
|
|
|
213
213
|
## Evidence
|
|
214
214
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Guarantees
|
|
2
|
+
|
|
3
|
+
What citeformer enforces, per backend, and by which mechanism.
|
|
4
|
+
|
|
5
|
+
## How the citation rule reaches the model
|
|
6
|
+
|
|
7
|
+
The rule is always the same: a citation may only point at one of the `N` sources you passed in. How it's enforced depends on the backend.
|
|
8
|
+
|
|
9
|
+
| Backend | Where it runs | Mechanism | Token-level? |
|
|
10
|
+
|---|---|---|---|
|
|
11
|
+
| `HFBackend` | In-process | citeformer's GBNF `cite-id` rule compiled by XGrammar (or llguidance) into a `LogitsProcessor` | **Yes.** Out-of-scope tokens are masked before sampling. |
|
|
12
|
+
| `VLLMBackend` | In-process | Same GBNF via vLLM `GuidedDecodingParams` (XGrammar default, llguidance optional) | **Yes.** |
|
|
13
|
+
| `LlamaCppBackend` | In-process | Same GBNF via `LlamaGrammar.from_string` | **Yes.** |
|
|
14
|
+
| `FireworksBackend` | Provider | Same GBNF, unchanged, via `response_format={"type": "grammar"}` | **Yes**, provider-side: Fireworks documents grammar mode as constrained decoding. We can't observe their sampler. |
|
|
15
|
+
| `OpenAIBackend` | Provider | Strict JSON schema (`strict: true`); citation ids are an `enum` of `1..N` | **Yes**, provider-side: OpenAI documents strict Structured Outputs as constrained decoding. Covers the `citations` array, not the free-form `text` field. |
|
|
16
|
+
| `TogetherBackend` | Provider | Strict `json_schema` (inherited from `OpenAIBackend`) | **Provider-dependent.** Together constrains output to the schema; citeformer doesn't verify whether that's token masking or validation. |
|
|
17
|
+
| `GeminiBackend` | Provider | `response_schema` (OpenAPI subset) with integer `enum` on citation ids | **Provider-dependent.** Gemini constrains output to the schema; citeformer doesn't verify whether that's token masking or validation. |
|
|
18
|
+
| `MistralBackend` | Provider | Strict `json_schema` (`strict: true`) | **Provider-dependent.** Same caveat as Gemini. |
|
|
19
|
+
| `OpenRouterBackend` | Provider (routed) | Strict JSON schema forwarded to the upstream; `provider.require_parameters: true` by default | **Depends on the upstream.** `require_parameters` only routes to upstreams that accept the `response_format` parameter; how each upstream enforces it is up to that upstream. With `require_provider_parameters=False` an upstream may ignore the schema. |
|
|
20
|
+
| `AnthropicBackend` | Provider | Native Citations API: documents are passed as content blocks and Claude returns citation blocks that reference them by index | **No grammar or schema.** The guarantee is the Citations API's: citations reference supplied documents. citeformer converts them to markers. |
|
|
21
|
+
|
|
22
|
+
`MockBackend` (tests only) returns scripted text and enforces nothing.
|
|
23
|
+
|
|
24
|
+
What citeformer itself does after generation: it parses markers from the text and renders the reference list. Out-of-range ids are skipped at render time, but they are not removed from `result.citations`. On the JSON-schema backends the model writes each segment's `text` freely, so a marker-shaped string typed into the text (e.g. a literal `[7]`) would not be stopped by the schema and would be parsed like any other marker. Run `verify()` if that matters to you.
|
|
25
|
+
|
|
26
|
+
## What holds on every backend
|
|
27
|
+
|
|
28
|
+
| Property | Status |
|
|
29
|
+
|---|---|
|
|
30
|
+
| Reference list renders deterministically | **Yes.** The model never touches it; six hand-written formatters (APA 7, MLA 9, Chicago author-date, IEEE, Nature, Vancouver). |
|
|
31
|
+
| Every inline marker has a matching reference, and vice versa | **Yes**, for in-range ids. Coupled at render time. |
|
|
32
|
+
| Claim is actually supported by the cited source | **Checked** by NLI entailment via `verify()`. |
|
|
33
|
+
| Sentence without a citation is actually non-factual | **Flagged** by the NLI coverage check in `verify()`. |
|
|
34
|
+
|
|
35
|
+
All ten backends produce the same `GenerationResult`, so verify / render / streaming work the same way across them.
|
|
36
|
+
|
|
37
|
+
## What's *not* enforced
|
|
38
|
+
|
|
39
|
+
- **Claim truth.** citeformer enforces that *if* a claim is cited, the citation points at a real source; and via `verify()`, that the source entails the claim. It does *not* verify the source itself is correct. Garbage in, cited garbage out.
|
|
40
|
+
- **Policy appropriateness.** You pick a `citation_policy` (`required`, `quotes_only`, `auto`). citeformer enforces the grammar that policy implies — it doesn't decide for you whether that policy is right for your domain.
|
|
41
|
+
- **Retrieval quality.** citeformer is downstream of your retriever. If you retrieved irrelevant chunks, the model has to cite them anyway (or hit the coverage-flag branch of `verify()`).
|
|
42
|
+
- **Natural sentence length under REQUIRED.** The `REQUIRED` policy bounds per-sentence content at 240 characters (configurable) to guarantee progression on small models — see [ADR-009](decisions/009-bounded-content-required.md) for the structural fix to the [ADR-007](decisions/007-required-policy-progression-gap.md) stall. Sentences that would naturally run longer get clipped mid-clause, with the citation landing at clip point. Tune `max_content_chars` higher for very long-sentence technical writing, or pass `None` to disable bounding entirely.
|
|
43
|
+
|
|
44
|
+
## Why the distinction matters
|
|
45
|
+
|
|
46
|
+
- **In-process grammar** (HF, vLLM, llama.cpp): the sampler never sees an out-of-scope token, and you can inspect the whole path.
|
|
47
|
+
- **Provider-side grammar or schema** (Fireworks, OpenAI, Together, Gemini, Mistral, OpenRouter): the rule is handed to someone else's runtime. When the provider honours it, the returned citation ids are in scope. You are trusting their implementation, and on the schema backends only the `citations` array is bounded.
|
|
48
|
+
- **Provider-native** (Anthropic Citations API): the provider's own citation system is the guarantee. We adapt its shape into `GenerationResult` and add no enforcement on top.
|
|
49
|
+
|
|
50
|
+
For most applications the downstream result is the same: the cite ids you get back are in scope. The difference matters if you're writing a threat model or need to audit the enforcement yourself.
|
|
51
|
+
|
|
52
|
+
## Live evidence
|
|
53
|
+
|
|
54
|
+
- [Adversarial](https://github.com/random-walks/citeformer/blob/main/benchmarks/README.md#finding-1--adversarial-100--0-fabrication): prompt explicitly demands `[7]` and `[8]` when only 6 sources are in scope. Baseline complies (100% fab); citeformer structurally can't (0%). Local HF backend.
|
|
55
|
+
- [40-run multi-prompt sweep](https://github.com/random-walks/citeformer/blob/main/benchmarks/README.md#finding-5--multi-prompt-sweep-structural-guarantee-is-prompt-invariant): 0.0 ± 0.0 fabrication across every (prompt, model, seed) cell. Local HF backend.
|
|
56
|
+
- [OpenAI + Anthropic live-API tests](https://github.com/random-walks/citeformer/blob/main/tests/integration/test_api_backends_live.py): env-gated integration suite that hits production endpoints and verifies the structural invariant holds end-to-end.
|
|
57
|
+
|
|
58
|
+
## Further reading
|
|
59
|
+
|
|
60
|
+
- [Architecture](reference/architecture.md) — the 6-layer design, the piggyback map, and the per-backend enforcement section.
|
|
61
|
+
- [Contracts](reference/contracts.md) — the three §10 invariants that govern versioning.
|
|
62
|
+
- [PREPRINT](https://github.com/random-walks/citeformer/blob/main/PREPRINT.md) — longer design + evaluation write-up.
|
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
**Verifiably cited text from language models: citation markers constrained to the sources you supply.**
|
|
4
4
|
|
|
5
|
-
citeformer makes citation fabrication *structurally impossible* at the
|
|
5
|
+
citeformer makes citation fabrication *structurally impossible* at the token level when you use a grammar-constrained backend (HF, vLLM, llama.cpp, Fireworks). The model can only emit citation markers that refer to sources you've actually supplied. Reference lists are rendered deterministically by home-grown formatters (APA 7, MLA 9, Chicago author-date, IEEE, Nature, Vancouver) — the model never touches the bibliography.
|
|
6
6
|
|
|
7
7
|
:::{important}
|
|
8
8
|
citeformer is pre-1.0 and under active development. Ten backends ship today:
|
|
9
|
-
three local (HF transformers, vLLM, llama.cpp) that mask in-process;
|
|
10
|
-
(native GBNF
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
[
|
|
15
|
-
for the per-provider breakdown.
|
|
9
|
+
three local (HF transformers, vLLM, llama.cpp) that mask tokens in-process;
|
|
10
|
+
**Fireworks** (native GBNF: citeformer's `cite-id` grammar drops in unchanged);
|
|
11
|
+
five JSON-schema API backends (OpenAI, OpenRouter, Together, Gemini, Mistral)
|
|
12
|
+
where the provider enforces an enum of in-scope citation ids; and Anthropic,
|
|
13
|
+
adapted from its native Citations API. The mechanism and what it covers differ
|
|
14
|
+
per backend; see [Guarantees](guarantees.md) for the per-backend table.
|
|
16
15
|
:::
|
|
17
16
|
|
|
18
17
|
## Install
|
|
@@ -36,7 +35,7 @@ Python 3.11+ (tested up to 3.14).
|
|
|
36
35
|
## Get started
|
|
37
36
|
|
|
38
37
|
- [Getting started](getting-started.md) — install, quickstart, verification.
|
|
39
|
-
- [Guarantees](guarantees.md) — what
|
|
38
|
+
- [Guarantees](guarantees.md) — what is enforced on each backend, and how.
|
|
40
39
|
- [Verification](verification.md) — how NLI-based `verify()` works.
|
|
41
40
|
- [Reference](reference/index.md) — architecture, the three §10 contracts, releasing.
|
|
42
41
|
- [Historical spec](spec/v0.md) — the frozen genesis plan this was built from.
|
|
@@ -32,7 +32,7 @@ The parts citeformer owns are the glue plus the render layer: the citation gramm
|
|
|
32
32
|
|
|
33
33
|
## Phase plan
|
|
34
34
|
|
|
35
|
-
v0.1.0 shipped on 2026-04-24. Each phase was a mergeable milestone with its own exit criterion; see the frozen genesis at [`docs/spec/v0.md`](../spec/v0.md) for the original plan.
|
|
35
|
+
v0.1.0 first shipped on 2026-04-24; the current release is whatever `src/citeformer/_version.py` says, with history in `CHANGELOG.md`. Each phase below was a mergeable milestone with its own exit criterion; see the frozen genesis at [`docs/spec/v0.md`](../spec/v0.md) for the original plan.
|
|
36
36
|
|
|
37
37
|
| Phase | Scope | Exit criterion |
|
|
38
38
|
|---|---|---|
|
|
@@ -46,27 +46,29 @@ v0.1.0 shipped on 2026-04-24. Each phase was a mergeable milestone with its own
|
|
|
46
46
|
| **Polish** | REQUIRED progression fix ([ADR-009](../decisions/009-bounded-content-required.md)), real CLI, examples as living reports | ADR-009 integration test passes; `citeformer` CLI covers generate/verify/render; `examples/` has runnable scripts with findings READMEs |
|
|
47
47
|
| **Expansion** | Marker-shape enum ([ADR-011](../decisions/011-configurable-marker-styles.md)), OpenAI + Anthropic + Gemini + Mistral API backends, threshold calibration, multi-prompt + ALCE benchmarks, literature-review notebook, HF Space demo, GROBID PDF extractor | Seven backends pass a shared contract; 40-run multi-prompt sweep reports 0.0 ± 0.0 fabrication; PREPRINT.md describes the v0.1 design + evaluation |
|
|
48
48
|
| **P7 (shipped)** | v0.1.0 on PyPI + GitHub Release | `pip install citeformer==0.1.0` works; docs built on RTD; CI green across Python 3.11–3.14 |
|
|
49
|
+
| **v0.2.0 (shipped)** | Gemini + Mistral backends, richer PDF extraction, ALCE harness | See `CHANGELOG.md` |
|
|
50
|
+
| **v0.3.x (shipped)** | Async surface end-to-end (ADRs 014–017), OpenRouter + Fireworks + Together backends (ten total), token usage on results; patch releases for docs and metadata | See `CHANGELOG.md` |
|
|
49
51
|
|
|
50
|
-
Next-up (
|
|
52
|
+
Next-up (scope TBD): full-ALCE reproducibility (ASQA / QAMPARI / ELI5), per-chunk NLI during generation, streaming refinements on API backends, and a possible `citeformer-ts` sibling if ecosystem demand materialises.
|
|
51
53
|
|
|
52
54
|
## Tiered enforcement — where the masking runs
|
|
53
55
|
|
|
54
|
-
v0.1 framed the API/local split as "schema-tier vs logit-tier", but
|
|
56
|
+
v0.1 framed the API/local split as "schema-tier vs logit-tier". That's still roughly right, but the more useful question is **where the constraint runs and what form it takes**: an in-process grammar, the same grammar inside a provider, a JSON schema handed to a provider, or a provider's own citation system. The per-backend table with what each mechanism covers is in [Guarantees](../guarantees.md); this is the implementation view:
|
|
55
57
|
|
|
56
58
|
| Backend | Where the masking runs | Mechanism | Notes |
|
|
57
59
|
|---------------------|------------------------------|----------------------------------------------|-------|
|
|
58
60
|
| `HFBackend` | In-process | XGrammar `LogitsProcessor` | The flagship — you own the runtime. |
|
|
59
61
|
| `VLLMBackend` | In-process | XGrammar / llguidance via `GuidedDecodingParams` | Linux/CUDA only. |
|
|
60
62
|
| `LlamaCppBackend` | In-process | Native GBNF (`Llama(grammar=...)`) | CPU + Metal + CUDA. |
|
|
61
|
-
| `OpenAIBackend` | Provider runtime | Strict JSON schema |
|
|
63
|
+
| `OpenAIBackend` | Provider runtime | Strict JSON schema | OpenAI documents strict mode as constrained decoding on `gpt-4o-2024-08-06+` and successors ([Aug 2024 announcement](https://openai.com/index/introducing-structured-outputs-in-the-api/)). Bounds the `citations` array; segment text is free-form. |
|
|
62
64
|
| `AnthropicBackend` | Provider runtime | Native Citations API + `cache_control` | Provider enforces that every cite references a supplied document. Prompt-caching on by default — repeat-source RAG bills cache-read prices on subsequent calls. |
|
|
63
|
-
| `OpenRouterBackend` | Provider runtime (per upstream) | Strict JSON via OpenAI wire format | Routes to Anthropic / OpenAI / Google / Mistral / Groq / Fireworks / Together / Cohere. `provider.require_parameters: true` (default)
|
|
64
|
-
| `FireworksBackend` | Provider runtime | **Native GBNF** (`type: grammar`) |
|
|
65
|
-
| `TogetherBackend` | Provider runtime | Strict `json_schema` |
|
|
66
|
-
| `GeminiBackend` | Provider runtime | `response_schema` (OpenAPI subset) |
|
|
67
|
-
| `MistralBackend` | Provider runtime | `response_format` strict JSON | `mistral-large-2411+`. |
|
|
65
|
+
| `OpenRouterBackend` | Provider runtime (per upstream) | Strict JSON via OpenAI wire format | Routes to Anthropic / OpenAI / Google / Mistral / Groq / Fireworks / Together / Cohere. `provider.require_parameters: true` (default) only routes to upstreams that accept the `response_format` parameter; how each upstream enforces it is up to that upstream. |
|
|
66
|
+
| `FireworksBackend` | Provider runtime | **Native GBNF** (`type: grammar`) | Token-level masking on a hosted API: citeformer's `cite-id` GBNF rule is dropped in unchanged via Fireworks's [grammar mode](https://docs.fireworks.ai/structured-responses/structured-output-grammar-based). Same constraint that masks logits inside `HFBackend`, just running on Fireworks's GPUs. |
|
|
67
|
+
| `TogetherBackend` | Provider runtime | Strict `json_schema` | Together's `json_schema` mode on open-weight upstreams (Llama / Qwen / DeepSeek / …). citeformer doesn't verify whether it's token masking. |
|
|
68
|
+
| `GeminiBackend` | Provider runtime | `response_schema` (OpenAPI subset) | Gemini 1.5+ / 2.x structured output. citeformer doesn't verify whether it's token masking. |
|
|
69
|
+
| `MistralBackend` | Provider runtime | `response_format` strict JSON | `mistral-large-2411+`. citeformer doesn't verify whether it's token masking. |
|
|
68
70
|
|
|
69
|
-
All
|
|
71
|
+
All ten backends produce the same `GenerationResult`; the orchestration, verify, and render layers are backend-agnostic. Choosing between in-process and provider-side enforcement is partly operational (host the model or pay someone to) and partly about trust: in-process you can inspect the whole path, provider-side you rely on the provider's implementation.
|
|
70
72
|
|
|
71
73
|
The bibliography pipeline is unchanged regardless: references are rendered deterministically by our home-grown formatters, never by the model.
|
|
72
74
|
|
|
@@ -236,9 +236,9 @@ def build_ui() -> Any:
|
|
|
236
236
|
) as app:
|
|
237
237
|
gr.Markdown(
|
|
238
238
|
"# citeformer\n"
|
|
239
|
-
"**
|
|
240
|
-
"Citation markers are *structurally impossible to fabricate* at the
|
|
241
|
-
"level when a grammar-
|
|
239
|
+
"**Verifiably cited text from language models: citation markers constrained to the sources you supply.** "
|
|
240
|
+
"Citation markers are *structurally impossible to fabricate* at the token "
|
|
241
|
+
"level when a grammar-constrained backend is used.\n\n"
|
|
242
242
|
"This demo runs the **adversarial prompt** — a prompt that *deliberately* "
|
|
243
243
|
"asks the model to cite sources [7] and [8] when only 6 sources are "
|
|
244
244
|
"provided. The baseline (plain HF generation) complies. citeformer's "
|
|
@@ -65,11 +65,10 @@ vllm = ["vllm>=0.7"]
|
|
|
65
65
|
llamacpp = ["llama-cpp-python>=0.3"]
|
|
66
66
|
# P6: NLI-based verification.
|
|
67
67
|
verify = ["transformers>=4.46", "torch>=2.8", "sentence-transformers>=3"]
|
|
68
|
-
# P7: API-provider backends.
|
|
69
|
-
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
# docs/reference/architecture.md for the per-provider breakdown.
|
|
68
|
+
# P7: API-provider backends. Enforcement is provider-side and the
|
|
69
|
+
# mechanism differs per provider (GBNF grammar, strict JSON schema, or
|
|
70
|
+
# Anthropic's Citations API). See docs/guarantees.md for the per-backend
|
|
71
|
+
# table.
|
|
73
72
|
openai = ["openai>=1.40"]
|
|
74
73
|
anthropic = ["anthropic>=0.40"]
|
|
75
74
|
gemini = ["google-genai>=0.7"]
|
|
@@ -81,8 +80,8 @@ openrouter = ["openai>=1.40"]
|
|
|
81
80
|
# mode — citeformer's `cite-id` rule is dropped in unchanged for true
|
|
82
81
|
# logit-tier enforcement on a hosted API.
|
|
83
82
|
fireworks = ["openai>=1.40"]
|
|
84
|
-
# Together is OpenAI wire-compatible —
|
|
85
|
-
#
|
|
83
|
+
# Together is OpenAI wire-compatible — strict json_schema mode on
|
|
84
|
+
# open-weight upstream models (Llama, Qwen, DeepSeek, …).
|
|
86
85
|
together = ["openai>=1.40"]
|
|
87
86
|
# Optional richer PDF extractor — GROBID is an external Java service the
|
|
88
87
|
# user stands up separately (Docker one-liner in the docs). Installing the
|
|
@@ -11,13 +11,14 @@ their submodules — they each require the matching extra.
|
|
|
11
11
|
- ``citeformer.backends.llamacpp.LlamaCppBackend`` needs ``[llamacpp]``.
|
|
12
12
|
- ``citeformer.backends.vllm.VLLMBackend`` needs ``[vllm]`` (Linux/CUDA only).
|
|
13
13
|
|
|
14
|
-
**API backends.**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
**API backends.** Enforcement runs provider-side and the mechanism differs:
|
|
15
|
+
Fireworks runs citeformer's GBNF, the JSON-schema backends bound citation
|
|
16
|
+
ids with an enum, and Anthropic uses its native Citations API. Only the
|
|
17
|
+
grammar backends are token-level by construction; for the schema backends
|
|
18
|
+
citeformer relies on the provider honouring the schema:
|
|
18
19
|
|
|
19
20
|
- ``citeformer.backends.openai.OpenAIBackend`` needs ``[openai]``.
|
|
20
|
-
Strict JSON schema
|
|
21
|
+
Strict JSON schema; OpenAI documents this as constrained decoding on
|
|
21
22
|
``gpt-4o-2024-08-06+`` and successors.
|
|
22
23
|
- ``citeformer.backends.anthropic.AnthropicBackend`` needs ``[anthropic]``.
|
|
23
24
|
Adapter over Anthropic's native Citations API — provider enforces that
|
|
@@ -28,19 +29,18 @@ runs", not "logit vs schema":
|
|
|
28
29
|
Strict JSON schema (``mistral-large-2411+``).
|
|
29
30
|
- ``citeformer.backends.openrouter.OpenRouterBackend`` needs ``[openrouter]``.
|
|
30
31
|
Multi-provider routing on the OpenAI wire format with
|
|
31
|
-
``provider.require_parameters`` so requests
|
|
32
|
-
|
|
32
|
+
``provider.require_parameters`` so requests only route to upstreams
|
|
33
|
+
that accept the strict ``response_format``.
|
|
33
34
|
- ``citeformer.backends.fireworks.FireworksBackend`` needs ``[fireworks]``.
|
|
34
|
-
|
|
35
|
+
Token-level masking on a hosted API: Fireworks's native GBNF grammar
|
|
35
36
|
mode accepts citeformer's ``cite-id`` rule unchanged, so the same
|
|
36
37
|
constraint that masks logits inside ``HFBackend`` runs inside the
|
|
37
38
|
Fireworks runtime.
|
|
38
39
|
- ``citeformer.backends.together.TogetherBackend`` needs ``[together]``.
|
|
39
|
-
Strict ``json_schema``
|
|
40
|
+
Strict ``json_schema`` mode on Together's
|
|
40
41
|
open-weight upstream models (Llama, Qwen, DeepSeek, …).
|
|
41
42
|
|
|
42
|
-
Per-
|
|
43
|
-
``docs/reference/architecture.md``.
|
|
43
|
+
Per-backend enforcement table: ``docs/guarantees.md``.
|
|
44
44
|
"""
|
|
45
45
|
|
|
46
46
|
from __future__ import annotations
|