{"id":26507485,"url":"https://github.com/milescb/sparseffn","last_synced_at":"2025-09-02T16:33:31.143Z","repository":{"id":280067711,"uuid":"940869155","full_name":"milescb/SparseFFN","owner":"milescb","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-01T02:07:36.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T03:18:45.810Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/milescb.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}},"created_at":"2025-03-01T00:23:02.000Z","updated_at":"2025-03-01T02:07:39.000Z","dependencies_parsed_at":"2025-03-01T03:28:50.931Z","dependency_job_id":null,"html_url":"https://github.com/milescb/SparseFFN","commit_stats":null,"previous_names":["milescb/sparseffn"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milescb%2FSparseFFN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milescb%2FSparseFFN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milescb%2FSparseFFN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milescb%2FSparseFFN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/milescb","download_url":"https://codeload.github.com/milescb/SparseFFN/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244706541,"owners_count":20496571,"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":[],"created_at":"2025-03-20T23:20:00.264Z","updated_at":"2025-03-20T23:20:00.627Z","avatar_url":"https://github.com/milescb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sparse FFN\n\nTrain a small network to learn the output of feed-forward (FFN) blocks of an LLM. This distilation technique can then be used to predict the sparsity of the FFN blocks in LLMs. \n\n## Setup the environment\n\n```\npython -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n```\n\n## Train the model\n\nTraining can be accomplished simply by running the `train.py` script:\n\n```\npython train.py -d \u003cdatapath\u003e.pt -od \u003coutdir\u003e -o \u003coutname\u003e -bs \u003cbatch_size\u003e -lr \u003clearning rate\u003e -e \u003cnumber of epochs\u003e\n``` \n\n## Use trained model\n\nTo test and make plots, simply run:\n\n```\npython test.py --data \u003cpath to data\u003e -mod \u003ctrained_model_name\u003e.pt\n```\n\nTo use trained models, run:\n\n```python\nfrom ffnsparse.query import predict\n\npred = predict(input_vector, \"model_name.pt\")\n```\n\nwhere `input_vector` is the embedded input to the FFN block, and `\"model_name.pt\"` is the path to the trained model. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilescb%2Fsparseffn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmilescb%2Fsparseffn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilescb%2Fsparseffn/lists"}