# How Deep Analysis Mode and Three-Round Questioning Work in main.py

> Explore how deep analysis mode and three-round questioning in main.py systematically generate 12 queries to extract structured insights from any document using NotebookLM.

- Repository: [向阳乔木/qiaomu-anything-to-notebooklm](https://github.com/joeseesun/qiaomu-anything-to-notebooklm)
- Tags: deep-dive
- Published: 2026-05-16

---

**Deep analysis mode implements a progressive three-round questioning strategy that automatically generates 12 targeted queries—4 for overview, 5 for in-depth analysis, and 3 for synthesis—to systematically interrogate NotebookLM and extract structured insights from any document.**

The `joeseesun/qiaomu-anything-to-notebooklm` repository provides a CLI automation tool that transforms static documents into interactive NotebookLM sessions. When you invoke the `--deep-analysis` flag, [`main.py`](https://github.com/joeseesun/qiaomu-anything-to-notebooklm/blob/main/main.py) initiates a sophisticated workflow that breaks down complex content through progressive questioning rounds, ultimately producing a structured JSON output or Feishu document.

## Enabling Deep Analysis Mode

The deep analysis workflow is triggered via command-line interface. The argument parser defined around lines 21-23 in [`main.py`](https://github.com/joeseesun/qiaomu-anything-to-notebooklm/blob/main/main.py) checks for the `--deep-analysis` flag, which routes execution to the `deep_analysis()` function at lines 38, 55, 92, or 141 depending on the input type (EPUB, plain document, podcast, or URL).

```bash
python main.py ./research-paper.pdf --deep-analysis --to-feishu

```

When this flag is present, `main()` bypasses standard processing and invokes `deep_analysis()` with the appropriate content type and file path parameters.

## The Three-Round Question Generation Strategy

At the heart of the system lies `generate_questions_progressive(content_type)`, implemented between lines 13-83 in [`main.py`](https://github.com/joeseesun/qiaomu-anything-to-notebooklm/blob/main/main.py). This function constructs three distinct question sets that progressively increase in analytical depth.

**Round 1: Overview and Framework** generates 4 high-level questions designed to establish a mental model of the content. These queries focus on summarization and structural comprehension.

**Round 2: Deep Mining** produces 5 analytical questions targeting logical details, evidence chains, contradictions, and critical perspectives. This round interrogates the substance beneath the surface structure.

**Round 3: Synthesis and Action** creates 3 questions focused on actionable insights and concise "elevator pitch" summaries. These extract practical takeaways from the analyzed material.

The function returns these as a list of tuples pairing round labels with question lists (lines 78-81), enabling the orchestration layer to iterate through them sequentially.

## Executing the Question Rounds

The `ask_round(round_label, questions, title)` function (lines 47-64) handles the actual interrogation of NotebookLM. For each question in a round, it calls `ask_notebooklm()` and implements a `time.sleep(1.5)` delay to respect rate limits.

The `ask_notebooklm()` utility (lines 84-102) wraps the `notebooklm ask` CLI command with retry logic—attempting once more on failure—and returns stripped answer text. All responses accumulate in the `all_questions` and `all_answers` lists within the main analysis loop (lines 91-95).

```python

# Simplified workflow from deep_analysis()

for round_label, questions in rounds:
    round_results = ask_round(round_label, questions, title)
    all_questions.extend([f"{round_label}: {q}" for q in questions])
    all_answers.extend(round_results)

```

## Orchestration and Data Collection

The `deep_analysis(file_path, title, content_type, to_feishu=False)` function at lines 66-89 orchestrates the complete workflow. The process follows five distinct phases:

1. **Upload**: The source file is uploaded to NotebookLM via `upload_to_notebooklm()`.
2. **Generation**: `generate_questions_progressive()` creates the three question sets.
3. **Iteration**: Each round is processed through `ask_round()`, collecting 12 total answers.
4. **Serialization**: Results are compiled into a JSON-serializable dictionary (lines 97-106) containing status, title, content type, round counts, and question-answer pairs.
5. **Export**: If `--to-feishu` is passed, `format_feishu_markdown()` structures the output for Feishu documents, then `create_feishu_doc()` posts the results.

The final output matches this structure:

```json
{
  "status": "success",
  "title": "research-paper",
  "content_type": "pdf",
  "rounds": 3,
  "questions": ["...", "..."],
  "answers": ["...", "..."],
  "total_questions": 12,
  "answered": 12
}

```

Console output displays round headers like `📌 【第一轮：概览与框架】` followed by individual question progress, providing real-time visibility into the analysis progression.

## Summary

Deep analysis mode in [`main.py`](https://github.com/joeseesun/qiaomu-anything-to-notebooklm/blob/main/main.py) implements a systematic approach to document intelligence through progressive questioning:

- **Twelve questions total** are automatically generated across three analytical tiers: 4 overview questions, 5 deep-dive questions, and 3 synthesis questions.
- **Rate-limited execution** uses 1.5-second pauses between queries to prevent NotebookLM API throttling while maintaining steady progress.
- **Flexible output** supports both local JSON serialization and direct Feishu document creation via the `--to-feishu` integration flag.
- **Robust error handling** includes retry logic in the `ask_notebooklm()` wrapper to ensure complete answer collection.
- **Modular architecture** separates question generation, round execution, and export formatting into distinct functions for maintainability.

## Frequently Asked Questions

### What triggers the three-round questioning workflow in main.py?

The workflow activates when you pass the `--deep-analysis` argument to the CLI. The argument parser (lines 21-23) detects this flag and routes execution to `deep_analysis()` instead of standard processing, initiating the progressive question generation and answer collection cycle.

### How many questions does each round generate, and what is their purpose?

**Round 1** generates 4 questions focused on high-level summaries and structural frameworks. **Round 2** creates 5 questions targeting evidence, contradictions, and logical details. **Round 3** produces 3 questions extracting actionable insights and synthesis. This 4-5-3 distribution ensures comprehensive coverage from overview to practical application.

### Where does the rate limiting occur in the questioning process?

The rate limiting happens inside `ask_round()` (lines 47-64) via `time.sleep(1.5)` between individual question submissions. This prevents overwhelming the NotebookLM API while processing the 12 total questions automatically generated by `generate_questions_progressive()`.

### Can deep analysis mode export results directly to Feishu?

Yes. When you include the `--to-feishu` flag alongside `--deep-analysis`, the `deep_analysis()` function invokes `format_feishu_markdown()` and `create_feishu_doc()` after collecting all answers. This creates a properly formatted Feishu document titled with the source filename plus "深度解读" (deep interpretation) suffix.