That guy is a goat. That video is very long it took me like 3 days to watch.
Concerning chatbot some new efficient methods that have reduce the size of LLM that have proposed learning predicting multiple tokens at once instead of single tokens such as capturing the next 2 words as demonstrated above in the for loop indexing words to
function cm.TrainLargeModel(strings,model)
--local model={}
for i, str in ipairs(strings) do -- loop through the strings in the table
local words=cm.splitString(str)
for t,wo in ipairs(words) do
local prevw,nextw
if wo~="I" then
wo=wo:lower()
end
local s=cm.Getsynonyms(wo,true)
--print(s[1])
if model[s[1]]==nil then
model[s[1]]={}
model[s[1]]["fr"]=1
model[s[1]]["pw"]={}
model[s[1]]["nw"]={}
model[s[1]]["p2w"]={}
model[s[1]]["n2w"]={}
-- print(model[s[1]])
end
model[s[1]].fr=model[s[1]].fr+1
if t~=1 then
local prev=cm.Getsynonyms(words[t-1],true)
prevw=prev[1]
if model[s[1]].pw[prevw]==nil and prevw then
-- model[s[1]].pw[prevw]=
model[s[1]].pw[prevw]=1
else model[s[1]].pw[prevw]=model[s[1]].pw[prevw]+1
end
end
if t>2 then
local prev=cm.Getsynonyms(words[t-2],true)
prevw=prev[1]
if model[s[1]].p2w[prevw]==nil and prevw then
-- model[s[1]].pw[prevw]=
model[s[1]].p2w[prevw]=1
else model[s[1]].p2w[prevw]=model[s[1]].p2w[prevw]+1
end
end
if t<#words-1 then
local nex=cm.Getsynonyms(words[t+2],true)
nextw=nex[1]
if model[s[1]].n2w[nextw]==nil then model[s[1]].n2w[nextw]=1
else model[s[1]].n2w[nextw]=model[s[1]].n2w[nextw]+1
end
end
if t~=#words then
local nex=cm.Getsynonyms(words[t+1],true)
nextw=nex[1]
if model[s[1]].nw[nextw]==nil then model[s[1]].nw[nextw]=1
else model[s[1]].nw[nextw]=model[s[1]].nw[nextw]+1
end
end
end
end
--print(model)
--table.sort(model, function(a, b) return a.fr > b.fr end)
return model
end
Another thing to note is their position in the sentence this increases the complexity and determines your context length. Typical methods train models on structured data like “<|system|> You are a chatbot, the user is asking about France, the capital is Paris. /n<|user|>\n What is the capital of France? \n<|assistant|>\n The capital of France is Paris.”
Then when you input queries to the model you replace the system message and perform next token prediction using your weights using some randomness (temperature), accumulated probability top_n, and top_p (only tokens with this probability are considered).
function cm.PredictRun2(strings,model)--strings are test inputs to predict every next two words. could be used for training a different layer--language can be compressed to a vector database
local responses={}
for i, str in ipairs(strings) do -- loop through the strings in the table
local words=cm.splitString(str)
local eo=0
local news=""
local prevc=str
local hci=0
local tnwo=nil
for t,wo in ipairs(words) do
local cap=false
--if cm.iscapitalized(wo)==true then
-- cap=true
--end
local prevw="$"
local nextw="$"
eo=eo+1
if t>=1 then
if eo>=3 then eo=0
if wo~="I" then
wo=wo:lower()
end
local s=cm.Getsynonyms(wo,true)
--model[s[1]].fr=model[s[1]].fr+1
if model[s[1]] then
local tn2w=nil
local tnw=nil
if t~=#words then
--local hc=0
--=words[i+1]
local hc=0
for c,t in model[s[1]].nw do
if c~="I" then
c=string.lower(c)
end
---local we =model[c].fr/8
local sol=t
if sol>hc and hc>hci then
hc=sol
tnw=tostring(c)
elseif hci>hc then
hc=hci
tnw=tnwo
end
end
hci=0
local hc=0
--=words[i+1]
if t<#words-1 then
for c,t in model[s[1]].n2w do
if c~="I" then
c=string.lower(c)
end
local we =model[c].fr/8
local sol=t
if sol>hc then
hc=sol
tn2w=tostring(c)
end
end
else
--tnw=words[#words]
end
end
--if t~=#words then
local hc=0
local lw=words[i-1]
local roll=cm.mathrandom(1,#model[s[1]].pw)
local i=0
for c,t in model[s[1]].pw do
i=i+1
if i==roll then --print(c)
if c~="I" then
c=string.lower(c)
end
--local we =model[c].fr/2
local sol=t
if sol>hc then
hc=sol
lw=tostring(c)
end
end
end
local l2w=nil
if i>=3 then l2w=words[i-2]
local roll=cm.mathrandom(1,#model[s[1]].p2w)
local i=0
for c,t in model[s[1]].p2w do
i=i+1
if i==roll then
--print(c)
if c~="I" then
c=string.lower(c)
end
--local we =model[c].fr/2
--local sol=t
--if sol>hc then
-- hc=sol
l2w=tostring(c)
--end
end
end
end
if l2w and l2w:lower()~=prevc:lower() then
news=news.." "..l2w
--elseif i>2 then
--news=news.." "..words[i-2]
end
if lw and lw:lower()~=prevc:lower() then
news=news.." "..lw
prevc=lw
elseif t~=1 then
news=news.." "..words[i-1]
end
if tnw and prevc:lower()~=tnw:lower() then
news=news.." "..s[1].." "..tnw
prevc=tnw
elseif i<#words then
news=news.." "..s[1].." "..words[i+1]
end
if tn2w and prevc:lower()~=tn2w:lower() then
news=news.." "..tn2w
prevc=tn2w
--elseif #words<i+2 then
-- news=news.." "..words[i+2]
end
prevc=s[1]
--table.insert()
--table.sort(model, function(a, b) return a.fr > b.fr end)
else
--news=news.." "..wo
end
else
local s=cm.Getsynonyms(wo,true)
local tnw=nil
if model[s] then
for c,t in model[s[1]].nw do
if c~="I" then
c=string.lower(c)
end
---local we =model[c].fr/8
local sol=t
if sol>hci then
hci=sol
tnwo=tostring(c)
end
end
end
--news=news.." "..wo
end
else news=news.." "..wo prevc=wo
end
end
table.insert(responses,news)
end
print(responses)
end
In this example it’s very simple and not doing too much math just sampling random tokens and inserting them into the input string as a test. That’s about where I left on that side project. Currently very busy working on a MMORPG with en-masse chatbot agents. On a side note, I have released a template model place of parralel chatbot agents, each with their own context window. The open-sourced code I published a couple days ago is something I threw together using the public modules I created. It’s very clean and neat. Took only a few hours to get up an running.
It uses the Awareness module, emojis, emotes, and a small bit of augmented generation, powered by a 7b parameter model on huggingface. It is designed to be simple and customizable check it out if you’re interested! [FREE] Mistral 7b AI Chatbot Agent: Simple to Use! Aware, Infinite Agents, 2000+ Emojis, 100+ Emotes, Memories , Wiki, 32k Context [Open Sourced]
This Chatbot module I still use for Advanced RAG. It now has a context network, where accumulated weights of the context are normalized, added and divided by 2 each step to get a curve where the earliest context has shrinking influence to score a databased response. It works well as a chatbot because it has about 14 nodes that specialize in different things. (MOE technique) These are manually connected to nodes that provide related content, and optimized to disconnect other nodes that are determined to be irrelevant given another context’s score passed the probability threshold, given the input and previous nodes input (Optimized to 1/6 of the input influence). To connect ideas and strengthen current context strength. The responses are stored in a table, organized by highest to low probability and concatenated as a response while dropping responses that are below the averaged scored of all responses.
local neur={}
local neu=require(script.VectorMath)
local ContextBias = {
["sam"]=function(a) return (a.X) end,
["smollos"]=function(a) return (a.X-((a.Y/2)*a.Z)) end,
["los"]=function(a) return (a.X-(a.Y-3*a.Z)) end,
["suplos"]=function(a) return (a.X-(a.Y*a.Z)) end,
["gan"]=function(a) return (a.X+(a.Y*a.Z)) end,
["supgan"]=function(a) return (a.X+((a.Y*a.Z)*2)) end,
["smolgan"]=function(a) return (a.X+(a.Y/2*a.Z)) end,
["div"]=function(a) return (a.X/(a.Y*a.Z)) end,
["mul"]=function(a) return (a.X*(a.Y*a.Z)) end,
}
local cwm
local lib=game.ReplicatedStorage.GlobalSpells.ChatbotAlgorithm
local sup2=lib.SupportingData
local sup=nil
local RunService = game:GetService("RunService")
local isLocal = RunService:IsClient()
local bind
if isLocal then
bind=game.ReplicatedFirst.ContextDBCaller.SS2.Event
--bind=game.Players.LocalPlayer.PlayerGui.Chatbot.LocalProcessor
else
bind=game.ReplicatedStorage.GlobalSpells.BindableFunction
end
--local bind=game.ReplicatedFirst.ContextDBCaller.SS2.Event
function neur.matrix(x,y,z,optionalparameters)
return neu.matrix(x,y,z,optionalparameters) end
function neur.ConvalutedContextClassificationModel()
local contextmodel = {
--context weight matrix Y,Z are calculated and influence X position.
["Greetings"] = {
["weights"] = neu.matrix(10, 1, 1),
--10 table 10 numbers ez
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Awareness"] = neu.matrix(8, 1, 1),
["Empathy"] = neu.matrix(7, 1, 1),
-- ["Search"]=neu.matrix(5,1,.9),
["Classify"] = neu.matrix(6, 1, 1),
["Support"] = neu.matrix(2, 1, .8),
["Database"] = neu.matrix(3, 1, 1),
["Greetings"]=neu.matrix(3,1,1),
["Wisdom"] = neu.matrix(4, 1, 1)
--["Math"]=neu.matrix(0,1,1),
-- ["Philosophy"]=neu.matrix(1,1,1),
--["Search"]=neu.matrix(1,1,1),
--search accuracy
},
["cone"] = {
-- ["Emotions"] = neu.matrix(9, 1, 1),
--["Support"] = neu.matrix(2, 1, .8),
--["Empathy"]=neu.matrix(9,1,1),
--["Awareness"]=neu.matrix(8,1,1),
["Classify"] = neu.matrix(6, 1, 1),
--["Database"] = neu.matrix(6, 1, 1),
--["Database"] = neu.matrix(6, 1, 1),
},
["disconnect"] = {
-- "Therapist
"ScienceWisdom","Database","Wisdom","Support","Empathy",--"Awareness"
},
["parameters"] = {
filter=true,
complete=true,
randomize=true
},
["entropy"] = ContextBias["gan"]
--decrease weight of go on to other topics.
},
["Determinant"] = {
["weights"] = neu.matrix(8, 1, 1),
--10 table 10 numbers ez
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Awareness"] = neu.matrix(8, 1, 1),
["Empathy"] = neu.matrix(7, 1, 1),
-- ["Search"]=neu.matrix(5,1,.9),
["Classify"] = neu.matrix(6, 1, 1),
["Support"] = neu.matrix(2, 1, .8),
["Database"] = neu.matrix(3, 1, 1),
["Greetings"]=neu.matrix(3,1,1),
["Wisdom"] = neu.matrix(4, 1, 1)
--["Math"]=neu.matrix(0,1,1),
-- ["Philosophy"]=neu.matrix(1,1,1),
--["Search"]=neu.matrix(1,1,1),
--search accuracy
},
["cone"] = {
-- ["Emotions"] = neu.matrix(9, 1, 1),
--["Support"] = neu.matrix(2, 1, .8),
--["Empathy"]=neu.matrix(9,1,1),
--["Awareness"]=neu.matrix(8,1,1),
-- ["Classify"] = neu.matrix(6, 1, 1),
--["Database"] = neu.matrix(6, 1, 1),
--["Database"] = neu.matrix(6, 1, 1),
},
["disconnect"] = {
--"Therapist,
"ScienceWisdom","Database","Wisdom","Support","Empathy","Awareness","Greetings","Love",
},
["parameters"] = {
filter=true,
complete=true,
randomize=true
},
["entropy"] = ContextBias["gan"]
--decrease weight of go on to other topics.
},
["Commands"] = {
["weights"] = neu.matrix(10, 1, 1),
--10 table 10 numbers ez
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Awareness"] = neu.matrix(8, 1, 1),
},
["cone"] = {
-- ["Emotions"] = neu.matrix(9, 1, 1),
--["Support"] = neu.matrix(2, 1, .8),
--["Empathy"]=neu.matrix(9,1,1),
--["Awareness"]=neu.matrix(8,1,1),
["Classify"] = neu.matrix(6, 1, 1),
--["Database"] = neu.matrix(6, 1, 1),
--["Database"] = neu.matrix(6, 1, 1),
},
["disconnect"] = {
-- "Therapist
-- "ScienceWisdom",
--"Database","Wisdom","Support","Empathy",--"Awareness"
},
["parameters"] = {
filter=true,
complete=true,
randomize=true
},
["entropy"] = ContextBias["gan"]
--decrease weight of go on to other topics.
},
["Personal"] = {
["weights"] = neu.matrix(8, 1, 1),
--10 table 10 numbers ez
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Awareness"] = neu.matrix(8, 1, 1),
["Empathy"] = neu.matrix(7, 1, 1),
-- ["Search"]=neu.matrix(5,1,.9),
["Classify"] = neu.matrix(6, 1, 1),
["Support"] = neu.matrix(2, 1, .8),
["Database"] = neu.matrix(3, 1, 1),
["Greetings"]=neu.matrix(3,1,1),
["Wisdom"] = neu.matrix(4, 1, 1)
--["Math"]=neu.matrix(0,1,1),
-- ["Philosophy"]=neu.matrix(1,1,1),
--["Search"]=neu.matrix(1,1,1),
--search accuracy
},
["cone"] = {
-- ["Emotions"] = neu.matrix(9, 1, 1),
--["Support"] = neu.matrix(2, 1, .8),
--["Empathy"]=neu.matrix(9,1,1),
--["Awareness"]=neu.matrix(8,1,1),
["Classify"] = neu.matrix(6, 1, 1),
--["Database"] = neu.matrix(6, 1, 1),
--["Database"] = neu.matrix(6, 1, 1),
},
["disconnect"] = {
-- "Therapist
"ScienceWisdom","Database","Wisdom","Support","Empathy",--"Awareness"
},
["parameters"] = {
filter=true,
complete=true,
randomize=true
},
["entropy"] = ContextBias["gan"]
--decrease weight of go on to other topics.
},
["Love"] = {
["weights"] = neu.matrix(8, 1, 1),
--10 table 10 numbers ez
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Awareness"] = neu.matrix(8, 1, 1),
["Empathy"] = neu.matrix(7, 1, 1),
-- ["Search"]=neu.matrix(5,1,.9),
["Classify"] = neu.matrix(6, 1, 1),
["Support"] = neu.matrix(2, 1, .8),
["Database"] = neu.matrix(3, 1, 1),
["Greetings"]=neu.matrix(3,1,1),
["Wisdom"] = neu.matrix(4, 1, 1)
--["Math"]=neu.matrix(0,1,1),
-- ["Philosophy"]=neu.matrix(1,1,1),
--["Search"]=neu.matrix(1,1,1),
--search accuracy
},
["cone"] = {
-- ["Emotions"] = neu.matrix(9, 1, 1),
--["Support"] = neu.matrix(2, 1, .8),
--["Empathy"]=neu.matrix(9,1,1),
--["Awareness"]=neu.matrix(8,1,1),
["Classify"] = neu.matrix(6, 1, 1),
--["Database"] = neu.matrix(6, 1, 1),
--["Database"] = neu.matrix(6, 1, 1),
},
["disconnect"] = {
-- "Therapist
"ScienceWisdom","Database","Wisdom","Support","Empathy",--"Awareness"
},
["parameters"] = {
filter=true,
complete=true,
randomize=true
},
["entropy"] = ContextBias["gan"]
--decrease weight of go on to other topics.
},
["Music"] = {
["weights"] = neu.matrix(2, 1, 1),
--10 table 10 numbers ez
["chain"] = {
},
["cone"] = {
},
["disconnect"] = {
"Therapist",
--"ScienceWisdom","Database","Wisdom","Support","Empathy",--"Awareness"
},
["parameters"] = {
filter=true,
complete=true,
randomize=true
},
["entropy"] = ContextBias["gan"]
--decrease weight of go on to other topics.
},
["Judgement"] = {
["weights"] = neu.matrix(5, 1, 1),
--10 table 10 numbers ez
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Awareness"] = neu.matrix(8, 1, 1),
["Empathy"] = neu.matrix(7, 1, 1),
-- ["Search"]=neu.matrix(5,1,.9),
["Classify"] = neu.matrix(6, 1, 1),
["Support"] = neu.matrix(2, 1, .8),
["Database"] = neu.matrix(3, 1, 1),
["Greetings"]=neu.matrix(3,1,1),
["Wisdom"] = neu.matrix(4, 1, 1)
},
["cone"] = {
["Classify"] = neu.matrix(6, 1, 1),
},
["disconnect"] = {
-- "Therapist
-- "ScienceWisdom","Database","Wisdom","Support","Empathy",--"Awareness"
},
["parameters"] = {
filter=true,
complete=true,
randomize=true
},
["entropy"] = ContextBias["gan"]
--decrease weight of go on to other topics.
},
["Emotions"] = {
["weights"] = neu.matrix(9, 1, 1),
["chain"] = {
--["Emotions"]=neu.matrix(9,1,1),
["Greetings"] = neu.matrix(5, 1, 1),
--["Math"]=neu.matrix(0,1,1),
["Awareness"] = neu.matrix(8, 1, 1),
["Empathy"] = neu.matrix(10, 1, 1),
--["Search"]=neu.matrix(4,1,.9),
["Classify"] = neu.matrix(7, 1, 1),
["Support"] = neu.matrix(3, 1, .8),
["Database"] = neu.matrix(6, 1, 1),
["Bestiary"] = neu.matrix(5, 1, 1),
["Wisdom"] = neu.matrix(4, 1, 1),
["Philosophy"] = neu.matrix(2, 1, 1)
},
["cone"] = {
--["Empathy"]=neu.matrix(9,1,1),
["Wisdom"] = neu.matrix(8, 1, 1)
--["Wisdom"]=neu.matrix(8,1,1),
},
["disconnect"] = {
"ScienceWisdom","Empathy","Database",--"Awareness"
},
["parameters"] = {
filter=true,
complete=true,
randomize=true
},
["entropy"] = ContextBias["smolgan"]
},
["Empathy"] = {
["weights"] = neu.matrix(7, 1, 1),
["chain"] = {
["Philosophy"] = neu.matrix(10, 1, 1),
--["Math"]=neu.matrix(0,1,1),
["Wisdom"] = neu.matrix(9, 1, 1),
["Bestiary"] = neu.matrix(8, 1, 1),
["Classify"] = neu.matrix(3, 1, 1),
["Emotions"] = neu.matrix(1, 1, 1),
["Database"] = neu.matrix(6, 1, 1),
--["Search"]=neu.matrix(7,1,.9),
["Awareness"] = neu.matrix(6, 1, 1),
["Greetings"] = neu.matrix(2, 1, 1),
["Support"] = neu.matrix(5, 1, .8)
},
--["Empathy"]=neu.matrix(,1,1),
["entropy"] = ContextBias["gan"],
["cone"] = {
["Wisdom"] = neu.matrix(9, 1, 1)
},
["disconnect"] = {
"ScienceWisdom","Database",--"Awareness"
},
["parameters"] = {
filter=false,
complete=true,
randomize=true
},
},
["Therapist"] = {
["weights"] = neu.matrix(8, 1, 1),
["chain"] = {
["Philosophy"] = neu.matrix(10, 1, 1),
--["Math"]=neu.matrix(0,1,1),
["Wisdom"] = neu.matrix(9, 1, 1),
["Bestiary"] = neu.matrix(8, 1, 1),
["Classify"] = neu.matrix(3, 1, 1),
["Emotions"] = neu.matrix(1, 1, 1),
["Database"] = neu.matrix(6, 1, 1),
--["Search"]=neu.matrix(7,1,.9),
["Awareness"] = neu.matrix(6, 1, 1),
["Greetings"] = neu.matrix(2, 1, 1),
["Support"] = neu.matrix(5, 1, .8)
},
--["Empathy"]=neu.matrix(,1,1),
["entropy"] = ContextBias["gan"],
["cone"] = {
--["Wisdom"] = neu.matrix(9, 1, 1)
},
["disconnect"] = {
--"Greetings"
},
["parameters"] = {
filter=true,
complete=true,
randomize=false
},
},
["Support"] = {
["weights"] = neu.matrix(2, 1, 1),
--subneuron only
["chain"] = {
["Emotions"] = neu.matrix(3, 1, 1),
--["Math"] = neu.matrix(2, 1, 1),
["Greetings"] = neu.matrix(1, 1, 1),
["Awareness"] = neu.matrix(6, 1, 1),
["Empathy"] = neu.matrix(4, 1, 1),
["Search"] = neu.matrix(2, 1, .9),
["Classify"] = neu.matrix(3, 1, 1),
--["Support"]=neu.matrix(,1,.8),
["Database"] = neu.matrix(8, 1, 1),
["Bestiary"] = neu.matrix(9, 1, 1),
["Wisdom"] = neu.matrix(6, 1, 1),
["Philosophy"] = neu.matrix(3, 1, 1)
},
["cone"] = {
["Motivation"] = neu.matrix(4, 1, .8),
["Wisdom"] = neu.matrix(3, 1, .8),
["Truths"] = neu.matrix(6, 1, .8)
},
["disconnect"] = {
"ScienceWisdom","Inspiration","Database","Wisdom",
},
["parameters"] = {
filter=false,
complete=true,
randomize=false
},
["entropy"] = ContextBias["los"]
},
["Wisdom"] = {
["weights"] = neu.matrix(3, 1, 1),
["chain"] = {
["Emotions"] = neu.matrix(4, 1, 1),
-- ["Math"] = neu.matrix(2, 1, 1),
["Greetings"] = neu.matrix(4, 1, 1),
["Awareness"] = neu.matrix(5, 1, 1),
["Empathy"] = neu.matrix(7, 1, 1),
["Search"] = neu.matrix(3, 1, .9),
["Classify"] = neu.matrix(1, 1, 1),
["Support"] = neu.matrix(5, 1, .8),
["Database"] = neu.matrix(8, 1, 1),
["Bestiary"] = neu.matrix(9, 1, 1),
--["Wisdom"]=neu.matrix(4,1,1),
["Philosophy"] = neu.matrix(10, 1, 1)
},
["cone"] = {
["Support"] = neu.matrix(5, 1, .8)
},
["entropy"] = ContextBias["smolgan"],
["disconnect"] = {
"Inspiration","Truths","Spirituality","Motivation","ScienceWisdom","Database"
},
["parameters"] = {
filter=true,
complete=true,
randomize=false
},
},
["Philosophy"] = {
["weights"] = neu.matrix(2, 1, 1),
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Greetings"] = neu.matrix(4, 1, 1),
["Awareness"] = neu.matrix(5, 1, 1),
["Empathy"] = neu.matrix(7, 1, 1),
["Classify"] = neu.matrix(1, 1, 1),
["Support"] = neu.matrix(6, 1, .8),
["Database"] = neu.matrix(8, 1, 1),
["Bestiary"] = neu.matrix(9, 1, 1),
["Wisdom"] = neu.matrix(10, 1, 1)
},
["cone"] = {
["Motivation"] = neu.matrix(4, 1, .8),
["Wisdom"] = neu.matrix(3, 1, .8),
["Truths"] = neu.matrix(6, 1, .8)
},
["disconnect"] = {
"Database"
},
["entropy"] = ContextBias["gan"],
["parameters"] = {
filter=true,
complete=true,
randomize=false
},
},
["Bestiary"] = {
["weights"] = neu.matrix(3, 1, 1),
["cone"] = {},
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
--["Math"] = neu.matrix(2, 1, 1),
["Greetings"] = neu.matrix(4, 1, 1),
["Awareness"] = neu.matrix(9, 1, 1),
["Empathy"] = neu.matrix(7, 1, 1),
--["Search"]=neu.matrix(6,1,.9),
["Classify"] = neu.matrix(5, 1, 1),
["Support"] = neu.matrix(1, 1, .8),
["Database"] = neu.matrix(10, 1, 1),
-- ["Bestiary"]=neu.matrix(3,1,1),
["Wisdom"] = neu.matrix(2, 1, 1),
["Philosophy"] = neu.matrix(1, 1, 1)
},
["disconnect"] = {
"Search","Sciencewisdom","Emotions","Greetings",
"Inspiration","Truths","Spirituality","Motivation","Philosophy",
},
["parameters"] = {
filter=true,
complete=false,
randomize=false
},
["entropy"] = ContextBias["gan"]
},
["Search"] = {
["weights"] = neu.matrix(2, 1, 1),
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
-- ["Math"] = neu.matrix(0, 1, 1),
["Greetings"] = neu.matrix(1, 1, 1),
["Awareness"] = neu.matrix(4, 1, 1),
["Empathy"] = neu.matrix(2, 1, 1),
--["Search"]=neu.matrix(4,1,.9),
["Classify"] = neu.matrix(7, 1, 1),
["Support"] = neu.matrix(5, 1, .8),
["Database"] = neu.matrix(7, 1, 1),
["Bestiary"] = neu.matrix(5, 1, 1),
["Wisdom"] = neu.matrix(7, 1, 1),
["Philosophy"] = neu.matrix(6, 1, 1)
},
["cone"] = {},
["entropy"] = ContextBias["gan"],
["disconnect"] = {
"Inspiration","Truths","Spirituality","Motivation","ScienceWisdom","Database","Wisdom","Support"
,"Philosophy","Bestiary"
},
},
["Database"] = {
["weights"] = neu.matrix(3, 1, 1),
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Math"] = neu.matrix(0, 1, 1),
["Greetings"] = neu.matrix(1, 1, 1),
["Awareness"] = neu.matrix(4, 1, 1),
["Empathy"] = neu.matrix(2, 1, 1),
["Search"] = neu.matrix(4, 1, .9),
["Classify"] = neu.matrix(7, 1, 1),
["Support"] = neu.matrix(5, 1, .8),
["Database"] = neu.matrix(2, 1, 1),
["Bestiary"] = neu.matrix(5, 1, 1),
["Wisdom"] = neu.matrix(7, 1, 1),
["Philosophy"] = neu.matrix(6, 1, 1)
},
["cone"] = {
["Support"] = neu.matrix(5, 1, .8)
},
["entropy"] = ContextBias["suplos"],
["disconnect"] = {
"ScienceWisdom"
,"Philosophy","Empathy","Support",
"Inspiration","Truths","Spirituality","Motivation",
},
["parameters"] = {
filter=true,
complete=false,
randomize=false
},
},
["Awareness"] = {
["weights"] = neu.matrix(5, 1, 1),
["cone"] = {
["Bestiary"] = neu.matrix(5, 1, 1)
},
--["Wisdom"]=neu.matrix(7,1,1),},
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Greetings"] = neu.matrix(7, 1, 1),
["Awareness"] = neu.matrix(4, 1, 1),
["Empathy"] = neu.matrix(2, 1, 1),
["Classify"] = neu.matrix(7, 1, 1),
["Support"] = neu.matrix(5, 1, .8),
["Database"] = neu.matrix(7, 1, 1),
["Bestiary"] = neu.matrix(5.5, 1, 1),
["Wisdom"] = neu.matrix(6.5, 1, 1),
["Philosophy"] = neu.matrix(6, 1, 1)
},
["parameters"] = {
filter=true,
complete=true,
randomize=false
},
["entropy"] = ContextBias["gan"]
},
["Math"] = {
["weights"] = neu.matrix(4, 1, 1),
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Greetings"] = neu.matrix(5, 1, 1), --["Math"]=neu.matrix(0,1,1),
["Awareness"] = neu.matrix(4, 1, 1),
["Empathy"] = neu.matrix(5, 1, 1),
["Search"] = neu.matrix(3, 1, .9),
["Classify"] = neu.matrix(6, 1, 1),
["Support"] = neu.matrix(7, 1, .8),
["Database"] = neu.matrix(1, 1, 1),
["Bestiary"] = neu.matrix(2, 1, 1),
["Wisdom"] = neu.matrix(4, 1, 1),
["Philosophy"] = neu.matrix(3, 1, 1)
}, --["Math"]=neu.matrix(0,1,1),
["cone"] = {},
["entropy"] = ContextBias["supgan"],
["disconnect"] = {
"Inspiration","Truths","Spirituality","Motivation","ScienceWisdom","Database","Wisdom"
,"Philosophy","Bestiary","Emotions","Empathy"
},
},
["Inspiration"] = {
["weights"] = neu.matrix(9, 1, 1),
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Math"] = neu.matrix(0, 1, 1),
["Greetings"] = neu.matrix(1, 1, 1),
["Awareness"] = neu.matrix(4, 1, 1),
["Empathy"] = neu.matrix(2, 1, 1),
["Search"] = neu.matrix(4, 1, .9),
["Classify"] = neu.matrix(7, 1, 1),
["Support"] = neu.matrix(5, 1, .8),
["Database"] = neu.matrix(7, 1, 1),
["Bestiary"] = neu.matrix(5, 1, 1),
["Wisdom"] = neu.matrix(7, 1, 1),
["Philosophy"] = neu.matrix(6, 1, 1)
},
["cone"] = {
["Greetings"] = neu.matrix(1, 1, 1),
["Classify"] = neu.matrix(7, 1, 1),
["Wisdom"] = neu.matrix(4, 1, 1)
},
["entropy"] = ContextBias["smolgan"],
["disconnect"] = {
"ScienceWisdom","Database"
,"Bestiary",
},
["query"] = function(str,_,filter, repetitive,randomize,context,reverse,spaces,mode,synomarray,words2,tl)
-- First, we need to get the ReplicatedStorage service
if sup == nil then
sup = require(sup2)
end -- object with the given name
local Result, blacklist, score, weight =
bind:Invoke(
str,
sup.Inspiration(),
filter,
repetitive,
randomize,
context,
reverse,
spaces,
mode,
synomarray,
words2
)
--print(Result)
return Result, blacklist, score, weight
end
},
["ScienceWisdom"] = {
["weights"] = neu.matrix(5, 1, 1),
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Math"] = neu.matrix(0, 1, 1),
["Greetings"] = neu.matrix(1, 1, 1),
["Awareness"] = neu.matrix(4, 1, 1),
["Empathy"] = neu.matrix(2, 1, 1),
["Search"] = neu.matrix(4, 1, .9),
["Classify"] = neu.matrix(7, 1, 1),
["Support"] = neu.matrix(5, 1, .8),
["Database"] = neu.matrix(7, 1, 1),
["Bestiary"] = neu.matrix(5, 1, 1),
["Wisdom"] = neu.matrix(7, 1, 1),
["Philosophy"] = neu.matrix(6, 1, 1)
},
["cone"] = {
["Support"] = neu.matrix(5, 1, .8)
},
["disconnect"] = {
"Spirituality","Wisdom","Bestiary","Empathy",--"Awareness"
},
["entropy"] = ContextBias["gan"],
["query"] = function(str,_,filter, repetitive,randomize,context,reverse,spaces,mode,synomarray,words2,tl)
-- First, we need to get the ReplicatedStorage service
if sup == nil then
sup = require(sup2)
end -- object with the given name
local Result, blacklist, score, weight =
bind:Invoke(
str,
sup.ScienceWisdom(),
filter,
repetitive,
randomize,
context,
reverse,
spaces,
mode,
synomarray,
words2
)
print(Result)
return Result, blacklist, score, weight
end
},
["Motivation"] = {
["weights"] = neu.matrix(3, 1, 1),
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Math"] = neu.matrix(0, 1, 1),
["Greetings"] = neu.matrix(1, 1, 1),
["Awareness"] = neu.matrix(4, 1, 1),
["Empathy"] = neu.matrix(2, 1, 1),
["Search"] = neu.matrix(4, 1, .9),
["Classify"] = neu.matrix(7, 1, 1),
["Support"] = neu.matrix(5, 1, .8),
["Database"] = neu.matrix(7, 1, 1),
["Bestiary"] = neu.matrix(5, 1, 1),
["Wisdom"] = neu.matrix(7, 1, 1),
["Philosophy"] = neu.matrix(6, 1, 1)
},
["cone"] = {
-- ["Motivation"] = neu.matrix(4, 1, .8),
["Wisdom"] = neu.matrix(3, 1, .8),
["Truths"] = neu.matrix(6, 1, .8),
-- ["Support"] = neu.matrix(5, 1, .8)
},
["disconnect"] = {
"ScienceWisdom","Search","Database"
},
["parameters"] = {
filter=true,
complete=true,
randomize=false
},
["entropy"] = ContextBias["smolgan"],
["query"] = function(
str,
_,
filter,
repetitive,
randomize,
context,
reverse,
spaces,
mode,
synomarray,
words2,
tl)
-- First, we need to get the ReplicatedStorage service
if sup == nil then
sup = require(sup2)
end -- object with the given name
local Result, blacklist, score, weight =
bind:Invoke(
str,
sup.Motivation(),
filter,
repetitive,
randomize,
context,
reverse,
spaces,
mode,
synomarray,
words2
)
-- print(Result)
return Result, blacklist, score, weight
end
},
["Truths"] = {
["weights"] = neu.matrix(3, 1, 1),
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Math"] = neu.matrix(0, 1, 1),
["Greetings"] = neu.matrix(1, 1, 1),
["Awareness"] = neu.matrix(4, 1, 1),
["Empathy"] = neu.matrix(2, 1, 1),
["Search"] = neu.matrix(4, 1, .9),
["Classify"] = neu.matrix(7, 1, 1),
["Support"] = neu.matrix(5, 1, .8),
["Database"] = neu.matrix(7, 1, 1),
["Bestiary"] = neu.matrix(5, 1, 1),
["Wisdom"] = neu.matrix(7, 1, 1),
["Philosophy"] = neu.matrix(6, 1, 1)
},
["cone"] = {
-- ["Motivation"] = neu.matrix(4, 1, .8),
["Wisdom"] = neu.matrix(3, 1, .8),
--["Truths"] = neu.matrix(6, 1, .8),
--["Support"] = neu.matrix(5, 1, .8)
},
["disconnect"] = {
"Bestiary","Database"
},
["parameters"] = {
filter=true,
complete=true,
randomize=false
},
["entropy"] = ContextBias["gan"],
["query"] = function(
str,
_,
filter,
repetitive,
randomize,
context,
reverse,
spaces,
mode,
synomarray,
words2,
tl)
-- First, we need to get the ReplicatedStorage service
if sup == nil then
sup = require(sup2)
end -- object with the given name
local Result, blacklist, score, weight =
bind:Invoke(
str,
sup.Truths(),
filter,
repetitive,
randomize,
context,
reverse,
spaces,
mode,
synomarray,
words2
)
print(Result)
return Result, blacklist, score, weight
end
},
["Spirituality"] = {
["weights"] = neu.matrix(3, 1, 1),
["chain"] = {
["Emotions"] = neu.matrix(9, 1, 1),
["Math"] = neu.matrix(0, 1, 1),
["Greetings"] = neu.matrix(1, 1, 1),
["Awareness"] = neu.matrix(4, 1, 1),
["Empathy"] = neu.matrix(2, 1, 1),
["Search"] = neu.matrix(4, 1, .9),
["Classify"] = neu.matrix(7, 1, 1),
["Support"] = neu.matrix(5, 1, .8),
["Database"] = neu.matrix(7, 1, 1),
["Bestiary"] = neu.matrix(5, 1, 1),
["Wisdom"] = neu.matrix(7, 1, 1),
["Philosophy"] = neu.matrix(6, 1, 1)
},
["cone"] = {
["Motivation"] = neu.matrix(4, 1, .8),
["Wisdom"] = neu.matrix(3, 1, .8),
["Truths"] = neu.matrix(6, 1, .8)
},
["disconnect"] = {
"ScienceWisdom","Database"
},
["parameters"] = {
filter=true,
complete=true,
randomize=false
},
["entropy"] = ContextBias["smolgan"],
["query"] = function(
str,
_,
filter,
repetitive,
randomize,
context,
reverse,
spaces,
mode,
synomarray,
words2,
tl)
-- First, we need to get the ReplicatedStorage service
if sup == nil then
sup = require(sup2)
end -- object with the given name
local Result, blacklist, score, weight =
bind:Invoke(
str,
sup.Spirituality(),
filter,
repetitive,
randomize,
context,
reverse,
spaces,
mode,
synomarray,
words2
)
print(Result)
return Result, blacklist, score, weight
end
}
}
return contextmodel
end
function sigmoid(x)
return 1 / (1 + math.exp(-x))
end
function neur.writevector(cwm,Key,X,Y,Z)--x is reptition, y is count,z weight
--if X==nil then X=0 end if Y==nil then Y=0 end if Z==nil then Z=0 end
local state
--neu.matrix(cwm[Key].x+X,cwm[Key].y+Y,cwm[Key].z+Z)
--local keyweight=cwm[Key]["weights"]
cwm[Key]["weights"].Y=Y
cwm[Key]["weights"].Z=Z
cwm[Key]["weights"].X=sigmoid(math.abs(cwm[Key]["entropy"](cwm[Key]["weights"])))
return cwm[Key]["weights"]
end
return neur
Finally it uses this function to transform the output based on the query, using the synonyms library.
function cm.randomizeStringLight(str,interphrases,randomize,once)
local newS = str
local s=str
local sentences = {}
if str then
local per=" "
if str:gmatch("[^%.]+") then
-- per=". "
for s in str:gmatch("[^%.]+") do
table.insert(sentences, s..".")
end
else
per=" "
sentences={str}
end
for i,v in sentences do
local str=sentences[i]
-- if phrase:lower():find(s:lower())==nil then
-- Pick a random phrase from the same group
for j, phrases in ipairs(interphrases) do
for k, phrase in ipairs(phrases) do
local pass=nil
if s:find(phrase) then
pass=true
elseif s:find(phrase:lower()) then
pass=false
elseif s:lower():find(phrase:lower()) then
pass=0
end
if pass~=nil then local randomPhrase,cap
-- local wordarray=cm.splitString(newS)
if randomize==nil then
randomPhrase = phrases[mathrandom(#phrases)]
elseif randomize=="query" then
-- print(once)
--query,database,filter,complete,words2,synomarray)
randomPhrase=cm.QueryDatabase(once,phrases,false,false)--,false,false,false,nil,nil)--,synomarray,filterwords,answer2)
-- print(randomPhrase)
if randomPhrase~=nil then
-- print("Got context phrase")
else randomPhrase = phrases[mathrandom(#phrases)]
end else
randomPhrase= phrases[randomize]
end
if pass==0 or false then randomPhrase=phrase:lower() end
newS = replace_str(newS, phrase, randomPhrase)
-- newS = newS:gsub(phrase, randomPhrase)
if once==true then break end
end
end
end
end
-- Define a function that takes three arguments: a string, a word to replace, and a replacement word
-- Define a function that takes three arguments: a string, a word to replace, and a replacement word
return newS
end
end
function cm.randomizeString(str,query)
local newS = str
if interchangephrases==nil then
interchangephrases=require(script.InterchangePhrases)
end
for j, phrases in (interchangephrases) do
for k, phrase in (phrases) do
--cm.GetInterchangephrases(s,complete)
if newS:lower():find(phrase:lower()) then
-- Pick a random phrase from the same group
-- local randomPhrase = phrases[mathrandom(#phrases)]
-- Replace the original phrase with the random one
--newS = newS:gsub(phrase, randomPhrase)
if query then
newS=cm.randomizeStringLight(str,{phrases},"query",query)
else
newS=cm.randomizeStringLight(str,{phrases})--,"query",query)
end
-- newS=replace_str(newS, phrase, randomPhrase)
-- newS=cm.randomizeStringLight(str,{phrases})
end
end
end
local wordarray=cm.splitString(newS)
for i, d in (wordarray) do
local phrases=cm.Getsynonyms(d,true)
if #phrases>1 then
for k, phrase in (phrases) do
-- print(phrases)
if newS:lower():find(phrase:lower()) then
-- Pick a random phrase from the same g
if query then
newS=cm.randomizeStringLight(str,{phrases},"query",query)
else
newS=cm.randomizeStringLight(str,{phrases})--,"query",query)
end
end
end
end
--newS=cm.randomizeStringLight(str,{phrases})
-- for k, phrase in (phrases) do
--if string.match(newS:lower(),"^"..phrase:lower().."$") then
-- --if cap==true then
-- -- Pick a random phrase from the same group
-- local randomPhrase = phrases[mathrandom(#phrases)]
-- -- Replace the original phrase with the random one
-- if cap==true then randomPhrase=cm.capitalize(randomPhrase) end
-- newS = newS:gsub(phrase, randomPhrase)
-- end
--end
--end
end
return newS
end
If is basically monte carlo tree search.
Improving LLM accuracy with Monte Carlo Tree Search (youtube.com)
A mixture of these implications combine in a retrieval based chat bot. That answers simple queries and uses a LLM for answers which it has low accuracy. You can test it here.
Epic RPG with AI +Optimized Performance - Roblox