{"id":25157571,"url":"https://github.com/sunsvea/cl-sparse-transformer","last_synced_at":"2026-04-12T20:35:15.284Z","repository":{"id":275144457,"uuid":"925210577","full_name":"Sunsvea/cl-sparse-transformer","owner":"Sunsvea","description":"A CL (coulstock) sparse transformer implementation","archived":false,"fork":false,"pushed_at":"2025-01-31T13:33:16.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T12:16:43.677Z","etag":null,"topics":["open-source","pytorch","sparse-transformer"],"latest_commit_sha":null,"homepage":"","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/Sunsvea.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-01-31T12:53:55.000Z","updated_at":"2025-01-31T13:07:21.000Z","dependencies_parsed_at":"2025-01-31T13:39:42.039Z","dependency_job_id":"fcdda166-0baa-477d-8b55-3162c982f5e3","html_url":"https://github.com/Sunsvea/cl-sparse-transformer","commit_stats":null,"previous_names":["sunsvea/cl-sparse-transformer"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Sunsvea/cl-sparse-transformer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sunsvea%2Fcl-sparse-transformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sunsvea%2Fcl-sparse-transformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sunsvea%2Fcl-sparse-transformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sunsvea%2Fcl-sparse-transformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sunsvea","download_url":"https://codeload.github.com/Sunsvea/cl-sparse-transformer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sunsvea%2Fcl-sparse-transformer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265947525,"owners_count":23853383,"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":["open-source","pytorch","sparse-transformer"],"created_at":"2025-02-09T01:40:49.258Z","updated_at":"2026-04-12T20:35:15.267Z","avatar_url":"https://github.com/Sunsvea.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sparse Transformer Implementation\n\nThis repository contains a PyTorch implementation of a Transformer model with sparse attention patterns. The goal is to explore and implement various sparse attention mechanisms to improve the efficiency of transformer models while maintaining performance.\n\n## Current Features\n\n- Local sparse attention mechanism (window-based)\n- Configurable model architecture (layers, heads, dimensions)\n- Basic positional encoding\n- Simple training loop for sequence prediction\n- CPU support\n\n## Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/Sunsvea/cl-sparse-transformer.git\ncd cl-sparse-transformer\n\n# Install dependencies\npip install torch\n```\n\n## Quick Start\n\n```python\n# Run the example training script\npython sparse_transformer.py\n```\n\n## Output\n\nWhen running the training script, you should see output similar to this:\n\n```\n2025-01-31 10:15:23,456 - INFO - Starting training...\n2025-01-31 10:15:23,789 - INFO - Generated 1000 sample sequences...\n2025-01-31 10:15:23,901 - INFO - Split data into 800 train and 200 validation sequences\n\n2025-01-31 10:15:24,123 - INFO - Epoch 1/5\n2025-01-31 10:15:24,456 - INFO - Batch 0, Loss: 4.6573\n2025-01-31 10:15:24,789 - INFO - Batch 10, Loss: 4.3291\n2025-01-31 10:15:25,012 - INFO - Training Loss: 4.2845\n2025-01-31 10:15:25,234 - INFO - Validation Loss: 4.1932\n2025-01-31 10:15:25,345 - INFO - Saved new best model checkpoint\n2025-01-31 10:15:25,456 - INFO - Epoch completed in 1.33s\n\n[...]\n\n2025-01-31 10:15:35,678 - INFO - Training completed in 12.22s\n2025-01-31 10:15:35,789 - INFO - Best validation loss: 3.2456\n```\n\nThe model saves checkpoints to `./checkpoints/` whenever the validation loss improves.\n\n## Architecture\n\nThe current implementation includes:\n\n- `LocalSparseAttention`: Implements window-based sparse attention where each token attends only to its neighbors\n- `SparseTransformerBlock`: A single transformer block with sparse attention\n- `SparseTransformer`: The full model with embedding layer and multiple transformer blocks\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\n\nMIT\n\n## Citation\n\nIf you use this code in your research, please cite:\n\n```bibtex\n@software{sparse_transformer2025,\n  author = {Dean Coulstock},\n  title = {Sparse Transformer Implementation},\n  year = {2025},\n  publisher = {GitHub},\n  url = {https://github.com/Sunsvea/sparse-transformer}\n}\n```\n\n## Contact\n\n- Dean Coulstock\n- deanjcoulstock@gmail.com\n- LinkedIn: https://www.linkedin.com/in/dean-coulstock/\n\n## Acknowledgments\n\nThis implementation draws inspiration from:\n- \"Generating Long Sequences with Sparse Transformers\" (Child et al., 2019)\n- \"Longformer: The Long-Document Transformer\" (Beltagy et al., 2020)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsvea%2Fcl-sparse-transformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunsvea%2Fcl-sparse-transformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunsvea%2Fcl-sparse-transformer/lists"}