Skip to main content

Vector Symbolic Architecture(VSA) library that allows building VSA apps that use various flavours of VSA vectors.

Project description

vsapy - Vector Symbolic Architecture(VSA) library.

This library implements the common methods used in hyperdimensional computing/Vector Symbolic Architectures. Namely bind, unbind and some bundling operations, bag, ShiftedBag, NamedBag and a hierarchical bundling method CSPvec. The main objective of the library is to enable a single API to cater for various flavours of VSA, including Binary Spatter Codes, Ternary, TernaryZero, Laiho and LaihoX (a simplified Laiho that is faster and supports incremental bundling without catastrophic forgetting).

A set of demo test cases are supplied to demonstrate the use of the library calls.

If installing from PyPi simply

  • Poetry add vsapy
    or
  • pip install vsapy (into your environment)

Installing from source

  • clone the code to a directory of your choice, say "vsapy"

Installing Dependancies

  • Poetry: the easiest way is using poetry

    • cd vsapy
    • poetry install
    • poetry shell (to activate the environment)
  • pip install vsapy

    • create an environment using your favorite environment manager
    • e.g. conda create -n vsapy39 python=3.9
    • conda activate vsapy39
    • pip install -r requirements.txt

Usage

Hint: Valid values for VSaType are, VsaType.BSC, VsaType.Laiho, VsaType.LaihoX(fastest), VsaType.Tern, VsaType.TernZero and VsaType.HRR
(** Note, the demos listed below will not run with type VsaType.HRR **).

  • For examples of using the vsapy library, see the code examples in the ./tests directory. Note there are no command-line arguments implemented for the tests at the moment. To change the type of VSA in use, edit the code changing vsa_type=VsaType.BSC as mentioned below. All of the test cases can be run by simply invoking from the command line, e.g., $python cspvec_sequence.py.

    • cspvec_sequence.py: This is the most straightforward demo. Try this first. It demonstrates building a sentence as a vsa sequence and stepping forward & backwards. Change vsa_type=VsaType.BSC in the code to change the type of VSA used to build the representation.

    • build_docs.py: demonstrates combining large documents into a hierarchical vsa code book. The top-level document vector is a high-level semantic representation of the entire document. Change vsa_type=VsaType.BSC in the code to change the type of VSA used to build the representation.

      • load_docs.py: compares the document vectors built using build_docs.py at various levels in the document hierarchy.

        Change levels_to_extract = [0, 1], 0=top-level document vectors, 1=Act-level vectors, 2=Scene-level vectors and so on (Can set to any level, e.g., levels_to_extract = [2] would compare only Scene-level vectors).

        • Understanding output names: OE_=Old English, NE_=New English, nf_=NoFear Shakespeare, tk_=NLTK Shakespeare, og_=Alternate Shakespeare, ham=Shakespeare's Hamlet , mbeth=Shakespeare's Macbeth.

    • json2vsa.py: demonstrates the creation of a VSA vector from an input JSON file and shows a comparison of various JSONs using VSA. Change vsa_type=VsaType.BSC in the code to change the type of VSA used to build the representation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vsapy-0.7.6.tar.gz (33.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vsapy-0.7.6-py3-none-any.whl (39.2 kB view details)

Uploaded Python 3

File details

Details for the file vsapy-0.7.6.tar.gz.

File metadata

  • Download URL: vsapy-0.7.6.tar.gz
  • Upload date:
  • Size: 33.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.15 CPython/3.9.10 Darwin/21.5.0

File hashes

Hashes for vsapy-0.7.6.tar.gz
Algorithm Hash digest
SHA256 d5946dfca1d53906babfe06377ddb05f4b93fe39807d8c7c4961046f18b8ad20
MD5 7bbe12130b3978a8ef07a8a0f3adc30e
BLAKE2b-256 cb0e8a5cdcb2b6fc204507f1538395abde0f59ec577d1f6ca39fcb8507e5fe25

See more details on using hashes here.

File details

Details for the file vsapy-0.7.6-py3-none-any.whl.

File metadata

  • Download URL: vsapy-0.7.6-py3-none-any.whl
  • Upload date:
  • Size: 39.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.15 CPython/3.9.10 Darwin/21.5.0

File hashes

Hashes for vsapy-0.7.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2ca07187d33004a67a505f685c43b47ff1db0c99ae81a84d9ce2481e1907cd78
MD5 86d4cd5fc8beb49499b846e7ba49710d
BLAKE2b-256 dd98de7523a594c8d6be2a8afe6158c573ae1d46945774ca1b760d187f479ea2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page