Hello.
I have recently encounter an issue with the API and GPT4, where it does not generate a leading white space when appropriate.
A trivial example:
text = “The capital of France is”
message = [
{“role”: “user”, “content”: text}
]result = openai.ChatCompletion.create(
model=“gpt-4”,
messages = message,
max_tokens=50,
top_p=1,
temperature=0.0,
stop=[“.”, “\n”])print(result)
The output is “Paris” with no leading space.
…
“model”: “gpt-4-0613”,
“choices”: [
{
“index”: 0,
“message”: {
“role”: “assistant”,
“content”: “Paris”
},
“logprobs”: null,
“finish_reason”: “stop”
}
…
Compare this to the response for completion with 3.5-turbo-instruct:
result= openai.Completion.create(
engine=“gpt-3.5-turbo-instruct”,
prompt=text,
max_tokens=50,
top_p=1,
temperature=0.0,
stop=[“.”, “\n”])print(result)
The output is " Paris" with a leading space.
…
“model”: “gpt-3.5-turbo-instruct”,
“choices”: [
{
“text”: " Paris",
“index”: 0,
“logprobs”: null,
“finish_reason”: “stop”
}
],
…
For my purposes I cannot know if a space needs to be appended for the completion. I am performing a beam search using top_logprobs and the completion may start in the middle of a word (e.g., “In France, the capit” the response should be “al is Paris”).
Is this due to the nature of chat completions? Will it never generate a leading whitespace?
Thanks!