创建技能和知识 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。当前支持的文档类型包括:

  • Markdown
  • PDF

1.1. 知识与知识概述

您可以使用知识和知识集,并指定域特定信息来呈现您的自定义模型。

知识
由信息和事实组成的数据集。在为模型创建知识数据时,您要为它提供附加数据和信息,以便模型可以更准确地回答问题。
技能

个数据集,您可以在其中教授模型如何执行任务。RHEL AI 的技术被分成几个类别:

  • 组成技能:组成技能允许 AI 模型执行特定任务或功能。有两种组成技能:

    • 自由组成技能:这些都是执行不需要额外上下文或信息才能正常工作的。
    • 现场组成技能:这些都是需要额外上下文的执行技能。例如,您可以省略模型来读取表,其中附加上下文是表布局的示例。
  • 基础技能:基础技能是涉及数学、原因和编码等技能。

其它资源

第 2 章 在您的税务树中添加知识

您可以自定义税务树,以便模型能够了解特定域的信息。对于 RHEL AI,您的知识数据托管在 Git 存储库中。知识贡献使用 qna.yaml 文件来了解如何阅读您要呈现模型的文档。每个用于知识的 qna.yaml 文件都包含一组键的键值条目:

Expand
表 2.1. Red Hat Enterprise Linux AI
字段描述约束(constraint)Example

version

qna.yaml 文件中使用的 taxonomy 模式版本。

此参数当前支持的值是 3

3

created_by

供稿者的名称或用户名。

-

kbrown

domain

知识文档的主题或类别。域在复合数据生成期间向教员模型提示并添加额外的上下文。

建议您的 domain 字段不超过三个单词。

有关 Phoenix contestation 的知识文档,域将是 Astronomy

有关健康保险信息的知识文档,域将是 Healthcare

seed_examples

包含与知识文档中的上下文的问答对的字段。

qna.yaml 文件中至少需要五个 seed 示例。

seed_examples:
  - context:
    questions_and_answers:
Copy to Clipboard Toggle word wrap

context

从知识文档中完全获取的信息块。突出显示不同类型的内容,包括表格、段落或列表,以帮助指导教员模型。

每个 qna.yaml 需要五个上下文块,且最大令牌计数为 500 个令牌。

Phoenix 是南部的小拥塞。在 mythical Phoenix_(myththology)后命名,最初在其 1603 Uranometria 的 celestial atlas 上被描述。法语学习者和 astronomer Nicolas Louis de Lacaille 图表了右边星,并在 1756 中给出了他们的"swonomer"设计。

questions_and_answers

包含您模型要学的问题和答案的字段。

每个 qna.yaml 需要每个 上下文 块的三个问题和回答对。

questions_and_answers:
  - question:
    answer:
Copy to Clipboard Toggle word wrap

问题

相关上下文中与 和 相关的问题。提供各种问题和问题类型,包括基于事实的问题、原因或说明。

最大令牌数量为 250 个令牌。

谁绘制了 Phoenix 销售?

回答

对指定问题的回答。答案应处于完整的句子中,并在 context 字段中引用。

最大令牌数量为 250 个令牌。

Phoenix constellation 由 french explorer 和 astronomer Nicolas Louis de Lacaille 图表。

document_outline

文档的简要摘要,类似于sis 语句。这为文档的内容提供了高级别的上下文。

必须详细地参考 context 字段中的内容。

有关 Phoenix Constellation 的信息,包括销售中星星的历史记录、特征和功能。

document

包含您的知识数据源的字段。

-

document:
   repo:
   commit:
   patterns:
Copy to Clipboard Toggle word wrap

repo

包含您的知识文件的 git 存储库的 URL。

-

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

commit

与 repo 中文档对应的完整提交哈希

-

-

模式

包含 git 存储库中的文件

有效值包括 .md.pdf

phoenix_constellation.md

用于创建 qna.yaml的其他资源

2.1. 创建知识 YAML 文件

以下流程演示了如何创建一个 qna.yaml 文件,该文件使用 RHEL AI 工具集指导您的 LLM 有关您提供的知识文件。

先决条件

  • 已使用可引导容器镜像安装了 RHEL AI。
  • 安装了 git CLI。
  • 您初始化了 InstructLab,可以使用 ilab CLI。
  • 在机器上具有 root 用户访问权限。

