Skip to content

Instantly share code, notes, and snippets.

@tcapelle
Created May 2, 2023 20:01
Show Gist options
  • Select an option

  • Save tcapelle/ed65beafb13e8ea1bb2cd2287ff2e05e to your computer and use it in GitHub Desktop.

Select an option

Save tcapelle/ed65beafb13e8ea1bb2cd2287ff2e05e to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "11a8c250-4a31-48da-a106-db5120aff42b",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"!pip install -qqq \"langchain==0.0.147\""
]
},
{
"cell_type": "code",
"execution_count": 175,
"id": "153ac224-2a2f-414b-a38b-cad3faff90bd",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from pathlib import Path\n",
"from langchain.document_loaders import TextLoader\n",
"from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
"from rich.markdown import Markdown"
]
},
{
"cell_type": "code",
"execution_count": 176,
"id": "c05c11c3-8944-4c7c-b823-860dafe1c42e",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"docs_path = Path(\"./docs/\")\n",
"md_files = list(docs_path.rglob(\"*.md\"))\n",
"md_files.sort()"
]
},
{
"cell_type": "code",
"execution_count": 177,
"id": "5543fe21-4b3c-423b-bd97-b7552868f9a3",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"[PosixPath('docs/guides/app/features/anon.md'),\n",
" PosixPath('docs/guides/app/features/custom-charts/intro.md'),\n",
" PosixPath('docs/guides/app/features/custom-charts/walkthrough.md'),\n",
" PosixPath('docs/guides/app/features/intro.md'),\n",
" PosixPath('docs/guides/app/features/notes.md')]"
]
},
"execution_count": 177,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"md_files[0:5]"
]
},
{
"cell_type": "code",
"execution_count": 178,
"id": "7529a1d0-468e-44a5-aeba-56ca57277ad5",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"one_file = md_files[0]"
]
},
{
"cell_type": "code",
"execution_count": 179,
"id": "3455304a-273e-4f12-8d49-088f57fd247a",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"data = TextLoader(one_file)"
]
},
{
"cell_type": "code",
"execution_count": 180,
"id": "4746ae20-3604-42b4-a03c-1fd12243bdfc",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #808000; text-decoration-color: #808000\">───────────────────────────────────────────────────────────────────────────────────────────────────────────────────</span>\n",
"\n",
" <span style=\"font-weight: bold; text-decoration: underline\">description: Log and visualize data without a W&amp;B account</span> \n",
"\n",
"╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n",
"║ <span style=\"font-weight: bold\">Anonymous Mode</span> ║\n",
"╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n",
"\n",
"Are you publishing code that you want anyone to be able to run easily? Use Anonymous Mode to let someone run your \n",
"code, see a W&amp;B dashboard, and visualize results without needing to create a Weights &amp; Biases account first. \n",
"\n",
"Allow results to be logged in Anonymous Mode with <span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000\">wandb.init(</span><span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000; font-weight: bold\">anonymous=\"allow\"</span><span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000\">)</span> \n",
"\n",
":::info <span style=\"font-weight: bold\">Publishing a paper?</span> Please <a href=\"https://docs.wandb.ai/company/academics#bibtex-citation\" target=\"_blank\"><span style=\"color: #0000ff; text-decoration-color: #0000ff\">cite W&amp;B</span></a>, and if you have questions about how to make your code accessible while\n",
"using W&amp;B, reach out to us at [email protected]. ::: \n",
"\n",
" <span style=\"font-weight: bold\">How does someone without an account see results?</span> \n",
"\n",
"If someone runs your script and you have to set <span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000\">anonymous=\"allow\"</span>: \n",
"\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">Auto-create temporary account:</span> W&amp;B checks for an account that's already signed in. If there's no account, we \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>automatically create a new anonymous account and save that API key for the session. \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">Log results quickly:</span> The user can run and re-run the script, and automatically see results show up in the W&amp;B \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>dashboard UI. These unclaimed anonymous runs will be available for 7 days. \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">Claim data when it's useful</span>: Once the user finds valuable results in W&amp;B, they can easily click a button in the \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>banner at the top of the page to save their run data to a real account. If they don't claim a run, it will be \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>deleted after 7 days. \n",
"\n",
":::caution <span style=\"font-weight: bold\">Anonymous run links are sensitive</span>. These links allow anyone to view and claim the results of an \n",
"experiment for 7 days, so make sure to only share links with people you trust. If you're trying to share results \n",
"publicly, but hide the author's identity, please contact us at [email protected] to share more about your use case.\n",
"::: \n",
"\n",
" <span style=\"font-weight: bold\">What happens to users with existing accounts?</span> \n",
"\n",
"If you set <span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000\">anonymous=\"allow\"</span> in your script, we will check to make sure there's not an existing account first, \n",
"before creating an anonymous account. This means that if a W&amp;B user finds your script and runs it, their results \n",
"will be logged correctly to their account, just like a normal run. \n",
"\n",
" <span style=\"font-weight: bold\">What are features that aren't available to anonymous users?</span> \n",
"\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">No persistent data</span>: Runs are only saved for 7 days in an anonymous account. Users can claim anonymous run data \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>by saving it to a real account. \n",
"\n",
"🌆 <a href=\"@site/static/images/app_ui/anon_mode_no_data.png\" target=\"_blank\">anon_mode_no_data.png</a> \n",
"\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">No artifact logging</span>: Runs will print a warning on the command line that you can't log an artifact to an \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>anonymous run. \n",
"\n",
"🌆 <a href=\"@site/static/images/app_ui/anon_example_warning.png\" target=\"_blank\">anon_example_warning.png</a> \n",
"\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">No profile or settings pages</span>: Certain pages aren't available in the UI, because they're only useful for real \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>accounts. \n",
"\n",
"\n",
" <span style=\"font-weight: bold; text-decoration: underline\">Example usage</span> \n",
"\n",
"<a href=\"http://bit.ly/anon-mode\" target=\"_blank\"><span style=\"color: #0000ff; text-decoration-color: #0000ff\">Try the example notebook</span></a> to see how anonymous mode works. \n",
"\n",
"<span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">import</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> wandb</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #75715e; text-decoration-color: #75715e; background-color: #272822\"># Start a run allowing anonymous accounts</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">wandb</span><span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">init(anonymous</span><span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">=</span><span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">\"allow\"</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">)</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #75715e; text-decoration-color: #75715e; background-color: #272822\"># Log results from your training loop</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">wandb</span><span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">log({</span><span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">\"acc\"</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">: </span><span style=\"color: #ae81ff; text-decoration-color: #ae81ff; background-color: #272822\">0.91</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">})</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #75715e; text-decoration-color: #75715e; background-color: #272822\"># Mark the run as finished</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">wandb</span><span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">finish()</span><span style=\"background-color: #272822\"> </span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[33m───────────────────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n",
"\n",
" \u001b[1;4mdescription: Log and visualize data without a W\u001b[0m\u001b[1;4m&\u001b[0m\u001b[1;4mB account\u001b[0m \n",
"\n",
"╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n",
"║ \u001b[1mAnonymous Mode\u001b[0m ║\n",
"╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n",
"\n",
"Are you publishing code that you want anyone to be able to run easily? Use Anonymous Mode to let someone run your \n",
"code, see a W&B dashboard, and visualize results without needing to create a Weights & Biases account first. \n",
"\n",
"Allow results to be logged in Anonymous Mode with \u001b[97;40mwandb.init(\u001b[0m\u001b[1;97;40manonymous=\"allow\"\u001b[0m\u001b[97;40m)\u001b[0m \n",
"\n",
":::info \u001b[1mPublishing a paper?\u001b[0m Please \u001b]8;id=155027;https://docs.wandb.ai/company/academics#bibtex-citation\u001b\\\u001b[94mcite W\u001b[0m\u001b]8;;\u001b\\\u001b]8;id=155027;https://docs.wandb.ai/company/academics#bibtex-citation\u001b\\\u001b[94m&\u001b[0m\u001b]8;;\u001b\\\u001b]8;id=155027;https://docs.wandb.ai/company/academics#bibtex-citation\u001b\\\u001b[94mB\u001b[0m\u001b]8;;\u001b\\, and if you have questions about how to make your code accessible while\n",
"using W&B, reach out to us at [email protected]. ::: \n",
"\n",
" \u001b[1mHow does someone without an account see results?\u001b[0m \n",
"\n",
"If someone runs your script and you have to set \u001b[97;40manonymous=\"allow\"\u001b[0m: \n",
"\n",
"\u001b[1;33m 1 \u001b[0m\u001b[1mAuto-create temporary account:\u001b[0m W&B checks for an account that's already signed in. If there's no account, we \n",
"\u001b[1;33m \u001b[0mautomatically create a new anonymous account and save that API key for the session. \n",
"\u001b[1;33m 2 \u001b[0m\u001b[1mLog results quickly:\u001b[0m The user can run and re-run the script, and automatically see results show up in the W&B \n",
"\u001b[1;33m \u001b[0mdashboard UI. These unclaimed anonymous runs will be available for 7 days. \n",
"\u001b[1;33m 3 \u001b[0m\u001b[1mClaim data when it\u001b[0m\u001b[1m'\u001b[0m\u001b[1ms useful\u001b[0m: Once the user finds valuable results in W&B, they can easily click a button in the \n",
"\u001b[1;33m \u001b[0mbanner at the top of the page to save their run data to a real account. If they don't claim a run, it will be \n",
"\u001b[1;33m \u001b[0mdeleted after 7 days. \n",
"\n",
":::caution \u001b[1mAnonymous run links are sensitive\u001b[0m. These links allow anyone to view and claim the results of an \n",
"experiment for 7 days, so make sure to only share links with people you trust. If you're trying to share results \n",
"publicly, but hide the author's identity, please contact us at [email protected] to share more about your use case.\n",
"::: \n",
"\n",
" \u001b[1mWhat happens to users with existing accounts?\u001b[0m \n",
"\n",
"If you set \u001b[97;40manonymous=\"allow\"\u001b[0m in your script, we will check to make sure there's not an existing account first, \n",
"before creating an anonymous account. This means that if a W&B user finds your script and runs it, their results \n",
"will be logged correctly to their account, just like a normal run. \n",
"\n",
" \u001b[1mWhat are features that aren\u001b[0m\u001b[1m'\u001b[0m\u001b[1mt available to anonymous users?\u001b[0m \n",
"\n",
"\u001b[1;33m • \u001b[0m\u001b[1mNo persistent data\u001b[0m: Runs are only saved for 7 days in an anonymous account. Users can claim anonymous run data \n",
"\u001b[1;33m \u001b[0mby saving it to a real account. \n",
"\n",
"🌆 \u001b]8;id=216123;@site/static/images/app_ui/anon_mode_no_data.png\u001b\\anon_mode_no_data.png\u001b]8;;\u001b\\ \n",
"\n",
"\u001b[1;33m • \u001b[0m\u001b[1mNo artifact logging\u001b[0m: Runs will print a warning on the command line that you can't log an artifact to an \n",
"\u001b[1;33m \u001b[0manonymous run. \n",
"\n",
"🌆 \u001b]8;id=159480;@site/static/images/app_ui/anon_example_warning.png\u001b\\anon_example_warning.png\u001b]8;;\u001b\\ \n",
"\n",
"\u001b[1;33m • \u001b[0m\u001b[1mNo profile or settings pages\u001b[0m: Certain pages aren't available in the UI, because they're only useful for real \n",
"\u001b[1;33m \u001b[0maccounts. \n",
"\n",
"\n",
" \u001b[1;4mExample usage\u001b[0m \n",
"\n",
"\u001b]8;id=778846;http://bit.ly/anon-mode\u001b\\\u001b[94mTry the example notebook\u001b[0m\u001b]8;;\u001b\\ to see how anonymous mode works. \n",
"\n",
"\u001b[38;2;249;38;114;48;2;39;40;34mimport\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mwandb\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;117;113;94;48;2;39;40;34m# Start a run allowing anonymous accounts\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;248;248;242;48;2;39;40;34mwandb\u001b[0m\u001b[38;2;249;38;114;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34minit\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34manonymous\u001b[0m\u001b[38;2;249;38;114;48;2;39;40;34m=\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34mallow\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;117;113;94;48;2;39;40;34m# Log results from your training loop\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;248;248;242;48;2;39;40;34mwandb\u001b[0m\u001b[38;2;249;38;114;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mlog\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m{\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34macc\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m:\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;174;129;255;48;2;39;40;34m0.91\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m}\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;117;113;94;48;2;39;40;34m# Mark the run as finished\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;248;248;242;48;2;39;40;34mwandb\u001b[0m\u001b[38;2;249;38;114;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mfinish\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n"
]
},
"execution_count": 180,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"docs = data.load()\n",
"Markdown(docs[0].page_content)"
]
},
{
"cell_type": "markdown",
"id": "16fa1c99-77b2-4a8c-ba7e-aa915d901b31",
"metadata": {},
"source": [
"Would love to actually use `MarkdownTextSplitter` here but it removes syntax symbols from the file (like the \\# headers and even code blocks sometimes)"
]
},
{
"cell_type": "code",
"execution_count": 182,
"id": "652f12c9-29dd-44d5-b590-42cac0ed6456",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"markdown_splitter = RecursiveCharacterTextSplitter(\n",
" separators=[\"\\n\\n\",\"\\n\",\" \"],\n",
" chunk_size=500, \n",
" chunk_overlap=0)"
]
},
{
"cell_type": "code",
"execution_count": 183,
"id": "5c3dfbac-c486-4ee3-9e5f-a3869ba49b99",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"split_docs = markdown_splitter.split_documents(docs)"
]
},
{
"cell_type": "code",
"execution_count": 184,
"id": "c6140829-8b9e-45b1-8959-2ea50d5da916",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"8"
]
},
"execution_count": 184,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(split_docs)"
]
},
{
"cell_type": "code",
"execution_count": 185,
"id": "2718f621-466e-4b23-9150-88b486749612",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"'---\\ndescription: Log and visualize data without a W&B account\\n---\\n\\n# Anonymous Mode\\n\\nAre you publishing code that you want anyone to be able to run easily? Use Anonymous Mode to let someone run your code, see a W&B dashboard, and visualize results without needing to create a Weights & Biases account first.\\n\\nAllow results to be logged in Anonymous Mode with `wandb.init(`**`anonymous=\"allow\"`**`)`'"
]
},
"execution_count": 185,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"split_docs[0].page_content"
]
},
{
"cell_type": "code",
"execution_count": 186,
"id": "2acebd78-bde2-4025-800f-270c9af6a4fd",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"':::info\\n**Publishing a paper?** Please [cite W&B](https://docs.wandb.ai/company/academics#bibtex-citation), and if you have questions about how to make your code accessible while using W&B, reach out to us at [email protected].\\n:::\\n\\n### How does someone without an account see results?\\n\\nIf someone runs your script and you have to set `anonymous=\"allow\"`:'"
]
},
"execution_count": 186,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"split_docs[1].page_content"
]
},
{
"cell_type": "markdown",
"id": "77cc3d23-24c7-4680-ae69-6d7b8f401da2",
"metadata": {},
"source": [
"## Prompt Setup"
]
},
{
"cell_type": "code",
"execution_count": 192,
"id": "2a8a98d9-4bd6-4c64-b91c-21d4d61997b9",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# MODEL_NAME = 'gpt-4'\n",
"MODEL_NAME = 'gpt-3.5-turbo'"
]
},
{
"cell_type": "code",
"execution_count": 193,
"id": "2b363190-6640-45de-8bd9-2c6aa3f96402",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from langchain.chat_models import ChatOpenAI\n",
"from langchain import PromptTemplate, LLMChain\n",
"from langchain.prompts.chat import (\n",
" ChatPromptTemplate,\n",
" SystemMessagePromptTemplate,\n",
" HumanMessagePromptTemplate,\n",
")\n",
"from langchain.schema import (\n",
" HumanMessage,\n",
" SystemMessage\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 194,
"id": "fea2f8f8-a602-43a5-ba13-f74bfce9b5b9",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"chat = ChatOpenAI(model_name=MODEL_NAME)"
]
},
{
"cell_type": "code",
"execution_count": 195,
"id": "d14cfb69-cb3a-4932-b8ef-3381c8ba6ac4",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"system_template = \"\"\"You are a translation assistant from {input_language} to {output_language}. Some rules to remember:\n",
"- Do not add extra blank lines.\n",
"- The results must be valid markdown\n",
"- It is important to maintain the accuracy of the contents but we don't want the output to read like it's been translated. So instead of translating word by word, prioritize naturalness and ease of communication.\n",
"- In code blocks, just translate the comments and leave the code as is.\n",
"Here is the translation dictionary for domain specific words:\n",
"- Use the dictionary where you see appropriate.\n",
"<Dictionary start>\n",
"{input_language}: {output_language}\n",
"{dictionary}\n",
"<End of Dictionary>\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 196,
"id": "97b1f3c2-55f7-40d6-9ebe-b3a24e2ab390",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"dictionary=\"\"\"\\\n",
"access: アクセス\n",
"accuracy plot: 精度図\n",
"address: アドレス\n",
"alias: エイリアス\n",
"analysis: 分析\n",
"API key: APIキー\n",
"application:アプリケーション\n",
"architecture: アーキテクチャー\n",
"arg: ARG\n",
"argument: 引数\n",
"artifact: アーティファクト\n",
"assignment: 課題\n",
"autonomous vehicle: 自動運転車\n",
"AV model: AVモデル\n",
"backup: バックアップ\n",
"baseline: ベースライン\n",
"Bayesian search: ベイズ探索\n",
"behavior :振る舞い\n",
"bias: バイアス\n",
"blog: ブログ\n",
"bucket: バケット\n",
"business context: ビジネスコンテキスト\n",
"chatbot: チャットボット\n",
"checkpoint: チェックポイント\n",
"cloud: クラウド\n",
"cluster:クラスター\n",
"Colab notebook: Colabノートブック\n",
"computer vision: コンピュータビジョン\n",
"configuration: 設定\n",
"convolutional block: 畳み込みブロック\n",
"course: コース\n",
"customer case study: 顧客ケーススタディ\n",
"cutting-edge: 最先端の\n",
"dashboard: ダッシュボード\n",
"data: データ\n",
"data leakage: データ漏洩\n",
"data obfuscation: データ難読化\n",
"data visualization: データ可視化\n",
"dataset: データセット\n",
"dataset-agnostic: データセットに依存しない\n",
"deep learning: ディープラーニング\n",
"demo: デモ\n",
"deployment:\t展開\n",
"directory: ディレクトリー\n",
"docker container: dockerコンテナ\n",
"ecosystem: エコシステム\n",
"edge case: 極端なケース\n",
"end-to-end: エンドツーエンド\n",
"environment: 環境\n",
"epoch: エポック\n",
"experiment: 実験\n",
"fine-tune: 微調整\n",
"forward pass: forwardパス\n",
"ground truth: 正解\n",
"guide: ガイド\n",
"hook: フック\n",
"host flag: ホストフラグ\n",
"Hugging Face Transformer: Hugging Faceトランスフォーマー\n",
"hyperparameter: ハイパーパラメーター\n",
"hyperparameter sweep: ハイパーパラメーター探索\n",
"hyperparameter tuning: ハイパーパラメータチューニング\n",
"infrastructure: インフラストラクチャー\n",
"key: キー\n",
"library: ライブラリ\n",
"line of code: (抜き出し方が良くないが)\"couple lines of code\" で 「コード2行」となる\n",
"lineage: 履歴\n",
"local minima: 局所的最小値\n",
"log: ログ\n",
"machine learning: 機械学習\n",
"machine learning practitioner: 機械学習開発者\n",
"metadata: メタデータ\n",
"method: メソッド\n",
"metrics: メトリクス\n",
"ML practitioner: MLエンジニア\n",
"model: モデル\n",
"model evolution: モデルの進化\n",
"model lineage: モデルの履歴\n",
"model management: モデル管理\n",
"model registry: モデルレジストリ\n",
"model training: モデルトレーニング\n",
"neural network: ニューラルネットワーク\n",
"noising: ノイジング\n",
"notebook: ノートブック\n",
"object: オブジェクト\n",
"on-prem: オンプレミス\n",
"Optimizer: オプティマイザー\n",
"orchestration: オーケストレーション\n",
"overfitting: 過学習\n",
"pipeline: 開発フロー\n",
"platform: プラットフォーム\n",
"population based training: 集団的学習\n",
"precision-recall curve: PR曲線\n",
"pre-trained: 学習済み\n",
"private cloud: プライベートクラウド\n",
"process: プロセス\n",
"processing: 処理する\n",
"production: プロダクション\n",
"project: プロジェクト\n",
"Quickstart: クイックスタート\n",
"recommender system: 推薦システム\n",
"reinforcement learning: 強化学習\n",
"report: レポート\n",
"reproducibility:再現性\n",
"result: 結果\n",
"run: run\n",
"runs: runs\n",
"SaaS: SaaS\n",
"script: スクリプト\n",
"semantic segmentation: セマンティックセグメンテーション\n",
"sentiment analysis: センチメント分析\n",
"server: サーバー\n",
"state assignments: 状態割り当て\n",
"subset: サブセット\n",
"support team: サポートチーム\n",
"sweep: スイープ\n",
"sweep agent: スイープエージェント\n",
"sweep configuration: スイープ構成\n",
"sweep server: スイープサーバー\n",
"system of record: 記録システム\n",
"test set: テストセット\n",
"text-to-image: text-to-image\n",
"time series: 時系列\n",
"tool: ツール\n",
"track: トラッキング\n",
"tracked hours: 追跡時間\n",
"training: トレーニング\n",
"training data: トレーニングデータ\n",
"training script: トレーニングスクリプト\n",
"trial: 試験\n",
"tune: チューニングする\n",
"use case: ユースケース\n",
"user: ユーザー\n",
"validation accuracy: 検証精度\n",
"version: バージョン\n",
"versioning: バージョン管理\n",
"W&B Fully Connected: W&B Fully Connected\n",
"wandb library: wandbライブラリ\n",
"Weave expression: Weave式\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 197,
"id": "451298b9-23b3-4663-ada3-5cfda9c35869",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"system_message_prompt = SystemMessagePromptTemplate.from_template(system_template)"
]
},
{
"cell_type": "code",
"execution_count": 198,
"id": "3f8285f3-0e39-47f4-86a4-87b2fecb4c73",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"human_template = \"Here is a chunk of Markdown text to translate. Return the translated text only, without adding anything else. Text: \\n {text}\"\n",
"human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)"
]
},
{
"cell_type": "code",
"execution_count": 199,
"id": "4754a459-a979-496a-afff-a261139995a2",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt])"
]
},
{
"cell_type": "markdown",
"id": "b1f579e3-854a-4606-9de6-b027b78a6764",
"metadata": {},
"source": [
"You could translate just doing this:"
]
},
{
"cell_type": "code",
"execution_count": 200,
"id": "f2d23fbc-190b-422b-9327-91e2706b3ae0",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"translating chunk 1/8...\n",
"translating chunk 2/8...\n",
"translating chunk 3/8...\n",
"translating chunk 4/8...\n",
"translating chunk 5/8...\n",
"translating chunk 6/8...\n",
"translating chunk 7/8...\n",
"translating chunk 8/8...\n"
]
}
],
"source": [
"translated_docs = []\n",
"for i, chunk in enumerate(split_docs):\n",
" print(f\"translating chunk {i+1}/{len(split_docs)}...\")\n",
" prompt = chat_prompt.format_prompt(\n",
" input_language=\"English\", \n",
" output_language=\"Japanese\", \n",
" dictionary=dictionary,\n",
" text=chunk.page_content)\n",
" \n",
" # get a chat completion from the formatted messages\n",
" translated_docs.append(chat(prompt.to_messages()))"
]
},
{
"cell_type": "markdown",
"id": "2db123f7-0f01-4400-874d-8970d98bbd57",
"metadata": {},
"source": [
"Or on a batched way..."
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "07469d0e-2e9e-44dd-b9a7-156f12fcec4f",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"batched_messages = [\n",
" chat_prompt.format_prompt(\n",
" input_language=\"English\", \n",
" output_language=\"Japanese\", \n",
" dictionary=dictionary,\n",
" text=chunk.page_content).to_messages() \n",
" for chunk in split_docs\n",
"]"
]
},
{
"cell_type": "markdown",
"id": "e695395a-8706-4796-bcfe-fa7b8a06b694",
"metadata": {},
"source": [
"Let's joind back the pieces:"
]
},
{
"cell_type": "code",
"execution_count": 201,
"id": "da906e79-2be8-46de-a701-ff8d395bc7fa",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"md_res = \"\\n\".join([gen[0].text for gen in res.generations])"
]
},
{
"cell_type": "code",
"execution_count": 202,
"id": "ce4fbdae-e1fc-44f6-882a-b57e9bfa650c",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #808000; text-decoration-color: #808000\">───────────────────────────────────────────────────────────────────────────────────────────────────────────────────</span>\n",
"\n",
" <span style=\"font-weight: bold; text-decoration: underline\">description: Weights &amp; Biasesアカウントを作成せずにログとデータを視覚化する</span> \n",
"\n",
"╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n",
"║ <span style=\"font-weight: bold\">匿名モード</span> ║\n",
"╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n",
"\n",
"誰でも簡単に実行できるようにコードを公開する場合は、匿名モードを使用して、Weights &amp; \n",
"Biasesアカウントを作成することなく、W&amp;Bダッシュボードを見て、結果を視覚化することができます。 \n",
"\n",
"結果を匿名モードでログに記録するには、 <span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000\">wandb.init(</span><span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000; font-weight: bold\">anonymous=\"allow\"</span><span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000\">)</span> を使用してください。 \n",
"\n",
":::info \n",
"<span style=\"font-weight: bold\">論文を発表する場合</span>は、<a href=\"https://docs.wandb.ai/company/academics#bibtex-citation\" target=\"_blank\"><span style=\"color: #0000ff; text-decoration-color: #0000ff\">W&amp;Bを引用</span></a>してください。W&amp;Bを使用しながらコードをアクセス可能にする方法についての質問がある場 \n",
"[email protected]にお問い合わせください。 ::: \n",
"\n",
" <span style=\"font-weight: bold\">アカウントを持っていない人が結果をどのように見るのですか?</span> \n",
"\n",
"もし、あなたがスクリプトを実行するために <span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000\">anonymous=\"allow\"</span> を設定する必要がある場合: \n",
"\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">一時アカウントの自動作成:</span> \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>W&amp;Bは、すでにサインインしているアカウントを確認します。アカウントがない場合は、新しい匿名アカウントが自動的に作 \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>成され、そのAPIキーがセッションに保存されます。 \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">高速にログを記録:</span> \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>ユーザーはスクリプトを実行し、何度も実行して、W&amp;BダッシュボードUIに結果が自動的に表示されるようになります。これ \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>の未確定の匿名ランは、7日間利用可能です。 \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">有用な場合にデータを請求する:</span> \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>W&amp;Bで有益な結果を見つけた場合、ユーザーはバナーのボタンをクリックして、実行データを実際のアカウントに保存でき \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>ます。実行を請求しない場合、7日後に削除されます。 \n",
"\n",
":::caution \n",
"<span style=\"font-weight: bold\">匿名実行リンクは機密情報です</span>。これらのリンクを使用すると、誰でも7日間の実験の結果を表示して請求できるため、信頼でき\n",
"を共有してください。著者の身元を隠したまま結果を公開しようとしている場合は、[email protected]にお問 \n",
"い合わせください。 ::: 既存のアカウントを持つユーザーはどうなりますか? \n",
"\n",
"スクリプトで <span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000\">anonymous=\"allow\"</span> \n",
"を設定すると、匿名アカウントを作成する前に、既存のアカウントがないかどうかを確認します。これは、W&amp;Bのユーザーが \n",
"あなたのスクリプトを見つけて実行した場合、通常のランと同様に、彼らの結果が正しく彼らのアカウントにログされることを \n",
"します。 \n",
"\n",
" <span style=\"font-weight: bold\">匿名ユーザーには利用できない機能は何ですか?</span> \n",
"\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">永続的なデータがない</span>:ランは匿名アカウントで7日間しか保存されません。ユーザーは匿名のランデータを実際のアカウン \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>トに保存することで、それを要求することができます。 \n",
"\n",
"🌆 <a href=\"@site/static/images/app_ui/anon_mode_no_data.png\" target=\"_blank\">anon_mode_no_data.png</a> \n",
"\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">アーティファクトのログがない</span>:ランはコマンドラインに警告を表示し、匿名のランにアーティファクトをログできないこと\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>を示します。 \n",
"\n",
"🌆 <a href=\"@site/static/images/app_ui/anon_example_warning.png\" target=\"_blank\">anon_example_warning.png</a> \n",
"\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">プロファイルや設定ページがない</span>:特定のページはUIで利用できません。それらは実際のアカウントにしか役立たないためで\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>す。 使用例 \n",
"\n",
"<a href=\"http://bit.ly/anon-mode\" target=\"_blank\"><span style=\"color: #0000ff; text-decoration-color: #0000ff\">例のノートブックを試してみてください</span></a>。匿名モードがどのように動作するかを確認できます。 \n",
"\n",
"<span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">import</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> wandb</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #75715e; text-decoration-color: #75715e; background-color: #272822\"># 匿名アカウントを許可して実行を開始します</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">wandb</span><span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">init(anonymous</span><span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">=</span><span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">\"allow\"</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">)</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #75715e; text-decoration-color: #75715e; background-color: #272822\"># 訓練ループの結果をログに記録します</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">wandb</span><span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">log({</span><span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">\"acc\"</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">: </span><span style=\"color: #ae81ff; text-decoration-color: #ae81ff; background-color: #272822\">0.91</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">})</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #75715e; text-decoration-color: #75715e; background-color: #272822\"># 実行を終了します</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">wandb</span><span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">finish()</span><span style=\"background-color: #272822\"> </span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[33m───────────────────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n",
"\n",
" \u001b[1;4mdescription: Weights \u001b[0m\u001b[1;4m&\u001b[0m\u001b[1;4m Biasesアカウントを作成せずにログとデータを視覚化する\u001b[0m \n",
"\n",
"╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n",
"║ \u001b[1m匿名モード\u001b[0m ║\n",
"╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n",
"\n",
"誰でも簡単に実行できるようにコードを公開する場合は、匿名モードを使用して、Weights & \n",
"Biasesアカウントを作成することなく、W&Bダッシュボードを見て、結果を視覚化することができます。 \n",
"\n",
"結果を匿名モードでログに記録するには、 \u001b[97;40mwandb.init(\u001b[0m\u001b[1;97;40manonymous=\"allow\"\u001b[0m\u001b[97;40m)\u001b[0m を使用してください。 \n",
"\n",
":::info \n",
"\u001b[1m論文を発表する場合\u001b[0mは、\u001b]8;id=203946;https://docs.wandb.ai/company/academics#bibtex-citation\u001b\\\u001b[94mW\u001b[0m\u001b]8;;\u001b\\\u001b]8;id=203946;https://docs.wandb.ai/company/academics#bibtex-citation\u001b\\\u001b[94m&\u001b[0m\u001b]8;;\u001b\\\u001b]8;id=203946;https://docs.wandb.ai/company/academics#bibtex-citation\u001b\\\u001b[94mBを引用\u001b[0m\u001b]8;;\u001b\\してください。W&Bを使用しながらコードをアクセス可能にする方法についての質問がある場 \n",
"[email protected]にお問い合わせください。 ::: \n",
"\n",
" \u001b[1mアカウントを持っていない人が結果をどのように見るのですか?\u001b[0m \n",
"\n",
"もし、あなたがスクリプトを実行するために \u001b[97;40manonymous=\"allow\"\u001b[0m を設定する必要がある場合: \n",
"\n",
"\u001b[1;33m 1 \u001b[0m\u001b[1m一時アカウントの自動作成:\u001b[0m \n",
"\u001b[1;33m \u001b[0mW&Bは、すでにサインインしているアカウントを確認します。アカウントがない場合は、新しい匿名アカウントが自動的に作 \n",
"\u001b[1;33m \u001b[0m成され、そのAPIキーがセッションに保存されます。 \n",
"\u001b[1;33m 2 \u001b[0m\u001b[1m高速にログを記録:\u001b[0m \n",
"\u001b[1;33m \u001b[0mユーザーはスクリプトを実行し、何度も実行して、W&BダッシュボードUIに結果が自動的に表示されるようになります。これ \n",
"\u001b[1;33m \u001b[0mの未確定の匿名ランは、7日間利用可能です。 \n",
"\u001b[1;33m 3 \u001b[0m\u001b[1m有用な場合にデータを請求する:\u001b[0m \n",
"\u001b[1;33m \u001b[0mW&Bで有益な結果を見つけた場合、ユーザーはバナーのボタンをクリックして、実行データを実際のアカウントに保存でき \n",
"\u001b[1;33m \u001b[0mます。実行を請求しない場合、7日後に削除されます。 \n",
"\n",
":::caution \n",
"\u001b[1m匿名実行リンクは機密情報です\u001b[0m。これらのリンクを使用すると、誰でも7日間の実験の結果を表示して請求できるため、信頼でき\n",
"を共有してください。著者の身元を隠したまま結果を公開しようとしている場合は、[email protected]にお問 \n",
"い合わせください。 ::: 既存のアカウントを持つユーザーはどうなりますか? \n",
"\n",
"スクリプトで \u001b[97;40manonymous=\"allow\"\u001b[0m \n",
"を設定すると、匿名アカウントを作成する前に、既存のアカウントがないかどうかを確認します。これは、W&Bのユーザーが \n",
"あなたのスクリプトを見つけて実行した場合、通常のランと同様に、彼らの結果が正しく彼らのアカウントにログされることを \n",
"します。 \n",
"\n",
" \u001b[1m匿名ユーザーには利用できない機能は何ですか?\u001b[0m \n",
"\n",
"\u001b[1;33m • \u001b[0m\u001b[1m永続的なデータがない\u001b[0m:ランは匿名アカウントで7日間しか保存されません。ユーザーは匿名のランデータを実際のアカウン \n",
"\u001b[1;33m \u001b[0mトに保存することで、それを要求することができます。 \n",
"\n",
"🌆 \u001b]8;id=267126;@site/static/images/app_ui/anon_mode_no_data.png\u001b\\anon_mode_no_data.png\u001b]8;;\u001b\\ \n",
"\n",
"\u001b[1;33m • \u001b[0m\u001b[1mアーティファクトのログがない\u001b[0m:ランはコマンドラインに警告を表示し、匿名のランにアーティファクトをログできないこと\n",
"\u001b[1;33m \u001b[0mを示します。 \n",
"\n",
"🌆 \u001b]8;id=219461;@site/static/images/app_ui/anon_example_warning.png\u001b\\anon_example_warning.png\u001b]8;;\u001b\\ \n",
"\n",
"\u001b[1;33m • \u001b[0m\u001b[1mプロファイルや設定ページがない\u001b[0m:特定のページはUIで利用できません。それらは実際のアカウントにしか役立たないためで\n",
"\u001b[1;33m \u001b[0mす。 使用例 \n",
"\n",
"\u001b]8;id=227637;http://bit.ly/anon-mode\u001b\\\u001b[94m例のノートブックを試してみてください\u001b[0m\u001b]8;;\u001b\\。匿名モードがどのように動作するかを確認できます。 \n",
"\n",
"\u001b[38;2;249;38;114;48;2;39;40;34mimport\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mwandb\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;117;113;94;48;2;39;40;34m# 匿名アカウントを許可して実行を開始します\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;248;248;242;48;2;39;40;34mwandb\u001b[0m\u001b[38;2;249;38;114;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34minit\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34manonymous\u001b[0m\u001b[38;2;249;38;114;48;2;39;40;34m=\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34mallow\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;117;113;94;48;2;39;40;34m# 訓練ループの結果をログに記録します\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;248;248;242;48;2;39;40;34mwandb\u001b[0m\u001b[38;2;249;38;114;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mlog\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m{\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34macc\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m:\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;174;129;255;48;2;39;40;34m0.91\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m}\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;117;113;94;48;2;39;40;34m# 実行を終了します\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;248;248;242;48;2;39;40;34mwandb\u001b[0m\u001b[38;2;249;38;114;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mfinish\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n"
]
},
"execution_count": 202,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Markdown(md_res)"
]
},
{
"cell_type": "markdown",
"id": "843cd8d3-2205-4e51-8aba-dfae635cef1d",
"metadata": {},
"source": [
"## Let's refactor as a Chain and add W&B"
]
},
{
"cell_type": "code",
"execution_count": 203,
"id": "3057eb11-1e47-414e-a7c0-5ca0f0eac6a5",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from langchain.chains import LLMChain\n",
"\n",
"from wandb.integration.langchain import WandbTracer"
]
},
{
"cell_type": "code",
"execution_count": 204,
"id": "fbba4542-b179-4c12-bcfe-7b3a6f031135",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[34m\u001b[1mwandb\u001b[0m: Streaming LangChain activity to W&B at https://wandb.ai/capecape/docs_translate/runs/dbrwxqmx\n",
"\u001b[34m\u001b[1mwandb\u001b[0m: `WandbTracer` is currently in beta.\n",
"\u001b[34m\u001b[1mwandb\u001b[0m: Please report any issues to https://github.com/wandb/wandb/issues with the tag `langchain`.\n"
]
}
],
"source": [
"WandbTracer.init({\"project\": \"docs_translate\"})"
]
},
{
"cell_type": "code",
"execution_count": 205,
"id": "60a9d1f9-7a9f-4146-b6de-fd2d5d4dbf14",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"chain = LLMChain(llm=chat, prompt=chat_prompt)"
]
},
{
"cell_type": "code",
"execution_count": 206,
"id": "78c251e8-d8c2-4896-b381-32fcd10d2148",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"translating chunk 1/8...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m Skipping model saving - unable to safely convert LangChain Model to dictionary due to: \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"translating chunk 2/8...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m Skipping model saving - unable to safely convert LangChain Model to dictionary due to: \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"translating chunk 3/8...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m Skipping model saving - unable to safely convert LangChain Model to dictionary due to: \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"translating chunk 4/8...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m Skipping model saving - unable to safely convert LangChain Model to dictionary due to: \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"translating chunk 5/8...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m Skipping model saving - unable to safely convert LangChain Model to dictionary due to: \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"translating chunk 6/8...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m Skipping model saving - unable to safely convert LangChain Model to dictionary due to: \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"translating chunk 7/8...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m Skipping model saving - unable to safely convert LangChain Model to dictionary due to: \n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"translating chunk 8/8...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[34m\u001b[1mwandb\u001b[0m: \u001b[33mWARNING\u001b[0m Skipping model saving - unable to safely convert LangChain Model to dictionary due to: \n"
]
}
],
"source": [
"translated_docs = []\n",
"for i, chunk in enumerate(split_docs):\n",
" print(f\"translating chunk {i+1}/{len(split_docs)}...\")\n",
" chain_out = chain.run(\n",
" input_language=\"English\", \n",
" output_language=\"Japanese\", \n",
" dictionary=dictionary,\n",
" text=chunk.page_content)\n",
" translated_docs += [chain_out] "
]
},
{
"cell_type": "code",
"execution_count": 208,
"id": "bb6f58ce-bc81-4847-ac58-58ae5c07465f",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"out_md = \"\\n\".join(translated_docs)"
]
},
{
"cell_type": "code",
"execution_count": 209,
"id": "c9655db4-a264-44fe-b448-e1ee92d25b51",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #808000; text-decoration-color: #808000\">───────────────────────────────────────────────────────────────────────────────────────────────────────────────────</span>\n",
"\n",
" <span style=\"font-weight: bold; text-decoration: underline\">description: W&amp;Bアカウントなしでデータを記録および可視化</span> \n",
"\n",
"╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n",
"║ <span style=\"font-weight: bold\">Anonymous Mode</span> ║\n",
"╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n",
"\n",
"誰でも簡単に実行できるようにしたいコードを公開していますか? Weights &amp; \n",
"Biasesアカウントの作成が必要なく、W&amp;Bダッシュボードを見て結果を可視化することができるAnonymous \n",
"Modeを使用してください。 \n",
"\n",
"<span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000\">wandb.init(</span><span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000; font-weight: bold\">anonymous=\"allow\"</span><span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000\">)</span>でAnonymous Modeでの結果の記録を許可します。 \n",
"\n",
" <span style=\"font-weight: bold\">アカウントを持っていない人が結果を見るにはどうすればいいですか?</span> \n",
"\n",
"もし誰かがあなたのスクリプトを実行し、<span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000\">anonymous=\"allow\"</span>を設定する必要がある場合: \n",
"\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 1 </span><span style=\"font-weight: bold\">一時アカウントを自動作成:</span> \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>W&amp;Bはすでにサインインしたアカウントを確認します。アカウントがない場合、自動的に新しい匿名アカウントを作成し、そ \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>のAPIキーをセッションに保存します。 \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 2 </span><span style=\"font-weight: bold\">素早く結果を記録:</span> \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>ユーザーはスクリプトを実行および再実行し、W&amp;BダッシュボードUIに結果が自動的に表示されるようになります。これらの \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>割り当ての匿名ランは、7日間利用可能です。 \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> 3 </span><span style=\"font-weight: bold\">役に立つときにデータを保存</span>: \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>ユーザーがW&amp;Bで価値ある結果を見つけた場合、ページの上部にあるバナーのボタンをクリックするだけで、ランデータを実 \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>際のアカウントに保存できます。保存しない場合、7日後にランデータは削除されます。 :::caution \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span><span style=\"font-weight: bold\">匿名の実行リンクには注意してください</span>。これらのリンクにより、実験の結果を誰でも7日間閲覧し、請求できるようになり \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>る人にのみリンクを共有するようにしてください。著者の身元を隠しつつ結果を公開しようとしている場合は、suppor \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>[email protected]までご連絡ください。あなたのユースケースについて詳しく共有してください。 ::: \n",
"\n",
" <span style=\"font-weight: bold\">既存アカウントを持つユーザーはどうなりますか?</span> \n",
"\n",
"スクリプトで <span style=\"color: #ffffff; text-decoration-color: #ffffff; background-color: #000000\">anonymous=\"allow\"</span> \n",
"を設定すると、匿名アカウントを作成する前に既存のアカウントがないか確認します。つまり、W&amp;Bユーザーがスクリプトを見つ\n",
"けて実行した場合、通常の実行と同様に、彼らの結果が正しくアカウントにログされます。 \n",
"\n",
" <span style=\"font-weight: bold\">匿名ユーザーに利用できない機能は何ですか?</span> \n",
"\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">永続的なデータなし</span>:ランは匿名アカウントでのみ7日間保存されます。ユーザーは実際のアカウントに保存することで匿名 \n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>のランデータを請求できます。 \n",
"\n",
"🌆 <a href=\"@site/static/images/app_ui/anon_mode_no_data.png\" target=\"_blank\">anon_mode_no_data.png</a> \n",
"\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">アーティファクトの記録なし</span>:ランには、匿名の実行にアーティファクトを記録できないことについての警告がコマンドライ\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> </span>ンに表示されます。 \n",
"\n",
"🌆 <a href=\"@site/static/images/app_ui/anon_example_warning.png\" target=\"_blank\">anon_example_warning.png</a> \n",
"\n",
"<span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\"> • </span><span style=\"font-weight: bold\">プロファイルまたは設定ページがありません</span>: 実際のアカウントにのみ有用なため、UIで特定のページが利用できません。 \n",
"\n",
"\n",
" <span style=\"font-weight: bold; text-decoration: underline\">使用例</span> \n",
"\n",
"<a href=\"http://bit.ly/anon-mode\" target=\"_blank\"><span style=\"color: #0000ff; text-decoration-color: #0000ff\">例のノートブックを試して</span></a>、匿名モードがどのように動作するかを確認してください。 \n",
"\n",
"<span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">import</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\"> wandb</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #75715e; text-decoration-color: #75715e; background-color: #272822\"># 匿名アカウントを許可するランを開始します</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">wandb</span><span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">init(anonymous</span><span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">=</span><span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">\"allow\"</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">)</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #75715e; text-decoration-color: #75715e; background-color: #272822\"># トレーニングループからの結果をログに記録します</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">wandb</span><span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">log({</span><span style=\"color: #e6db74; text-decoration-color: #e6db74; background-color: #272822\">\"acc\"</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">: </span><span style=\"color: #ae81ff; text-decoration-color: #ae81ff; background-color: #272822\">0.91</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">})</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #75715e; text-decoration-color: #75715e; background-color: #272822\"># ランを終了します</span><span style=\"background-color: #272822\"> </span>\n",
"<span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">wandb</span><span style=\"color: #f92672; text-decoration-color: #f92672; background-color: #272822\">.</span><span style=\"color: #f8f8f2; text-decoration-color: #f8f8f2; background-color: #272822\">finish()</span><span style=\"background-color: #272822\"> </span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[33m───────────────────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n",
"\n",
" \u001b[1;4mdescription: W\u001b[0m\u001b[1;4m&\u001b[0m\u001b[1;4mBアカウントなしでデータを記録および可視化\u001b[0m \n",
"\n",
"╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n",
"║ \u001b[1mAnonymous Mode\u001b[0m ║\n",
"╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n",
"\n",
"誰でも簡単に実行できるようにしたいコードを公開していますか? Weights & \n",
"Biasesアカウントの作成が必要なく、W&Bダッシュボードを見て結果を可視化することができるAnonymous \n",
"Modeを使用してください。 \n",
"\n",
"\u001b[97;40mwandb.init(\u001b[0m\u001b[1;97;40manonymous=\"allow\"\u001b[0m\u001b[97;40m)\u001b[0mでAnonymous Modeでの結果の記録を許可します。 \n",
"\n",
" \u001b[1mアカウントを持っていない人が結果を見るにはどうすればいいですか?\u001b[0m \n",
"\n",
"もし誰かがあなたのスクリプトを実行し、\u001b[97;40manonymous=\"allow\"\u001b[0mを設定する必要がある場合: \n",
"\n",
"\u001b[1;33m 1 \u001b[0m\u001b[1m一時アカウントを自動作成:\u001b[0m \n",
"\u001b[1;33m \u001b[0mW&Bはすでにサインインしたアカウントを確認します。アカウントがない場合、自動的に新しい匿名アカウントを作成し、そ \n",
"\u001b[1;33m \u001b[0mのAPIキーをセッションに保存します。 \n",
"\u001b[1;33m 2 \u001b[0m\u001b[1m素早く結果を記録:\u001b[0m \n",
"\u001b[1;33m \u001b[0mユーザーはスクリプトを実行および再実行し、W&BダッシュボードUIに結果が自動的に表示されるようになります。これらの \n",
"\u001b[1;33m \u001b[0m割り当ての匿名ランは、7日間利用可能です。 \n",
"\u001b[1;33m 3 \u001b[0m\u001b[1m役に立つときにデータを保存\u001b[0m: \n",
"\u001b[1;33m \u001b[0mユーザーがW&Bで価値ある結果を見つけた場合、ページの上部にあるバナーのボタンをクリックするだけで、ランデータを実 \n",
"\u001b[1;33m \u001b[0m際のアカウントに保存できます。保存しない場合、7日後にランデータは削除されます。 :::caution \n",
"\u001b[1;33m \u001b[0m\u001b[1m匿名の実行リンクには注意してください\u001b[0m。これらのリンクにより、実験の結果を誰でも7日間閲覧し、請求できるようになり \n",
"\u001b[1;33m \u001b[0mる人にのみリンクを共有するようにしてください。著者の身元を隠しつつ結果を公開しようとしている場合は、suppor \n",
"\u001b[1;33m \u001b[[email protected]までご連絡ください。あなたのユースケースについて詳しく共有してください。 ::: \n",
"\n",
" \u001b[1m既存アカウントを持つユーザーはどうなりますか?\u001b[0m \n",
"\n",
"スクリプトで \u001b[97;40manonymous=\"allow\"\u001b[0m \n",
"を設定すると、匿名アカウントを作成する前に既存のアカウントがないか確認します。つまり、W&Bユーザーがスクリプトを見つ\n",
"けて実行した場合、通常の実行と同様に、彼らの結果が正しくアカウントにログされます。 \n",
"\n",
" \u001b[1m匿名ユーザーに利用できない機能は何ですか?\u001b[0m \n",
"\n",
"\u001b[1;33m • \u001b[0m\u001b[1m永続的なデータなし\u001b[0m:ランは匿名アカウントでのみ7日間保存されます。ユーザーは実際のアカウントに保存することで匿名 \n",
"\u001b[1;33m \u001b[0mのランデータを請求できます。 \n",
"\n",
"🌆 \u001b]8;id=228189;@site/static/images/app_ui/anon_mode_no_data.png\u001b\\anon_mode_no_data.png\u001b]8;;\u001b\\ \n",
"\n",
"\u001b[1;33m • \u001b[0m\u001b[1mアーティファクトの記録なし\u001b[0m:ランには、匿名の実行にアーティファクトを記録できないことについての警告がコマンドライ\n",
"\u001b[1;33m \u001b[0mンに表示されます。 \n",
"\n",
"🌆 \u001b]8;id=283230;@site/static/images/app_ui/anon_example_warning.png\u001b\\anon_example_warning.png\u001b]8;;\u001b\\ \n",
"\n",
"\u001b[1;33m • \u001b[0m\u001b[1mプロファイルまたは設定ページがありません\u001b[0m: 実際のアカウントにのみ有用なため、UIで特定のページが利用できません。 \n",
"\n",
"\n",
" \u001b[1;4m使用例\u001b[0m \n",
"\n",
"\u001b]8;id=19060;http://bit.ly/anon-mode\u001b\\\u001b[94m例のノートブックを試して\u001b[0m\u001b]8;;\u001b\\、匿名モードがどのように動作するかを確認してください。 \n",
"\n",
"\u001b[38;2;249;38;114;48;2;39;40;34mimport\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mwandb\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;117;113;94;48;2;39;40;34m# 匿名アカウントを許可するランを開始します\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;248;248;242;48;2;39;40;34mwandb\u001b[0m\u001b[38;2;249;38;114;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34minit\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34manonymous\u001b[0m\u001b[38;2;249;38;114;48;2;39;40;34m=\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34mallow\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;117;113;94;48;2;39;40;34m# トレーニングループからの結果をログに記録します\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;248;248;242;48;2;39;40;34mwandb\u001b[0m\u001b[38;2;249;38;114;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mlog\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m{\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34macc\u001b[0m\u001b[38;2;230;219;116;48;2;39;40;34m\"\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m:\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m \u001b[0m\u001b[38;2;174;129;255;48;2;39;40;34m0.91\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m}\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;117;113;94;48;2;39;40;34m# ランを終了します\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n",
"\u001b[38;2;248;248;242;48;2;39;40;34mwandb\u001b[0m\u001b[38;2;249;38;114;48;2;39;40;34m.\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34mfinish\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m(\u001b[0m\u001b[38;2;248;248;242;48;2;39;40;34m)\u001b[0m\u001b[48;2;39;40;34m \u001b[0m\n"
]
},
"execution_count": 209,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Markdown(out_md)"
]
},
{
"cell_type": "code",
"execution_count": 211,
"id": "760b5a39-6aab-47b7-a5f8-d9b47d35b28c",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[34m\u001b[1mwandb\u001b[0m: Finished uploading data to W&B at https://wandb.ai/capecape/docs_translate/runs/dbrwxqmx\n"
]
}
],
"source": [
"WandbTracer.finish()"
]
}
],
"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.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment