{"id":37085410,"url":"https://github.com/leoneversberg/pdf2md_llm","last_synced_at":"2026-01-14T10:30:01.693Z","repository":{"id":280806742,"uuid":"943167949","full_name":"leoneversberg/pdf2md_llm","owner":"leoneversberg","description":"Use a local LLM to convert PDF to Markdown","archived":false,"fork":false,"pushed_at":"2025-03-10T16:00:24.000Z","size":174,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-29T22:54:07.581Z","etag":null,"topics":["conversion","llm","markdown","parser","pdf"],"latest_commit_sha":null,"homepage":"https://ai.gopubby.com/pdf-to-markdown-document-conversion-with-local-llms-e8ad26c13c8d","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leoneversberg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-05T09:22:28.000Z","updated_at":"2025-10-22T19:10:52.000Z","dependencies_parsed_at":"2025-03-05T12:41:12.105Z","dependency_job_id":null,"html_url":"https://github.com/leoneversberg/pdf2md_llm","commit_stats":null,"previous_names":["leoneversberg/pdf2md_llm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leoneversberg/pdf2md_llm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoneversberg%2Fpdf2md_llm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoneversberg%2Fpdf2md_llm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoneversberg%2Fpdf2md_llm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoneversberg%2Fpdf2md_llm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leoneversberg","download_url":"https://codeload.github.com/leoneversberg/pdf2md_llm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoneversberg%2Fpdf2md_llm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28417322,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:25:19.714Z","status":"ssl_error","status_checked_at":"2026-01-14T10:22:49.371Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conversion","llm","markdown","parser","pdf"],"created_at":"2026-01-14T10:30:01.184Z","updated_at":"2026-01-14T10:30:01.685Z","avatar_url":"https://github.com/leoneversberg.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pdf2md_llm\n\n`pdf2md_llm` is a Python package that converts PDF files to Markdown using a local Large Language Model (LLM). \n\nThe package leverages the `pdf2image` library to convert PDF pages to images and a vision language model to generate Markdown text from these images.\n\n## Features\n\n- Convert PDF files to images.\n- Generate Markdown text from images using a local LLM.\n- Keep your data private. No third-party file uploads. \n\n## Installation\n\nYou need a CUDA compatible GPU to run local LLMs with vLLM.\n\nYou can use `pip` to install the package:\n\n```bash\npip install pdf2md-llm\n```\n## Usage\n\n### CLI\n\nYou can use the `pdf2md_llm` package via the **command line interface (CLI)**.\n\nTo convert a PDF file to Markdown, run the following command:\n\n```bash\npdf2md_llm \u003cpdf_file\u003e [options]\n```\n\n#### Options\n\n* `pdf_file`: Path to the PDF file to convert.\n* `--model`: Name of the model to use (default: `Qwen/Qwen2.5-VL-3B-Instruct-AWQ`).\n* `--dtype`: Data type for the model weights and activations (default: `None`).\n* `--max_model_len`: Max model context length (default: `7000`).\n* `--prompt`: Custom prompt for the LLM. (default: `None`).\n* `--size`: Image size as a tuple (default: `(700, None)`).\n* `--dpi`: DPI of the images (default: `200`).\n* `--fmt`: Image format (default: `jpeg`).\n* `--output_folder`: Folder to save the output Markdown file (default: `./out`).\n\n#### Example\n\n```bash\npdf2md_llm example.pdf --model \"Qwen/Qwen2.5-VL-3B-Instruct-AWQ\" --output_folder \"./output\"\n```\n\n##### Model Support:\nCurrently the following Qwen2.5-VL models are supported: \n\n* `Qwen/Qwen2.5-VL-3B-Instruct`\n* `Qwen/Qwen2.5-VL-3B-Instruct-AWQ`\n* `Qwen/Qwen2.5-VL-7B-Instruct`\n* `Qwen/Qwen2.5-VL-7B-Instruct-AWQ`\n* `Qwen/Qwen2.5-VL-72B-Instruct`\n* `Qwen/Qwen2.5-VL-72B-Instruct-AWQ`\n\nIf you want to use a different model, feel free to add a vLLM compatible model to the factory function `llm_model()` in `llm.py`\n\n### Python API\n\nYou can use the `pdf2md_llm` package via the **Python API**.\n\nBasic usage:\n\n```python\nfrom vllm import SamplingParams\n\nfrom pdf2md_llm.llm import llm_model\nfrom pdf2md_llm.pdf2img import PdfToImg\n\npdf2img = PdfToImg(size=(700, None), output_folder=\"./out\")\nimg_files = pdf2img.convert(\"example.pdf\")\n\nllm = llm_model(\n    model=\"Qwen/Qwen2.5-VL-3B-Instruct-AWQ\",  # Name of the huggingface model\n    dtype=\"half\",  # Model data type\n)\n\nsampling_params = SamplingParams(\n    temperature=0.1,\n    min_p=0.1,\n    max_tokens=8192,\n    stop_token_ids=[],\n)\n\n# Append all pages to one output Markdown file\nfor img_file in img_files:\n    markdown_text = llm.generate(\n        img_file, sampling_params=sampling_params\n    )  # convert image to Markdown with LLM\n    with open(\"example.md\", \"a\", encoding=\"utf-8\") as myfile:\n        myfile.write(markdown_text)\n```\n\nFor a full example, see [example_api.py](./pdf2md_llm/example_api.py)\n\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## Acknowledgements\n\n* [pdf2image](https://github.com/Belval/pdf2image) for converting PDF files to images.\n\n* [Qwen2.5-VL](https://github.com/QwenLM/Qwen2.5-VL) LLM model\n\n* [vLLM](https://github.com/vllm-project/vllm) for efficient LLM model inference","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoneversberg%2Fpdf2md_llm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleoneversberg%2Fpdf2md_llm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoneversberg%2Fpdf2md_llm/lists"}