第2章 タクソノミーツリーへのナレッジの追加


モデルがドメイン固有の情報を学習できるように、タクソノミーツリーをカスタマイズできます。RHEL AI の場合、ナレッジデータは Git リポジトリーでホストされます。ナレッジコントリビューションは、qna.yaml ファイルを使用して、モデルを訓練するドキュメントの読み取り方法を学習します。ナレッジの各 qna.yaml ファイルには、次のキーを持つキー値エントリーのセットが含まれています。

Expand
表2.1 Red Hat Enterprise Linux AI
フィールド説明制約

version

qna.yaml ファイルで使用されるタクソノミースキーマのバージョン。

このパラメーターで現在サポートされている値は 3 です。

3

created_by

コントリビューターの名前またはユーザー名。

-

kbrown

domain

ナレッジドキュメントの主題またはカテゴリー。ドメインは、合成データの生成中に教師モデルにプロンプトを表示し、別のコンテキストを追加します。

domain フィールドは、3 単語未満にすることを推奨します。

ほうおう座に関するナレッジドキュメントの場合、ドメインは Astronomy です。

健康保険情報に関するナレッジドキュメントの場合、ドメインは Healthcare です。

seed_examples

ナレッジドキュメントからのコンテキストを含む質問と回答のペアが含まれるフィールド。

qna.yaml ファイルには少なくとも 5 つのシード例が必要です。

seed_examples:
  - context:
    questions_and_answers:

context

ナレッジドキュメントからそのまま取得された情報のチャンク。表、段落、リストなど、さまざまな種類のコンテンツを強調表示して、教師のモデルをガイドします。

各 qna.yaml には 5 つのコンテキストブロックが必要で、最大トークン数は 500 です。

ほうおう座は南の空にある小さな星座です。神話上のフェニックスにちなんで名付けられ、1603 年にヨハンバイエルンが著した天体地図ウラノメトリアに初めて描かれました。フランスの探検家で天文学者の Nicolas Louis de Lacaille は、1756 年に明るい星を星図に記し、バイエル符号を与えました。

questions_and_answers

モデルが学習する質問と回答が含まれるフィールド。

qna.yaml には、context ブロックごとに 3 つの質問と回答のペアが必要です。

questions_and_answers:
  - question:
    answer:

question

関連するコンテキストで、およびそれに関連する質問です。事実に基づく質問、推論、説明など、さまざまな質問と質問タイプを提供します。

最大トークン数は 250 です。

ほうおう座を星図に記したのは誰ですか?

answer

指定された質問に対する回答。回答は完全な文章で記述し、context フィールドで参照する必要があります。

最大トークン数は 250 です。

ほうおう座は、フランスの探検家で天文学者の Nicolas Louis de Lacaille によって星図に記されました。

document_outline

論文の要旨に似た、文書の簡単な要約。これにより、ドキュメントの内容に関するコンテキストの概要がわかります。

context フィールドの内容を詳細に記述し、参照する必要があります。

ほうおう座に関する情報 (星座の歴史、特性、特徴など)。

document

ナレッジデータのソースが含まれるフィールド。

-

document:
   repo:
   commit:
   patterns:

repo

ナレッジファイルを含む git リポジトリーへの URL。

-

github.com/<profile>/<repo-name>

commit

リポジトリー内のドキュメントに対応する完全なコミットハッシュ

-

-

patterns

git リポジトリーのファイルが含まれています。

有効な値は .md または .pdf です。

phoenix_constellation.md

qna.yaml を作成するための関連情報

2.1. ナレッジ YAML ファイルの作成

次のプロセスは、RHEL AI ツールセットを使用して、提供されたナレッジファイルについて LLM に教える qna.yaml ファイルを作成する方法を示しています。

前提条件

  • 起動可能なコンテナーイメージを使用して RHEL AI をインストールしている。
  • git CLI をインストールしている。
  • InstructLab を初期化し、ilab CLI を使用できる。
  • マシンの root ユーザーアクセス権がある。

