Ai Dreams Forum

Member's Experiments & Projects => General Project Discussion => Topic started by: Zero on June 02, 2021, 03:06:27 pm

Title: Speech acts with trees of word-vectors
Post by: Zero on June 02, 2021, 03:06:27 pm
As part of what I'm working on (same huge project for several weeks, woohoo!!), I was wondering how I was going to store statements, questions, ...etc. Structured meaning blocks.

Starting from word-vectors, with the famous example of king - man + woman = queen, my first intuition was that a block would be an ordered list of vectors.

Using stanleyfok's vector-object (https://github.com/stanleyfok/vector-object) library, that would be an array like this (dumb example):
Code
[
    new Vector({ react: 1, nodejs: 2, angular: 1 }),
    new Vector({ nodejs: 2, marko: 3, nextjs: 2 })
]

But thinking about it, sentences and phrases are not really linear, they are rather like trees. Targetting natural language realization with jsRealB (https://github.com/lapalme/jsRealB), the shape of sentences (https://github.com/lapalme/jsRealB/blob/master/Architecture/README.md) is more like this ("he eats apples"):
Code
S(Pro("I").g("m"),
  VP(V("eat"),
     NP(D("a"),N("apple").n("p")))
 )

What I'm thinking here, is that meaning-vectors, organized as leaves of trees, and manipulated accordingly, should make a nice language of thought (https://en.wikipedia.org/wiki/Language_of_thought_hypothesis).

edit:

But then, how would I calculate the vector of a phrase or sentence, based on the vectors of its constituants?
Title: Re: Speech acts with trees of word-vectors
Post by: frankinstien on June 02, 2021, 05:03:05 pm
Here's a similar concept and was used to model emotions (https://aidreams.co.uk/forum/general-project-discussion/emotions-15065/) but is used to model other concepts as well. It incorporates an object-oriented data model so it can benefit from inheritance, and nesting.

(https://i.imgur.com/WeWLPXU.png)(https://i.imgur.com/QlQnHMA.png)

(https://i.imgur.com/HkJ5cN9.png)
Title: Re: Speech acts with trees of word-vectors
Post by: Zero on June 02, 2021, 09:14:28 pm
Looks like a really nice tool you have here. If I understand correctly, you're doing single inheritance with overloading? Cool.
 8)

Say you have (A) the boy eats the apple. The meaning-vector of this sentence is more than just an object that would inherit the meaning-vectors of the boy, eats and the apple. We know it's more than that because inheritance à la OO (overloading or adding) would give the same m-vector for (B) the apple eats the boy, which is not the same.

And the missing part is not even in the structure of the sentence, since (A) and (B) have the very same structure. Even if an m-vector gets added because of the structure, it's still not enough to differentiate (A) and (B).

This example makes obvious that the additional information which we're looking for, is the role of the constituants. I'm wondering how to turn these roles into new valued dimensions. Or any other way to solve this!
Title: Re: Speech acts with trees of word-vectors
Post by: Zero on June 02, 2021, 10:39:36 pm
Nice article about vectors from a machine-learning perspective (https://neptune.ai/blog/understanding-vectors-from-a-machine-learning-perspective)   :knuppel2:

edit:

Got it. I think. An m-vector encodes not only a target, but also its role in the sentence or phrase. So the boy in (A) is NOT the same as the boy in (B). But the relation holds.

Let's call them:
Code
[the boy](A)
[the boy](B)
[the apple](A)
[the apple](B)

Then we have:
Code
[the apple](B) - [the apple](A) = [the boy](B) - [the boy](A)

Et voilà, everything follows.

edit:

But it still means the m-vector of the sentence is not the sum of the m-vectors of its constituants.

How about... adding siblings, and multiplying children? Or something.

edit:

  :D The meaning-vector of a sentence is a formula, a higher-order value!!
Code
boy = () => human(1) + young(1)
eats = () => action(1) + foodRelated(2)
apple = () => fruit(1) + foodRelated(3)

boy eats apple = (subject, verb, object) =>
    human(1 * subject) + young(1 * subject) +
    action(1 * verb) + foodRelated(2 * verb) +
    fruit(1 * object) + foodRelated(3 * object)
Title: Re: Speech acts with trees of word-vectors
Post by: frankinstien on June 03, 2021, 12:34:37 am
Looks like a really nice tool you have here. If I understand correctly, you're doing single inheritance with overloading? Cool.
 8)

It can do multiple inheritances and can manage circular references (this is good when you have deeply nested objects).

Say you have (A) the boy eats the apple. The meaning-vector of this sentence is more than just an object that would inherit the meaning-vectors of the boy, eats and the apple. We know it's more than that because inheritance à la OO (overloading or adding) would give the same m-vector for (B) the apple eats the boy, which is not the same.

Well, no since an apple doesn't have a mouth or other digestive capabilities, so it would not be the same.

This example makes obvious that the additional information which we're looking for, is the role of the constituants. I'm wondering how to turn these roles into new valued dimensions. Or any other way to solve this!

The roles are determined by definitions described as capabilities and attributes where metaphorical scenarios are detected when those capabilities and attributes are violated by the context of the sentence.
Title: Re: Speech acts with trees of word-vectors
Post by: frankinstien on June 03, 2021, 01:23:32 am
Just to elaborate a bit more the ontological framework provides the means to associate pieces of data that can be standardized. So there are vectors in the form of various definitions, below is an image:

(https://i.imgur.com/KGzFylN.png)

Note that in features "part" is marked in a red box. So if you noticed in the RootDescriptor tree a "Head" is a part described as a generalized type. So a machine can sense if something has parts and what kind. The vectors are in the form of enumerators that can be extended indefinitely without having to recode in some programming language and are stored in a NoSQL database. This approach makes the creation, and editing  machine and human readable. So we can provide this kind of input to a neural network or some other algorithm.

This also allows for the compare and contrast operation to be fairly straightforward. Also, note (if you looked at how Emotions are modeled) data can be assigned or associated that can be anything, video, audio, scable vectors, or functions from any language.

Also, note that this approach involves the machine interact with some mentor, machine or human, to learn new concepts that it does not understand. I did describe a means to teach the machine in a previous post (https://aidreams.co.uk/forum/general-project-discussion/it-s-here!/). This is all work in progress, as I wish I could find the funding to do much much more...
Title: Re: Speech acts with trees of word-vectors
Post by: MagnusWootton on June 03, 2021, 01:53:15 am
The apple eats the boy,  is an example where word precedence matters.

But there is lots of cases where it doesnt matter as well.

See you later.
you later see.
see later you.
later you see.
later see you.

could be similar,   im yet to code it tho,  but thats one of my ideas that help plasticize its word dictionary,  cause there is not enough dictionary size on the planet,  for a decent chat bot,   theres got to be some way of increasing the patterns you have.
Title: Re: Speech acts with trees of word-vectors
Post by: Zero on June 03, 2021, 09:44:52 am
Quote
Well, no since an apple doesn't have a mouth or other digestive capabilities, so it would not be the same.

Yes it would give the same m-vector for (A) and (B). Here is a snippet that shows this unwanted outcome:

Code
const Vector = require("vector-object");



let boy = new Vector({
    human: 1,
    young: 1
});

let eats = new Vector({
    action: 1,
    foodRelated: 1
});

let apple = new Vector({
    fruit: 1,
    foodRelated: 1
});



let sentenceA = new Vector({}).add(boy).add(eats).add(apple);

console.log("boy + eats + apple = ", sentenceA);



let sentenceB = new Vector({}).add(apple).add(eats).add(boy);

console.log("apple + eats + boy = ", sentenceB);



console.log(
    sentenceA.isEqual(sentenceB) ?
        "boy + eats + apple == apple + eats + boy" :
        "boy + eats + apple != apple + eats + boy"
);

This Javascript code actually outputs:
Code
boy + eats + apple =  Vector {
  vector: { human: 1, young: 1, action: 1, foodRelated: 2, fruit: 1 }
}
apple + eats + boy =  Vector {
  vector: { fruit: 1, foodRelated: 2, action: 1, human: 1, young: 1 }
}
boy + eats + apple == apple + eats + boy

As you can see, the meaning of the sentence is not only the addition of the meaning of its constituants. The role of constituants has to be part of the sentence's m-vector, one way or another.

Quote
could be similar,   im yet to code it tho,  but thats one of my ideas that help plasticize its word dictionary,  cause there is not enough dictionary size on the planet,  for a decent chat bot,   theres got to be some way of increasing the patterns you have.

In other words, the same m-vector should be realizable through different structures. I think it fits with my idea of a formula, where several "math" expressions can be equivalent.
Title: Re: Speech acts with trees of word-vectors
Post by: Zero on June 03, 2021, 11:27:47 am
Bivectors (https://en.wikipedia.org/wiki/Bivector) could be what I need here...

edit:

A resource here: http://www.jaapsuter.com/geometric-algebra.pdf

I need blades (https://en.wikipedia.org/wiki/Blade_(geometry)) and ganja (https://github.com/enkimute/ganja.js).
Doing my homework.
Title: Re: Speech acts with trees of word-vectors
Post by: Zero on June 03, 2021, 11:54:57 am
Quote
I did describe a means to teach the machine in a previous post (https://aidreams.co.uk/forum/general-project-discussion/it-s-here!/).
I love it!  O0
Title: Re: Speech acts with trees of word-vectors
Post by: frankinstien on August 22, 2021, 10:30:06 pm
Quote
Well, no since an apple doesn't have a mouth or other digestive capabilities, so it would not be the same.

Yes it would give the same m-vector for (A) and (B). Here is a snippet that shows this unwanted outcome:

Code
const Vector = require("vector-object");



let boy = new Vector({
    human: 1,
    young: 1
});

let eats = new Vector({
    action: 1,
    foodRelated: 1
});

let apple = new Vector({
    fruit: 1,
    foodRelated: 1
});



let sentenceA = new Vector({}).add(boy).add(eats).add(apple);

console.log("boy + eats + apple = ", sentenceA);



let sentenceB = new Vector({}).add(apple).add(eats).add(boy);

console.log("apple + eats + boy = ", sentenceB);



console.log(
    sentenceA.isEqual(sentenceB) ?
        "boy + eats + apple == apple + eats + boy" :
        "boy + eats + apple != apple + eats + boy"
);

This Javascript code actually outputs:
Code
boy + eats + apple =  Vector {
  vector: { human: 1, young: 1, action: 1, foodRelated: 2, fruit: 1 }
}
apple + eats + boy =  Vector {
  vector: { fruit: 1, foodRelated: 2, action: 1, human: 1, young: 1 }
}
boy + eats + apple == apple + eats + boy

As you can see, the meaning of the sentence is not only the addition of the meaning of its constituants. The role of constituants has to be part of the sentence's m-vector, one way or another.

Quote
could be similar,   im yet to code it tho,  but thats one of my ideas that help plasticize its word dictionary,  cause there is not enough dictionary size on the planet,  for a decent chat bot,   theres got to be some way of increasing the patterns you have.

In other words, the same m-vector should be realizable through different structures. I think it fits with my idea of a formula, where several "math" expressions can be equivalent.

Actually, your algorithm is simply conveying whether your terms are elements of a sentence, not the notion of what the word represents and how actions can be executed or applied to the concept(s) of what the word represents.
Title: Re: Speech acts with trees of word-vectors
Post by: Zero on August 23, 2021, 04:35:02 pm
Quote
Actually, your algorithm is simply conveying whether your terms are elements of a sentence,

Actually it's not even conveying that, since it's not connected to anything "outside". But you already know it.