Package: chatting-chatbots
Chatting ChatbotsA library for running experiments of multiple genarative language models having conversations with each other.InstallationInstall chatting chatbots from PiPy:pipinstallchatting_chatbotsor directly from GitHub:pipinstallgit+https://github.com/centre-for-humanities-computing/chatbot-conversationsUsageThe package currently works only with PyTorch.an example of usage (seen in tutorials/examples.ipynb):importchatting_chatbotsascccc.Experiment(population={"John":"gpt2","Margaret":"gpt2","Alice":"gpt2","Bob":"gpt2","Eve":"gpt2","Charlie":"gpt2","Darwin":"gpt2"},cycles=2,initial_context="Hi. Why are you late?",conversation_length=10,verbose=True,use_gpu=0,use_files=False).run()Parameters forExperimentparametertypedefaultdescriptionpopulationdictrequired parameterA dictionary, where each element is an agent, defined as"Agent_Name" : "Agent_Model". The model can either be the name of a model available on HuggingFace, or a list[tokenizer, model]of a tokenizer and a model you have already created.cyclesint1The number of cycles of conversation, where one cycle is each agent in the population talking to each other agent twice (starting the conversation once, and being second once).initial_contextstr"Hello."The initial context the first agent in a conversation uses i.e. each conversation starts with this sentence.conversation_lengthint10The length of the conversation in turns (excluding the initial context).random_lengthint0A randomisation variable for the length; the length is taken from a uniform distribution of[conversation_length - random_length, conversation_length + random_length].training_argsTrainingArgumentsNoneA TrainingArguments parameter passed to the HuggingFaceTrainer()class. IfNone, some default parameters are used.verboseboolFalseIf set toTrue, class outputs some extra text about what is happening.use_filesboolTrueIf set toTrue, during training, conversations are saved to files in theoutput_pathdirectory, and all of the files in theoutput_pathwill be used for training. Otherwise, only the conversations generated during a single.run()are used.use_gpuint-1If not set, uses cpu, otherwise, uses the gpu specified.generation_parameterslistNoneA list of parameters used for themodel.generate()function (not tested). If not used, some default parameters are used instead.context_sizeint600How many tokens should be used on each generation. If set to 0, uses the entire conversation as context. Note that this is prone to crashing as some models cannot handle large contexts.full_conversationboolTrueIf set toTrue, uses the entire conversation for training. If set toFalse, uses only theother agent'stext for training.batch_sizeint128The batch size used for training. If the experiment crashes because of no examples for training, you should either decrease this value or increase the conversation length.train_after_runboolTrueIf set toTrue, every agent is trained after a.run().output_pathstr"outputs"The path where the conversation files should be saved.cache_pathstr".cache/huggingface/transformers"The path where the models (if they are downloaded from HuggingFace) should be stored.Functions availablefunctionargumentsreturndescriptionconversation_generation()str speaker_one, str speaker_twostr conversationGenerates a conversation betweenspeaker_oneandspeaker_two. Returns the conversation. Note that the speakers must be in the population of theExperiment.run()--Runs the experiment by having each agent speak with each other agent for the set number of cycles, optionally training them afterwards.train_participant()str participant-Trains the participant specified. Note that the participant must be part of thepopulationof theExperiment.return_modelstr participantmodelReturns the current model of the specified participant.CreditsThis package was created using theNameproject template.