{"id":13701788,"url":"https://github.com/avidale/compress-fasttext","last_synced_at":"2026-01-16T11:45:59.467Z","repository":{"id":39971846,"uuid":"242237151","full_name":"avidale/compress-fasttext","owner":"avidale","description":"Tools for shrinking fastText models (in gensim format)","archived":false,"fork":false,"pushed_at":"2024-05-03T06:37:37.000Z","size":32386,"stargazers_count":181,"open_issues_count":1,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2026-01-06T09:35:25.845Z","etag":null,"topics":["fasttext","fasttext-embeddings","nlp","python","word-embeddings"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/avidale.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":"2020-02-21T21:52:51.000Z","updated_at":"2025-12-16T20:20:14.000Z","dependencies_parsed_at":"2024-04-13T01:01:53.701Z","dependency_job_id":"2aab5ac8-74c4-47ff-8a43-f145540ce2bc","html_url":"https://github.com/avidale/compress-fasttext","commit_stats":{"total_commits":35,"total_committers":3,"mean_commits":"11.666666666666666","dds":0.4285714285714286,"last_synced_commit":"9829067966c2aebb3c14c877a8514080144507f9"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/avidale/compress-fasttext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avidale%2Fcompress-fasttext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avidale%2Fcompress-fasttext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avidale%2Fcompress-fasttext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avidale%2Fcompress-fasttext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avidale","download_url":"https://codeload.github.com/avidale/compress-fasttext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avidale%2Fcompress-fasttext/sbom","scorecard":{"id":218127,"data":{"date":"2025-08-11","repo":{"name":"github.com/avidale/compress-fasttext","commit":"78f13cf7cd1924a1eb64d4931094225c1b6e7dbc"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.3,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 2/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test_and_deploy.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact gensim-4-draft not signed: https://api.github.com/repos/avidale/compress-fasttext/releases/55101014","Warn: release artifact v0.0.4 not signed: https://api.github.com/repos/avidale/compress-fasttext/releases/24531368","Warn: release artifact gensim-4-draft does not have provenance: https://api.github.com/repos/avidale/compress-fasttext/releases/55101014","Warn: release artifact v0.0.4 does not have provenance: https://api.github.com/repos/avidale/compress-fasttext/releases/24531368"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test_and_deploy.yaml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/avidale/compress-fasttext/test_and_deploy.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test_and_deploy.yaml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/avidale/compress-fasttext/test_and_deploy.yaml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/test_and_deploy.yaml:18","Warn: pipCommand not pinned by hash: .github/workflows/test_and_deploy.yaml:19","Warn: pipCommand not pinned by hash: .github/workflows/test_and_deploy.yaml:20","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'","Warn: branch protection not enabled for branch 'gensim-4'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"13 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2018-34 / GHSA-2fc2-6r4j-p65h","Warn: Project is vulnerable to: PYSEC-2021-856 / GHSA-5545-2q6w-2gh6","Warn: Project is vulnerable to: PYSEC-2019-108 / GHSA-9fq2-x9r6-wfmf","Warn: Project is vulnerable to: PYSEC-2018-33 / GHSA-cw6w-4rcx-xphc","Warn: Project is vulnerable to: PYSEC-2021-857 / GHSA-f7c7-j99h-c22f","Warn: Project is vulnerable to: GHSA-fpfv-jqm9-f5jm","Warn: Project is vulnerable to: PYSEC-2017-1 / GHSA-frgw-fgh6-9g52","Warn: Project is vulnerable to: PYSEC-2020-107 / GHSA-jjw5-xxj6-pcv5","Warn: Project is vulnerable to: PYSEC-2024-110 / GHSA-jw8x-6495-233v","Warn: Project is vulnerable to: PYSEC-2020-108","Warn: Project is vulnerable to: PYSEC-2019-156 / GHSA-xp76-357g-9wqq","Warn: Project is vulnerable to: PYSEC-2023-102","Warn: Project is vulnerable to: PYSEC-2023-114"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T02:00:58.597Z","repository_id":39971846,"created_at":"2025-08-17T02:00:58.598Z","updated_at":"2025-08-17T02:00:58.598Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478369,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","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":["fasttext","fasttext-embeddings","nlp","python","word-embeddings"],"created_at":"2024-08-02T20:01:58.054Z","updated_at":"2026-01-16T11:45:59.462Z","avatar_url":"https://github.com/avidale.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook","Pretrained models"],"sub_categories":[],"readme":"# Compress-fastText\nThis Python 3 package allows to compress fastText word embedding models \n(from the `gensim` package) by orders of magnitude, \nwithout significantly affecting their quality. \n\n[Here](https://github.com/avidale/compress-fasttext/releases/tag/gensim-4-draft) are some links to the models that have already been compressed.\n\nThis [blogpost in Russian](https://habr.com/ru/post/489474) \nand [this one in English](https://towardsdatascience.com/eb212e9919ca)\ngive more details about the motivation and \nmethods for compressing fastText models.\n\n\n**Note: gensim==4.0.0 has introduced some backward-incompatible changes:**\n* With gensim\u003c4.0.0, please use compress-fasttext\u003c=0.0.7 \n(and optionally Russian models from [our first release](https://github.com/avidale/compress-fasttext/releases/tag/v0.0.1)).\n* With gensim\u003e=4.0.0, please use compress-fasttext\u003e=0.1.0\n(and optionally Russian or English models from [our 0.1.0 release](https://github.com/avidale/compress-fasttext/releases/tag/gensim-4-draft)).\n* Some models are no longer supported in the new version of gensim+compress-fasttext \n  (for example, multiple models from [RusVectores](https://rusvectores.org/ru/models/) that use `compatible_hash=False`). \n* For any particular model, compatibility should be determined experimentally. \n  If you notice any strange behaviour, please report in the Github issues.\n\n\nThe package can be installed with `pip`:\n```commandline\npip install compress-fasttext[full]\n```\nIf you are not going to perform matrix decomposition or quantization,\n you can install a variety with less dependencies: \n```commandline\npip install compress-fasttext\n```\n\n### Model compression\nYou can use this package to compress your own fastText model (or one downloaded e.g. from \n[RusVectores](https://rusvectores.org/ru/models/)):\n\nCompress a model in Gensim format:\n```python\nimport gensim\nimport compress_fasttext\nbig_model = gensim.models.fasttext.FastTextKeyedVectors.load('path-to-original-model')\nsmall_model = compress_fasttext.prune_ft_freq(big_model, pq=True)\nsmall_model.save('path-to-new-model')\n```\n\nImport a model in Facebook original format and compress it:\n```python\nfrom gensim.models.fasttext import load_facebook_model\nimport compress_fasttext\nbig_model = load_facebook_model('path-to-original-model').wv\nsmall_model = compress_fasttext.prune_ft_freq(big_model, pq=True)\nsmall_model.save('path-to-new-model')\n```\nTo perform this compression, you will need to `pip install gensim==3.8.3 sklearn` beforehand. \n\nDifferent compression methods include:\n- matrix decomposition (`svd_ft`)\n- product quantization (`quantize_ft`)\n- optimization of feature hashing (`prune_ft`)\n- feature selection (`prune_ft_freq`)\n\nThe recommended approach is combination of feature selection and quantization (`prune_ft_freq` with `pq=True`).\n\n### Model usage\nIf you just need a tiny fastText model for Russian, you can download \n[this](https://github.com/avidale/compress-fasttext/releases/download/gensim-4-draft/geowac_tokens_sg_300_5_2020-100K-20K-100.bin)\n21-megabyte model. It's a compressed version of \n[geowac_tokens_none_fasttextskipgram_300_5_2020](http://vectors.nlpl.eu/repository/20/214.zip) model\nfrom [RusVectores](https://rusvectores.org/ru/models/).\n\nIf `compress-fasttext` is already installed, you can download and use this tiny model\n```python\nimport compress_fasttext\nsmall_model = compress_fasttext.models.CompressedFastTextKeyedVectors.load(\n    'https://github.com/avidale/compress-fasttext/releases/download/gensim-4-draft/geowac_tokens_sg_300_5_2020-100K-20K-100.bin'\n)\nprint(small_model['спасибо'])\n# [ 0.26762889  0.35489027 ...  -0.06149674] # a 300-dimensional vector\nprint(small_model.most_similar('котенок'))\n# [('кот', 0.7391024827957153), ('пес', 0.7388300895690918), ('малыш', 0.7280327081680298), ... ]\n```\nThe class `CompressedFastTextKeyedVectors` inherits from `gensim.models.fasttext.FastTextKeyedVectors`, \nbut makes a few additional optimizations.\n\nFor English, you can use [this](https://github.com/avidale/compress-fasttext/releases/download/v0.0.4/cc.en.300.compressed.bin) tiny model, \nobtained by compressing [the model by Facebook](https://fasttext.cc/docs/en/crawl-vectors.html).\n\n```python\nimport compress_fasttext\nsmall_model = compress_fasttext.models.CompressedFastTextKeyedVectors.load(\n    'https://github.com/avidale/compress-fasttext/releases/download/v0.0.4/cc.en.300.compressed.bin'\n)\nprint(small_model['hello'])\n# [ 1.84736611e-01  6.32683930e-03  4.43901886e-03 ... -2.88431027e-02]  # a 300-dimensional vector\nprint(small_model.most_similar('Python'))\n# [('PHP', 0.5252903699874878), ('.NET', 0.5027452707290649), ('Java', 0.4897131323814392),  ... ]\n```\n\nMore compressed models for 101 various languages can be found at https://zenodo.org/record/4905385. \n\n### Example of application\n\nIn practical applications, you usually feed fastText embeddings to some other model.\nThe class `FastTextTransformer` uses [the scikit-learn interface](https://scikit-learn.org/stable/data_transforms.html)\nand represents a text as the average of the embedding of its words.\nWith it you can, for example, train a classifier on top of fastText \nto tell edible things from inedible ones:\n\n```python\nimport compress_fasttext\nfrom sklearn.pipeline import make_pipeline\nfrom sklearn.linear_model import LogisticRegression\nfrom compress_fasttext.feature_extraction import FastTextTransformer\n\nsmall_model = compress_fasttext.models.CompressedFastTextKeyedVectors.load(\n    'https://github.com/avidale/compress-fasttext/releases/download/v0.0.4/cc.en.300.compressed.bin'\n)\n\nclassifier = make_pipeline(\n    FastTextTransformer(model=small_model), \n    LogisticRegression()\n).fit(\n    ['banana', 'soup', 'burger', 'car', 'tree', 'city'],\n    [1, 1, 1, 0, 0, 0]\n)\nclassifier.predict(['jet', 'train', 'cake', 'apple'])\n# array([0, 0, 1, 1])\n```\n\n### Notes\nThis code is heavily based on the [navec](https://github.com/natasha/navec) package by Alexander Kukushkin and \n[the blogpost](https://medium.com/@vasnetsov93/shrinking-fasttext-embeddings-so-that-it-fits-google-colab-cd59ab75959e) \nby Andrey Vasnetsov about shrinking fastText embeddings.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favidale%2Fcompress-fasttext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favidale%2Fcompress-fasttext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favidale%2Fcompress-fasttext/lists"}