スキルとナレッジの YAML ファイルの作成


Red Hat Enterprise Linux AI 1.5

スキルとナレッジの YAML ファイルを作成するためのガイドライン

Red Hat RHEL AI Documentation Team

概要

このドキュメントでは、モデルをトレーニングするためのスキルとナレッジの YAML データファイルを作成する方法を説明します。

第1章 タクソノミーツリーのカスタマイズ

RHEL AI 環境内のナレッジまたはスキルデータを使用してタクソノミーツリーを変更し、独自のカスタム Granite Large Language Model (LLM) を作成できます。RHEL AI では、ナレッジとスキルで作成されたデータセットが YAML でフォーマットされています。この YAML 設定は qna.yaml ファイルと呼ばれ、"qna" は質問と回答を表します。タクソノミーツリーは、qna.yaml ファイルを保持するカテゴリーおよび情報分類の方法です。

次のドキュメントセクションでは、タクソノミーツリーのスキルとナレッジの qna.yaml ファイルを作成する方法について説明します。

スターター Granite LLM のトレーニングに使用できる、サポート対象のナレッジドキュメントタイプがいくつかあります。現在サポートされているドキュメントの種類は次のとおりです。

  • マークダウン
  • PDF

1.1. スキルとナレッジの概要

スキルとナレッジセットを使用し、ドメイン固有の情報を指定してカスタムモデルを教えることができます。

ナレッジ
情報およびファクトで構成されるデータセット。モデルのナレッジデータを作成するときは、モデルが質問に正確に答えられるように、追加のデータと情報を提供します。
スキル

モデルにタスクの実行方法を教えることができるデータセット。RHEL AI のスキルは、次のカテゴリーに分類されます。

  • 構成スキル: 構成スキルにより、AI モデルは特定のタスクや機能を実行できます。構成スキルには、以下の 2 つのタイプがあります。

    • 自由形式の構成スキル: 機能するために追加のコンテキストや情報を必要としないパフォーマンススキルです。
    • グラウンディング構成スキル: このスキルは追加のコンテキストを必要とする実行スキルです。たとえば、モデルが表を読み取れるように訓練できます。この場合、追加のコンテキストは表のレイアウトの例などです。
  • 基礎スキル: 基礎スキルとは、数学、推論、コーディングに関わるスキルです。

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

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

表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:
Copy to Clipboard

context

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

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

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

questions_and_answers

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

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

questions_and_answers:
  - question:
    answer:
Copy to Clipboard

question

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

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

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

answer

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

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

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

document_outline

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

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

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

document

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

-

document:
   repo:
   commit:
   patterns:
Copy to Clipboard

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
    Copy to Clipboard

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

    注記

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

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

検証

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

    $ ilab taxonomy diff
    Copy to Clipboard

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

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

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

    無効なタクソノミーツリーとエラーのある 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.
    Copy to Clipboard

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
Copy to Clipboard

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 内でファイルタイプを混在させることはサポートされていません。

2.2. ナレッジマークダウンファイルの作成

Red Hat Enterprise Linux AI バージョン 1.5 では、ナレッジドキュメントとデータを git リポジトリーにマークダウン形式でホストする必要があります。標準の git ワークフローを使用して、ファイルを作成し、リポジトリーにアップロードできます。使用できるオープンソースのマークダウン変換ツールは、次のとおりです。

  • Pandoc: オープンソースの変換ツール。
  • All in One エクステンションを備えた Visual Studio Code: Visual Studio Code でドキュメントを開き、Markdown All in One エクステンション を使用して Markdown に変換できます。
  • IBM Deepsearch/Docling: PDF ドキュメントを JSON およびマークダウンに変換する機能を自己完結型パッケージにバンドルします。

