This commit is contained in:
austin 2024-12-28 22:45:59 -05:00
parent ef66c21cad
commit bcf40e1334
10 changed files with 183 additions and 1 deletions

View File

View File

View File

@ -0,0 +1,5 @@
Greeting function misinterpretation
Misinterpreting a greeting sentence as an information-querying sentence is an acceptable mistake.
Lots of people make it when greeted with "How are ya?"

View File

@ -0,0 +1,10 @@
A list of things to consider fleshing out in the web
Qualia

View File

@ -0,0 +1,22 @@
Arguments justifying different features
Information Priority
Pieces of information have different priorities and should be handled accordingly.
Keep a 'hot' web of the most important parts of info that should immediately be searchable every frame.
This can link into 'colder' webs that store lower priority information.
Will have this with both relations and nodes in the web.
To justify for nodes, some people in your life are of higher importance than others to remember.
You don't keep all people you know immediately accessible in your brain.
To justify for relations, relations between specific numbers are thrown out almost immediately when done solving a math problem.
Layered webs
If you have a conversation about the color of a hat, you will not store the color of the hat in your immediately accessible brain long term.
This lets you not constantly scan a huge repertoire of information when you want to perform day-to-day tasks.
Thus, I want to create an information heirarchy to mimic this and make engineering potentially easier.

6
docs/mantas.txt Normal file
View File

@ -0,0 +1,6 @@
1. keep it simple, stupid
2. make everything easily debug-able
3. work on a single sentence at a time

View File

@ -1 +1,11 @@
summarize previous statements to provide context instead of using full statement
summarize previous statements to provide context instead of using full statement
Come up with strategies for culling the number of connections in the knowledge web
- Particularly, connections used during immediate processing
- don't need to keep track of the color of the paper that a sentence you're going to forget about is written on
- Assign value weight to different nodes in web and use that to periodically clean web (?)
Layered webs
- Have more fine grained processing data get pushed into a lower priority web that is not immediately searched all the time
- ie low value detail relations, like colors or other qualities of objects, relations between people, etc

View File

@ -0,0 +1,20 @@
package org.studiorailgun.conversation.evaluators;
/**
* Evaluates a greeting
*/
public class GreetingEval {
/**
* Evaluates a greeting
* @param input The sentence
*/
public static void evaluate(String input){
switch(input){
case "Hello": {
} break;
}
}
}

View File

@ -36,6 +36,10 @@ public class SentenceSubjectParser {
// System.out.println(model.functions().get(0).signature().getInputs().values().iterator().next().shape);
}
/**
* Evaluates a sentence
* @param sentence The sentence to evaluate
*/
public void evaluate(String sentence){
//run predict
TInt64 tensor = TInt64.scalarOf(10);

View File

@ -0,0 +1,105 @@
import tensorflow as tf
keras = tf.keras
from tensorflow import Tensor
from keras.api.layers import TextVectorization, Embedding, LSTM, Dense, Input
from keras.api.models import Sequential
import numpy as np
import numpy.typing as npt
#
#
# Description: The purpose of this model is to qualify sentences into different 'functions'
#
# - "Utility" - A sentence whose purpose is to perform some non-informational duty in a conversation.
# An example of this could be a greeting or farewell.
#
# - "Transfer" - Transfers a piece of information to another participant. For instance, describing
# the details of an object.
#
# - "Query" - Queries a piece of information from another participant.
#
# - "Imperative" - Commands a participant to do something.
#
# Model constants.
max_features: int = 20000
embedding_dim: int = 128
sequence_length: int = 500
epochs: int = 50
max_tokens: int = 5000
output_sequence_length: int = 4
# read sentences
data_path: str = './data/semantic/subject.txt'
data_raw: str = open(data_path).read()
vocab: list[str] = data_raw.split('\n')
# read labels
label_data_path: str = './data/semantic/subject_label.txt'
label_data_raw: str = open(label_data_path).read()
labels: list[int] = list(map(int,label_data_raw.split()))
# init vectorizer
textVec: TextVectorization = TextVectorization(
max_tokens=max_tokens,
output_mode='int',
output_sequence_length=output_sequence_length,
pad_to_max_tokens=True)
# Add the vocab to the tokenizer
textVec.adapt(vocab)
input_data: list[str] = vocab
data: Tensor = textVec.call(input_data)
# construct model
model: Sequential = Sequential([
keras.Input(shape=(None,), dtype="int64"),
Embedding(max_features + 1, embedding_dim),
LSTM(64),
Dense(1, activation='sigmoid')
])
#compile the model
# model.build(keras.Input(shape=(None,), dtype="int64"))
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
# fit the training data
npData = np.array(data)
npLabel = np.array(labels)
model.fit(npData,npLabel,epochs=epochs)
# evaluate here
# predict
predictTargetRaw: list[str] = ['saf']
predictTargetToken: list[int] = textVec.call(predictTargetRaw)
npPredict: npt.NDArray[np.complex64] = np.array(predictTargetToken)
# print(npPredict)
result: list[int] = model.predict(npPredict)
print("predict result:")
print(predictTargetToken)
print(result)
print(data)
print(labels)
# save the model so keras can reload
# savePath: str = './data/semantic/model.keras'
# model.save(savePath)
# export the model so java can leverage it
exportPath: str = './data/semantic/model'
model.export(exportPath)
# tf.keras.utils.get_file('asdf')
# asdf: str = 'a'