- Create the chat dataset.
- Use the LangSmithDatasetChatLoader to load examples.
- Fine-tune your model.
Prerequisites
Ensure you’ve installed langchain >= 0.0.311 and have configured your environment with your LangSmith API key.1. Select a dataset
This notebook fine-tunes a model directly on selecting which runs to fine-tune on. You will often curate these from traced runs. You can learn more about LangSmith datasets in the docs docs. For the sake of this tutorial, we will upload an existing dataset here that you can use.2. Prepare data
Now we can create an instance of LangSmithRunChatLoader and load the chat sessions using its lazy_load() method.With the chat sessions loaded, convert them into a format suitable for fine-tuning
3. Fine-tune the model
Now, initiate the fine-tuning process using the OpenAI library.4. Use in LangChain
After fine-tuning, use the resulting model ID with the ChatOpenAI model class in your LangChain app.Connect these docs to Claude, VSCode, and more via MCP for real-time answers.