手順

  1. 希望する git ホスティングプラットフォームを選択します。Git と互換性がある限り、RHEL AI ではどのプラットフォームでも使用できます。
  2. ドキュメントを .md マークダウン形式に変換します。ナレッジデータには、任意のマークダウン変換ソフトウェアを使用できます。

    次のリストには、ナレッジマークダウンファイルのガイドラインが含まれています。

    • すべてのドキュメントはテキストである必要があります。イメージは現在サポートされていません。
    • ドキュメントから脚注を削除します。
    • 表はマークダウン形式である必要があります。
    • チャートとグラフは現在サポートされていません。
  3. ファイル名とコミットハッシュをメモします。この値は qna.yaml ファイルで使用されます。
  4. md ファイルを作成し、git リポジトリーにアップロードします。

    ナレッジドキュメントのマークダウンの例

    # Phoenix (constellation)
    
    **Phoenix** is a minor constellation in the southern sky. Named after the mythical phoenix,
    it was first depicted on a celestial atlas by Johann Bayer in 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.
    
    The brightest star, Alpha Phoenicis, is named Ankaa, an Arabic word meaning 'the Phoenix'.
    It is an orange giant of apparent magnitude 2.4. Next is Beta Phoenicis, actually a
    binary system composed of two yellow giants with a combined apparent magnitude of 3.3. Nu Phoenicis
    has a dust disk, while the constellation has ten star systems with known planets and the recently
    discovered galaxy clusters El Gordo and the Phoenix Cluster—located 7.2 and 5.7 billion light years
    away respectively, two of the largest objects in the visible universe. Phoenix is the radiant of
    two annual meteor showers: the Phoenicids in December, and the July Phoenicids.
    
    ## History
    
    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 35-cm 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's*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", symbolizing 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.
    
    Celestial historian Richard Allen noted that unlike the other constellations introduced by Plancius and La
    Caille, Phoenix has actual precedent in ancient astronomy, as the Arabs saw this formation as representing
    young ostriches, *Al Ri'āl*, or as a griffin or eagle. In addition, the same group of stars was sometimes
    imagined by the Arabs as a boat, *Al Zaurak*, on the nearby river Eridanus. He observed,
    "the introduction of a Phoenix into modern astronomy was, in a measure, by adoption rather than by invention."
    
    The Chinese incorporated Phoenix's brightest star, Ankaa (Alpha Phoenicis), and stars from the adjacent
    constellation Sculptor to depict *Bakui*, a net for catching birds. Phoenix and the neighboring constellation
    of Grus together were seen by Julius Schiller as portraying Aaron the High Priest. These two constellations,
    along with nearby Pavo and Tucana, are called the Southern Birds.
    
    ## Characteristics
    
    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.
    Copy to Clipboard

第3章 タクソノミーツリーへのスキルの追加

スターターモデルは、ドメイン固有のスキルを qna.yaml ファイルに入力することでカスタムスキルを学習できます。スキルの各 qna.yaml ファイルには、次のキーを持つキー値エントリーのセットが含まれています。

表3.1 Red Hat Enterprise Linux AI
フィールド説明制限

version

qna.yaml ファイルのバージョン。これは、SDG に使用されるファイルの形式です。

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

created_by

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

なし

task_description

スキルとその機能の説明。

なし

seed_examples

キーと値のエントリーのコレクションです。

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

context

グラウンディングスキルでは、モデルがスキルを実行するために知っておく必要のある情報など、追加のコンテキストをユーザーが提供する必要があります。

このフィールドは、グラウンディングスキルに必須です。各 qna.yaml には 5 つのコンテキストブロックが必要で、最大トークン数は 500 です。

question

モデルに対する質問を指定します。

qna.yaml ファイルには、少なくとも 5 つの質問と回答のペアが必要で、トークンの最大数は 250 です。

answer

モデルの回答を指定します。

qna.yaml ファイルには、少なくとも 5 つの質問と回答のペアが必要で、トークンの最大数は 250 です。

3.1. スキルの YAML ファイルの作成

タクソノミーツリーをカスタマイズして、モデルが目的のユースケースのスキルを新たに学習できるようにします。次の手順では、スキル qna.yaml ファイルを含むタクソノミーツリーを作成する方法を示します。