流程

  1. 由于您在 git 存储库中托管您的知识文件,因此在更新税务时,您需要签出一个正常工作的分支。
  2. 导航到 taxonomy 文件夹。RHEL AI 包含可与之交互的税务树。
  3. 导航到 taxonomy 目录中的 knowledge 文件夹。
  4. 在您要添加知识 qna.yaml 文件的 taxonomy 树中添加目录和文件夹。

    taxonomy 树中的文件路径示例

    taxonomy/knowledge/technical_documents/product_customer_cases/qna.yaml
    Copy to Clipboard Toggle word wrap

  5. 使用所需的文本编辑器,创建 qna.yaml 文件。您的 YAML 必须具有 qna.yaml 标题。

    注意

    要使 SDG 正确运行,必须至少包含五个 上下文块和三个问题,并在 questions_and_answers 参数中回答每个上下文值的 seeds。

  6. 将所需的密钥添加到 qna.yaml 文件中并保存您的更改。有关格式化 qna.yaml 文件的更多信息,请参阅"Sample knowledge YAML 规格"。

验证

  • 要验证您的知识 qna.yaml 文件是否正确格式,您可以运行以下命令:

    $ ilab taxonomy diff
    Copy to Clipboard Toggle word wrap

    如果您的 taxonomy 树和 qna.yaml 文件有效且正确格式化,则 CLI 会显示。CLI 还会显示您在哪里可以修复遇到的任何错误。

    有效 taxonomy 树和 qna.yaml 文件示例

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

    无效的 taxonomy 树和 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 Toggle word wrap

2.1.1. 知识 YAML 规格示例

知识贡献使用 qna.yaml 文件来了解如何阅读您要呈现模型的文档。在 RHEL AI 上,合成数据生成(SDG)进程使用 qna.yaml seed 示例来创建大量人工数据。这个过程使其使其具有更多数据,以便从中获取更多数据,而不依赖于提供的示例。

知识库 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 Toggle word wrap

1
指定 knowledge qna.yaml 格式的版本。目前,有效的值为 3
2
指定文档的主题或类别。例如,"技术文档"或"安装指南"。
3
指定文档内容概述。建议引用您在 document_outline 字段中 上下文 参数中包含的主题。例如,如果文档是安装指南,且每个 上下文 都包含有关不同云供应商的详情,则 document_outline 将是 "Installation Guide for AWS, GCP, 和 Azure"。
4
指定名称或 git username。
5
指定您的知识数据的段落。这是您的问题和答案要基于的内容。上下文块的格式必须与您的知识文件的格式匹配。例如,如果您的知识库文章为 Markdown,您的 上下文 块也必须采用 Markdown 格式。
6
为模型指定一个问题。问题应基于 上下文 字段中的信息。例如,"产品的最新版本是什么?"
7
指定来自模型所需的响应。必须包含回答信息,但不从 上下文 块复制,并处于完整的句子中。回答应处于完整的句子。例如,"产品的最新版本为 1.5 版本"。
8
指定包含您的知识文件的存储库的 URL。
9
指定来自您的知识文件的 git 存储库中的提交的 SHA。
10
指定 git 存储库中的文档。有效的文档类型值包括 .md.pdf。单个 qna.yaml 文件只能引用一个文档类型,不支持在同一 qna.yaml 中混合文件类型。

2.2. 创建知识标记文件

在 Red Hat Enterprise Linux AI 版本 1.5 中,您必须以 git 存储库和 markdown 格式托管您的知识文档和数据。您可以使用标准 git 工作流创建文件并上传到存储库。您可以使用各种开源标记转换工具,包括:

  • Pandoc:开源转换工具.
  • Visual Studio Code with All in one extention:您可以在 Visual Studio Code 中打开您的文档,并使用 Markdown All in One 扩展 来转换为 Markdown。
  • IBM Deepsearch/Docling:捆绑 PDF 文档转换为 JSON,并在自包含的软件包中标记。

流程

  1. 选择您首选的 git 托管平台。只要与 git 兼容,就可以在 RHEL AI 上使用任何平台。
  2. 将您的文档转换为 .md 标记格式。您可以使用您想要进行知识数据的任何标记转换软件。

    以下列表包含知识标记文件的指南:

    • 所有文档都必须是文本,当前不支持镜像。
    • 从您的文档中删除任何脚注。
    • 表必须采用 markdown 格式。
    • 目前不支持图表和图形。
  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 Toggle word wrap

第 3 章 在您的税务树中添加技能

初学者模型可以通过使用域特定技能填充 qna.yaml 文件来了解自定义技能。每个用于技能的 qna.yaml 文件都包含一组键值条目,其中包含以下键:

Expand
表 3.1. Red Hat Enterprise Linux AI
字段Desciptionrestraints

version

qna.yaml 文件的版本,这是用于 SDG 的文件格式

此参数当前支持的值是 2。

created_by

