{"id":13452865,"url":"https://github.com/siboehm/lleaves","last_synced_at":"2025-05-14T18:00:23.703Z","repository":{"id":38286889,"uuid":"362006346","full_name":"siboehm/lleaves","owner":"siboehm","description":"Compiler for LightGBM gradient-boosted trees, based on LLVM. Speeds up prediction by ≥10x.","archived":false,"fork":false,"pushed_at":"2025-05-05T23:52:48.000Z","size":4976,"stargazers_count":416,"open_issues_count":22,"forks_count":32,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-14T11:11:05.241Z","etag":null,"topics":["decision-trees","gradient-boosting","lightgbm","llvm","machine-learning","python"],"latest_commit_sha":null,"homepage":"https://lleaves.readthedocs.io/en/latest/","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/siboehm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-04-27T06:35:23.000Z","updated_at":"2025-05-07T07:54:48.000Z","dependencies_parsed_at":"2023-11-11T02:26:10.742Z","dependency_job_id":"9b7c7acc-69f2-4c19-8845-3110089fa02b","html_url":"https://github.com/siboehm/lleaves","commit_stats":{"total_commits":244,"total_committers":8,"mean_commits":30.5,"dds":"0.11885245901639341","last_synced_commit":"425148024e5ca44ac1e01781b0771d0d785a3c80"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siboehm%2Flleaves","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siboehm%2Flleaves/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siboehm%2Flleaves/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siboehm%2Flleaves/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siboehm","download_url":"https://codeload.github.com/siboehm/lleaves/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198452,"owners_count":22030964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["decision-trees","gradient-boosting","lightgbm","llvm","machine-learning","python"],"created_at":"2024-07-31T08:00:25.312Z","updated_at":"2025-05-14T18:00:23.670Z","avatar_url":"https://github.com/siboehm.png","language":"Python","funding_links":[],"categories":["Machine Learning"],"sub_categories":[],"readme":"# lleaves 🍃\n![CI](https://github.com/siboehm/lleaves/workflows/CI/badge.svg)\n[![Documentation Status](https://readthedocs.org/projects/lleaves/badge/?version=latest)](https://lleaves.readthedocs.io/en/latest/?badge=latest)\n![Downloads](https://static.pepy.tech/badge/lleaves)\n\nA LLVM-based compiler for LightGBM decision trees.\n\n`lleaves` converts trained LightGBM models to optimized machine code, speeding-up prediction by ≥10x.\n\n## Example\n\n```python\nlgbm_model = lightgbm.Booster(model_file=\"NYC_taxi/model.txt\")\n%timeit lgbm_model.predict(df)\n# 12.77s\n\nllvm_model = lleaves.Model(model_file=\"NYC_taxi/model.txt\")\nllvm_model.compile()\n%timeit llvm_model.predict(df)\n# 0.90s \n```\n\n## Why lleaves?\n- Speed: Both low-latency single-row prediction and high-throughput batch-prediction.\n- Drop-in replacement: The interface of `lleaves.Model` is a subset of `LightGBM.Booster`.\n- Dependencies: `llvmlite` and `numpy`. LLVM comes statically linked.\n\n## Installation\n`conda install -c conda-forge lleaves` or `pip install lleaves` (Linux and MacOS only).\n\n## Benchmarks\nRan on a dedicated Intel i7-4770 Haswell, 4 cores.\nStated runtime is the minimum over 20.000 runs.\n\n### Dataset: [NYC-taxi](https://www1.nyc.gov/site/tlc/about/tlc-trip-record-data.page)\nmostly numerical features.\n|batchsize   | 1  | 10| 100 |\n|---|---:|---:|---:|\n|LightGBM   | 52.31μs   | 84.46μs   | 441.15μs |\n|ONNX  Runtime| 11.00μs | 36.74μs | 190.87μs  |\n|Treelite   | 28.03μs   | 40.81μs   | 94.14μs  |\n|``lleaves``   | 9.61μs | 14.06μs | 31.88μs  |\n\n### Dataset: [MTPL2](https://www.openml.org/d/41214)\nmix of categorical and numerical features.\n|batchsize   | 10,000  | 100,000  | 678,000 |\n|---|---:|---:|---:|\n|LightGBM   | 95.14ms | 992.47ms   | 7034.65ms  |\n|ONNX  Runtime | 38.83ms  | 381.40ms  | 2849.42ms  |\n|Treelite   | 38.15ms | 414.15ms  | 2854.10ms  |\n|``lleaves``  | 5.90ms  | 56.96ms | 388.88ms |\n\n## Advanced Usage\nTo avoid expensive recompilation, you can call `lleaves.Model.compile()` and pass a `cache=\u003cfilepath\u003e` argument.\nThis will store an ELF (Linux) / Mach-O (macOS) file at the given path when the method is first called.\nSubsequent calls of `compile(cache=\u003csame filepath\u003e)` will skip compilation and load the stored binary file instead.\nFor more info, see [docs](https://lleaves.readthedocs.io/en/latest/).\n\nTo eliminate any Python overhead during inference you can link against this generated binary.\nFor an example of how to do this see `benchmarks/c_bench/`.\nThe function signature might change between major versions.\n\n## Development\nHigh-level explanation of the inner workings of the lleaves compiler: [link](https://siboehm.com/articles/21/lleaves)\n```bash\nmamba env create\nconda activate lleaves\npip install -e .\npre-commit install\n./benchmarks/data/setup_data.sh\npytest -k \"not benchmark\"\n```\n\n## Cite\nIf you're using lleaves for your research, I'd appreciate if you could cite it. Use:\n```\n@software{Boehm_lleaves,\n  author = {Boehm, Simon},\n  title = {lleaves},\n  url = {https://github.com/siboehm/lleaves},\n  license = {MIT},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiboehm%2Flleaves","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiboehm%2Flleaves","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiboehm%2Flleaves/lists"}