前提条件

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

手順

  1. taxonomy ディレクトリーの compositional_skills フォルダーに移動します。

    重要

    基礎スキル、つまりコード作成を伴うスキルの作成は、現在 RHEL AI バージョン 1.5 ではサポートされていません。

  2. ツリー内に存在するディレクトリーに基づいて、ツリー内で、スキルの qna.yaml ファイルの追加先を選択します。

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

    taxonomy/compositional_skills/grounded/<add_example>/qna.yaml
    Copy to Clipboard

  3. 任意のテキストエディターを使用して、qna.yaml ファイルを作成します。

    注記

    SDG を適切に実行するには、qna.yaml ファイルに少なくとも 5 つの質問と回答のペアの例を含める必要があります。

  4. 必要なキーを qna.yaml ファイルに追加し、変更を保存します。qna.yaml ファイルのフォーマットの詳細は、「スキル YAML 仕様のサンプル」を参照してください。

検証

  • スキルが適切な形式であることを確認するには、次のコマンドを実行します。

    $ ilab taxonomy diff
    Copy to Clipboard

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

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

    compositional_skills/writing/freeform/<example>/qna.yaml
    Taxonomy in /taxonomy/ is valid :)
    Copy to Clipboard

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

    6:11 error syntax error: mapping values are not allowed here (syntax)
    Reading taxonomy failed with the following error: 1 taxonomy with errors! Exiting.
    Copy to Clipboard

3.2. スキル YAML 仕様のサンプル

スキルは、ナレッジ YAML ファイルと同様の質問と回答のレイアウトを共有します。RHEL AI では、合成データ生成 (SDG) プロセスは、ユーザーが生成したデータのみに依存するのではなく、qna.yaml シード例を使用して、モデルが学習するための大量の人工データを作成します。

質問、回答、コンテキストのペアの順序は、SDG またはトレーニングプロセスに影響しません。スキルには複数の種類があり、フリーフォーム、グラウンディング、基礎スキルのカテゴリーに分類されます。各カテゴリーのサンプルは次の例で確認できます。

フリーフォーム構成スキル qna.yaml ファイルの例

version: 2 
1

created_by: <user-name> 
2

task_description: 'Teach the model how to rhyme.' 
3

seed_examples:
  - question: What are 5 words that rhyme with horn? 
4

    answer: warn, torn, born, thorn, and corn. 
5

  - question: What are 5 words that rhyme with cat?
    answer: bat, gnat, rat, vat, and mat.
  - question: What are 5 words that rhyme with poor?
    answer: door, shore, core, bore, and tore.
  - question: What are 5 words that rhyme with bank?
    answer: tank, rank, prank, sank, and drank.
  - question: What are 5 words that rhyme with bake?
    answer: wake, lake, steak, make, and quake.
Copy to Clipboard

グラウンディング構成スキルの qna.yaml ファイルの例

version: 2 
1

created_by: <user-name> 
2

task_description: This skill provides the ability to read a markdown-formatted table. 
3

seed_examples:
  - context: | 
4

      | **Breed**      | **Size**     | **Barking** | **Energy** |
      |----------------|--------------|-------------|------------|
      | Afghan Hound   | 25-27 in     | 3/5         | 4/5        |
      | Labrador       | 22.5-24.5 in | 3/5         | 5/5        |
      | Cocker Spaniel | 14.5-15.5 in | 3/5         | 4/5        |
      | Poodle (Toy)   | <= 10 in     | 4/5         | 4/5        |
    question: | 
5

      Which breed has the most energy?
    answer: | 