手順

  1. ナレッジファイルを git リポジトリーでホストしているため、タクソノミーを更新するときは作業ブランチをチェックアウトする必要があります。
  2. taxonomy フォルダーに移動します。RHEL AI には、対話するための既成のタクソノミーツリーが含まれています。
  3. taxonomy ディレクトリー内の knowledge フォルダーに移動します。
  4. ナレッジ qna.yaml ファイルを追加するタクソノミーツリーにディレクトリーとフォルダーを追加します。

    タクソノミーツリー内のファイルパスの例

    taxonomy/knowledge/technical_documents/product_customer_cases/qna.yaml

  5. 任意のテキストエディターを使用して、qna.yaml ファイルを作成します。YAML には qna.yaml のタイトルが必要です。

    注記

    SDG を適切に実行するには、questions_and_answers パラメーターに、コンテキスト値ごとに少なくとも 5 つの context チャンクと 3 つの質問と回答のシードを含める必要があります。

  6. 必要なキーを qna.yaml ファイルに追加し、変更を保存します。qna.yaml ファイルのフォーマットに関する詳細は、「ナレッジ YAML 仕様の例」を参照してください。

検証

  • ナレッジの qna.yaml ファイルが正しい形式であることを確認するには、以下のコマンドを実行します。

    $ ilab taxonomy diff

    CLI には、タクソノミーツリーと qna.yaml ファイルが有効であるか、適切にフォーマットされているかが表示されます。CLI では、発生したエラーを修正できる場所も表示されます。

    有効なタクソノミーツリーと qna.yaml ファイルの出力例

    knowledge/technical_documents/product_customer_cases/qna.yaml
    Taxonomy in /taxonomy/ is valid :)

    無効なタクソノミーツリーとエラーのある qna.yaml ファイルの出力例

    9:15 error syntax error: mapping values are not allowed here (syntax)
    Reading taxonomy failed with the following error: 1 taxonomy with errors! Exiting.

2.1.1. ナレッジ YAML 仕様の例

ナレッジコントリビューションは、qna.yaml ファイルを使用して、モデルを訓練するドキュメントの読み取り方法を学習します。RHEL AI の合成データ生成 (SDG) プロセスは qna.yaml シード例を使用して大量の人工データを作成します。このプロセスにより、モデルは提供されたサンプルだけに頼るのではなく、より多くのデータから学習できるようになります。

ナレッジの qna.yaml ファイルの例

version: 3 
1

domain: astronomy 
2

document_outline: | 
3

  Information about the Phoenix Constellation including the
  history, characteristics, and features of the stars in the constellation.
created_by: <user-name> 
4

seed_examples:
  - context: | 
5

      **Phoenix** is a minor constellation in the southern sky. Named after the mythical
      Phoenix_(mythology), it was first depicted on a celestial atlas by Johann Bayerin his 1603
      Uranometria. The French explorer and astronomer Nicolas Louis de Lacaille charted the brighter stars
      and gave their Bayer designations in 1756. The constellation stretches from roughly −39 degrees to −57
      degrees declination, and from 23.5h to 2.5h of right ascension. The constellations Phoenix, Grus,
      Pavo and Tucana are known as the Southern Birds.
    questions_and_answers:
      - question: | 
6

          What is the Phoenix constellation?
        answer: | 
