Skip to content

Commit

Permalink
Rename notebook to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Miller committed Oct 15, 2024
1 parent d361ce9 commit b07e011
Showing 1 changed file with 24 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,6 @@
" # \"lora_dynamic_folder\": \"dspy/lora_weights/prodjob_qmulcjw4x8z599m8hkyja8tbmi/meta-llama/Llama-3.2-1B-Instruct\"\n",
"}\n",
"\n",
"\n",
"finetuneable_lm = dspy.LM(model=\"meta-llama/Llama-3.2-1B-Instruct\")\n",
"finetuning_job = await finetuneable_lm.finetune(method, train_path, eval_path, provider=\"anyscale\", train_kwargs=kwargs)\n",
"model_names = []\n",
Expand Down Expand Up @@ -991,6 +990,29 @@
"all_llamas = {**finetuned_llamas_1b, \"base\": llama_1b}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# # Sanity check that the finetuned models are working\n",
"llama1 = list(finetuned_llamas_1b.values())[3]\n",
"with dspy.context(lm=llama1):\n",
" print(llama1.model)\n",
" test_predictor = IntentClassificationModule()\n",
" sample_input = ft_trainset[11]\n",
" print(sample_input)\n",
" print(test_predictor(**sample_input.inputs()).label)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now let's try optimizing the program with the finetuned model"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -1021,29 +1043,6 @@
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# # Sanity check that the finetuned models are working\n",
"llama1 = list(finetuned_llamas_1b.values())[3]\n",
"with dspy.context(lm=llama1):\n",
" print(llama1.model)\n",
" test_predictor = IntentClassificationModule()\n",
" sample_input = ft_trainset[11]\n",
" print(sample_input)\n",
" print(test_predictor(**sample_input.inputs()).label)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now let's try optimizing the program with the finetuned model"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -1063,7 +1062,6 @@
" return dspy.Example(text=data[\"example\"][\"text\"], label=data[\"prediction\"][\"label\"]).with_inputs(\"text\")\n",
"\n",
"collected_data_examples = [collected_data_to_example(x) for x in collected_data_filtered]\n",
"# collected_data_examples[0]\n",
"\n",
"devset_synthetic = collected_data_examples[:DEV_SIZE]\n",
"ft_optimizer_devset = collected_data_examples[DEV_SIZE:DEV_SIZE+OPTIMIZER_NUM_VAL]\n",
Expand Down Expand Up @@ -1111,7 +1109,7 @@
"metadata": {},
"outputs": [],
"source": [
"if False:\n",
"if True:\n",
" import json\n",
" with open(\"ft_results.json\", \"w\") as f:\n",
" json.dump(ft_results, f)\n",
Expand Down

0 comments on commit b07e011

Please sign in to comment.