6

      The breed with the most energy is the Labrador.
  - context: |
      | **Name** | **Date** | **Color** | **Letter** | **Number** |
      |----------|----------|-----------|------------|------------|
      | George   | Mar 5    | Green     | A          | 1          |
      | Gráinne  | Dec 31   | Red       | B          | 2          |
      | Abigail  | Jan 17   | Yellow    | C          | 3          |
      | Bhavna   | Apr 29   | Purple    | D          | 4          |
      | Rémy     | Sep 9    | Blue      | E          | 5          |
    question: |
      What is Gráinne's letter and what is her color?
    answer: |
      Gráinne's letter is B and her color is red.
  - context: |
      | Banana | Apple      | Blueberry | Strawberry |
      |--------|------------|-----------|------------|
      | Yellow | Red, Green | Blue      | Red        |
      | Large  | Medium     | Small     | Small      |
      | Peel   | Peel       | No peel   | No peel    |
    question: |
      Which fruit is blue, small, and has no peel?
    answer: |
      The blueberry is blue, small, and has no peel.
Copy to Clipboard

1 1
スキル qna.yaml 形式のバージョンを指定します。
2 2
名前または git ユーザー名を指定します。
3 3
スキルとその機能の説明を指定します。
4
スキルを実行するためにモデルが知っておく必要のある情報を含む追加のコンテキストを指定します。基礎スキルに必要です。
4 5
モデルに対する質問を指定します。
5 6
モデルからの望ましい応答を指定します。

第4章 モデルのパフォーマンスの最適化のための YAML 作成プラクティス

タクソノミーツリーへのナレッジの追加 および タクソノミーツリーへのスキルの追加 で参照されるガイドラインは、スキルとナレッジ YAML ファイルの作成に関する標準手順を提供します。ただし、生成された合成データを最適化し、より高い品質モデルを作成するために、YAML ファイルを改善する方法もあります。

YAML ファイルの context フィールドにおける多様で包括的なコンテンツ

context ブロックには、ドキュメントのさまざまな情報と形式を含める必要があります。これにより、モデルは情報を提供するさまざまな方法を学ぶことができます。これらの情報を提供するさまざまな方法には、パラグラフ、さまざまな種類の表、リスト、手順、定義などがあります。

context ブロックは、ドキュメントの包括的な例である必要があります。context コンテンツと Q&A ペアの合計の長さは、750 トークンを超えることはできません。

効果的な質問の作成

質問は、モデルが回答できるような質問のタイプに合わせる必要があります。各質問は一意で、context フィールドの情報を参照する必要があります。完全な文章での質問を含めると、生成される合成データが向上し、モデルの回答品質が向上します。

効果的な回答の作成

回答は、質問に直接答え、モデルが提供できる回答のタイプを反映する必要があります。回答は完全な文章で、元の質問を参照する必要があります。完全な文章での回答を含めると、生成される合成データが向上し、モデルの回答品質が向上します。

回答は、context ブロックから直接コピーしないでください。直接コピーすると、モデルは推論するのではなく、抽出を学習する可能性があります。

質問に回答するための情報は、context ブロックにある必要があります。情報が別の context ブロックにあるか、参照されていない場合は、モデルがハルシネーションを起こす可能性があります。

高品質の質問と回答ペアの例

- question: How many eggs are needed to make roughly 24 chocolate chip cookies?

  answer: You need around two eggs to make 24 chocolate chip cookies.
Copy to Clipboard

複数のドキュメントまたは複数の qna.yaml ファイルを使用する場合

複数のドキュメントが同様のサブジェクトまたはドメインに関連する場合は、qna.yaml ファイル 1 つを使用することが推奨されます。それぞれの qna.yaml ファイルには単数形のドキュメントタイプが含まれている必要がありますが、YAML ファイルでドキュメントタイプを混在させることはできません。

複数のドキュメントが関連していない場合は、個別の qna.yaml ファイルを使用することが推奨されます。

YAML ファイルへのリンクの追加

モデルはリンクを記憶できるため、YAML ファイルにリンクを追加できます。ただし、ハイパーリンクが頻繁に変更される場合は、ハイパーリンクを追加しないようにすることを推奨します。

法律上の通知

Copyright © 2025 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

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

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

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

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

会社概要

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

Theme

© 2025 Red Hat