DSPy: The framework for programming—not prompting—language models
Python
Import finetuning method
Isaac Millerb56eb2a16cbb
diff --git a/dsp/modules/openai.py b/dsp/modules/openai.pyindex 93238cffb..cdcaf602c 100644--- a/dsp/modules/openai.py+++ b/dsp/modules/openai.py@@ -3,7 +3,7 @@ import timefrom typing import Any, Optional, Literal, Unionimport openai-from dsp.modules.lm import FinetunableLM+from dsp.modules.lm import FinetunableLM, FinetuningMethodfrom dsp.modules.gpt3 import GPT3from collections import defaultdict@@ -76,7 +76,7 @@ def num_tokens_from_messages(messages, tokens_per_message=3, tokens_per_name=1):def num_assistant_tokens_from_messages(messages):import tiktokenencoding = tiktoken.get_encoding("cl100k_base")-+num_tokens = 0for message in messages:if message["role"] == "assistant":@@ -151,8 +151,6 @@ def backoff_hdlr(details):"{kwargs}".format(**details),)-FinetuningMethod = Literal["SFT", "Contrastive"]-class OpenAIModel(GPT3, FinetunableLM):"""Wrapper around specifically the OpenAI API to finetune.