Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

remove finetune_test

Isaac Millerf698df97a78a
diff --git a/examples/finetuning/finetune_test.ipynb b/examples/finetuning/finetune_test.ipynb
deleted file mode 100644
index 71c43bbcf..000000000
--- a/examples/finetuning/finetune_test.ipynb
+++ /dev/null
@@ -1,163 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "The autoreload extension is already loaded. To reload it, use:\n",
- " %reload_ext autoreload\n"
- ]
- }
- ],
- "source": [
- "%load_ext autoreload\n",
- "%autoreload 2\n",
- "\n",
- "import os\n",
- "\n",
- "os.environ[\"DSPY_CACHEDIR\"] = \"\"\n",
- "os.environ[\"DSP_CACHEDIR\"] = \"\"\n",
- "os.environ[\"OPENAI_API_KEY\"] = \"\"\n",
- "\n",
- "import dspy\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "['Hello! I’m here and ready to help you with whatever you need. What’s on your mind?']"
- ]
- },
- "execution_count": 2,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# Ensure that we can use the LM interface\n",
- "lm = dspy.LM('openai/gpt-4o-mini')\n",
- "lm(\"What's up GPT?\", temperature=1.5)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "dspy.clients.openai.FinetuneJobOpenAI"
- ]
- },
- "execution_count": 3,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# Example call to the finetune method for OpenAI\n",
- "# Doesn't call the real functions for the time being\n",
- "dspy.settings.experimental = True\n",
- "\n",
- "training_data = [\n",
- " dict(prompt=\"What is the capital of France?\", completion=\"Paris\"),\n",
- " dict(prompt=\"What is the capital of Germany?\", completion=\"Berlin\"),\n",
- " dict(prompt=\"What is the capital of Italy?\", completion=\"Rome\"),\n",
- " dict(prompt=\"What is the capital of Spain?\", completion=\"Madrid\"),\n",
- " dict(prompt=\"What is the capital of Portugal?\", completion=\"Lisbon\"),\n",
- " dict(prompt=\"What is the capital of the United States?\", completion=\"Washington, D.C.\"),\n",
- "]\n",
- "\n",
- "config = {\n",
- " \"quantized\": True,\n",
- " \"learning_rate\": \"whatever\",\n",
- "}\n",
- "\n",
- "job = lm.finetune(message_completion_pairs=training_data, config=config)\n",
- "type(job)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "False"
- ]
- },
- "execution_count": 4,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# This will return False until the job is complete\n",
- "job.done()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "'FakeLM'"
- ]
- },
- "execution_count": 5,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# Once the hjob is complete, this will return the new language model\n",
- "finetuned_lm = job.result()\n",
- "finetuned_lm"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "dspy25",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.9.19"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}