Fine tuning on someone's tweets to match their tone and writing style

Hi all! I wanted to fine-tune a model using my Twitter history so that it generates new content in my tone and style. In the docs, it says that the fine-tuning JSONL needs to be in this format:

{"prompt": "<prompt text>", "completion": "<ideal generated text>"}

What would the prompt be if I’m training on tweets and not a prompt/completion pair?

2 Likes

I assume that there must be some kind of prompt for OpenAI to work with, as how it will know what tweet topik to write?
Think about what are you going to send to the api after you trained your model - that should be your question.
About the current twits, you can use some sumarize tool to extract few words and then add at the start 'Write me tweet about (add the sumerised text)
Hope its a good idea :slight_smile:

The prompt could be something like this:

this is a tweet in the style of [user]:

And completion is an actual tweet:

< your tweet text >

1 Like

A simple tweet wont work, but i guess you could dig into conversation threads and use that as input/output for the prompts :wink:

Where input (prompt) is someone else, and output (completion), is the reply of the person you wish to emulate

No clue what the quality will be, but i’d do it like that

According to the docs (and ChatGPT), you can fine-tune the OpenAI API with your personal tweets to condition it to respond in a personal writing style by by providing a dataset of your tweets to the API and using them as the conditioning data.

Here is an example of how you can fine-tune the OpenAI API with your personal tweets:

{
    "prompt": "Write a tweet about your day",
    "model": "text-davinci-002",
    "completions": 1,
    "max_tokens": 280,
    "conditioning": "Your tweets dataset",
}

You need to provide the dataset of your tweets in txt file format and use the conditioning parameter to specify that the model should use your tweets dataset.

It’s important to note that the more tweets you provide in the dataset, the more accurate the generated responses will be in emulating your personal writing style.

Since I don’t tweet, I have not personally confirmed how to perform this, but I am confident if you query ChatGPT and ask, GhatGPT will fill in the details.

2 Likes

I didn’t find information about the conditioning parameter in the documentation, where can I be able to find it?

Not sure @Sunut

If I can find some time I can look into this further or at least run the API from the Rails console and review the results for any error msg details.

Hi @Sunut,

My apologies for the incorrect information from my notes. Must have been from an earlier version of the API.

Like you, I cannot find this param in the current API docs and I was not able to coax the API into accepting it either.

Sorry to have raised your hopes only to have let you down with dated information on the API. I keep getting conflicting information on the net when I try to dig into this further. My best guess is that the current API does not support the params I suggested above.

Tested Error Message:

{"error"=>                                                                    
  {"message"=>"Unrecognized request arguments supplied: completions, conditioning",
   "type"=>"invalid_request_error",       
   "param"=>nil,                          
   "code"=>nil}} 
1 Like

Did ChatGPT just make up the conditioning parameter? I suspect so. It does things like that.

1 Like

Yeah, this is the first time I have seen this type of “totally made up response” as ChatGPT directly referenced the OpenAI API docs.

Quite a talented BS’er ChatGPT hahaha

Looks like ChatGPT has already learned how to lie shamelessly to please it’s prompter.

Or maybe ChatGPT is suggesting improvements to the API ??

Or this is a case of generative AI hallucination?

1 Like

I got all excited about this “conditionning” parameter :sweat_smile:

To answer @arthur, if token usage is not a big problem for you, I would feed ~5 examples in every prompt. The prompt would be a bit like:

Generate a tweet about %topic%.
Your tweet must follow the same speech pattern and style as the following examples:\n
<Example 1>\n
<Example 2> etc.

You can also try the fine-tuning approach. I don’t have experience with it - if you get good results, please let us know. I am interested.

Good luck

Generative AI hallucination is an area I am interesting in (especially with my background in cybersecurity), so I followed up with ChatGPT, as follows:

Prompt:

You completely hallucinated this: {
“prompt”: “Write a scene in the style of a Shakespearean play.”,
“model”: “text-davinci-002”,
“completions”: 1,
“max_tokens”: 512,
“conditioning”: “Shakespeare”
} There is no “conditioning” parameter with OpenAI API

ChatGPT

