Model ID is not working for me

I have my trained model id, after training ChatGPT with my dataset.

However, whenever I use it, for building a chat interface it keeps saying
the model id does not exist.

Not sure what I’m doing wrong here

Hey jez !
Can you share your function call and what was the call you used to train the model?
I think you might be mistaken in the sense that the ChatGPT model is currently not available to be fine-tuned

Here is the python code i used to train it

import openai
import PyPDF2

Read the PDF document

with open(‘mydoc.pdf’, ‘rb’) as file:
pdf_reader = PyPDF2.PdfReader(file)
document_text = “”
for page in pdf_reader.pages:
document_text += page.extract_text()

Set up your OpenAI API credentials

openai.api_key = my own api key

Split document into chunks

max_token_length = 4096
chunks = [document_text[i:i+max_token_length] for i in range(0, len(document_text), max_token_length)]

Train a new model with each chunk

model_id = None
training_data = “”
for i, chunk in enumerate(chunks):
# Prepare messages for the chunk
messages = [
{“role”: “system”, “content”: “You are a helpful assistant.”},
{“role”: “user”, “content”: chunk}

# Fine-tune a new model with the chunk
response = openai.ChatCompletion.create(

# Get the trained model ID
model_id = response['id']

Use the trained model ID in subsequent API calls

print(“Trained model ID:”, model_id)

So it output the mode_id which i used in the following python code
import openai

import gradio as gr

openai.api_key = my own api key

messages = [
{“role”: “system”, “content”: “You are a helpful and kind AI Assistant.”},

def chatbot(input):
if input:
messages.append({“role”: “user”, “content”: input})
chat = openai.ChatCompletion.create(
model = “chatcmpl-followed by a load of numbers and letters”,
reply = chat.choices[0].message.content
messages.append({“role”: “assistant”, “content”: reply})
return reply

inputs = gr.inputs.Textbox(lines=7, label=“Chat with AI”)
outputs = gr.outputs.Textbox(label=“Reply”)

gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title=“AI Chatbot”,
description=“Ask anything you want”,

Sorry the formatting there messed up but they are two separate python programs

it said on the last one when the chat web interface appeared, that the model id did not exist

I’m sorry to say this, but someone seems to have given you a vast misunderstanding of what “training” is and what an AI model is.

All I see happening here is you sending a chatbot a chopped up piece of a pdf as a question, and getting back the answer (which is probably gpt-3.5-turbo responding “I don’t know what you’re saying”), and putting that answer’s unique internal message identifier into a variable called model_id.

The code that comes after is further misconceptions.

Okay, im new to so thanks for the insight, so what would the Model Id that is returned back actually represent? If it’s not a trained model

The ID that comes with a response is undocumented, but analysis and logic tells us that it is a unique internal ID assigned to the generated response.

One could use this if, for example, you were making your own database of chat conversation history, and didn’t want to create your own identifier.

It also could be employed for error diagnosis by those that have high tiers of support, and as an identifier for the thumbs up/down rating system that is exposed in ChatGPT but not the API.

Okay - thanks
So if I wish to actually train to get my own trained model id
I should just add something along the lines of:-

Set the training parameters

model = ‘gpt-3.5-turbo’ # Or use another model variant
max_tokens = 1000 # Adjust as needed
temperature = 0.8 # Controls the randomness of the generated responses
epochs = 3 # Number of training epochs

Start the training loop

for _ in range(epochs):
response = openai.Completion.create(

# Extract the generated completion
completion = response.choices[0].text.strip()

# Append the completion to the training data
training_text += '\n' + completion

Save the trained model

model_id = ‘your_model_id’ # Replace with your desired model ID

print(“Training completed successfully!”)

I don’t know where are you are getting your information or code, but it is completely misguided. There is no “training” in any manner like you describe, and the whole idea should be tossed out the window.

You should start anew down the correct path for “asking about a pdf” - which is to use an embeddings-based database, that can give the AI specific and relevant pieces of information from the documents or company knowledge, that will then help it better answer the question the chatbot user has asked.

This documentation from OpenAI jumps right in to creating such a system for a knowledgeable audience:

For more basic guides and examples, you can look for “vector database” “embeddings” “openai api” or other such searches to get preliminary information. I would suggest making yourself an expert in other aspects of API programming chatbots and the models before embarking on such a task.

1 Like

I obtained the code by asking ChatGPT

to.provide a Python example

Thanks, ill go from the ground up. It does appear that guidance from.ChatGPT itself is not so reliable.