Skip to content

Commit

Permalink
Merge pull request #167 from dwmorris11/defaults
Browse files Browse the repository at this point in the history
fix: added defaults.  mistral added to layer.py
  • Loading branch information
jamescalam authored Feb 23, 2024
2 parents bad9d46 + bcdebc8 commit 550e159
Show file tree
Hide file tree
Showing 16 changed files with 1,602 additions and 1,211 deletions.
932 changes: 634 additions & 298 deletions coverage.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/05-local-execution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
" n_gpu_layers=-1 if enable_gpu else 0,\n",
" n_ctx=2048,\n",
")\n",
"_llm.verbose=False\n",
"_llm.verbose = False\n",
"llm = LlamaCppLLM(name=\"Mistral-7B-v0.2-Instruct\", llm=_llm, max_tokens=None)\n",
"\n",
"rl = RouteLayer(encoder=encoder, routes=routes, llm=llm)"
Expand Down
26 changes: 18 additions & 8 deletions docs/encoders/vision-transformer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@
"from datasets import load_dataset\n",
"\n",
"images = load_dataset(\"aurelio-ai/shrek-detection\")\n",
"shrek_entries = filter(lambda entry: entry[\"is_shrek\"], images[\"train\"]) # We only want Shrek images for our route\n",
"shrek_entries = filter(\n",
" lambda entry: entry[\"is_shrek\"], images[\"train\"]\n",
") # We only want Shrek images for our route\n",
"shrek_images = list(map(lambda entry: entry[\"image\"], shrek_entries))\n",
"shrek_images"
]
Expand All @@ -95,10 +97,7 @@
"source": [
"from semantic_router import Route\n",
"\n",
"shrek = Route(\n",
" name=\"shrek\",\n",
" utterances=shrek_images\n",
")\n",
"shrek = Route(name=\"shrek\", utterances=shrek_images)\n",
"\n",
"routes = [shrek]"
]
Expand Down Expand Up @@ -131,7 +130,9 @@
"source": [
"from semantic_router.encoders import VitEncoder\n",
"\n",
"encoder = VitEncoder(device=\"mps\") # Using MBP Metal acceleration (for other platforms, please see https://pytorch.org/docs/stable/tensor_attributes.html#torch.device)"
"encoder = VitEncoder(\n",
" device=\"mps\"\n",
") # Using MBP Metal acceleration (for other platforms, please see https://pytorch.org/docs/stable/tensor_attributes.html#torch.device)"
]
},
{
Expand Down Expand Up @@ -179,12 +180,21 @@
"\n",
"from PIL import Image\n",
"\n",
"\n",
"def load_img(url):\n",
" resp = requests.get(url)\n",
" return Image.open(BytesIO(resp.content))\n",
"\n",
"test_shrek = load_img(\"https://static.wikia.nocookie.net/dreamworks/images/6/67/Shrek_Profile.jpg/revision/latest/thumbnail/width/360/height/360?cb=20231223041813\")\n",
"test_not_shrek = list(map(lambda entry: entry[\"image\"], filter(lambda entry: not entry[\"is_shrek\"], images[\"train\"])))[0]"
"\n",
"test_shrek = load_img(\n",
" \"https://static.wikia.nocookie.net/dreamworks/images/6/67/Shrek_Profile.jpg/revision/latest/thumbnail/width/360/height/360?cb=20231223041813\"\n",
")\n",
"test_not_shrek = list(\n",
" map(\n",
" lambda entry: entry[\"image\"],\n",
" filter(lambda entry: not entry[\"is_shrek\"], images[\"train\"]),\n",
" )\n",
")[0]"
]
},
{
Expand Down
Loading

0 comments on commit 550e159

Please sign in to comment.