【Dify】RAGのためのKnowledge構築でSegmenting in Q&Aは必要か

私は研究をしている中で、『どこかの論文に書いてあったのだけど、どうだったっけ?』や『この論文は以前どこかで読んだ論文と主張が逆じゃないか?』と思ったことがあります。

しかし、なかなか、昔読んだ論文が思い出せず、結局『まぁ、いっか』となることもよくありました。

そこで、Difyに様々な論文をKnowledgeに保存しておいて、複数の論文に基づいてAI経由で質問してみたいと思うようになりました。

以前の記事にKnowledge構築の詳細等ありますので、御覧ください。

今回のテーマはこちら

Knowledgeの作成時に『Segmenting in Question & Answer format』はオンにした方がいいのかどうか?

私はovary(卵巣)の研究をしていることから、2022年にでた、こちらのNatureの論文を参考にKnowledgeを作成して、RAGからの質問応答の返答の質を検討しました。

Segmenting in Question & Answer formatを使うとどうなるのか

Knowlegeの実際のデータベースを見てみると(Automatic設定でKnowledge構築を実行)

オフにした場合

オンにした場合

このようにオンにした場合だと、Knowledgeの中のデータベースがQ&Aベースで蓄積されることになります。

ちなみに、こちらの画面は

普通にこのtest.pdfのところをクリックすると開きます。

Difyの公式では下記のように書かれています。

『In Segmenting in Question & Answer format, instead of normal “Q to P” (question matches paragraphs), it uses “Q to Q” (question matches question) matching. After segmentation, Q&A pairs are generated for each passage. When users ask questions, the system finds the most similar question and returns the corresponding passage as the answer. This is more precise because it directly matches the user’s question and retrieves the information they need.』

左が通常のKnowledgeを用いた場合

右がSegmenting in Question & Answer formatを用いた場合

つまり、こちらからの質問に一番合致している質問を探し出して、そこの答えを抽出してきます、というworkflowになります。

実際に論文で試した結果 – Segmenting なし

質問は『how do the granulosa cells grow in gonad ?』

答えは

『Based on the provided extract from the article:

  • Regulation and Differentiation in Humans and Primates:
    • Granulosa cells growth is regulated by transcription factors (TFs) which exhibit well-preserved modules between humans and macaques, with differences noted in mice.
    • A primate-specific TF, LHX2, is activated by the ovarian surface epithelium (OSE) and remains active in pregranulosa cells type IIa (preGC-IIa).
    • As differentiation progresses, pregranulosa cells type IIb (preGC-IIb) upregulate FOXL2 and express WNT-induced TFs such as HIF1A, FOXO1, and FOXP1, indicating a higher WNT environment deeper in the ovary.
    • Key to their development, granulosa cells in primates upregulate the steroid hormone receptor NR1H4 and the developmental factor PBX3.
  • Microenvironment Influence in the Ovarian Cortex and Medulla:
    • In the ovarian cortex, preGC-IIa cells produce chemoattractants like NRG1 and survival factors such as KITLG, with STAT3 being active downstream of KIT in primordial germ cells (PGCs).
    • PreGC-IIb cells located in the inner cortex express ligands that initiate meiosis (e.g., retinoic acid by ALDH1A1) and support oogenesis (e.g., BMP2).
    • In the medulla, preGC-Is upregulate enzymes like HSD17B6 and CYP19A1 which are involved in oestrogen production.

This information outlines the key aspects of granulosa cell growth and differentiation in relation to transcription factors, microenvironment influences, and hormonal activity within the ovarian context.』

となり、なかなかこちらが望んでいた解答が返ってきました。

実際に論文で試した結果 – Segmenting あり

こちらも同様に

質問は『how do the granulosa cells grow in gonad ?』

答えは

  • 17 PCW Development: Around 17 post-conception weeks (PCW), developing granulosa cells start to express markers for folliculogenesis, such as NOTCH3 and HEYL, as well as retinol dehydrogenase (RDH10), which appear in the inner cortex of the ovary.
  • Role in Germ Cell Differentiation: Pregranulosa cells play significant roles in influencing germ cell differentiation:
    • PreGC-IIa Cells: Located in the outer ovarian cortex, these cells express chemoattractants and survival factors.
    • PreGC-IIb Cells: Found in the inner cortex, they express ligands that are crucial for initiating meiosis and oogenesis, thus supporting primordial germ cell (PGC) differentiation.

For further detailed mechanisms on how granulosa cells grow specifically, there is no scientific evidence provided within the provided context.』

となりました。

ちょっと内容わかっていないヒトみたいな返答が返ってきました。

結論

つまり、今回の質問のような広い質問に対してはSegmentingはない方がいい。

こちらは論文を読んでいるので、全体の文脈として『こういうことが所々書いてあったよな』と認知して読んでいますが、おそらく、Q&A形式にしてしまうと、大きな文脈による認知が消失してしまうような印象です。

もともとのシステムで述べられているように、すでにあるQuestionが似通っていなかった場合には情報としてピックアップされないのだと思います。

Segmentingの使い道

試してはいないので確証はないのですが、

『〇〇の補助金の申請の仕方を教えて』などの、Questionとして構築されていそうな質問が想定される場合は効果があるとは思いますが、

私のような論文に対する質問の場合にはSegmentingはナシとなります。

Segmentingの注意点

さらに、悪いこと?に

SegmentingにはgptのAPIが使用されますが、SegmentingにはかなりのTokenが使用されます。

今回の約12万文字の論文相手だと、5ドル程度請求されました。

Segmentingにはほぼ課金はかかりません

まとめ

論文のような広い内容をカバーしており、文脈も重要な場合にはSegmenting Q&A formatは不要だと思います。

参考になれば幸いです。

Difyの操作記事一覧に戻る場合はこちら

【Dify】Dify操作記事まとめ(随時更新)

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA