How should I go about creating a Chatbot, of the likes of ChatGPT

Hello, I’m trying to create a Chatbot similar to ChatGPT or similar AI’s. To my understanding this would be extremely difficult or even impossible without the usage of an external source, for machine learning purposes. I’m making this post to ask if it is possible to make a Chatbot entirely within ROBLOX, and only ROBLOX. Also, I’m not talking simple NLP that just looks at pre-written responses and chosen from the best one, I mean full on generative AI.

From my progress already, I can use NLP strategies to dissect subjects, verbs, and other important information from given sentences and statements, aswell as questions. Additionally, I’ve implemented Term Frequency functions, aswell as Inverse Document Frequency functions to determine importance of certain words, also to chop off useless words. (ex: the, an, etc.)

But, my main issue, how would YOU go about generating responses with given information, without the use of predefined responses?

Thanks for your time.

Background knowledge:

  • NLP is Natural Language Processing.

  • Tokenization is the method of splitting a document into singular words.

  • Term frequency (TF) is how often a word appears in a document.

  • Inverse document frequency (IDF) is how unique or rare a word is.

1 Like

httpsservice, :GetAsync(), and some basic devforum searching skills

Doing this using Roblox programming is next to impossible. Yes, an external service is your only option. Use http service and do in depth research. We cannot help further.

I think that by “only ROBLOX” the author means that they want to make the AI itself run within Roblox. Not request it from an external source.

Given the amount of neurons ChatGPT has I highly doubt you will be able to make anything close to it within Roblox.

If I was you I’d try to figure out a way to train the AI outside of Roblox(for example in a dedicated resource for that) and then a way to encode all the information for recreating the final trained result(all weights and neurons information after training) as text. Then what I would make in Roblox is a way to decode the text back to the AI and somehow a way to understand the information in order to run it there(within the game server).

JUST USE HTTPS SERVICE FOR THE LOVE OF GOD. like… just send an request to open ai with https to prompts. or just search it up?

I’m not the author, I don’t make the rules.

oh wait sorry wrong reply 300 chars

correct, I plan on making everything myself, not using an external source like OpenAI, although it seems very challenging.

why though… i doubt roblox servers will be able to hold that much memory.

okay one way to do it is to make your own web server, and just call https service from that

for fun really. And yes, i know, even making an RNN/LSTM is going to be very VERY difficult.

yeah, thats what im assuming ill have to result to, considering i doubt i can do much within the constraints of roblox lol, it was worth a shot though.

just use https service… its not that deep

its to learn aswell, i honestly have no use for it once i make it, just expanding my knowledge.

You don’t have the computational resources and the budget to make that thing yourself. Even if you somehow copy entirely what ChatGPT does given your resources it will only output almost random looking sentences that slightly resemble human speech(but definitely not human intelligence).

Also another issue is the training data. OpenAI was able to get it freely, you have to scrap the entire internet to get it, so given the amount of websites not liking that getting the information is actually the hard part here.

There’s a reason why ChatGPT-like apps either use ChatGPT, or are competitors of it made by other big companies. It’s basically a data war between the big guys.

1 Like

ha, gotcha, okay, well it was worth a shot, thanks again for your time

For learning you can still give it a shot tho. Especially when it comes to things like learning how to tokenize words. There’re also a few neural network modules made by the community(you can easily find them in community resources) although I’m not entirely certain if they’re useful for this.

In general it’s possible to run small networks completely in Roblox. For example for controlling cars or the behaviour of NPC’s given a few input neurons. I assume you can also do the number guessing thing. But compared to those ChatGPT is a beast.

1 Like

i mean, ive done some very simplistic things so far…:

local ai = {
	patterns = {},
	dataset = {},
	ml = {},
	mind = {},
}