7

         The Phoenix constellation is a minor constellation in the southern sky.
      - question: |
          Who charted the Phoenix constellation?
        answer: |
          The Phoenix constellation was charted by french explorer and
          astronomer Nicolas Louis de Lacaille.
      - question: |
          How far does the Phoenix constellation stretch?
        answer: |
          The phoenix constellation stretches from roughly −39° to −57°
          declination, and from 23.5h to 2.5h of right ascension.
  - context: |
      Phoenix was the largest of the 12 constellations established by Petrus Plancius from the observations
      of Pieter Dirkszoon Keyser and Frederick de Houtman. It first appeared on a 35cm diameter celestial globe
      published in 1597 (or 1598) in Amsterdam by Plancius with Jodocus Hondius. The first depiction of this
      constellation in a celestial atlas was in Johann Bayer *Uranometria* of 1603. De Houtman included it in
      his southern star catalog the same year under the Dutch name *Den voghel Fenicx*, "The Bird Phoenix",
      symbolising the phoenix of classical mythology. One name of the brightest star Alpha Phoenicis—Ankaa—is
      derived from the Arabic: العنقاء, romanized: al-‘anqā’, lit. 'the phoenix', and was coined sometime after
      1800 in relation to the constellation.
    questions_and_answers:
      - question: |
          What is the brightest star in the Phoenix constellation
          called?
        answer: |
          Alpha Phoenicis or Ankaa is the brightest star in the Phoenix
          Constellation.
      - question: Where did the Phoenix constellation first appear?
        answer: |
          The Phoenix constellation first appeared on a 35-cm diameter
          celestial globe published in 1597 (or 1598) in Amsterdam by
          Plancius with Jodocus Hondius.
      - question: |
          What does "The Bird Phoenix" symbolize?
        answer: |
          "The Bird Phoenix" symbolizes the phoenix of classical mythology.
  - context: |
      Phoenix is a small constellation bordered by Fornax and Sculptor to the north, Grus to the west,
      Tucana to the south, touching on the corner of Hydrus to the south, and Eridanus to the east and southeast.
      The bright star Achernar is nearby. The three-letter abbreviation for the constellation, as adopted by
      the International Astronomical Union in 1922, is "Phe". The official constellation boundaries,
      as set by Belgian astronomer Eugène Delporte in 1930, are defined by a polygon of 10 segments.
      In the equatorial coordinate system, the right ascension coordinates of these borders lie
      between 23<sup>h</sup> 26.5<sup>m</sup> and 02<sup>h</sup> 25.0<sup>m</sup>,
      while the declination coordinates are between −39.31° and −57.84°. This means it remains
      below the horizon to anyone living north of the 40th parallel in the Northern
      Hemisphere, and remains low in the sky for anyone living north of the equator. It is most
      visible from locations such as Australia and South Africa during late Southern Hemisphere spring.
      Most of the constellation lies within, and can be located by, forming a triangle of the bright
      stars Achernar, Fomalhaut and Beta Ceti—Ankaa lies roughly in the centre of this.
    questions_and_answers:
      - question: What are the characteristics of the Phoenix constellation?
        answer: |
          Phoenix is a small constellation bordered by Fornax and Sculptor to
          the north, Grus to the west, Tucana to the south, touching on the
          corner of Hydrus to the south, and Eridanus to the east and southeast.
          The bright star Achernar is nearby.
      - question: |
          When is the phoenix constellation most visible?
        answer: |
          Phoenix is most visible from locations such as Australia and
          South Africa during late Southern Hemisphere spring.
      - question: |
          What are the Phoenix Constellation boundaries?
        answer: |
          The official constellation boundaries for Phoenix, as set by Belgian
          astronomer Eugène Delporte in 1930, are defined by a polygon of 10
          segments.
  - context: |
      Ten stars have been found to have planets to date, and four planetary systems have been
      discovered with the SuperWASP project. HD 142 is a yellow giant that has an apparent magnitude
      of 5.7, and has a planet (HD 142b) 1.36 times the mass of Jupiter which orbits every 328 days.
      HD 2039 is a yellow subgiant with an apparent magnitude of 9.0 around 330 light years away which
      has a planet (HD 2039) six times the mass of Jupiter. WASP-18 is a star of magnitude 9.29 which
      was discovered to have a hot Jupiter-like planet (WASP-18b) taking less than a day to orbit the star.
      The planet is suspected to be causing WASP-18 to appear older than it really is. WASP-4and WASP-5
      are solar-type yellow stars around 1000 light years distant and of 13th magnitude, each with a single
      planet larger than Jupiter. WASP-29 is an orange dwarf of spectral type K4V and visual magnitude 11.3,
      which has a planetary companion of similar size and mass to Saturn. The planet completes an orbit
      every 3.9 days.
    questions_and_answers:
      - question: In the Phoenix constellation, how many stars have planets?
        answer: |
          In the Phoenix constellation, ten stars have been found to have
          planets to date, and four planetary systems have been discovered
          with the SuperWASP project.
      - question: |
          What is HD 142?
        answer: |
          HD 142 is a yellow giant that has an apparent magnitude of 5.7, and
          has a planet (HD 142 b) 1.36 times the mass of Jupiter which
          orbits every 328 days.
      - question: |
          Are WASP-4 and WASP-5 solar-type yellow stars?
        answer: |
          Yes, WASP-4 and WASP-5 are solar-type yellow stars around 1000 light
          years distant and of 13th magnitude, each with a single planet
          larger than Jupiter.
  - context: |
      The constellation does not lie on the galactic plane of the Milky Way, and there are no prominent star
      clusters. NGC 625 is a dwarf irregular galaxy of apparent magnitude 11.0 and lying some 12.7 million
      light years distant. Only 24000 light years in diameter, it is an outlying member of the Sculptor Group.
      NGC 625 is thought to have been involved in a collision and is experiencing a burst of active star formation.
      NGC 37 is a lenticular galaxy of apparent magnitude 14.66. It is approximately 42 kiloparsecs 137,000
      light-years in diameter and about 12.9 billion years old. Robert's Quartet composed of the irregular galaxy
      NGC 87, and three spiral galaxies NGC 88, NGC 89 and NGC 92 is a group of four galaxies located around 160 million
      light-years away which are in the process of colliding and merging. They are within a circle of radius of 1.6 arcmin,
      corresponding to about 75,000 light-years. Located in the galaxy ESO 243-49 is HLX-1, an intermediate-mass
      black hole—the first one of its kind identified. It is thought to be a remnant of a dwarf galaxy that was absorbed
      in a collision with ESO 243-49. Before its discovery, this class of black hole was only hypothesized.
    questions_and_answers:
      - question: |
          Is the Phoenix Constellation part of the Milky Way?
        answer: |
          The Phoenix constellation does not lie on the galactic plane of
          the Milky Way, and there are no prominent star clusters.
      - question: |
          How many light years away is NGC 625?
        answer: |
          NGC 625 is 24000 light years in diameter and is an outlying
          member of the Sculptor Group.
      - question: |
          What is Robert's Quartet composed of?
        answer: |
          Robert's Quartet is composed of the irregular galaxy NGC 87,
          and three spiral galaxies NGC 88, NGC 89 and NGC 92.
