Skip to content

Commit

Permalink
Merge pull request #4 from zhafen/ml_exploration
Browse files Browse the repository at this point in the history
Refactor and fix Cartographer.expand, add .model to gitignore, and additional scratch work
  • Loading branch information
nathimel authored Mar 27, 2024
2 parents a6f0cb9 + be6f89a commit ef1e20f
Show file tree
Hide file tree
Showing 6 changed files with 473 additions and 23 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,9 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Only include models if forced
*.model

# Only include vscode settings if forced.
.vscode/settings.json
2 changes: 1 addition & 1 deletion src/examples/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@
" atl=atl,\n",
" crt=crt,\n",
" atlas_dir=\"atlas\",\n",
" target_size=1000,\n",
" target_size=10000,\n",
" center=atl.center,\n",
")"
]
Expand Down
134 changes: 134 additions & 0 deletions src/examples/scratch/hf_custom_endpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example Notebook for Integrating with Hugging Face"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Setup"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import huggingface_hub as hfhub"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Settings\n",
"endpoint_name=\"my-endpoint-name\"\n",
"endpoint_config = dict(\n",
" repository=\"gpt2\",\n",
" framework=\"pytorch\",\n",
" task=\"text-generation\",\n",
" accelerator=\"gpu\",\n",
" vendor=\"aws\",\n",
" region=\"us-east-1\",\n",
" type=\"protected\",\n",
" instance_size=\"small\",\n",
" instance_type=\"c6i\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Login\n",
"token = hfhub.get_token()\n",
"if token is None:\n",
" hfhub.login()\n",
" token = hfhub.get_token()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# get or create endpoint\n",
"endpoint_names = [\n",
" _.name for _ in hfhub.list_inference_endpoints(namespace=\"*\")\n",
"]\n",
"if endpoint_name in endpoint_names:\n",
" endpoint = hfhub.get_inference_endpoint(endpoint_name)\n",
"else:\n",
" endpoint = hfhub.create_inference_endpoint(endpoint_name, **endpoint_config)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Start the endpoint up\n",
"endpoint.wait()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"endpoint.client.text_generation(\"I am\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Shut down\n",
"endpoint.pause()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "llm",
"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.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit ef1e20f

Please sign in to comment.