A rich research framework for hyperdimensional computing on large boolean vectors supporting program transformation and multiple backends for computation (plain Python, C++, NumPy, PyTorch). Many metrics and utility functions aim to aid the intuitive understanding of this new paradigm, and there are multiple levels of functionality available from the data marshalling and the basic (XOR, MAJ, PERMUTE)-algebra to cryptography support. All vector operations are implemented in C(++) and make use of bit-packing and SIMD, subprograms can be optimized and compiled to these operations in Python or C, and parallelization and pipelining are planned.
If your application is a relatively direct pipeline, take a look at HDCC. If you want a more stable library, or want to work with another base field than the booleans, use torch-hd. For C/C++, please see CBHV.
The fundamental research includes finding algebras with interesting properties on top of large boolean vectors. To this extent the library has laws used for testing and an expansive set of operators including:
Additionally, provided are
Make sure you have a recent Python version, 3.10 is recommended.
pip install bhv
If you want a specific definition of "hyper" (the default is 8192) you can specify that as follows:
DIMENSION=512 pip install bhv
Note, use multiples of 512 and preferably powers of 2.
If you only want to work with plain Python, you're good to go with from bhv.vanilla VanillaBHV as BHV
.
For the native option, you need a modern C++ compiler and use from bhv.native import NativePackedBHV as BHV
. The setup process should attempt to install this by default.
For interop with (the Python interface of) NumPy and PyTorch, you'll need
pip install numpy
or pip install torch
with respectively from bhv.np import NumPyPacked64BHV as BHV
or from bhv.np import TorchBoolBHV as BHV
.
Some resources to get started with the library, if you're looking for a broader intro, please take a look at hd-computing.com.
Basic uses (in the context of neo-GOFAI) are given in my presentation with a installation-free notebook.
The fundamental angle is to start is with Kanerva's initial paper together with the library. For that, multiple resources are provided:
As for a Machine Learning angle, you may enjoy:
If you like to dive into the code directly, I suggest the following entrypoints:
Example exploratory usages of the library:
This repository is (highly) active development, and a work-in-progress. Do expect changes to the naming, and even features to be swapped for more elegant alternatives.
The codebase also works with PyPy. Use the vanilla Python implementation. The numeric operations are slower than on CPython, but the symbolic ones are way faster.
If you have any feedback, raise an informal issue, or email me at contact@adamv.be
If the library is not as fast as possible, that's a bug, please report.