nikkie-ftnextの日記

イベントレポートや読書メモを発信

Googleが発表した genai-processors の Research Agent Example を触る

はじめに

七尾百合子さん、お誕生日 127日目 おめでとうございます! nikkieです。

気になるライブラリに(deep) researchっぽい例があったので動かしました。

目次

genai-processors が来ったぞ〜

Googleはすでにgoogle-genai(など)といったSDKをリリースしている1のですが、この7月に新たなSDKを投入しました。
google-genaiをラップしています。

Today, we're introducing GenAI Processors, a new open-source Python library from Google DeepMind designed to bring structure and simplicity to these challenges.

なんでもProcessorというインターフェースを導入し、入力の扱いからモデル呼び出し、出力の処理までをProcessorインターフェースで統一するという構想

At its core, GenAI Processors treat all input and output as asynchronous streams of ProcessorParts (i.e. two-way aka bidirectional streaming).

今回は立ち入りませんが、Liveなアプリケーション開発もやりやすくなることを狙っている印象を受けました。

Research Agent Exampleを動かす

genai-processorsにはexamplesが同梱されています!2

その中からResearch Agentを動かします。
https://github.com/google-gemini/genai-processors/tree/v1.0.5/examples/research

Automate Information Gathering and Synthesis with GenAI Processors.

動かしているnotebookがあったので、これをスクリプト化します。

Research the best things about owning dalmatians!

出力はこちら
https://gist.github.com/ftnext/9fd7290b79a496a34e9a255777154ce7

  • レポートの前にトピック出し(5つ)
  • 各トピックを調査(Web検索)
  • 調査を統合してレポート生成

Processorインターフェースに統一された一端を覗く

Research Agentの実装を覗きます。

https://github.com/google-gemini/genai-processors/blob/v1.0.5/examples/research/processors/topic_generator.py#L110

self._pipeline = p_preamble + p_suffix + self._p_genai_model

https://github.com/google-gemini/genai-processors/blob/v1.0.5/examples/research/processors/topic_researcher.py#L80-L82

self._pipeline = (
    p_verbalizer + p_preamble + p_suffix + self._genai_processor
)

https://github.com/google-gemini/genai-processors/blob/v1.0.5/examples/research/agent.py#L118-L125

self._pipeline = (
    p_topic_generator
    + p_topic_researcher
    + p_topic_verbalizer
    + p_preamble
    + p_suffix
    + p_genai_model
)

ここの + で組合せていけるところが売りみたいですね。
レゴブロックっぽい、シンプル!

https://github.com/google-gemini/genai-processors/tree/v1.0.5?tab=readme-ov-file#-key-features

Modular: Breaks down complex tasks into reusable Processor and PartProcessor units, which are easily chained (+) or parallelized (//) to create sophisticated data flows and agentic behaviors.

より深く理解するには以下のnotebookが積ん読です。

終わりに

Googleが発表したgenai-processorsのResearch Agent Exampleを動かしてみました。
例として同梱されているのですぐに動きましたね。
genai-processorsは構想が面白いと思うので、理解を深めていきたいところ!

researchの仕組みは、以下の並列検索と同じなんですよね。
deepにする余地は残されていそうな印象でした。


  1. Google、またあんた新しいSDK作って!
  2. Pydantic AIを思い出しました https://ai.pydantic.dev/examples/