Skip to content

Instantly share code, notes, and snippets.

@uogbuji
Created July 10, 2023 14:58
Show Gist options
  • Save uogbuji/a302619053754a198b7cbe5f097f2793 to your computer and use it in GitHub Desktop.
Save uogbuji/a302619053754a198b7cbe5f097f2793 to your computer and use it in GitHub Desktop.
Jupyter Notebook Experiment: Trying out orca_mini_v2_13b LLM
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "36653f03",
"metadata": {},
"source": [
"Trying out [orca_mini_v2_13b/GGML](https://huggingface.co/TheBloke/orca_mini_v2_13b-GGML). Downloaded as follows:\n",
"```sh\n",
"python download-model.py --output . --select=\"orca_mini_v2_13b.ggmlv3.q4_K_M.bin|orca_mini_v2_13b.ggmlv3.q5_K_M.bin\" TheBloke/orca_mini_v2_13b-GGML\n",
"```\n",
"\n",
"Model card suggests the following prompt template:\n",
"\n",
"```\n",
"### System:\n",
"You are an AI assistant that follows instruction extremely well. Help as much as you can.\n",
"\n",
"### User:\n",
"prompt\n",
"\n",
"### Input:\n",
"input, if required\n",
"\n",
"### Response:\n",
"```\n",
"\n",
"Which is I think is its own style(?). Of course there are plenty of examples in the [training data](https://huggingface.co/datasets/psmathur/orca_minis_uncensored_dataset)."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "6c8fda5c",
"metadata": {},
"outputs": [],
"source": [
"from functools import partial\n",
"from ogbujipt.config import openai_emulation\n",
"from ogbujipt.prompting.basic import context_build\n",
"from ogbujipt.prompting.model_style import ORCA_DELIMITERS\n",
"\n",
"HOST, PORT = 'http://localhost', '8000'\n",
"\n",
"openai_api = openai_emulation(host=HOST, port=PORT)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "1f9abcfd",
"metadata": {},
"outputs": [],
"source": [
"request = partial(openai_api.Completion.create, model='', temperature=0.1, max_tokens=100)\n",
"\n",
"BAD_XML_CODE = '''\\\n",
"<earth>\n",
"<country><b>Russia</country></b>\n",
"<capital>Moscow</capital>\n",
"</Earth>'''\n",
"\n",
"prompt = context_build(\n",
" 'Correct the given XML to make it well-formed',\n",
" contexts=BAD_XML_CODE,\n",
" delimiters=ORCA_DELIMITERS)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a79b97d0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
"<earth>\n",
" <country>\n",
" <b>Russia</b>\n",
" </country>\n",
" <capital>Moscow</capital>\n",
"</earth>\n"
]
}
],
"source": [
"response = request(prompt=prompt)\n",
"print(response['choices'][0]['text'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8a068365",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment