{"id":13467459,"url":"https://github.com/hora-search/hora","last_synced_at":"2025-05-14T09:11:41.789Z","repository":{"id":37512313,"uuid":"367571115","full_name":"hora-search/hora","owner":"hora-search","description":"🚀  efficient approximate nearest neighbor search algorithm collections library written in Rust 🦀 . ","archived":false,"fork":false,"pushed_at":"2024-01-31T01:18:35.000Z","size":14854,"stargazers_count":2642,"open_issues_count":24,"forks_count":76,"subscribers_count":48,"default_branch":"main","last_synced_at":"2025-05-11T12:48:28.247Z","etag":null,"topics":["algorithm","approximate-nearest-neighbor-search","artificial-intelligence","data-structures","high-performance","hnsw","image-search","k-nearest-neighbors","machine-learning","neural-network","numeric","recommender-system","rust","rust-sci","search-engine","simd","similarity-search","vector-search"],"latest_commit_sha":null,"homepage":"http://horasearch.com/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hora-search.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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}},"created_at":"2021-05-15T07:46:32.000Z","updated_at":"2025-05-08T20:34:01.000Z","dependencies_parsed_at":"2024-04-20T04:33:31.238Z","dependency_job_id":"da4aab9a-ecda-4a89-a303-22bd27c90660","html_url":"https://github.com/hora-search/hora","commit_stats":{"total_commits":60,"total_committers":7,"mean_commits":8.571428571428571,"dds":"0.15000000000000002","last_synced_commit":"239bd366693cd4fabf11c30786139ea9cc5cf40f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hora-search%2Fhora","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hora-search%2Fhora/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hora-search%2Fhora/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hora-search%2Fhora/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hora-search","download_url":"https://codeload.github.com/hora-search/hora/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254110374,"owners_count":22016391,"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":["algorithm","approximate-nearest-neighbor-search","artificial-intelligence","data-structures","high-performance","hnsw","image-search","k-nearest-neighbors","machine-learning","neural-network","numeric","recommender-system","rust","rust-sci","search-engine","simd","similarity-search","vector-search"],"created_at":"2024-07-31T15:00:56.794Z","updated_at":"2025-05-14T09:11:41.764Z","avatar_url":"https://github.com/hora-search.png","language":"Rust","funding_links":[],"categories":["Rust","Multidimensional data / Vectors","向量数据库、向量搜索、最近邻搜索","Sdks \u0026 Libraries","artificial-intelligence","Awesome Vector Search Engine","*Ops for AI","Search","Model Serving \u0026 Inference"],"sub_categories":["网络服务_其他","Library","Model Serving \u0026 Inference","Vector Databases \u0026 Retrieval Infrastructure"],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"asset/logo.svg\" width=\"70%\"/\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch3\u003e  English | \u003ca href=\"https://github.com/hora-search/hora/blob/main/README_FR.md\"\u003e Français \u003c/a\u003e | \u003ca href=\"https://github.com/hora-search/hora/blob/main/README_JP.md\"\u003e 日本語 \u003c/a\u003e | \u003ca href=\"https://github.com/hora-search/hora/blob/main/README_KR.md\"\u003e한국어\u003c/a\u003e | \u003ca href=\"https://github.com/hora-search/hora/blob/main/README_RU.md\"\u003eРусский\u003c/a\u003e | \u003ca href=\"https://github.com/hora-search/hora/blob/main/README_CN.md\"\u003e中文\u003c/a\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\n# Hora\n\n**[[Homepage](http://horasearch.com/)]** **[[Document](https://horasearch.com/doc)]** **[[Examples](https://horasearch.com/doc/example.html)]**\n\n**_Hora Search Everywhere!_**\n\nHora is an **approximate nearest neighbor search algorithm** ([wiki](https://en.wikipedia.org/wiki/Nearest_neighbor_search)) library. We implement all code in `Rust🦀` for reliability, high level abstraction and high speeds comparable to `C++`.\n\nHora, **`「ほら」`** in Japanese, sounds like `[hōlə]`, and means `Wow`, `You see!` or `Look at that!`. The name is inspired by a famous Japanese song **`「小さな恋のうた」`**.\n\n# Demos\n\n**👩 Face-Match [[online demo](https://horasearch.com/#Demos)], have a try!**\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"asset/demo3.gif\" width=\"100%\"/\u003e\n\u003c/div\u003e\n\n**🍷 Dream wine comments search [[online demo](https://horasearch.com/#Demos)], have a try!**\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"asset/demo2.gif\" width=\"100%\"/\u003e\n\u003c/div\u003e\n\n# Features\n\n- **Performant** ⚡️\n\n  - **SIMD-Accelerated ([packed_simd](https://github.com/rust-lang/packed_simd))**\n  - **Stable algorithm implementation**\n  - **Multiple threads design**\n\n- **Supports Multiple Languages** ☄️\n\n  - `Python`\n  - `Javascript`\n  - `Java`\n  - `Go` (WIP)\n  - `Ruby` (WIP)\n  - `Swift` (WIP)\n  - `R` (WIP)\n  - `Julia` (WIP)\n  - **Can also be used as a service**\n\n- **Supports Multiple Indexes** 🚀\n\n  - `Hierarchical Navigable Small World Graph Index (HNSWIndex)` ([details](https://arxiv.org/abs/1603.09320))\n  - `Satellite System Graph (SSGIndex)` ([details](https://arxiv.org/abs/1907.06146))\n  - `Product Quantization Inverted File(PQIVFIndex)` ([details](https://lear.inrialpes.fr/pubs/2011/JDS11/jegou_searching_with_quantization.pdf))\n  - `Random Projection Tree(RPTIndex)` (LSH, WIP)\n  - `BruteForce (BruteForceIndex)` (naive implementation with SIMD)\n\n- **Portable** 💼\n\n  - Supports `WebAssembly`\n  - Supports `Windows`, `Linux` and `OS X`\n  - Supports `IOS` and `Android` (WIP)\n  - Supports `no_std` (WIP, partial)\n  - **No** heavy dependencies, such as `BLAS`\n\n- **Reliability** 🔒\n\n  - `Rust` compiler secures all code\n  - Memory managed by `Rust` for all language libraries such as `Python's`\n  - Broad testing coverage\n\n- **Supports Multiple Distances** 🧮\n\n  - `Dot Product Distance`\n    - ![equation](https://latex.codecogs.com/gif.latex?D%28x%2Cy%29%20%3D%20%5Csum%7B%28x*y%29%7D)\n  - `Euclidean Distance`\n    - ![equation](https://latex.codecogs.com/gif.latex?D%28x%2Cy%29%20%3D%20%5Csqrt%7B%5Csum%7B%28x-y%29%5E2%7D%7D)\n  - `Manhattan Distance`\n    - ![equation](https://latex.codecogs.com/gif.latex?D%28x%2Cy%29%20%3D%20%5Csum%7B%7C%28x-y%29%7C%7D)\n  - `Cosine Similarity`\n    - ![equation](https://latex.codecogs.com/gif.latex?D%28x%2Cy%29%20%3D%20%5Cfrac%7Bx%20*y%7D%7B%7C%7Cx%7C%7C*%7C%7Cy%7C%7C%7D)\n\n- **Productive** ⭐\n  - Well documented\n  - Elegant, simple and easy to learn API\n\n# Installation\n\n**`Rust`**\n\nin `Cargo.toml`\n\n```toml\n[dependencies]\nhora = \"0.1.1\"\n```\n\n**`Python`**\n\n```Bash\n$ pip install horapy\n```\n\n**`Javascript (WebAssembly)`**\n\n```Bash\n$ npm i horajs\n```\n\n**`Building from source`**\n\n```bash\n$ git clone https://github.com/hora-search/hora\n$ cargo build\n```\n\n# Benchmarks\n\n\u003cimg src=\"asset/fashion-mnist-784-euclidean_10_euclidean.png\"/\u003e\n\nby `aws t2.medium (CPU: Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz)` [more information](https://github.com/hora-search/ann-benchmarks)\n\n# Examples\n\n**`Rust` example** [[more info](https://github.com/hora-search/hora/tree/main/examples)]\n\n```Rust\nuse hora::core::ann_index::ANNIndex;\nuse rand::{thread_rng, Rng};\nuse rand_distr::{Distribution, Normal};\n\npub fn demo() {\n    let n = 1000;\n    let dimension = 64;\n\n    // make sample points\n    let mut samples = Vec::with_capacity(n);\n    let normal = Normal::new(0.0, 10.0).unwrap();\n    for _i in 0..n {\n        let mut sample = Vec::with_capacity(dimension);\n        for _j in 0..dimension {\n            sample.push(normal.sample(\u0026mut rand::thread_rng()));\n        }\n        samples.push(sample);\n    }\n\n    // init index\n    let mut index = hora::index::hnsw_idx::HNSWIndex::\u003cf32, usize\u003e::new(\n        dimension,\n        \u0026hora::index::hnsw_params::HNSWParams::\u003cf32\u003e::default(),\n    );\n    for (i, sample) in samples.iter().enumerate().take(n) {\n        // add point\n        index.add(sample, i).unwrap();\n    }\n    index.build(hora::core::metrics::Metric::Euclidean).unwrap();\n\n    let mut rng = thread_rng();\n    let target: usize = rng.gen_range(0..n);\n    // 523 has neighbors: [523, 762, 364, 268, 561, 231, 380, 817, 331, 246]\n    println!(\n        \"{:?} has neighbors: {:?}\",\n        target,\n        index.search(\u0026samples[target], 10) // search for k nearest neighbors\n    );\n}\n```\n\nthank @vaaaaanquish for this complete pure `Rust 🦀` image search [example](https://github.com/vaaaaanquish/rust-ann-search-example), For more information about this example, you can click [Pure Rust な近似最近傍探索ライブラリ hora を用いた画像検索を実装する](https://vaaaaaanquish.hatenablog.com/entry/2021/08/10/065117)\n\n**`Python` example** [[more info](https://github.com/hora-search/horapy)]\n\n```Python\nimport numpy as np\nfrom horapy import HNSWIndex\n\ndimension = 50\nn = 1000\n\n# init index instance\nindex = HNSWIndex(dimension, \"usize\")\n\nsamples = np.float32(np.random.rand(n, dimension))\nfor i in range(0, len(samples)):\n    # add node\n    index.add(np.float32(samples[i]), i)\n\nindex.build(\"euclidean\")  # build index\n\ntarget = np.random.randint(0, n)\n# 410 in Hora ANNIndex \u003cHNSWIndexUsize\u003e (dimension: 50, dtype: usize, max_item: 1000000, n_neigh: 32, n_neigh0: 64, ef_build: 20, ef_search: 500, has_deletion: False)\n# has neighbors: [410, 736, 65, 36, 631, 83, 111, 254, 990, 161]\nprint(\"{} in {} \\nhas neighbors: {}\".format(\n    target, index, index.search(samples[target], 10)))  # search\n\n```\n\n**`JavaScript` example** [[more info](https://github.com/hora-search/hora-wasm)]\n\n```JavaScript\nimport * as horajs from \"horajs\";\n\nconst demo = () =\u003e {\n    const dimension = 50;\n    var bf_idx = horajs.BruteForceIndexUsize.new(dimension);\n    // var hnsw_idx = horajs.HNSWIndexUsize.new(dimension, 1000000, 32, 64, 20, 500, 16, false);\n    for (var i = 0; i \u003c 1000; i++) {\n        var feature = [];\n        for (var j = 0; j \u003c dimension; j++) {\n            feature.push(Math.random());\n        }\n        bf_idx.add(feature, i); // add point\n    }\n    bf_idx.build(\"euclidean\"); // build index\n    var feature = [];\n    for (var j = 0; j \u003c dimension; j++) {\n        feature.push(Math.random());\n    }\n    console.log(\"bf result\", bf_idx.search(feature, 10)); //bf result Uint32Array(10) [704, 113, 358, 835, 408, 379, 117, 414, 808, 826]\n}\n\n(async () =\u003e {\n    await horajs.default();\n    await horajs.init_env();\n    demo();\n})();\n```\n\n**`Java` example** [[more info](https://github.com/hora-search/hora-java)]\n\n```Java\npublic void demo() {\n    final int dimension = 2;\n    final float variance = 2.0f;\n    Random fRandom = new Random();\n\n    BruteForceIndex bruteforce_idx = new BruteForceIndex(dimension); // init index instance\n\n    List\u003cfloat[]\u003e tmp = new ArrayList\u003c\u003e();\n    for (int i = 0; i \u003c 5; i++) {\n        for (int p = 0; p \u003c 10; p++) {\n            float[] features = new float[dimension];\n            for (int j = 0; j \u003c dimension; j++) {\n                features[j] = getGaussian(fRandom, (float) (i * 10), variance);\n            }\n            bruteforce_idx.add(\"bf\", features, i * 10 + p); // add point\n            tmp.add(features);\n          }\n    }\n    bruteforce_idx.build(\"bf\", \"euclidean\"); // build index\n\n    int search_index = fRandom.nextInt(tmp.size());\n    // nearest neighbor search\n    int[] result = bruteforce_idx.search(\"bf\", 10, tmp.get(search_index));\n    // [main] INFO com.hora.app.ANNIndexTest  - demo bruteforce_idx[7, 8, 0, 5, 3, 9, 1, 6, 4, 2]\n    log.info(\"demo bruteforce_idx\" + Arrays.toString(result));\n}\n\nprivate static float getGaussian(Random fRandom, float aMean, float variance) {\n    float r = (float) fRandom.nextGaussian();\n    return aMean + r * variance;\n}\n```\n\n# Roadmap\n\n- [ ] Full test coverage\n- [ ] Implement [EFANNA](http://arxiv.org/abs/1609.07228) algorithm to achieve faster KNN graph building\n- [ ] Swift support and iOS/macOS deployment example\n- [ ] Support `R`\n- [ ] support `mmap`\n\n# Related Projects and Comparison\n\n- [Faiss](https://github.com/facebookresearch/faiss), [Annoy](https://github.com/spotify/annoy), [ScaNN](https://github.com/google-research/google-research/tree/master/scann):\n\n  - **`Hora`'s implementation is strongly inspired by these libraries.**\n  - `Faiss` focuses more on the GPU scenerio, and `Hora` is lighter than Faiss (**no heavy dependencies)**.\n  - `Hora` expects to support more languages, and everything related to performance will be implemented by Rust🦀.\n  - `Annoy` only supports the `LSH (Random Projection)` algorithm.\n  - `ScaNN` and `Faiss` are less user-friendly, (e.g. lack of documentation).\n  - Hora is **ALL IN RUST** 🦀.\n\n- [Milvus](https://github.com/milvus-io/milvus), [Vald](https://github.com/vdaas/vald), [Jina AI](https://github.com/jina-ai/jina)\n  - `Milvus` and `Vald` also support multiple languages, but serve as a service instead of a library\n  - `Milvus` is built upon some libraries such as `Faiss`, while `Hora` is a library with all the algorithms implemented itself\n\n# Contribute\n\n**We appreciate your participation!**\n\nWe are glad to have you participate, any contributions are welcome, including documentations and tests.\nYou can create a `Pull Request` or `Issue` on GitHub, and we will review it as soon as possible.\n\nWe use GitHub issues for tracking suggestions and bugs.\n\n#### Clone the repo\n\n```bash\ngit clone https://github.com/hora-search/hora\n```\n\n#### Build\n\n```bash\ncargo build\n```\n\n#### Test\n\n```bash\ncargo test --lib\n```\n\n#### Try the changes\n\n```bash\ncd examples\ncargo run\n```\n\n# License\n\nThe entire repository is licensed under the [Apache License](https://github.com/hora-search/hora/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhora-search%2Fhora","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhora-search%2Fhora","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhora-search%2Fhora/lists"}