第2章 タクソノミーツリーへのナレッジの追加
モデルがドメイン固有の情報を学習できるように、タクソノミーツリーをカスタマイズできます。RHEL AI の場合、ナレッジデータは Git リポジトリーでホストされます。ナレッジコントリビューションは、qna.yaml ファイルを使用して、モデルを訓練するドキュメントの読み取り方法を学習します。ナレッジの各 qna.yaml ファイルには、次のキーを持つキー値エントリーのセットが含まれています。
| フィールド | 説明 | 制約 | 例 |
|---|---|---|---|
|
| qna.yaml ファイルで使用されるタクソノミースキーマのバージョン。 |
このパラメーターで現在サポートされている値は |
|
|
| コントリビューターの名前またはユーザー名。 | - |
|
|
| ナレッジドキュメントの主題またはカテゴリー。ドメインは、合成データの生成中に教師モデルにプロンプトを表示し、別のコンテキストを追加します。 |
|
ほうおう座に関するナレッジドキュメントの場合、ドメインは
健康保険情報に関するナレッジドキュメントの場合、ドメインは |
|
| ナレッジドキュメントからのコンテキストを含む質問と回答のペアが含まれるフィールド。 |
|
|
|
| ナレッジドキュメントからそのまま取得された情報のチャンク。表、段落、リストなど、さまざまな種類のコンテンツを強調表示して、教師のモデルをガイドします。 | 各 qna.yaml には 5 つのコンテキストブロックが必要で、最大トークン数は 500 です。 |
|
|
| モデルが学習する質問と回答が含まれるフィールド。 |
各 |
|
|
| 関連するコンテキストで、およびそれに関連する質問です。事実に基づく質問、推論、説明など、さまざまな質問と質問タイプを提供します。 | 最大トークン数は 250 です。 |
|
|
|
指定された質問に対する回答。回答は完全な文章で記述し、 | 最大トークン数は 250 です。 |
|
|
| 論文の要旨に似た、文書の簡単な要約。これにより、ドキュメントの内容に関するコンテキストの概要がわかります。 |
|
|
|
| ナレッジデータのソースが含まれるフィールド。 | - |
|
|
| ナレッジファイルを含む git リポジトリーへの URL。 | - |
|
|
| リポジトリー内のドキュメントに対応する完全なコミットハッシュ | - | - |
|
| git リポジトリーのファイルが含まれています。 |
有効な値は |
|
qna.yaml を作成するための関連情報
-
サンプルパラメーターを含む完全な
qna.yamlファイルは、サンプルナレッジ YAML 仕様 ドキュメントを参照してください。 - YAML キュレーションプロセスの完全なガイドラインは、モデルパフォーマンスを最適化するための YAML 作成プラクティス ドキュメントを参照してください。
2.1. ナレッジ YAML ファイルの作成 リンクのコピーリンクがクリップボードにコピーされました!
次のプロセスは、RHEL AI ツールセットを使用して、提供されたナレッジファイルについて LLM に教える qna.yaml ファイルを作成する方法を示しています。
前提条件
- 起動可能なコンテナーイメージを使用して RHEL AI をインストールしている。
- git CLI をインストールしている。
-
InstructLab を初期化し、
ilabCLI を使用できる。 - マシンの root ユーザーアクセス権がある。
手順
- ナレッジファイルを git リポジトリーでホストしているため、タクソノミーを更新するときは作業ブランチをチェックアウトする必要があります。
- taxonomy フォルダーに移動します。RHEL AI には、対話するための既成のタクソノミーツリーが含まれています。
- taxonomy ディレクトリー内の knowledge フォルダーに移動します。
ナレッジ
qna.yamlファイルを追加するタクソノミーツリーにディレクトリーとフォルダーを追加します。タクソノミーツリー内のファイルパスの例
taxonomy/knowledge/technical_documents/product_customer_cases/qna.yaml任意のテキストエディターを使用して、
qna.yamlファイルを作成します。YAML にはqna.yamlのタイトルが必要です。注記SDG を適切に実行するには、
questions_and_answersパラメーターに、コンテキスト値ごとに少なくとも 5 つのcontextチャンクと 3 つの質問と回答のシードを含める必要があります。-
必要なキーを
qna.yamlファイルに追加し、変更を保存します。qna.yamlファイルのフォーマットに関する詳細は、「ナレッジ YAML 仕様の例」を参照してください。
検証
ナレッジの
qna.yamlファイルが正しい形式であることを確認するには、以下のコマンドを実行します。$ ilab taxonomy diffCLI には、タクソノミーツリーと
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
domain: astronomy
document_outline: |
Information about the Phoenix Constellation including the
history, characteristics, and features of the stars in the constellation.
created_by: <user-name>
seed_examples:
- context: |
**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: |
What is the Phoenix constellation?
answer: |
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> /
commit: <commit hash>
patterns:
- phoenix_constellation.md
- 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内でファイルタイプを混在させることはサポートされていません。