您的 Git 用户名或贡献者名称。

None

task_description

对您的技能及其功能的描述。

None

seed_examples

键和值条目的集合。

每个 qna.yaml 文件至少需要五个 seed 示例

context

逐步技能要求用户提供额外的上下文,其中包含模型执行该技能所需的信息。

对于基本技能,需要此文件。每个 qna.yaml 需要五个上下文块,且最大令牌计数为 500 个令牌。

问题

为模型指定一个问题。

每个 qna.yaml 文件至少需要五个问题,并回答对最多有 250 个令牌的数量。

回答

指定模型的回答。

每个 qna.yaml 文件至少需要五个问题,并回答对最多有 250 个令牌的数量。

3.1. 创建技能 YAML 文件

您可以自定义税务树,以便模型能够了解所需用例的新技能。以下流程演示了如何创建一个包含您的技术 qna.yaml 文件的税onomy 树。

先决条件

  • 已使用可引导容器镜像安装了 RHEL AI。
  • 您初始化了 InstructLab,可以使用 ilab CLI。
  • 在机器上具有 root 用户访问权限。

流程

  1. 导航到 compositional_skills 文件夹,位于 taxonomy 目录。

    重要

    目前,RHEL AI 版本 1.5 不支持创建代码的基础技能。

  2. 根据树中存在的目录,选择您要添加技术 qna.yaml 文件的树中。

    taxonomy 树中的文件路径示例

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

  3. 使用所需的文本编辑器,创建 qna.yaml 文件。

    注意

    要使 SDG 正确运行,您必须在 qna.yaml 文件中至少包含五个问题和回答对示例。

  4. 将所需的密钥添加到 qna.yaml 文件中并保存您的更改。有关格式化 qna.yaml 文件的更多信息,请参阅"Sample skills YAML 规格"。

验证

  • 要验证您的技能是否正确格式,您可以运行以下命令:

    $ ilab taxonomy diff
    Copy to Clipboard Toggle word wrap

    如果您的 taxonomy 树和 qna.yaml 文件有效且正确格式化,则 CLI 会显示。CLI 也会显示修复您可能遇到的任何错误的位置。

    有效 taxonomy 树和 qna.yaml 文件示例

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

    无效的 taxonomy 树和 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 Toggle word wrap

3.2. 示例技能 YAML 规格

技能分享类似问题并回答布局,作为知识的 YAML 文件。在 RHEL AI 上,合成数据生成(SDG)进程使用您的 qna.yaml seed 示例为模型创建大量智能数据来了解,而不是完全依赖于用户生成的数据。

问题、答案和上下文对的顺序不会影响 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 Toggle word wrap

组成技术示例 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 Toggle word wrap

1 1
指定技术 qna.yaml 格式的版本。
2 2
指定名称或 git username。
3 3
指定您的技术及其功能的描述。
4
指定包含模型执行技能所需的信息的额外上下文。实践技能需要.
4 5
为模型指定一个问题。
5 6
指定来自模型所需的响应。

第 4 章 优化模型性能的 YAML 创建实践

在为您的税务树 添加知识和为您的税务树 添加技能时所 参考的指南提供了创建知识和知识 YAML 文件的标准说明。但是,您可以通过多种方式改进 YAML 文件,以优化生成的复合数据并创建更高质量的模型。

YAML 文件的 context 字段中有不同和全面的内容

每个 上下文 块都包含文档中的各种信息和格式类型。这允许模型了解显示信息的不同方法。这些不同的信息表示类型包括:段落、不同类型的表、列表、程序和定义。

context 块应该是您的文档中的一个全面的示例。上下文 内容的总长度和 Q&A 对不应超过 750 令牌。

编写有效问题

问题应该与您希望模型可以回答的问题类型一致。每个问题都应该是唯一的,并在 上下文 字段中引用信息。包括完整句子问题可改进生成的复合数据,并改进模型响应质量。

编写有效答案

回答直接回答问题,并应反映您希望模型能够提供的回答类型。回答应处于完全句子,并参考原始问题。包括完整句子答案可提高生成的复合数据,并改进模型响应质量。

不应直接从 上下文 块直接复制答案,这可能导致模型学习提取而不是原因。

回答问题的信息必须在 上下文 块中。如果信息位于单独的上下文块中,或者根本没有引用,则模型可能会妨碍。

高质量问答对示例

- 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 Toggle word wrap

何时使用多个文档或多个 qna.yaml 文件

如果多个文档与类似的主题或域相关,建议使用单个 qna.yaml 文件。每个 qna.yaml 文件必须包含 singular 文档类型,您不能在 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

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部