-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from AutoResearch/carlosg/genargs
feat: Add arguments for model parameters
- Loading branch information
Showing
8 changed files
with
273 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%load_ext autoreload\n", | ||
"%autoreload 2\n", | ||
"from autora.doc.runtime.predict_hf import Predictor\n", | ||
"from autora.doc.runtime.prompts import INSTR, SYS, InstructionPrompts, SystemPrompts" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# model = \"../../models\" # if model has been previously downloaded via huggingface-cli\n", | ||
"model = \"meta-llama/Llama-2-7b-chat-hf\"\n", | ||
"pred = Predictor(model)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"TEST_CODE = \"\"\"\n", | ||
"from sweetpea import *\n", | ||
"from sweetpea.primitives import *\n", | ||
"\n", | ||
"number_list = [125, 132, 139, 146, 160, 167, 174, 181]\n", | ||
"letter_list = ['b', 'd', 'f', 'h', 's', 'u', 'w', 'y']\n", | ||
"\n", | ||
"number = Factor(\"number\", number_list)\n", | ||
"letter = Factor(\"letter\", letter_list)\n", | ||
"task = Factor(\"task\", [\"number task\", \"letter task\", \"free choice task\"])\n", | ||
"\n", | ||
"\n", | ||
"def is_forced_trial_switch(task):\n", | ||
" return (task[-1] == \"number task\" and task[0] == \"letter task\") or \\\n", | ||
" (task[-1] == \"letter task\" and task[0] == \"number task\")\n", | ||
"\n", | ||
"\n", | ||
"def is_forced_trial_repeat(task):\n", | ||
" return (task[-1] == \"number task\" and task[0] == \"number task\") or \\\n", | ||
" (task[-1] == \"letter task\" and task[0] == \"letter task\")\n", | ||
"\n", | ||
"\n", | ||
"def is_free_trial_transition(task):\n", | ||
" return task[-1] != \"free choice task\" and task[0] == \"free choice task\"\n", | ||
"\n", | ||
"\n", | ||
"def is_free_trial_repeat(task):\n", | ||
" return task[-1] == \"free choice task\" and task[0] == \"free choice task\"\n", | ||
"\n", | ||
"\n", | ||
"def is_not_relevant_transition(task):\n", | ||
" return not (is_forced_trial_repeat(task) or is_forced_trial_switch(task) or is_free_trial_repeat(\n", | ||
" task) or is_free_trial_transition(task))\n", | ||
"\n", | ||
"\n", | ||
"transit = Factor(\"task transition\", [\n", | ||
" DerivedLevel(\"forced switch\", transition(is_forced_trial_switch, [task]), 3),\n", | ||
" DerivedLevel(\"forced repeat\", transition(is_forced_trial_repeat, [task])),\n", | ||
" DerivedLevel(\"free transition\", transition(is_free_trial_transition, [task]), 4),\n", | ||
" DerivedLevel(\"free repeat\", transition(is_free_trial_repeat, [task]), 4),\n", | ||
" DerivedLevel(\"forced first\", transition(is_not_relevant_transition, [task]), 4)\n", | ||
"])\n", | ||
"design = [letter, number, task, transit]\n", | ||
"crossing = [[letter], [number], [transit]]\n", | ||
"constraints = [MinimumTrials(256)]\n", | ||
"\n", | ||
"block = MultiCrossBlock(design, crossing, constraints)\n", | ||
"\n", | ||
"experiment = synthesize_trials(block, 1)\n", | ||
"\n", | ||
"save_experiments_csv(block, experiment, 'code_1_sequences/seq')\n", | ||
"\"\"\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"output = pred.predict(\n", | ||
" SYS[SystemPrompts.SYS_1],\n", | ||
" INSTR[InstructionPrompts.INSTR_SWEETP_EXAMPLE],\n", | ||
" [TEST_CODE],\n", | ||
" temperature=0.05,\n", | ||
" top_k=10,\n", | ||
" num_ret_seq=3,\n", | ||
")[0]\n", | ||
"for i, o in enumerate(output):\n", | ||
" print(f\"******** Output {i} ********\\n{o}*************\\n\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "autodoc", | ||
"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.8.18" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.