The latest model of gpt3.5 (gpt-3.5-turbo-0613) as of date(29th Sep 2023) is significantly slower than the older legacy version(gpt-3.5-turbo-0301).
Here’s a snippet which does summarisation on a paragraph of text with the same parameters only differing in the model type.
Gist to reproduce the issue:
import time
import requests
import aiohttp
import openai
from typing import List, Union, Tuple, Dict
def get_openai_api_response_sync(
prompt_message: List, model: str, max_tokens : int,
) -> Union[Tuple[str, Dict], None]:
response = None
with requests.Session() as session:
openai.requestssession = session
response = openai.ChatCompletion.create(
model=model,
messages=prompt_message,
temperature=0,
frequency_penalty=1,
max_tokens=max_tokens,
request_timeout=15,
)
if response:
return response["choices"][0]["message"]["content"], dict(response['usage'])
return None
prompt_message = [
{
"role": "system",
"content": "Given a large piece of text, write a summary in 3-4 sentences",
},
{
"role": "user",
"content": "Text : Throughout the history of mankind, music has served as an essential element of society, representing the emotions, experiences, and philosophies of its composers and listeners alike. From the ancient flutes crafted by early humans to the complex symphonies penned in the age of Romanticism, music is an art form that expresses the vast spectrum of human sentiment. It transcends tangible barriers and abstract differences, soothing souls and inspiring change. Beyond its emotional appeal, music also wields the power to shape cognition and development in exquisite, profound ways. Children who learn music often exhibit improved cognitive skills and academic proficiency. Research has further divulged enhanced neural plasticity and memory consolidation in musicians. On a societal level, music taps into the cultural tapestry of races and nations, bridging diverse cultures and fostering communal harmony. It has been leveraged as a vehicle for change during pivotal historical events and stands as an unceasing source of unity and strength in turbulent times. Music, thus, is not just an auditory pleasure but a medium of holistic human expression, cognitive enhancement, and societal cohesion. Summary : ",
},
]
print("--------- Test with gpt-3.5-turbo-0613 (new & slower) ---------")
start = time.time()
model = "gpt-3.5-turbo-0613"
out = get_openai_api_response_sync(
prompt_message = prompt_message,
model = model,
max_tokens = 50
)
end = time.time()
print(out,'\n')
print(f"Took {(end - start) * 1000} ms with {model}\n\n")
print("--------- Test with gpt-3.5-turbo-0301 (old & faster) ---------")
start = time.time()
model = "gpt-3.5-turbo-0301"
out = get_openai_api_response_sync(
prompt_message = prompt_message,
model = model,
max_tokens = 50
)
end = time.time()
print(out)
print(f"\nTook {(end - start) * 1000} ms with {model}\n\n")
Output
--------- Test with gpt-3.5-turbo-0613 (new & slower) ---------
('Music has played a significant role throughout history, expressing human emotions and experiences. It goes beyond cultural differences, inspiring change and fostering unity. Learning music has been shown to improve cognitive skills and academic performance in children, while musicians also exhibit enhanced neural plasticity', {'prompt_tokens': 247, 'completion_tokens': 50, 'total_tokens': 297})
Took 2617.2635555267334 ms with gpt-3.5-turbo-0613
--------- Test with gpt-3.5-turbo-0301 (old & faster) ---------
('Music has been an essential part of human society throughout history, expressing a wide range of emotions and experiences. It has the power to shape cognition and development, with children who learn music exhibiting improved cognitive skills and academic proficiency. Music also serves as a vehicle', {'prompt_tokens': 249, 'completion_tokens': 50, 'total_tokens': 299})
Took 912.5313758850098 ms with gpt-3.5-turbo-0301
gpt-3.5-turbo-0613 - 2600 ms
gpt-3.5-turbo-0301 - 900 ms
That’s a huge difference between the same type of model but different checkpoints.