{"id":13513570,"url":"https://github.com/ankane/faiss-ruby","last_synced_at":"2025-11-17T14:05:55.339Z","repository":{"id":56845431,"uuid":"245893491","full_name":"ankane/faiss-ruby","owner":"ankane","description":"Efficient similarity search and clustering for Ruby","archived":false,"fork":false,"pushed_at":"2025-11-12T17:23:51.000Z","size":108,"stargazers_count":144,"open_issues_count":0,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-12T19:16:06.217Z","etag":null,"topics":["ann","approximate-nearest-neighbors","kmeans","pca"],"latest_commit_sha":null,"homepage":"","language":"C++","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/ankane.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2020-03-08T21:51:19.000Z","updated_at":"2025-11-12T17:23:55.000Z","dependencies_parsed_at":"2023-12-26T21:21:13.065Z","dependency_job_id":"b4ea83d7-3ced-4e10-bdbd-df829c621589","html_url":"https://github.com/ankane/faiss-ruby","commit_stats":{"total_commits":138,"total_committers":2,"mean_commits":69.0,"dds":"0.23913043478260865","last_synced_commit":"a1f11564d2565d24eaa419d720aef3007bbceba3"},"previous_names":["ankane/faiss"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/ankane/faiss-ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Ffaiss-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Ffaiss-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Ffaiss-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Ffaiss-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankane","download_url":"https://codeload.github.com/ankane/faiss-ruby/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Ffaiss-ruby/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284893573,"owners_count":27080532,"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","status":"online","status_checked_at":"2025-11-17T02:00:06.431Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["ann","approximate-nearest-neighbors","kmeans","pca"],"created_at":"2024-08-01T05:00:31.642Z","updated_at":"2025-11-17T14:05:55.333Z","avatar_url":"https://github.com/ankane.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# Faiss Ruby\n\n[Faiss](https://github.com/facebookresearch/faiss) - efficient similarity search and clustering - for Ruby\n\nLearn more about [Faiss](https://engineering.fb.com/data-infrastructure/faiss-a-library-for-efficient-similarity-search/)\n\n[![Build Status](https://github.com/ankane/faiss-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/faiss-ruby/actions)\n\n## Installation\n\nFirst, ensure BLAS, LAPACK, and OpenMP are installed. For Mac, use:\n\n```sh\nbrew install libomp\n```\n\nFor Ubuntu, use:\n\n```sh\nsudo apt-get install libblas-dev liblapack-dev\n```\n\nThen add this line to your application’s Gemfile:\n\n```ruby\ngem \"faiss\"\n```\n\nIt can take a few minutes to compile the gem. Windows is not currently supported.\n\n## Getting Started\n\nPrep your data\n\n```ruby\nobjects = [\n  [1, 1, 2, 1],\n  [5, 4, 6, 5],\n  [1, 2, 1, 2]\n]\n```\n\nBuild an index\n\n```ruby\nindex = Faiss::IndexFlatL2.new(4)\nindex.add(objects)\n```\n\nSearch\n\n```ruby\ndistances, ids = index.search(objects, 3)\n```\n\n\u003e Use `index.freeze` to release the GVL for searches\n\nSave an index\n\n```ruby\nindex.save(\"index.bin\")\n```\n\nLoad an index\n\n```ruby\nindex = Faiss::Index.load(\"index.bin\")\n```\n\n\u003e Use `Faiss::IndexBinary` to load binary indexes\n\n## Basic Indexes\n\nExact search for L2\n\n```ruby\nFaiss::IndexFlatL2.new(d)\n```\n\nExact search for inner product\n\n```ruby\nFaiss::IndexFlatIP.new(d)\n```\n\nHierarchical navigable small world graph exploration\n\n```ruby\nFaiss::IndexHNSWFlat.new(d, m)\n```\n\nInverted file with exact post-verification\n\n```ruby\nFaiss::IndexIVFFlat.new(quantizer, d, nlists)\n```\n\nLocality-sensitive hashing\n\n```ruby\nFaiss::IndexLSH.new(d, nbits)\n```\n\nScalar quantizer (SQ) in flat mode\n\n```ruby\nFaiss::IndexScalarQuantizer.new(d, qtype)\n```\n\nProduct quantizer (PQ) in flat mode\n\n```ruby\nFaiss::IndexPQ.new(d, m, nbits)\n```\n\nIVF and scalar quantizer\n\n```ruby\nFaiss::IndexIVFScalarQuantizer.new(quantizer, d, nlists, qtype)\n```\n\nIVFADC (coarse quantizer+PQ on residuals)\n\n```ruby\nFaiss::IndexIVFPQ.new(quantizer, d, nlists, m, nbits)\n```\n\nIVFADC+R (same as IVFADC with re-ranking based on codes)\n\n```ruby\nFaiss::IndexIVFPQR.new(quantizer, d, nlists, m, nbits, m_refine, nbits_refine)\n```\n\n## Binary Indexes\n\nIndex binary vectors\n\n```ruby\nFaiss::IndexBinaryFlat.new(d)\n```\n\nSpeed up search with an inverse vector file\n\n```ruby\nFaiss::IndexBinaryIVF.new(quantizer, d, nlists)\n```\n\n## K-means Clustering\n\nTrain\n\n```ruby\nkmeans = Faiss::Kmeans.new(4, 2)\nkmeans.train(objects)\n```\n\nGet the centroids\n\n```ruby\nkmeans.centroids\n```\n\n## PCA\n\nTrain\n\n```ruby\nmat = Faiss::PCAMatrix.new(40, 10)\nmat.train(objects)\n```\n\nApply\n\n```ruby\nmat.apply(mt)\n```\n\n## Product Quantizer\n\nTrain\n\n```ruby\npq = Faiss::ProductQuantizer.new(32, 4, 8)\npq.train(objects)\n```\n\nEncode\n\n```ruby\npq.compute_codes(objects)\n```\n\nDecode\n\n```ruby\npq.decode(codes)\n```\n\nSave a quantizer\n\n```ruby\npq.save(\"pq.bin\")\n```\n\nLoad a quantizer\n\n```ruby\npq = Faiss::ProductQuantizer.load(\"pq.bin\")\n```\n\n## Data\n\nData can be an array of arrays\n\n```ruby\n[[1, 2, 3], [4, 5, 6]]\n```\n\nOr a Numo array\n\n```ruby\nNumo::NArray.cast([[1, 2, 3], [4, 5, 6]])\n```\n\n## History\n\nView the [changelog](CHANGELOG.md)\n\n## Contributing\n\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https://github.com/ankane/faiss-ruby/issues)\n- Fix bugs and [submit pull requests](https://github.com/ankane/faiss-ruby/pulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features\n\nTo get started with development:\n\n```sh\ngit clone --recursive https://github.com/ankane/faiss-ruby.git\ncd faiss-ruby\nbundle install\nbundle exec rake compile\nbundle exec rake test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Ffaiss-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankane%2Ffaiss-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Ffaiss-ruby/lists"}