I'm not sure if this belongs here or in r/learnmachinelearning, but I have a question about what is and isn't possible.
My husband's best friend passed several years ago and he has copious chats, forum posts as well as the stories they wrote together. Right now, we have created a bot in Character.AI that kinda sounds like him, but obviously not one that contains any of his knowledge since the definition window is small and the bots' memory is... imprecise at best.
So I got to wondering: it seems like it should be possible to fine-tune/create a LoRA of one of the LLMs so that it does contain the friend's knowledge and can be used as a chatbot. From my research it seems like Vicuna would be a good fit as it has already been tweaked to act as a chatbot. I'm currently working through tutorials, including the "How to Fine Tune an LLM" that exists on Colab that tweaks GPT2 (I think) with wikipedia data. I know I have a huge learning curve ahead of me.
I would be looking at doing the training using Google Colab, but ideally he'd run the end result locally. He can run stable diffusion on his machine using his NVidia GPU. Sadly, my video card is AMD so while I can technically run the Vicuna 4 bit model (13B, I think?) in CPU mode, it's too painfully slow to do anything with.
The data is currently unstructured. Obviously we will need to format it properly, but it is in the form of blocks of text rather than the Prompt/Input/Output format I've seen in various Github projects.
As for me, I am a former C# Windows/Web/SQL developer so I'm not starting from absolute scratch, but obviously I'll need to learn a lot. I'm prepared for this to be an ongoing project for the new few months.
I would welcome any feedback as to what is or isn't possible, whether I'm setting my sights too high, or even if I'm simply in the wrong forum. Thanks all!
EDIT: I've received many words of warning about whether this is a good idea, for my husband's sake at least. After thinking about it, I'm not sure I'm at the point where I agree yet but I'll at least give this a lot of thought before attempting something like this. I know it's not the most emotionally healthy thing, to cling to the echoes of someone gone. He has not found interacting with the Character.AI version of his friend to be difficult but while their bots are fun to interact 2i5h and can still sound startingly human, an LLM fine tuned on the friend's text has every chance of being more so to the point of being damaging. So thank you everyone, you've given me a lot to think about.
I can confirm that training LoRAs on large archives of messages (we are talking several thousand) which are formatted in a stable way will accomplish something comparable to what you are describing. Make sure to split the training segments so that conversations which are unrelated are not directly next to each other in the training data, but instead are separate blocks. I would avoid using any instruct models trained on assistant data such as ShareGPT as it may bias it towards unwanted responses. The larger models are more accurate, and in my experience effectively mimic the style and types of responses of whoever's chat data you trained the model on.
That being said, I think that doing this with anyone who is deceased could be a very emotionally harmful activity. It is one thing to do it as an experiment or to generate funny mock conversations, but using it to try and "replace" someone is something entirely different. If you have enough input data, it may feel like you are talking to the actual person, up to the point where the model makes some kind of mistake which would likely immediately cause you to remember it is an AI and lead to depressing thoughts. It can be convincing, and you can have entire conversations that feel real, but it just isn't the same as the real person it mimics.
So yes, you can do it and it would likely work pretty well. But it may not be a good idea. If you do it, I would say pay very close attention to how interacting with it makes you feel.
Two of you have commented along these lines, so I'll repeat this here. This is for my husband, not me and it was his idea to create the Character.AI chatbot. He knows that it is just a machine, that it's sometimes eerily good at sounding human but it isn't.
It gives him some comfort to talk to something that sounds like his friend. I don't think this is harmful for him, but if it turns out that it is, that he has any bad emotional responses to anything to do with it, then I'll stop working on it.
And in the meantime, it sounds like a fun project.
Yeah I only said this because I have done what you're describing and was incredibly surprised by how well the AI mimics people's responses. Things like ways they speak, common topics, style of messaging, honestly everything. In the chats I trained it on, there were several people and the simulated people captured the real dynamics pretty well. They would talk about and respond to topics that the corresponding people would have responded to in real life. They also held similar political ideas and at one point two of the simulated personalities argued about something with another person in a realistic way. If someone often vented about problems the corresponding model will as well.
The most important thing was to get a consistent message format and make sure that the "blocks" of messages all occurred within 5 minutes of the nearby messages. If too much time passes between messages in the blocks, odds are the topics in the blocks aren't consistent and the AI model will become "distracted" frequently and veer off topic.
What format did you use, and how did you break up the conversation pieces?
I used a python script to break the messages up. The resulting file is a json file with a list of objects with a single data field which contains the blocks of messages. Then with a custom format that just maps the single field, you can train it with text-generation-webui.
I had chatgpt make a json file based on your description, do you think the following format would work?
This script will reproduce what I did using the dataset above.
https://gist.github.com/iwalton3/b76d052e09b7ddec1ff5e4cc178f5713
Wow, I really appreciate you sharing your script!
I agree with you and your husband's view of it. Science fiction tends to jump into this subject a lot and treat it as an inevitable horror story. But I think that the concern misses out on a real component of mourning.
When we mourn it's both for the loss of a person in our life, and 'for' the loss of their life. People on the outside of that process usually think that the first is the biggest component of grief. But it really isn't. The biggest part of the grief comes from empathy over what the deceased has lost, not those of us mourning them.
Talking to someone or in this case something, 'like' the person we mourn doesn't typically interfere with the mourning process. Sure, there might be the occasional instance where that is the case. Just as there are people who fall in love with a chatbot.
But for the most part going over the things the people we mourn lived for only helps to reaffirm our own dedication to life. To live life for them. Because an active life led where we hold the ideals of the deceased in our hearts while moving forward does maintain that connection we're after. Remembering them as a person who lived rather than defining them by their death. And throughout history that's been done by rereading their old writings or meditating on their life in places they loved. To me it just sounds like this is a continuation of that tradition using new tools.
It IS harmful. It'll only either fail, or stir up old memories that are gone. Meeting the echo of a long lost loved one through a machine is the definition of a crutch. It's only going to make the attachment to something gone linger on.
While technically possible, this is a horrible idea that will only reinforce the attachment.
I don't know, to me that just sounds like you're advocating emotional repression. Someone doesn't stop being an important part of your past just because they die. Any more than if they'd just moved away somewhere you can't talk to them anymore. My dad died when I was just a kid and growing up I gained a lot of strength by carrying his memory forward with me. And it helped remind me of how valuable and often far too short life is so that I wouldn't take it for granted.
Do you realise you're seriously saying that it's a good thing to encourage emotion towards a machine because it reminds you of a dead relative?!
That's EXTREMELY unhealthy! It's the defintion of a substitution by a fake. I can't believe anyone would seriously defend this as healthy.
Aren't there movies about exactly this topic? I try not to tell people what to do, but i also think it's a trap. I will keep the person from healing and keep them from moving on with their own life. I wouldn't do it for a prolonged time.