此内容没有您所选择的语言版本。
Chapter 2. Adding knowledge to your taxonomy tree
You can customize your taxonomy tree so a model can learn domain-specific information. For RHEL AI, your knowledge data is hosted in a Git repository. Knowledge contributions use the qna.yaml
file to learn how to read the document that you want to teach the model. Each qna.yaml
file for knowledge contains a set of key-value entries with the following keys:
Field | Description | Constraints | Example |
---|---|---|---|
| The taxonomy schema version used in the qna.yaml file. |
The currently supported value for this parameter is |
|
| The name or username of the contributor. | - |
|
| The subject or category of the knowledge document. The domain prompts to the teacher model during synthetic data generation and adds additional context. |
It is recommended that your |
For a knowledge document about the Phoenix contestation, the domain would be
For a knowledge document about Health insurance information, the domain would be |
| The field that contains the question-and-answer pairs with context from the knowledge document. |
At least five seed examples are required in your |
seed_examples: - context: questions_and_answers: |
| A chunk of information taken exactly from the knowledge document. Highlight different types of content, including tables, paragraphs or lists, to help guide the teacher model. | Each qna.yaml needs five context blocks and has a maximum token count of 500 tokens. |
|
| The field that contains the questions and answers for your model to learn. |
Each |
questions_and_answers: - question: answer: |
| A question related to and grounded in the relevant context. Provide a variety questions and question types, including fact-based, reasoning, or clarifications. | Maximum token count of 250 tokens. |
|
|
The answer to the specified question. Answers should be in complete sentences and be referenced in the | Maximum token count of 250 tokens. |
|
| A brief summary of the document, similar to a thesis statement. This provides a high-level context for the content of the document. |
Must be detailed and reference the content in the |
|
| The field that contains the source of your knowledge data. | - |
document: repo: commit: patterns: |
| The URL to your git repository that contains your knowledge files. | - |
|
| The full commit hash that corresponds to the document in the repo | - | - |
| Contains the file(s) in your git repository |
Valid values include |
|
Additional resources for creating a qna.yaml
-
For a full
qna.yaml
file with example parameters, see the Sample knowledge YAML specifications documentation. - For full guidelines on the YAML curation process, see the YAML creation practices for optimizing model performance documentation.
2.1. Creating a knowledge YAML file
The following process displays how to create a qna.yaml
file that teaches your LLM about your provided knowledge files using the RHEL AI toolset.
Prerequisites
- You installed RHEL AI with the bootable container image.
- You installed the git CLI.
-
You initialized InstructLab and can use the
ilab
CLI. - You have root user access on your machine.
Procedure
- Since you are hosting your knowledge files in a git repository, you need to checkout a working branch when updating your taxonomy.
- Navigate to the taxonomy folder. RHEL AI includes a ready made taxonomy tree to interact with.
- Navigate to the knowledge folder in the taxonomy directory.
Add directories and folders in the taxonomy tree where you want to add your knowledge
qna.yaml
file.Example file path in the taxonomy tree
taxonomy/knowledge/technical_documents/product_customer_cases/qna.yaml
Using your desired text editor, create the
qna.yaml
file. Your YAML must have theqna.yaml
title.NoteFor SDG to run properly, you must include at least five
context
chunks and three question and answer seeds per context value in thequestions_and_answers
parameter.-
Add the necessary keys to the
qna.yaml
file and save your changes. For more information about formatting yourqna.yaml
file, see "Sample knowledge YAML specifications".
Verification
To verify that your knowledge
qna.yaml
file is in the proper format, you can run the following command:$ ilab taxonomy diff
The CLI displays if your taxonomy tree and
qna.yaml
file is valid and properly formatted. The CLI also shows you where you can fix any errors you encounter.Example output of valid taxonomy tree and
qna.yaml
fileknowledge/technical_documents/product_customer_cases/qna.yaml Taxonomy in /taxonomy/ is valid :)
Example output of invalid taxonomy tree and
qna.yaml
file with errors9: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. Sample knowledge YAML specifications
Knowledge contributions use the qna.yaml
file to learn how to read the document that you want to teach the model. On RHEL AI, the synthetic data generation (SDG) process uses your qna.yaml
seed examples to create a large quantity of artificial data. This process makes it so the model has more data to learn from rather than exclusively relying on provided samples.
Example knowledge qna.yaml
file
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
- Specify the version of the knowledge
qna.yaml
format. Currently, the valid value is3
. - 2
- Specify the subject or category of the document. For example, "Technical Documents" or "Installation Guides".
- 3
- Specify a outline of the document’s contents. It is recommenced to reference the subjects that you include in the
context
parameter in thedocument_outline
field. For example, if the document was an installation guide and eachcontext
included details on different cloud providers, thedocument_outline
would be "Installation guides for AWS, GCP, and Azure". - 4
- Specify your name or git username.
- 5
- Specify a paragraph of your knowledge data. This is content that your questions and answers are be based on. The format of the context block must match the format of the your knowledge file. For example, if your knowledge document is in Markdown, your
context
block must also be in the Markdown format. - 6
- Specify a question for the model. The question should be based on the information in the
context
field. For example, "What is the latest version of the product?". - 7
- Specify the desired response from the model. The information for the answer must be included, but not copied, from the
context
block and be in complete sentences. Answers should be in complete sentences. For example, "The latest version of the product is version 1.5". - 8
- Specify the URL to the repository that holds your knowledge files.
- 9
- Specify the SHA of the commit from your git repository of your knowledge files.
- 10
- Specify the documents in your git repository. Valid document type values include
.md
or.pdf
. A singleqna.yaml
file can only reference one document type, mixing file types within the sameqna.yaml
is not supported.
2.2. Creating a knowledge markdown file
On Red Hat Enterprise Linux AI version 1.4, you must host your knowledge documentation and data in a git repository and in markdown format. You can use the standard git workflow to create and upload files to your repository. There are various open source markdown conversion tools you can use, including:
- Pandoc: An open source conversion tool.
- Visual Studio Code with All in one extention: You can open your document in Visual Studio Code, and use the Markdown All in One extensions to convert to Markdown.
- IBM Deepsearch/Docling: Bundles PDF document conversion to JSON and markdown in a self-contained package.
Procedure
- Select your preferred git hosting platform. You can use any platform on RHEL AI as long as it’s compatible with git.
Convert your documents into the
.md
markdown format. You can use any markdown conversion software you want for your knowledge data.The following list includes guidelines for knowledge markdown files:
- All documents must be text, images are not currently supported.
- Remove any footnotes from your documents.
- Tables must be in markdown format.
- Charts and graphs are currently not supported.
-
Make a note of your file name and commit hash. This value is used in your
qna.yaml
file. Create and upload a
md
file into your git repository.Example markdown of a knowledge document
# 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.