OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-matrix commits / 6a35369

Brush up the README some more
6a353690a80b1406b16c3385cf2c505fa32d8abe
by Linas Vepštas <linasvepstas@gmail.com> · 2025-01-21T17:02:34.000Z

Changed files (1) +44 -12

README.md +44 -12
……@@ -10,12 +10,16 @@ similar "objects", much like all of the rows of a database table are
1010"similar". That collection of vertexes/edges can be thought of as
1111forming a vector. Such a vector is sparse, in that it is built out of
1212only some small fragment of the total graph. If the graph is big enough,
13there might be thousands (or millions) of such vectors, and then one is
13there might be thousands (or millions) of such vectors. One is then
1414typically interested in doing conventional vector, matrix, tensor
1515analysis on that collection of (sparse) vectors. This repo contains
1616a library/toolset for performing this kind of analysis: correlation,
17covariance, mutual information, similarity measures of various kinds,
18and more.
17covariance, mutual information, overlap, Hamming distance, similarity
18measures of various kinds, and more.
19
20In essence, large graphs have many similar sub-patterns and structures
21inside of them. This is a toolkit for discovering and working with such
22similar subgraphs.
1923
2024### Sparse and Dense Vectors
2125These are *not DL/NN vectors*. The vectors and weight matrices that
……@@ -23,27 +27,55 @@ arise in deep learning neural nets (transformers, generative AI, etc.)
2327are dense, not sparse. If a typical DL/NN vector is one-million-dimensional,
2428then a dense vector will have all million basis coefficients be non-zero.
2529A sparse vector will have all except a small number (say, a thousand) be
26zero.
30zero. So, if 1,000 of 1,000,000 entries are non-zero, this means that
3199.9% of the sparse vector is zero.
2732
28This has storage implications: if 99% of a vector is zero, you don't need
29to store those zeros! If 99% of a vector is zero, you don't need to pass
30it into your GPU's for processing, or send those zeros to some remote
31machine in a compute cluster.
33This has all sorts of implications. If 99.9% of a vector is zero, you
34don't need to store those zeros! (Who wants to fill up their RAM and
35storage with 99.9% zeros???) If 99.9% of a vector is zero, you don't
36need to pass those parts to a GPU for processing. Or send those zeros
37to some remote machine in a compute cluster. Or even run a for-loop
38over them.
3239
3340The [AtomSpace](https://github.com/opencog/atomspace) is a (hyper-)graph
3441database, and, as such, is highly optimized for sparse vector storage.
35Thus, all the code here is in reference to the AtomSpce (and not some
36other graph database.)
42Thus, all the code here explicitly designed for the AtomSpace (and not
43some other graph database.)
3744
38The code here is a library build from the ground-up. It does ***not***
45The code here is a library built from the ground-up. It does ***not***
3946make use of pre-existing tools or libraries that can be found in R or
40SciPy. It would be nice if it was possible to use those systems: they
47SciPy. It would be nice if it was possible to use those systems, as they
4148are very popular, with many many users. Unfortunately, both of them
4249choke on large vectors, and have no support for sparse vectors. If you
4350ask SciPy to create a million-dimensional vector, you'll run out of RAM
4451and then crash. The code in this directory routinely handles vectors of
4552this size.
4653
54### Results
55Some notes to get your juices flowing, and get an idea of what this is
56all about:
57
58* This library forms a central part of the Opencog
59 [Learn project](https://github.com/opencog/learn), where it is used to
60 extract structural similarities in natural language.
61
62* Some typical statistical results seen there resemble those of
63 traditional network analysis: vector lengths have a Zipfian
64 distribution, or sometimes a
65 [square-root Zipfian distribution](https://en.wikipedia.org/wiki/Wikipedia:Does_Wikipedia_traffic_obey_Zipf%27s_law%3F).
66 In such distributions, a handful of vectors are extremely long,
67 and almost all the rest are extremely short. This has been seen
68 in genetic, protein and reactome data (using this library) as
69 well as in natural language, and in Wikipedia reference pages
70 (using this library; see graph above).
71
72* When such vectors are classified according to pair-wise similarity,
73 they form a Gaussian Orthogonal Ensemble (GOE). This means that
74 traditional principles from physics and statistical mechanics can be
75 applied to them. Of course, the 2024 Nobel Prize was awarded for this
76 kind of work: but it is for *dense* vectors, as they appear in neural
77 nets. It turns out that such ideas hold for sparse vectors as well.
78
4779Motivation
4880----------
4981In symbolic AI, there is a generic need to perform "reasoning" or