{"id":48246192,"url":"https://github.com/fcjr/smll","last_synced_at":"2026-04-04T20:37:41.979Z","repository":{"id":336960605,"uuid":"1083809067","full_name":"fcjr/smll","owner":"fcjr","description":"Near optimal compression with LLMs","archived":false,"fork":false,"pushed_at":"2026-02-11T18:06:34.000Z","size":510,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-19T10:07:35.233Z","etag":null,"topics":["ai","compression","cpp","llm","python"],"latest_commit_sha":null,"homepage":"https://www.frankchiarulli.com/blog/smll/","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/fcjr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-26T18:52:00.000Z","updated_at":"2026-02-07T19:57:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/fcjr/smll","commit_stats":null,"previous_names":["fcjr/smll"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fcjr/smll","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcjr%2Fsmll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcjr%2Fsmll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcjr%2Fsmll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcjr%2Fsmll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fcjr","download_url":"https://codeload.github.com/fcjr/smll/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcjr%2Fsmll/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31413279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T20:09:54.854Z","status":"ssl_error","status_checked_at":"2026-04-04T20:09:44.350Z","response_time":60,"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":["ai","compression","cpp","llm","python"],"created_at":"2026-04-04T20:37:41.568Z","updated_at":"2026-04-04T20:37:41.969Z","avatar_url":"https://github.com/fcjr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# smll\n\nLLM-powered text compression. Combines a language model with arithmetic coding to approach Shannon's theoretical entropy limit for text compression.\n\nThe text is tokenized and fed to the LLM, which outputs probability distributions for the next token. Arithmetic coding then converts these probabilities into bits proportional to `-log2(probability)`. Both the compressor and decompressor use the same model weights as a shared codebook.\n\nFor a deeper explanation, see the [blog post](https://www.frankchiarulli.com/blog/smll/).\n\n## Installation\n\n```bash\npip install pysmll\n```\n\n## Usage\n\n```python\nimport smll\n\nwith smll.Compressor.from_pretrained(\n    repo_id=\"QuantFactory/SmolLM2-360M-GGUF\",\n    filename=\"*Q4_0.gguf\",\n) as compressor:\n    compressed = compressor.compress(\"Hello, world!\")\n    decompressed = compressor.decompress(compressed)\n```\n\nYou can also load a local GGUF model directly:\n\n```python\ncompressor = smll.Compressor(\"model.gguf\")\ncompressed = compressor.compress(\"Hello, world!\")\ndecompressed = compressor.decompress(compressed)\n```\n\n## Compression results\n\nUsing SmolLM2-360M on an Apple M4 Max (128GB):\n\n| Data type | Compression ratio |\n|---|---|\n| LLM-generated text | 14.96x |\n| Wikipedia | 14.83x |\n| C code | 11.19x |\n| Natural prose | 9.75x |\n| Random data (UUIDs) | 0.94x |\n\nAt 1000 characters, smll achieves ~0.85 bits/character, near the estimated English entropy of 0.6-1.3 bits/char.\n\n## Tradeoffs\n\n- **Speed**: ~700 chars/sec (gzip: ~6.5M chars/sec). A 10KB document compresses in ~15 seconds.\n- **Model size**: Both sides need the model weights (~200MB for SmolLM2-360M Q4).\n\n## Building from source\n\nRequires Python 3.12+, CMake 3.21+, and a C++11 compiler.\n\n```bash\ngit clone --recurse-submodules https://github.com/fcjr/smll.git\ncd smll\npip install .\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffcjr%2Fsmll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffcjr%2Fsmll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffcjr%2Fsmll/lists"}