document:
  repo: https://github.com/<profile>/<repo-name> /
8

  commit: <commit hash> 
9

  patterns:
  - phoenix_constellation.md 
10

  - phoenix_history.md

1
ナレッジ qna.yaml 形式のバージョンを指定します。現在、有効な値は 3 です。
2
ドキュメントの件名またはカテゴリーを指定します。たとえば、"Technical Documents" または "Installation Guides" です。
3
ドキュメントの内容の概要を指定します。document_outline フィールドの コンテキスト パラメーターに含める主題を参照することを推奨します。たとえば、ドキュメントがインストールガイドで、各 context にさまざまなクラウドプロバイダーの詳細が含まれている場合、document_outline は "Installation guides for AWS, GCP, and Azure" になります。
4
名前または git ユーザー名を指定します。
5
ナレッジデータの段落を指定します。これは、質問と回答のベースとなるコンテンツです。コンテキストブロックの形式は、ナレッジファイルの形式と一致する必要があります。たとえば、ナレッジドキュメントが Markdown 形式である場合は、context ブロックも Markdown 形式である必要があります。
6
モデルに対する質問を指定します。問題は、context フィールドの情報に基づいている必要があります。たとえば、"What is the latest version of the product?" です。
7
モデルからの望ましい応答を指定します。回答の情報は context ブロックからコピーするのではなく、完全な文で含める必要があります。回答は完全な文章にする必要があります。たとえば、"The latest version of the product is version 1.5" です。
8
ナレッジファイルを保持するリポジトリーへの URL を指定します。
9
ナレッジファイルの git リポジトリーからのコミットの SHA を指定します。
10
git リポジトリーでドキュメントを指定します。有効なドキュメントタイプの値には、.md または .pdf が含まれます。1 つの qna.yaml ファイルは 1 つのドキュメントタイプのみを参照でき、同じ qna.yaml 内でファイルタイプを混在させることはサポートされていません。
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2026 Red Hat
トップに戻る