Skip to content

Commit cf355c7

Browse files
committed
Update gpt-3.5-turbo-instruct to act as Completion model instead of Instruct (as OpenAI API doesn't honor <|endofprompt|> special token)
1 parent 9df3e89 commit cf355c7

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

guidance/models/_openai.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def __init__(self, model, tokenizer=None, echo=True, caching=True, api_key=None,
6868
found_subclass = OpenAIChat
6969

7070
# instruct
71-
elif "instruct" in model:
72-
found_subclass = OpenAIInstruct
71+
# elif "instruct" in model: # All current OpenAI instruct models behave as Completion models.
72+
# found_subclass = OpenAIInstruct
7373

7474
# regular completion
7575
else:

tests/models/test_openai.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def test_openai_class_detection():
1414
"ft:gpt-4": guidance.models.OpenAIChat,
1515
"ft:gpt-4-vision-preview": guidance.models.OpenAIChat,
1616
"ft:gpt-3.5-turbo:my-org:custom_suffix:id": guidance.models.OpenAIChat,
17-
"gpt-3.5-turbo-instruct": guidance.models.OpenAIInstruct,
18-
"ft:gpt-3.5-turbo-instruct": guidance.models.OpenAIInstruct,
17+
"gpt-3.5-turbo-instruct": guidance.models.OpenAICompletion,
18+
"ft:gpt-3.5-turbo-instruct": guidance.models.OpenAICompletion,
1919
"text-curie-001": guidance.models.OpenAICompletion,
2020
"ft:text-curie-001": guidance.models.OpenAICompletion,
2121
"text-davinci-003": guidance.models.OpenAICompletion,
@@ -40,19 +40,6 @@ def test_openai_basic():
4040
lm += f"""{gen(max_tokens=1, suffix=nl)}aaaaaa"""
4141
assert str(lm)[-5:] == "aaaaa"
4242

43-
def test_openai_gpt35_instruct():
44-
from guidance import gen, instruction
45-
46-
# this relies on the environment variable OPENAI_API_KEY being set
47-
try:
48-
lm = guidance.models.OpenAI('gpt-3.5-turbo-instruct')
49-
except:
50-
pytest.skip("Skipping OpenAI test because we can't load the model!")
51-
52-
with instruction():
53-
lm += "What is a popular flavor?"
54-
lm += gen('flavor', max_tokens=2, stop=".")
55-
assert len(lm['flavor']) > 0
5643

5744
def test_openai_select():
5845
try:

0 commit comments

Comments
 (0)