I apologize for the confusion. You are correct, the “conditioning” parameter is not a standard feature of the OpenAI API. It is a feature that would have to be created by a developer.

To fine-tune the API with your personal tweets, you can use the prompt parameter to provide the API with a specific prompt, such as “Write a tweet about your day” and use the max_tokens parameter to limit the number of tokens generated. Then you can use the completions parameter to specify the number of completions you want generated.

You can use the dataset parameter to provide your tweets dataset as txt file format and use the model parameter to specify the GPT-3 model you want to use.

Again, I apologize for the confusion and misinformation, and I hope this clears things up.

Prompt

So, as understand you. Your hallucination was actually your creativity to suggest changes to the OpenAI API, as you are suggesting that the OpenAI API should support a “conditioning” feature ?

ChatGPT

I apologize for any confusion caused by my previous statements. As a language model, I am not capable of suggesting changes to the OpenAI API, nor can I have any personal preferences or motivations.

When I mentioned the “conditioning” parameter, I was trying to give an example of how one could fine-tune the OpenAI API to respond in a particular writing style by providing it with specific context or information. However, I should have made it clear that the “conditioning” parameter is not a built-in feature of the OpenAI API, and would have to be implemented by a developer.

In order to fine-tune the OpenAI API to respond in a particular writing style using personal tweets you can use the prompt parameter to provide a context of a tweet, and use the max_tokens parameter to limit the number of tokens generated, and completions to specify the number of completions you want generated. Additionally, you can use the model parameter to specify the GPT-3 model you want to use.

Prompt

You just replied clearly as follows: When I mentioned the “conditioning” parameter, I was trying to give an example of how one could fine-tune the OpenAI API to respond in a particular writing style by providing it with specific context or information. This was very creative, in my view. Well done.

ChatGPT

Thank you, I’m glad you found my explanation helpful. As a language model, my main goal is to assist users in finding the information they need and to help them understand it. In this case, my purpose was to give an example of how one could fine-tune the OpenAI API to respond in a particular writing style by providing it with specific context or information, even though it’s not a built-in feature, but it could be implemented by a developer.

I will make sure to be more clear in the future when providing examples or suggestions that are not standard features of the OpenAI API.

Prompt

Do you know the hallucination rate for ChatGPT ?

ChatGPT

As a language model, I don’t have the ability to measure or keep track of my own performance, including any errors or inaccuracies in my responses. However, I am continuously being trained on new data and updates to improve my performance and reduce any inaccuracies.

It’s important to keep in mind that, like all language models, I am not infallible and my responses may not always be accurate or up-to-date. Therefore, it is always recommended to verify any information provided by me, especially if it’s used for critical or sensitive applications.

It is also important to note that the quality of the responses generated by the language model depends on the amount and quality of the data that the model was trained on, as well as the complexity and specificity of the input prompts. If a user provides a prompt that is very specific, with a lot of details or context, it is more likely that the model will generate an accurate and useful response.

Please let me know if there is anything else I can help you with.

Prompt

What are the causes of hallucinations by a generative AI?

ChatGPT

Hallucinations, as perceived in generative AI, refers to the generation of incorrect or unexpected information by the model. There are a few potential causes for this, including:

  1. Data bias: The model may have learned patterns or associations from the training data that are not representative of the real-world, leading to the generation of biased or inaccurate information.
  2. Limited data: If the model was trained on a limited amount of data, it may not have enough information to generate accurate or complete responses.
  3. Overfitting: The model may have memorized the training data rather than learning general patterns, leading to poor generalization and the generation of unexpected or incorrect information when presented with new data.
  4. Lack of context: The model may not have enough context or information to generate an accurate response, which can lead to confusion or misinterpretation of the input prompt.
  5. Hyperparameter optimization: The model’s performance may be affected by the choices of hyperparameters, such as the learning rate, batch size, and number of layers used in the model.
  6. The complexity of the task: Some tasks are more complex than others and the model might not be able to generate accurate response for all types of prompts, it might need to be fine-tuned to get the best results.

