diff --git a/notebooks/how_to/qualitative_text/qualitative_text_generation.ipynb b/notebooks/how_to/qualitative_text/qualitative_text_generation.ipynb
new file mode 100644
index 000000000..d85879f94
--- /dev/null
+++ b/notebooks/how_to/qualitative_text/qualitative_text_generation.ipynb
@@ -0,0 +1,951 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "9a900020",
+ "metadata": {},
+ "source": [
+ "# Generate qualitative text with the ValidMind library\n",
+ "\n",
+ "This notebook shows how to generate qualitative documentation content directly from the ValidMind library using both `vm.run_text_generation()` and `vm.generate_documentation_text()`. Instead of switching to the UI to write text manually or trigger generation one section at a time, you can generate content for documentation text blocks programmatically from within a notebook and log it back to the corresponding sections of the model document.\n",
+ "\n",
+ "After building an example model and documenting its quantitative results, we’ll show how to generate text for individual content blocks, customize the output with prompts, control the context used for generation, and use a configuration-driven workflow to populate multiple qualitative sections across the document. By the end, you’ll have an end-to-end example of how quantitative test results and AI-generated qualitative content can work together to populate a full model document from Python, giving you a more automated documentation workflow directly in the library."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "cd48db57",
+ "metadata": {},
+ "source": [
+ "::: {.content-hidden when-format=\"html\"}\n",
+ "## Contents \n",
+ "- [About ValidMind](#toc1__) \n",
+ " - [Before you begin](#toc1_1__) \n",
+ " - [New to ValidMind?](#toc1_2__) \n",
+ " - [Key concepts](#toc1_3__) \n",
+ "- [Setting up](#toc2__) \n",
+ " - [Install the ValidMind Library](#toc2_1__) \n",
+ " - [Initialize the ValidMind Library](#toc2_2__) \n",
+ " - [Register sample model](#toc2_2_1__) \n",
+ " - [Apply documentation template](#toc2_2_2__) \n",
+ " - [Get your code snippet](#toc2_2_3__) \n",
+ " - [Initialize the Python environment](#toc2_3__) \n",
+ "- [Getting to know ValidMind](#toc3__) \n",
+ " - [Preview the documentation template](#toc3_1__) \n",
+ " - [View model documentation in the ValidMind Platform](#toc3_2__) \n",
+ "- [Build the example model](#toc4__) \n",
+ " - [Import the sample dataset](#toc4_1__) \n",
+ " - [Preprocessing the raw dataset](#toc4_2__) \n",
+ " - [Training an XGBoost classifier model](#toc4_3__) \n",
+ "- [Initialize the ValidMind inputs](#toc5__) \n",
+ "- [Document test results](#toc6__) \n",
+ "- [Document qualitative sections](#toc7__) \n",
+ " - [Generate text for a single content block](#toc7_1__) \n",
+ " - [Customize the prompt](#toc7_2__) \n",
+ " - [Pass section-specific context](#toc7_3__) \n",
+ " - [Append a new text block to a section](#toc7_4__) \n",
+ " - [Generate text across the document](#toc7_5__) \n",
+ "- [In summary](#toc8__) \n",
+ "- [Next steps](#toc9__) \n",
+ " - [Work with your model documentation](#toc9_1__) \n",
+ " - [Discover more learning resources](#toc9_2__) \n",
+ "- [Upgrade ValidMind](#toc10__) \n",
+ "\n",
+ ":::\n",
+ "\n",
+ ""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "a67217b3",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "## About ValidMind\n",
+ "\n",
+ "ValidMind is a suite of tools for managing model risk, including risk associated with AI and statistical models. \n",
+ "\n",
+ "You use the ValidMind Library to automate documentation and validation tests, and then use the ValidMind Platform to collaborate on model documentation. Together, these products simplify model risk management, facilitate compliance with regulations and institutional standards, and enhance collaboration between yourself and model validators."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "281cfb86",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Before you begin\n",
+ "\n",
+ "This notebook assumes you have basic familiarity with Python, including an understanding of how functions work. If you are new to Python, you can still run the notebook but we recommend further familiarizing yourself with the language. \n",
+ "\n",
+ "If you encounter errors due to missing modules in your Python environment, install the modules with `pip install`, and then re-run the notebook. For more help, refer to [Installing Python Modules](https://docs.python.org/3/installing/index.html)."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "51c11b52",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### New to ValidMind?\n",
+ "\n",
+ "If you haven't already seen our documentation on the [ValidMind Library](https://docs.validmind.ai/developer/validmind-library.html), we recommend you begin by exploring the available resources in this section. There, you can learn more about documenting models and running tests, as well as find code samples and our Python Library API reference.\n",
+ "\n",
+ "
For access to all features available in this notebook, you'll need access to a ValidMind account.\n",
+ " \n",
+ "Register with ValidMind
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "9103cd45",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Key concepts\n",
+ "\n",
+ "**Validation report**: A comprehensive and structured assessment of a model’s development and performance, focusing on verifying its integrity, appropriateness, and alignment with its intended use. It includes analyses of model assumptions, data quality, performance metrics, outcomes of testing procedures, and risk considerations. The validation report supports transparency, regulatory compliance, and informed decision-making by documenting the validator’s independent review and conclusions.\n",
+ "\n",
+ "**Validation report template**: Serves as a standardized framework for conducting and documenting model validation activities. It outlines the required sections, recommended analyses, and expected validation tests, ensuring consistency and completeness across validation reports. The template helps guide validators through a systematic review process while promoting comparability and traceability of validation outcomes.\n",
+ "\n",
+ "**Tests**: A function contained in the ValidMind Library, designed to run a specific quantitative test on the dataset or model. Tests are the building blocks of ValidMind, used to evaluate and document models and datasets.\n",
+ "\n",
+ "**Metrics**: A subset of tests that do not have thresholds. In the context of this notebook, metrics and tests can be thought of as interchangeable concepts.\n",
+ "\n",
+ "**Custom metrics**: Custom metrics are functions that you define to evaluate your model or dataset. These functions can be registered with the ValidMind Library to be used in the ValidMind Platform.\n",
+ "\n",
+ "**Inputs**: Objects to be evaluated and documented in the ValidMind Library. They can be any of the following:\n",
+ "\n",
+ " - **model**: A single model that has been initialized in ValidMind with [`vm.init_model()`](https://docs.validmind.ai/validmind/validmind.html#init_model).\n",
+ " - **dataset**: Single dataset that has been initialized in ValidMind with [`vm.init_dataset()`](https://docs.validmind.ai/validmind/validmind.html#init_dataset).\n",
+ " - **models**: A list of ValidMind models - usually this is used when you want to compare multiple models in your custom metric.\n",
+ " - **datasets**: A list of ValidMind datasets - usually this is used when you want to compare multiple datasets in your custom metric. (Learn more: [Run tests with multiple datasets](https://docs.validmind.ai/notebooks/how_to/tests/run_tests/configure_tests/run_tests_that_require_multiple_datasets.html))\n",
+ "\n",
+ "**Parameters**: Additional arguments that can be passed when running a ValidMind test, used to pass additional information to a metric, customize its behavior, or provide additional context.\n",
+ "\n",
+ "**Outputs**: Custom metrics can return elements like tables or plots. Tables may be a list of dictionaries (each representing a row) or a pandas DataFrame. Plots may be matplotlib or plotly figures."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "23020a1b",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "## Setting up"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "6202d6dc",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Install the ValidMind Library\n",
+ "\n",
+ "
\n",
+ "\n",
+ "To install the library:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "045b05a6",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "%pip install -q validmind"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "b3231d8e",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Initialize the ValidMind Library"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "56592217",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "#### Register sample model\n",
+ "\n",
+ "Let's first register a sample model for use with this notebook:\n",
+ "\n",
+ "1. In a browser, [log in to ValidMind](https://docs.validmind.ai/guide/configuration/log-in-to-validmind.html).\n",
+ "\n",
+ "2. In the left sidebar, navigate to **Inventory** and click **+ Register Model**.\n",
+ "\n",
+ "3. Enter the model details and click **Next >** to continue to assignment of model stakeholders. ([Need more help?](https://docs.validmind.ai/guide/model-inventory/register-models-in-inventory.html))\n",
+ "\n",
+ "4. Select your own name under the **MODEL OWNER** drop-down.\n",
+ "\n",
+ "5. Click **Register Model** to add the model to your inventory."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "43ed3d0c",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "#### Apply documentation template\n",
+ "\n",
+ "Once you've registered your model, let's select a documentation template. A template predefines sections for your model documentation and provides a general outline to follow, making the documentation process much easier.\n",
+ "\n",
+ "1. In the left sidebar that appears for your model, click **Documents** and select **Development**.\n",
+ "\n",
+ "2. Under **TEMPLATE**, select `Binary classification`.\n",
+ "\n",
+ "3. Click **Use Template** to apply the template."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "9b9203be",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "#### Get your code snippet\n",
+ "\n",
+ "Initialize the ValidMind Library with the *code snippet* unique to each model per document, ensuring your test results are uploaded to the correct model and automatically populated in the right document in the ValidMind Platform when you run this notebook.\n",
+ "\n",
+ "1. On the left sidebar that appears for your model, select **Getting Started** and select `Development` from the **DOCUMENT** drop-down menu.\n",
+ "2. Click **Copy snippet to clipboard**.\n",
+ "3. Next, [load your model identifier credentials from an `.env` file](https://docs.validmind.ai/developer/model-documentation/store-credentials-in-env-file.html) or replace the placeholder with your own code snippet:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "690dc368",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Load your model identifier credentials from an `.env` file\n",
+ "\n",
+ "%load_ext dotenv\n",
+ "%dotenv .env\n",
+ "\n",
+ "# Or replace with your code snippet\n",
+ "\n",
+ "import validmind as vm\n",
+ "\n",
+ "vm.init(\n",
+ " api_host=\"http://localhost:5000/api/v1/tracking\",\n",
+ " api_key=\"..\",\n",
+ " api_secret=\"..\",\n",
+ " document=\"documentation\", # requires library >=2.12.0\n",
+ " model=\"..\",\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "a68f6031",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Initialize the Python environment\n",
+ "\n",
+ "Then, let's import the necessary libraries and set up your Python environment for data analysis:\n",
+ "\n",
+ "- Import **Extreme Gradient Boosting** (XGBoost) with an alias so that we can reference its functions in later calls. XGBoost is a powerful machine learning library designed for speed and performance, especially in handling structured or tabular data.\n",
+ "- Enable **`matplotlib`**, a plotting library used for visualizing data. Ensures that any plots you generate will render inline in our notebook output rather than opening in a separate window."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "3fa2d9de",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "%matplotlib inline\n",
+ "\n",
+ "import xgboost as xgb"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "69a37995",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "## Getting to know ValidMind"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "40c9eb24",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Preview the documentation template\n",
+ "\n",
+ "Let's verify that you have connected the ValidMind Library to the ValidMind Platform and that the appropriate *template* is selected for your model.\n",
+ "\n",
+ "You will upload documentation and test results unique to your model based on this template later on. For now, **take a look at the default structure that the template provides with [the `vm.preview_template()` function](https://docs.validmind.ai/validmind/validmind.html#preview_template)** from the ValidMind library and note the empty sections:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "62842e84",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "vm.preview_template()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "6fab1c1c",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### View model documentation in the ValidMind Platform\n",
+ "\n",
+ "Next, let's head to the ValidMind Platform to see the template in action:\n",
+ "\n",
+ "1. In a browser, [log in to ValidMind](https://docs.validmind.ai/guide/configuration/log-in-to-validmind.html).\n",
+ "\n",
+ "2. In the left sidebar, navigate to **Inventory** and select the model you registered for this notebook.\n",
+ "\n",
+ "3. Click **Development** under Documents for your model and note how the structure of the documentation matches our preview above."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "606d932b",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "## Build the example model"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3d7ad25a",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Import the sample dataset\n",
+ "\n",
+ "First, let's import the public [Bank Customer Churn Prediction](https://www.kaggle.com/datasets/shantanudhakadd/bank-customer-churn-prediction) dataset from Kaggle so that we have something to work with.\n",
+ "\n",
+ "In our below example, note that: \n",
+ "\n",
+ "- The target column, `Exited` has a value of `1` when a customer has churned and `0` otherwise.\n",
+ "- The ValidMind Library provides a wrapper to automatically load the dataset as a [Pandas DataFrame](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html) object. A Pandas Dataframe is a two-dimensional tabular data structure that makes use of rows and columns."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "8ea8188e",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from validmind.datasets.classification import customer_churn\n",
+ "\n",
+ "print(\n",
+ " f\"Loaded demo dataset with: \\n\\n\\t• Target column: '{customer_churn.target_column}' \\n\\t• Class labels: {customer_churn.class_labels}\"\n",
+ ")\n",
+ "\n",
+ "raw_df = customer_churn.load_data()\n",
+ "raw_df.head()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "a5ceef72",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Preprocessing the raw dataset\n",
+ "\n",
+ "In this section, we preprocess the raw dataset so it is ready for model training and validation. This includes splitting the data into training, validation, and test subsets to support both model fitting and evaluation on unseen data, and then separating each subset into input features and target labels so the model can learn from customer attributes and predict whether a customer churned."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "9d2bec58",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "train_df, validation_df, test_df = customer_churn.preprocess(raw_df)\n",
+ "\n",
+ "x_train = train_df.drop(customer_churn.target_column, axis=1)\n",
+ "y_train = train_df[customer_churn.target_column]\n",
+ "x_val = validation_df.drop(customer_churn.target_column, axis=1)\n",
+ "y_val = validation_df[customer_churn.target_column]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3b9edacf",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Training an XGBoost classifier model\n",
+ "\n",
+ "In this section, we train an XGBoost classifier to predict customer churn, using early stopping to halt training if performance does not improve after 10 rounds and reduce unnecessary fitting. We configure the model to evaluate performance with three complementary metrics: error for incorrect predictions, logloss for prediction confidence, and auc for class separation. The model is trained on the training split and evaluated against the validation split during fitting, while verbose=False keeps the training output concise."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "658447fc",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "model = xgb.XGBClassifier(early_stopping_rounds=10)\n",
+ "\n",
+ "model.set_params(\n",
+ " eval_metric=[\"error\", \"logloss\", \"auc\"],\n",
+ ")\n",
+ "\n",
+ "model.fit(\n",
+ " x_train,\n",
+ " y_train,\n",
+ " eval_set=[(x_val, y_val)],\n",
+ " verbose=False,\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "c2a6b492",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "## Initialize the ValidMind inputs\n",
+ "\n",
+ "We begin by registering the datasets and trained model as ValidMind inputs so they can be referenced consistently throughout the documentation workflow. For the datasets, this means creating ValidMind Dataset objects for the raw, training, and testing data, each with a unique `input_id` for traceability. Where needed, we also provide supporting metadata such as the target column and class labels so tests can interpret the data correctly."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "081548ae",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Initialize the raw dataset\n",
+ "vm_raw_dataset = vm.init_dataset(\n",
+ " dataset=raw_df,\n",
+ " input_id=\"raw_dataset\",\n",
+ " target_column=customer_churn.target_column,\n",
+ " class_labels=customer_churn.class_labels,\n",
+ ")\n",
+ "\n",
+ "# Initialize the training dataset\n",
+ "vm_train_ds = vm.init_dataset(\n",
+ " dataset=train_df,\n",
+ " input_id=\"train_dataset\",\n",
+ " target_column=customer_churn.target_column,\n",
+ ")\n",
+ "\n",
+ "# Initialize the testing dataset\n",
+ "vm_test_ds = vm.init_dataset(\n",
+ " dataset=test_df,\n",
+ " input_id=\"test_dataset\",\n",
+ " target_column=customer_churn.target_column\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "1ebfda19",
+ "metadata": {},
+ "source": [
+ "Next, we initialize a ValidMind model object with `vm.init_model()`. This creates a standardized representation of the trained model that can be passed into ValidMind tests and other library functions, making it possible to evaluate the model and connect its results to the documentation."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "6cc5aff8",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Initialize the model\n",
+ "vm_model = vm.init_model(\n",
+ " model,\n",
+ " input_id=\"model\",\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "48d23cf8",
+ "metadata": {},
+ "source": [
+ "Finally, we assign predictions from the trained model to the training and testing datasets. The `assign_predictions()` method links predicted classes and probabilities to each dataset, and can also compute predictions automatically if they are not passed explicitly. This step is what allows ValidMind to run performance and diagnostic tests using the model outputs."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "922baa9d",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "vm_train_ds.assign_predictions(\n",
+ " model=vm_model,\n",
+ ")\n",
+ "vm_test_ds.assign_predictions(\n",
+ " model=vm_model,\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "7c9a174d",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "## Document test results\n",
+ "\n",
+ "In this section, we run the documentation tests defined by the applied template to populate the quantitative parts of the model documentation. The `vm.run_documentation_tests()` function discovers each test-driven block in the template, executes the corresponding tests, and uploads the resulting artifacts to the ValidMind Platform.\n",
+ "\n",
+ "To run the full suite successfully, ValidMind needs to know which model and dataset inputs should be used for each test. This can be done with a shared `inputs` argument when all tests use the same objects, or with a `config` dictionary when individual tests require specific inputs or parameters. In this example, we use the default test parameters and provide the input configuration needed for the demo model."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "47f7e709",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from validmind.utils import preview_test_config\n",
+ "\n",
+ "test_config = customer_churn.get_demo_test_config()\n",
+ "preview_test_config(test_config)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3f22d37b",
+ "metadata": {},
+ "source": [
+ "Once the configuration is prepared, we pass it to `vm.run_documentation_tests()` and execute the full suite. The returned `full_suite` object contains the test results and represents the quantitative documentation that has been generated for the model."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "999be7fe",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "full_suite = vm.run_documentation_tests(config=test_config)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "5d531744",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "## Document qualitative sections\n",
+ "\n",
+ "In addition to documenting quantitative results through tests, ValidMind now supports programmatic generation of qualitative content for the text blocks in a model documentation template through `vm.run_text_generation()`. This function allows you to generate AI-assisted text for a specific content block directly from a notebook and then log it back to the corresponding section of the document. As a result, you can populate qualitative sections without switching to the UI to write text manually or trigger generation one section at a time.\n",
+ "\n",
+ "In the next sections, we’ll walk through the main ways to use this functionality. We’ll start by generating text for a single content block with the default behavior, then show how to customize the output with a prompt, how to control the context used for generation by selecting specific sections, and finally how to scale the same pattern across all text blocks in the document."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "899c8553",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Generate text for a single content block\n",
+ "\n",
+ "First, we’ll use `vm.run_text_generation()` to generate qualitative text for a single documentation block. By providing a `content_id`, you can target the exact text placeholder you want to populate and let ValidMind generate content using the current document context. The helper `vm.get_content_ids()` is useful for inspecting which content blocks are available in the active template, making it easier to identify the IDs you can use when generating and logging text programmatically."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "85cc552f",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "vm.get_content_ids()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "26fcddf9",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "vm.run_text_generation(\n",
+ " content_id=\"dataset_summary_text\",\n",
+ ").log()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "caff6490",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Customize the prompt\n",
+ "\n",
+ "Next, we’ll customize the generated output by passing a `prompt` to `vm.run_text_generation()`. This makes it possible to guide not just the subject of the generated text, but also its structure, tone, level of detail, and presentation format. In practice, this allows you to tailor the output for different documentation needs, such as producing a short narrative summary, a more structured section, or content written for a specific audience, while still relying on the same underlying document context for generation."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "52165b98",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "prompt = \"\"\"\n",
+ "Use exactly this structure:\n",
+ "\n",
+ "
Dataset Overview
\n",
+ "
Explain in 1-2 sentences what the dataset contains and what it is used for.
\n",
+ "\n",
+ "
Dataset Summary
\n",
+ "
Summarize the dataset structure, target outcome, and the main types of input features in 2-3 sentences.
\n",
+ "\n",
+ "
Key Characteristics
\n",
+ "
\n",
+ "
Include 2-3 concise points about the most important characteristics of the dataset.
\n",
+ "
\n",
+ "\n",
+ "
Data Quality and Considerations
\n",
+ "
\n",
+ "
Include 2-3 concise points about important quality observations, limitations, or considerations relevant to the dataset.
\n",
+ "
\n",
+ "\n",
+ "
Overall Assessment
\n",
+ "
End with a short balanced conclusion on the dataset's suitability for model development and evaluation.
\n",
+ "\"\"\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "fbf10ad9",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "vm.run_text_generation(\n",
+ " content_id=\"dataset_summary_text\",\n",
+ " prompt=prompt,\n",
+ ").log()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "99a0740e",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Pass section-specific context\n",
+ "\n",
+ "Then, we’ll control the `context` used for generation by passing a selected set of content IDs to `vm.run_text_generation()`. Rather than relying on the full document, this lets you focus the model on the most relevant parts of the documentation for a given text block. In practice, that means you can generate more targeted qualitative content by choosing which existing test and text blocks should inform the output."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "43cf0e7d",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "vm.get_content_ids(\"data_description\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "1e1a919e",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "vm.run_text_generation(\n",
+ " content_id=\"dataset_summary_text\",\n",
+ " context={\"content_ids\": vm.get_content_ids(\"data_description\")},\n",
+ ").log()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "701a0323",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Append a new text block to a section\n",
+ "\n",
+ "Sometimes you may want to generate text for a `content_id` that is not already defined in the template. In that case, you can still generate the text with `vm.run_text_generation()` and then use `.log(section_id=...)` to tell ValidMind where that new text block should be placed in the document. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "6a9ba924",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "vm.run_text_generation(\n",
+ " content_id=\"intended_use\",\n",
+ " section_id=\"intended_use\",\n",
+ ").log()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "6e032b79",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Generate text across the document\n",
+ "\n",
+ "At this stage, instead of generating one block at a time, we can populate multiple qualitative sections in a single pass.\n",
+ "\n",
+ "The [`vm.generate_documentation_text`](https://docs.validmind.ai/validmind/validmind.html#generate_documentation_text) function reads a configuration dictionary, generates content for each target block, logs the generated text to the ValidMind Platform, and returns a notebook summary grouped by section.\n",
+ "\n",
+ "- The function uses a `config` argument to describe which text blocks to generate and how each one should be handled.\n",
+ "- The `config` parameter is a dictionary with the following structure:\n",
+ "\n",
+ " ```python\n",
+ " config = {\n",
+ " \"\": {\n",
+ " \"section_id\": \"\",\n",
+ " \"prompt\": \"Optional custom prompt\",\n",
+ " \"context\": {\n",
+ " \"content_ids\": [\"\", \"\"]\n",
+ " }\n",
+ " },\n",
+ " ...\n",
+ " }\n",
+ " ```\n",
+ "\n",
+ " Each `` represents a documentation text block to populate. Use `section_id` when the block should be inserted into a specific section, `prompt` when you want to shape the output more explicitly, and `context.content_ids` when you want the generation step to focus on selected parts of the document. In this notebook, `text_config` comes from `customer_churn.get_demo_text_config()`, which provides the demo setup for the customer churn example."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "a97bb129",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "text_config = customer_churn.get_demo_text_config()\n",
+ "preview_test_config(text_config)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "aff42702",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "results = vm.generate_documentation_text(config=text_config)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "03b6b875",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "## In summary\n",
+ "\n",
+ "In this notebook, you learned how to:\n",
+ "\n",
+ "- [x] Build and document an example customer churn model with ValidMind\n",
+ "- [x] Run documentation tests to populate the quantitative sections of a model document\n",
+ "- [x] Generate qualitative text for a single documentation content block with `vm.run_text_generation()`\n",
+ "- [x] Customize generated output by passing a prompt\n",
+ "- [x] Control generation context by selecting specific sections of the document\n",
+ "- [x] Use a configuration-driven workflow to generate qualitative content across the document with `vm.generate_documentation_text()`"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3db3c328",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "## Next steps\n",
+ "\n",
+ "You can look at the output produced by the ValidMind Library right in the notebook where you ran the code, as you would expect. But there is a better way — use the ValidMind Platform to work with your model documentation."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "d7bd8df8",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Work with your model documentation\n",
+ "\n",
+ "1. From the **Inventory** in the ValidMind Platform, go to the model you registered earlier. ([Need more help?](https://docs.validmind.ai/guide/model-inventory/working-with-model-inventory.html))\n",
+ "\n",
+ "2. In the left sidebar that appears for your model, click **Development** under Documents.\n",
+ "\n",
+ "What you see is the full draft of your model documentation in a more easily consumable version. From here, you can make qualitative edits to model documentation, view guidelines, collaborate with validators, and submit your model documentation for approval when it's ready. [Learn more ...](https://docs.validmind.ai/guide/working-with-model-documentation.html)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "c0951457",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "### Discover more learning resources\n",
+ "\n",
+ "For a more in-depth introduction to using the ValidMind Library for development, check out our introductory development series and the accompanying interactive training:\n",
+ "\n",
+ "- **[ValidMind for model development](https://docs.validmind.ai/developer/validmind-library.html#for-model-development)**\n",
+ "- **[Developer Fundamentals](https://docs.validmind.ai/training/developer-fundamentals/developer-fundamentals-register.html)**\n",
+ "\n",
+ "We also offer many interactive notebooks to help you document models:\n",
+ "\n",
+ "- [Run tests & test suites](https://docs.validmind.ai/developer/how-to/testing-overview.html)\n",
+ "- [Use ValidMind Library features](https://docs.validmind.ai/developer/how-to/feature-overview.html)\n",
+ "- [Code samples by use case](https://docs.validmind.ai/guide/samples-jupyter-notebooks.html)\n",
+ "\n",
+ "Or, visit our [documentation](https://docs.validmind.ai/) to learn more about ValidMind."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "24532182",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "## Upgrade ValidMind\n",
+ "\n",
+ "
After installing ValidMind, you’ll want to periodically make sure you are on the latest version to access any new features and other enhancements.