From fc8006121fa5b37dd8451895cc308675f8e82a50 Mon Sep 17 00:00:00 2001 From: Leonid Ganeline Date: Fri, 13 Dec 2024 16:47:16 -0800 Subject: [PATCH] docs: integrations W&B update (#28059) Issue: Here is an ambiguity about W&B integrations. There are two existing provider pages. Fix: Added the "root" W&B provider page. Added there the references to the documentation in the W&B site. Cleaned up formats in existing pages. Added one more integration reference. --------- Co-authored-by: Erick Friis Co-authored-by: Eugene Yurtsev --- docs/docs/integrations/providers/wandb.mdx | 42 ++++++++++++ .../providers/wandb_tracing.ipynb | 4 +- .../providers/wandb_tracking.ipynb | 65 +++++++++++++++++-- 3 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 docs/docs/integrations/providers/wandb.mdx diff --git a/docs/docs/integrations/providers/wandb.mdx b/docs/docs/integrations/providers/wandb.mdx new file mode 100644 index 0000000000000..8eb85116ff02f --- /dev/null +++ b/docs/docs/integrations/providers/wandb.mdx @@ -0,0 +1,42 @@ +# Weights & Biases + +>[Weights & Biases](https://wandb.ai/) is provider of the AI developer platform to train and +> fine-tune AI models and develop AI applications. + +`Weights & Biase` products can be used to log metrics and artifacts during training, +and to trace the execution of your code. + +There are several main ways to use `Weights & Biases` products within LangChain: +- with `wandb_tracing_enabled` +- with `Weave` lightweight toolkit +- with `WandbCallbackHandler` (deprecated) + + +## wandb_tracing_enabled + +See a [usage example](/docs/integrations/providers/wandb_tracing). + +See in the [W&B documentation](https://docs.wandb.ai/guides/integrations/langchain). + +```python +from langchain_community.callbacks import wandb_tracing_enabled +``` + +## Weave + +See in the [W&B documentation](https://weave-docs.wandb.ai/guides/integrations/langchain). + + +## WandbCallbackHandler + +**Note:** the `WandbCallbackHandler` is being deprecated in favour of the `wandb_tracing_enabled`. + +See a [usage example](/docs/integrations/providers/wandb_tracking). + +See in the [W&B documentation](https://docs.wandb.ai/guides/integrations/langchain). + +```python +from langchain_community.callbacks import WandbCallbackHandler +``` + + diff --git a/docs/docs/integrations/providers/wandb_tracing.ipynb b/docs/docs/integrations/providers/wandb_tracing.ipynb index 89b0dd8d3b727..ce6480d1a0d06 100644 --- a/docs/docs/integrations/providers/wandb_tracing.ipynb +++ b/docs/docs/integrations/providers/wandb_tracing.ipynb @@ -5,7 +5,7 @@ "id": "5371a9bb", "metadata": {}, "source": [ - "# WandB Tracing\n", + "# Weights & Biases tracing\n", "\n", "There are two recommended ways to trace your LangChains:\n", "\n", @@ -165,7 +165,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.3" + "version": "3.10.12" } }, "nbformat": 4, diff --git a/docs/docs/integrations/providers/wandb_tracking.ipynb b/docs/docs/integrations/providers/wandb_tracking.ipynb index 5f034619867a1..ea49435e24efd 100644 --- a/docs/docs/integrations/providers/wandb_tracking.ipynb +++ b/docs/docs/integrations/providers/wandb_tracking.ipynb @@ -6,19 +6,24 @@ "id": "e43f4ea0", "metadata": {}, "source": [ - "# Weights & Biases\n", + "# Weights & Biases tracking\n", "\n", - "This notebook goes over how to track your LangChain experiments into one centralized Weights and Biases dashboard. To learn more about prompt engineering and the callback please refer to this Report which explains both alongside the resultant dashboards you can expect to see.\n", + "This notebook goes over how to track your LangChain experiments into one centralized `Weights and Biases` dashboard. \n", "\n", + "To learn more about prompt engineering and the callback please refer to this notebook which explains both alongside the resultant dashboards you can expect to see:\n", "\n", "\"Open\n", "\n", "\n", - "[View Report](https://wandb.ai/a-sh0ts/langchain_callback_demo/reports/Prompt-Engineering-LLMs-with-LangChain-and-W-B--VmlldzozNjk1NTUw#👋-how-to-build-a-callback-in-langchain-for-better-prompt-engineering\n", - ") \n", + "View a detailed description and examples in the [W&B article](https://wandb.ai/a-sh0ts/langchain_callback_demo/reports/Prompt-Engineering-LLMs-with-LangChain-and-W-B--VmlldzozNjk1NTUw#👋-how-to-build-a-callback-in-langchain-for-better-prompt-engineering\n", + "). \n", "\n", "\n", - "**Note**: _the `WandbCallbackHandler` is being deprecated in favour of the `WandbTracer`_ . In future please use the `WandbTracer` as it is more flexible and allows for more granular logging. To know more about the `WandbTracer` refer to the [agent_with_wandb_tracing](/docs/integrations/providers/wandb_tracing) notebook or use the following [colab notebook](http://wandb.me/prompts-quickstart). To know more about Weights & Biases Prompts refer to the following [prompts documentation](https://docs.wandb.ai/guides/prompts)." + "**Note**: _the `WandbCallbackHandler` is being deprecated in favour of the `WandbTracer`_ . In future please use the `WandbTracer` as it is more flexible and allows for more granular logging. \n", + "\n", + "To know more about the `WandbTracer` refer to the [agent_with_wandb_tracing](/docs/integrations/providers/wandb_tracing) notebook or use the following [colab notebook](http://wandb.me/prompts-quickstart). \n", + "\n", + "To know more about Weights & Biases Prompts refer to the following [prompts documentation](https://docs.wandb.ai/guides/prompts)." ] }, { @@ -248,6 +253,38 @@ "The `flush_tracker` function is used to log LangChain sessions to Weights & Biases. It takes in the LangChain module or agent, and logs at minimum the prompts and generations alongside the serialized form of the LangChain module to the specified Weights & Biases project. By default we reset the session as opposed to concluding the session outright." ] }, + { + "cell_type": "markdown", + "id": "483eefd4-633e-4686-8730-944705fe8a80", + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-12T18:20:31.003316Z", + "iopub.status.busy": "2024-11-12T18:20:31.003152Z", + "iopub.status.idle": "2024-11-12T18:20:31.006033Z", + "shell.execute_reply": "2024-11-12T18:20:31.005546Z", + "shell.execute_reply.started": "2024-11-12T18:20:31.003303Z" + } + }, + "source": [ + "## Usage Scenarios" + ] + }, + { + "cell_type": "markdown", + "id": "066adc04-8180-4936-8d75-5c3660b61de7", + "metadata": { + "execution": { + "iopub.execute_input": "2024-11-12T18:20:45.826326Z", + "iopub.status.busy": "2024-11-12T18:20:45.825714Z", + "iopub.status.idle": "2024-11-12T18:20:45.830483Z", + "shell.execute_reply": "2024-11-12T18:20:45.830037Z", + "shell.execute_reply.started": "2024-11-12T18:20:45.826279Z" + } + }, + "source": [ + "### With LLM" + ] + }, { "cell_type": "code", "execution_count": 4, @@ -373,6 +410,14 @@ "wandb_callback.flush_tracker(llm, name=\"simple_sequential\")" ] }, + { + "cell_type": "markdown", + "id": "7dcfc24b-f0b0-48ec-89ce-beeb2fb763d5", + "metadata": {}, + "source": [ + "### Within Chains" + ] + }, { "cell_type": "code", "execution_count": 5, @@ -524,6 +569,14 @@ "wandb_callback.flush_tracker(synopsis_chain, name=\"agent\")" ] }, + { + "cell_type": "markdown", + "id": "533cd4c9-56e2-4ad9-a83e-4653bfcf322f", + "metadata": {}, + "source": [ + "### With Agents" + ] + }, { "cell_type": "code", "execution_count": 7, @@ -646,7 +699,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.1" + "version": "3.10.12" } }, "nbformat": 4,