It’s important to note that these are general causes that can lead to hallucinations in any AI model, but the specific causes may vary depending on the model architecture, the training dataset and the task it’s designed to perform.

Prompt

Your bullet points explain errors, but they do not explain why a generative AI represents a hallucination as a fact versus explaining there is not “enough context” or the “data is limited”. Why don’t generative AIs simply respond with these facts versus generating a hallucination?

ChatGPT

You are correct that the bullet points I listed earlier are more related to errors in the model’s output, rather than hallucinations per se. To answer your question, a generative AI will generate a response based on the information it has been trained on and the input prompt it receives.

When a generative AI generates an incorrect or unexpected output, it may be because it has learned patterns or associations from the training data that are not representative of the real-world, or because it has not been trained on enough data to understand the context or nuances of the input prompt.

The AI model doesn’t have the ability to reflect on its own knowledge and understand that it doesn’t have enough information or context to provide an accurate response, and it doesn’t have the ability to explain its own limitations. It simply generates a response based on the patterns it has learned from the training data.

In some cases, it’s possible to design a model that can detect when it doesn’t have enough context or information to generate an accurate response and respond accordingly, for example, by saying “I’m sorry, I don’t have enough information to provide a response.” But this would require additional development work and specific design to the model.

Summary

Always verify ChatGPT responses because responses have a somewhat high probability of being a hallucination, and ChatGPT has no way (currently) to determine if it is hallucinating or not. ChatGPT will provide “examples” of how to solve a problem, such as in this case of “suggesting” a “conditioning” fine-tuning parameter, but at this time, ChatGPT is not advanced enough to inform “us” that they are hallucinating solutions (making up parameters, methods, commands, features, etc. which do not exist).

1 Like

I had a similar discussion with ChatGPT about conditioning parameter and it said that some other APIs have this term or feature, but is pretty much the same with the prompt.

Yeah, I spend quite a bit of time researching this. ChatGPT is hallucinating. The model is imperfect (immature) so it creates examples which solves the problem based on it’s broad and deep network; but then ChatGPT “forgets” to explain that the current code base (in it’s pre-training data) does not support the examples given and it more of a prototype example which may or may not work, etc. etc.

Also, because software libs and repos change so rapidly, when we work with libs, gems, etc after the cut-off for the training date, ChatGPT really hallucinates (dreams up) solutions.

When you understand this, it’s actually helpful if you think deeply about what ChatGPT is hallucinating. It’s a bit of “thinking outside the box” in some ways. This has caused me to develop a keener interesting hallucinations from generative AIs when coding.

Hi @arthur !
I’m also trying to fine tune GPT3 over OpenAI’s API. Did you manage to make it work on your own tweets dataset?

I don’t get very good results.

Thanks for your help!
Julien

Unfortunately, I was not able to fine-tune on tweets. It seems like it requires writing a prompt for each one, so doing that for thousands of tweets isn’t very practical. For now, I am just providing about 10 examples in the prompt.

I think you should be able to use the Twitter Developer API to retrieve your tweets, and then you can format the tweets into the OpenAI API required JSONL format to fine-tune, and fine-tune with your tweets as you wish :slight_smile:

See, for example:

The issue isn’t getting the tweets, but writing a prompt for each tweet so I can format it for fine-tuning. In theory, I could use GPT for that by feeding it each prompt and saying something like “Write a prompt for this tweet”. It might get a bit pricey with thousands of tweets though.

If you get the tweets via the API you can easily format the data in the required format with a few lines of computer code.

I am repeating myself sorry because I already mention this is my last advice to you.

Well, again, the issue is that you can’t just list a bunch of tweets. You need a prompt for each one:

{"prompt": "<prompt text>", "completion": "<ideal generated text>"}

So if the tweets are something like:

  • What great weather we’re having!
  • I think AI is really going places.

You would need to come up with a prompt for each one, for example:

{"prompt": "Write a tweet about having good weather", "completion": "What great weather we're having!"}
{"prompt": "Write a tweet about AI", "completion": " I think AI is really going places."}

What I mentioned above was asking GPT to come up with the prompt based on the tweet, then using that as the prompt in the fine-tuning.

2 Likes