Storing OpenAI Models in a Database

I am building a system in which I require a uniquely fine-tuned model for each user in my database.

How do I go about persisting each model? Is there a simple way for me to (A) create an instance of a gpt-3.5-turbo model, and (B) store the model in some cloud storage system like MongoDB or S3?

Upon user sign in I will also require a mechanism to query the model with a given userID.

Thanks in advance for any insight!

Hi and welcome to the Developer Forum!

From the rate limit figures for a standard account the limit is 48 fine tunes per day, every fine tune is persistent on OpenAI’s server infrastructure, the models cannot be stored locally.

How you manage user logins and selecting the model they have trained is up to you.

Thanks for the response.

So if I create a model instance for each user using const model = new OpenAIApi(config), and then fine tune the model on the user’s data, how would i then query this model that’s persisted on the server?

Ok, so the flow is this

Create a fine tuning dataset of Question and Answer pairs

Upload that file to OpenAI

Issue a fine tune request stating the file you just uploaded as the tuning source and which model you would like to fine tune, gpt-3.5-turbo for example. That call will place your file in the training que.

Monitor the fine tuning que for your job to be completed.

Once your model is completed you receive a file name that is your new custom model and you can now run API calls against that new model name .

Documentation here : OpenAI Platform

I have a feeling you are very far from understanding how openai models work, what the meaning and purpose of fine-tune or training is, or how to program an existing AI model to satisfy a particular need.

What is the application you are seeing here?

1 Like

I’d agree that a fine-tune model for each user is not optimal or intended use.

What are you trying to achieve? We might be able to help, @jaspreet

Thanks @PaulBellow and @_j , yeah there’s some (probably most) stuff that I’m misunderstanding, so apologies for that.

The foundation is of my use case is that I want a user of my application to interact with an AI model that roughly resembles themselves (tone of voice, personality, etc.).

My thinking was that if I fine tune a model using the Q/A input format on data the user provides, I would repeat this X times for each user, and then store the model somewhere mapped to their userID.

What would be the correct approach? Would I instead tune the model to resemble people generally, and then customize the prompt with the user’s data?

If you train an AI to produce the same output it already produced based on prior user input, then you would just be training the AI to behave as it already does for the same input again.

Fine tuning a model is providing examples of user input, and then responding in a different way than the AI normally would. So you’d have to have questions that are possible input to the chatbot, and them being answered like the user would answer.

Fine tuning a model per customer? No, unless your customer is Delta Air Lines and you’re being paid thousands to develop the thousands of training cues to make a custom model - which is still running on OpenAI’s platform.

Right, but I wouldn’t be training it on the previous output.

My customer is a brand that wants to generate copy which aligns with their tone of voice.

I would prepare a dataset using existing copy (i.e. captions of their previous posts/tweets, in Q/A format). After prompting the model to generate new output I would want to resemble the training dataset to come up with new variations.

How would I approach this problem. What’s a workaround for not training a model for each user. @_j

That sounds like an exact match for the use of per client fine tunes. Also sounds like interesting and potentially complex project to manage and pre process the data, but if you have those Q/A format pairs, you can absolutely generate article variations all day long.