gigasquid / vsa-clj

VSA Computing Experiments in Clojure
Eclipse Public License 1.0
57 stars 2 forks source link

query-cleanup-mem should return entry, not ffirst? #2

Open benjamin-asdf opened 11 months ago

benjamin-asdf commented 11 months ago

Hello

;; current:
(do
  (vb/reset-mem!)
  (vb/add-hdv! :name)
  (vb/add-hdv! "alice")
  (vb/add-hdv! "bob")

  (def
    H
    (->
     (vb/bind
      (vb/get-hdv :name)
      (vb/get-hdv "alice"))
     (vb/bundle
      (vb/bind
       (vb/get-hdv :name)
       (vb/get-hdv "bob")))))
  (vb/unbind-get H "alice" nil true))

[:name #tech.v3.tensor<int8>[10000]
 [1 1 -1 ... -1 -1 -1]]

;; there is no :dot and :cos-sim but I wanted verbose

;; use first instead of ffirst

(do
  (vb/reset-mem!)
  (vb/add-hdv! :name)
  (vb/add-hdv! "alice")
  (vb/add-hdv! "bob")

  (def
    H
    (->
     (vb/bind
      (vb/get-hdv :name)
      (vb/get-hdv "alice"))
     (vb/bundle
      (vb/bind
       (vb/get-hdv :name)
       (vb/get-hdv "bob")))))
  (vb/unbind-get H "alice" nil true))

{:name #tech.v3.tensor<int8>
 [10000] [1 1 1 ... 1 1 1]
 :dot 4970.0
 :cos-sim 0.7049822692805826}

;; the output is a map instead
gigasquid commented 11 months ago

Good question. The verbose feature was added on a bit later in my explorations and was meant to help my use cases.

Feel free to use this code as a launching point for however you best think it should evolve.