{"id":25126108,"url":"https://github.com/stephantul/reach","last_synced_at":"2025-04-23T07:15:14.747Z","repository":{"id":9002442,"uuid":"59490899","full_name":"stephantul/reach","owner":"stephantul","description":"Load embeddings and featurize your sentences.","archived":false,"fork":false,"pushed_at":"2024-10-23T08:13:26.000Z","size":1133,"stargazers_count":28,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-23T07:15:07.631Z","etag":null,"topics":["embeddings","numpy","vectorization","word2vec"],"latest_commit_sha":null,"homepage":null,"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/stephantul.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":"2016-05-23T14:44:09.000Z","updated_at":"2025-02-19T17:50:48.000Z","dependencies_parsed_at":"2024-06-21T20:17:31.038Z","dependency_job_id":"6af57574-7b6d-4425-9148-83ea85bb9182","html_url":"https://github.com/stephantul/reach","commit_stats":{"total_commits":132,"total_committers":6,"mean_commits":22.0,"dds":0.5378787878787878,"last_synced_commit":"ae704219e7aed326bdd7739451abeb03ba2d3bbf"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephantul%2Freach","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephantul%2Freach/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephantul%2Freach/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephantul%2Freach/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephantul","download_url":"https://codeload.github.com/stephantul/reach/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250386840,"owners_count":21422040,"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":["embeddings","numpy","vectorization","word2vec"],"created_at":"2025-02-08T09:17:59.913Z","updated_at":"2025-04-23T07:15:14.738Z","avatar_url":"https://github.com/stephantul.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cdiv align=\"center\"\u003e\n    \u003cpicture\u003e\n      \u003cimg width=\"25%\" alt=\"Reach logo\" src=\"assets/reach_logo.png\"\u003e\n    \u003c/picture\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch2\u003eA small vector store for your RAG system\u003c/h2\u003e\n\u003c/div\u003e\n\n[![PyPI version](https://badge.fury.io/py/reach.svg)](https://badge.fury.io/py/reach)\n[![Downloads](https://pepy.tech/badge/reach)](https://pepy.tech/project/reach)\n\n# Table of contents\n\n1. [Quickstart](#quickstart)\n2. [What do I use it for?](#what-do-i-use-it-for)\n3. [Example](#)\n\nReach is the lightest-weight vector store. Just put in some vectors, calculate query vectors, and off you go.\n\n## Quickstart\n\n```bash\npip install reach\n```\n\nAssume you've got some vectors and a model. We'll assume you have a nice [model2vec](https://github.com/MinishLab/model2vec) model.\n\n```python\nfrom model2vec import StaticModel\nfrom reach import Reach\n\nmodel = StaticModel.from_pretrained(\"minishlab/m2v_output_base\")\ntexts = [\"dog walked home\", \"cat walked home\", \"robot was in his lab\"]\nvectors = model.encode(texts)\n\nr = Reach(vectors, texts)\nr.most_similar(texts[0])\n\nnew_text = \"robot went to his house\"\nsimilarities = r.nearest_neighbor(model.encode(new_text))\n\nprint(similarities)\n\n# Store the vector space\nr.save(\"tempo.json\")\n# Load it again\nnew_reach = Reach.load(\"tempo.json\")\n\n```\n\nAnd that's it!\n\n## What do I use it for?\n\nReach is an extremely simple but extremely fast vector store. No magic here, it just uses numpy really effectively to obtain impressive speeds. Reach will be fast enough for your RAG projects until 1M vectors, after which you may have to switch to something heavier.\n\nReach is designed to load really quickly from disk, see below, making it ideal for just-in-time projects, such as querying texts on the fly. No need to keep a heavy vector database running, just load your reach, do the computation, and then throw it away.\n\n# Examples\n\nHere's some examples and benchmarks.\n\n## Retrieval\n\nFor your RAG system, you need fast retrieval. We got it!\n\n```python\nimport numpy as np\nfrom reach import Reach\n\ndummy_words = list(map(str, range(100_000)))\ndummy_vector = np.random.randn(100_000, 768)\nr = Reach(dummy_vector, dummy_words)\n\n# Query with a single vector\nx = np.random.randn(768)\n%timeit r.nearest_neighbor(x)\n# 6.8 ms ± 286 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n\n# Query reach with 10 vectors\nx = np.random.randn(10, 768)\n%timeit r.nearest_neighbor(x)\n# 27.5 ms ± 187 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n# 2.7 ms per vector\n\n# 100 vectors.\nx = np.random.randn(100, 768)\n%timeit r.nearest_neighbor(x)\n# 143 ms ± 943 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n# 1.4 ms per vector\n```\n\n# Saving and loading\n\nNo need to keep a vector database in memory, or on some server. Just load and save your thing whenever you need it.\n\n```python\nimport numpy as np\nfrom reach import Reach\n\ndummy_words = list(map(str, range(100_000)))\ndummy_vector = np.random.randn(100_000, 768)\nr = Reach(dummy_vector, dummy_words)\n\n# Loading from disk\nr.save(\"temp.json\")\n%timeit Reach.load(\"temp.json\")\n# 79.9 ms ± 1.22 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n```\n\n## Installation\n\n```\npip install reach\n```\n\n# License\n\nMIT\n\n# Author\n\nStéphan Tulkens\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephantul%2Freach","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephantul%2Freach","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephantul%2Freach/lists"}