function ai.respond(input : string) --//input:string::>generate_response:func({info})::>response:string
	local tokenized = tokenize(input)
	local termfrequecny = tokenize_termfrequency(tokenized)
	local inversedocumentfrequency = tokenize_inversedocumentfrequency(tokenized)
	local features = tokenize_features(tokenized, termfrequecny, inversedocumentfrequency)

	local subject = determine_subject(input, tokenized)
	local isQuestion = check_ifquestion(input)
	local verb = find_verb(tokenized)

	local knowledge = {
		["question"] = isQuestion,
		["subject"] = subject,
		["verb"] = verb,
	}
	return generate_response(knowledge)
end

function tokenize(input : string)
	return string.split(string.lower(input), " ")

end

function tokenize_termfrequency(tokenized : {}) --//tokenized:{string}::>importance_values:{int}
	local importance_values = {}
	local total_tokens = #tokenized

	for _, token in ipairs(tokenized) do
		if importance_values[token] then
			importance_values[token] = importance_values[token] + 1
		else
			importance_values[token] = 1
		end
	end

	for token, count in pairs(importance_values) do
		importance_values[token] = count / total_tokens
	end

	return importance_values
end


function tokenize_inversedocumentfrequency(tokenized : {}) --//tokenized:{string}::>importance_values:{int}
	local importance_values = {}
	local total_tokens = #tokenized

	for _, token in ipairs(tokenized) do
		if importance_values[token] then
			importance_values[token] = importance_values[token] + 1
		else
			importance_values[token] = 1
		end
	end

	for token, count in pairs(importance_values) do
		importance_values[token] = math.log(total_tokens/count)
	end

	return importance_values
end

function tokenize_features(tokenized : {}, termfrequency : {}, inversedocumentfrequency : {}) --//tokenized:{string}|inversedocumentfrequency:{int}::>importance_values:{int}
	local importance_values = {}

	for _, token in ipairs(tokenized) do
		importance_values[token] = termfrequency[token]*inversedocumentfrequency[token]
	end

	return importance_values
end

function check_ifquestion(input : string) --//input:string::>boolean
	if string.find(input, "?") then
		return true
	else
		return false
	end
end

function determine_subject(input : string, tokenized : {}) --//input:string|tokenized:{string}::>
	local verb = find_verb(tokenized)
	local l, r = string.find(input, verb)
	if l and r then
		local left_part = string.sub(input, 1, l - 1)
		local last_word = string.match(left_part, "(%w+)%s*$")
		return last_word
	end
	return nil
end

function find_verb(sentence : string) --//sentence:string::>found_verb(s):{string}
	local verbs = require(script.verbs)
	local found_verbs = {}

	for _, word in sentence do
		if table.find(verbs, word) then
			table.insert(found_verbs, word)
		end
	end

	if #found_verbs > 1 then
		print("more than one verb")
	else
		return found_verbs[1]
	end
	return nil
end

function structure_sentence(knowledge: {})
	local sentnce_structures = {
		["simple"] = {}
	}
	
	local FANBOYS = {"for, an, nor, but, or, yet, so"}
	local ABBISAWAWUWU = {"as, because, before, if, since, although, when, after, while, until, whether, unless"}
	
	return 
end

function generate_response(knowledge : {}) --//knowledge:{info}::>response:string
	local QUESTION = knowledge.question
	local SUBJECT = knowledge.subject
	local VERB = knowledge.verb

	print("QUESTION: " .. tostring(QUESTION) .. ", SUBJECT: " .. SUBJECT ..", VERB: " .. VERB )
	return QUESTION, SUBJECT, VERB
end


return ai

i just havent pieced alot together and have only been working on this for a few combined hours.
(by piece together i mean combine the different features)

1 Like

but yes, i plan to still try, even if its small, just to learn, it seems useful later on.

1 Like

Also if I’m not mistaken OpenAI really limits the constraints they give to the AI. Basically it learns how to do most(if not all) things you define on the code on its own, without being specifically told to do them(for example it can do math on its own). So if you add a few constraints in there(as you did above) it may be able to function a bit better given its small size.

1 Like