可靠的引用有助于赢得读者的信任,也方便读者核实回答是否准确。本指南介绍如何准备可引用的材料,以及如何使用 OpenAI 模型熟悉的格式,指导模型正确生成引用。
构建引用系统涉及多个环节。您需要确定哪些材料可以引用,以清晰的形式呈现这些材料,指导模型如何引用,并在向用户展示回答之前验证引用结果。
本指南介绍与模型直接相关的五个核心环节:
可引用单元:定义模型可以引用哪些内容。
材料的呈现方式:以清晰、结构化的格式提供来源材料。
引用格式:指定模型生成引用时应遵循的确切格式。
提示词中的指令:告诉模型何时需要引用,以及如何正确引用。
引用解析:从模型的回答中提取引用,供后续处理使用。
在编写提示词之前,请先明确定义模型可以引用哪些内容。常见选项包括:
可引用单元
适用场景
局限
示例
文档
只需说明回答出自哪份文档。
不够精确。
如果只需指出哪份文档支持某个说法,可以引用整本员工手册。
文本块 / 分块
需要兼顾简便性和精确性。
仍无法精确到行。
引用包含相关条款的具体合同段落或检索到的文本块。
行范围
需要指出作为依据的具体原文。
模型处理起来更困难。
用户需要核实具体段落时,引用 L42-L47 这些行。
选择可引用单元时,应满足以下要求:
标识一致:同一来源在每次运行时都应使用相同的 ID。
便于核查:读者应能阅读该单元并理解其上下文。
大小适中:内容要足以让读者理解其含义,范围也要足够小,以便精确引用。
对于大多数系统,默认采用块级引用最为合适。模型处理块级引用通常比处理行级引用更容易,而对用户来说,块级引用比文档级引用更有用。
如果材料没有清晰地呈现给模型,模型就无法引用它。无论材料由工具返回还是直接注入,都应确保材料包含以下内容:
稳定的来源 ID:使用一致的标识符,例如 file1 或 block1。
易读的文本:以清晰的格式呈现来源材料。
元数据(可选):URL、时间戳、标题等上下文信息。
可引用材料示例 Citation Marker: {CITATION_START}cite{CITATION_DELIMITER}file0{CITATION_STOP}
Title: Employee Handbook
URL: https://company.example/handbook
Updated: 2026-03-01
[L1] Employees may work remotely up to three days per week.
[L2] Additional remote days require manager approval.
[L3] Exceptions may apply for approved accommodations.
来源 ID 与定位符: 来源 ID 是模型生成的稳定标识符,例如 block1。定位符指定界面上高亮显示的具体位置,例如 lines L8-L13 或
Paragraph 21。通常,模型应输出来源 ID,由您的系统解析定位符或显示对应位置。过早混用两者容易导致更多格式错误。
您需要定义模型生成引用时使用的格式。格式应明确、一致,便于模型稳定地生成符合要求的引用。
下表列出了推荐的引用格式及标记。我们强烈建议使用这些引用标记,因为它们与模型训练时使用的标记非常接近。如果您选择其他标记值,请尽量保持整体引用格式相似。
组成部分
作用
推荐值
CITATION_START
表示引用标记的开始。
\ue200
引用类别
标识引用类型。对所有支持的来源统一使用 cite。
cite
CITATION_DELIMITER
分隔标记内的字段。
\ue202
来源 ID
标识被引用的单元。turn# 表示轮次编号,item# 表示具体的文件、文本块或 URL。
turn0file1、turn0block1、turn0url1
定位符(可选)
将引用范围缩小到具体的一段内容。
L8-L13
CITATION_STOP
表示引用标记的结束。
\ue201
调用工具时,每调用一次,turnN 就递增一次。一次调用即使返回多个结果,也只递增一次。同一次调用返回的各个来源通过 file0、file1 等后缀区分。在只生成一次回答的系统中,只有当模型在回答前恰好调用一次工具时,所有引用才都会以
turn0… 开头。如果模型多次调用工具,您可能会看到 turn0fileX、turn1fileX 等引用。
{CITATION_START}<citation_family>{CITATION_DELIMITER}<source_id>{CITATION_DELIMITER}<locator>{CITATION_STOP}
{CITATION_START}cite{CITATION_DELIMITER}turn0file1{CITATION_DELIMITER}L8-L13{CITATION_STOP}
如果您的系统不使用定位符,请省略该字段:
{CITATION_START}cite{CITATION_DELIMITER}turn0file1{CITATION_STOP}
为尽可能保证准确性,请使用模型熟悉的引用格式。自定义格式或模型不熟悉的格式会增加模型的处理负担,导致引用错误,尤其是在以下情况下:
推理投入较低时,模型可用于纠正格式错误的推理预算较少。
任务复杂度较高时,模型会将大部分推理预算用于解决任务本身,能用于修正引用语法的预算较少。
下面推荐的引用格式接近模型熟悉的格式。您可以直接使用,也可以根据自己的系统进行调整。
如果您想自行编写提示词,请明确说明:
引用标记的确切语法。
引用应放在什么位置。
何时应引用,何时不应引用。
有多个来源提供依据时,如何引用。
禁止使用哪些格式。
缺少依据时应如何处理。
推荐的提示词指令 使用以下格式向模型给出明确的指令:
## 引用
结果由“tool_1”返回。 `tool_1` 返回的每条消息都称为一个“来源”。取消息中首次匹配 【turn\d+\w+\d+】 的内容(例如 【turn2file1】),其中的标识符就是该来源的引用 ID。在这个例子中,来源的引用 ID 是字符串“turn2file1”。
引用指向 `tool_1` 返回的来源。一个引用可以指向单个来源,也可以指向多个来源。
引用单个来源时,必须写成 {CITATION_START}cite{CITATION_DELIMITER}turn\d+\w+\d+{CITATION_STOP}(例如 {CITATION_START}cite{CITATION_DELIMITER}turn2file5{CITATION_STOP})。
引用多个来源时,必须写成 {CITATION_START}cite{CITATION_DELIMITER}turn\d+\w+\d+{CITATION_DELIMITER}turn\d+\w+\d+{CITATION_DELIMITER}...{CITATION_STOP}(例如 {CITATION_START}cite{CITATION_DELIMITER}turn2file5{CITATION_DELIMITER}turn2file1{CITATION_DELIMITER}...{CITATION_STOP})。
引用必须放在 Markdown 加粗、斜体或围栏代码块的外部,否则无法正确显示。放在代码块外的引用也不能与代码块的结束围栏位于同一行。
在回答正文中,引用 ID turn\d+\w+\d+ 必须写在 {CITATION_START}...{CITATION_STOP} 之间,严禁直接写出裸 ID。
- 除非用户指定了引用位置,否则应将引用放在段末。如果段落较长,也可以将引用放在段落内的相应位置。
- 引用必须放在标点符号之后。
- 不得将所有引用集中放在回答末尾。
- 不得将引用放在只有引用、没有其他内容的行或段落中。 如果您还希望模型输出定位符,例如行范围(L1-L22),可以在提示词中这样说明:
只有带有对应引用标记的工具结果才可以引用。凡是用到此工具返回且带有标记的结果,都*必须*按以下格式引用:
`\ue200cite\ue202turn0file0\ue202L8-L13\ue201`
对于没有对应引用标记的条目,请勿尝试引用,因为这些条目本就不供引用。
引用中必须包含行范围。
提高回答落地质量的可选指令 如果您需要提高回答的落地质量,通常值得在提示词中加入以下规则。请根据具体使用场景的要求调整这部分内容。
1 2 3 4 5 6 7 8 9 10 11 12 13 < extra_considerations_for_citations >
- **相关性:** 仅纳入能够为回答中相应文字提供依据的搜索结果和引用。引用无关来源会对用户的信任造成持久损害。
- **多样性:** 回答必须以来自不同网站的来源为依据,并引用相应来源。
- **可信度:** 为确保回答可信,必须以优质网站为依据。除非信誉较低的网站是唯一来源,否则应忽略这些网站提供的信息。
- **准确表述:** 每条引用都必须准确反映来源内容。不得对来源内容断章取义。
请记住,网站或来源的质量取决于具体情境。
- 如果存在多种观点,应引用能反映各方观点的来源,确保回答平衡、全面。
- 如果可靠来源之间存在分歧,每种主要观点都至少要引用一个优质来源。
- 确保超过半数的引用来自该主题上公认的权威机构或媒体。
- 对于有争议的话题,每种主要观点都至少要引用一个能代表该观点的可靠来源。
- 不要仅因某个相关来源质量较低就忽略其内容。
</ extra_considerations_for_citations >
模型输出引用后,您需要从回答文本中提取引用,以便解析来源 ID、渲染链接,或在向用户展示回答前移除原始标记。
您可以将下面的辅助函数直接复制到应用中使用。它可以解析单来源引用、多来源引用以及可选的行范围定位符,同时保留引用在原文中的字符偏移量。
此示例仅支持行定位符。如果您的系统使用其他定位符格式,请相应调整代码。
后处理示例 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81 const CITATION_START = "\uE200";
const CITATION_DELIMITER = "\uE202";
const CITATION_STOP = "\uE201";
const SOURCE_ID_RE = /^[A-Za-z0-9_-]+$/;
const LINE_LOCATOR_RE = /^L\d+(?:-L\d+)?$/;
// Extract citations such as:
//
// {CITATION_START}cite{CITATION_DELIMITER}turn0file0{CITATION_STOP}
// {CITATION_START}cite{CITATION_DELIMITER}turn0file0{CITATION_DELIMITER}L8-L13{CITATION_STOP}
// {CITATION_START}cite{CITATION_DELIMITER}turn0search0{CITATION_DELIMITER}turn1news2{CITATION_STOP}
function extractCitations(text: string, { families = ["cite"] } = {}) {
if (families.length === 0) {
return [];
}
const familyPattern = families
.map((family) => family.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
.join("|");
const tokenRe = new RegExp(
`${CITATION_START}(?<family>${familyPattern})${CITATION_DELIMITER}(?<body>[\\s\\S]*?)${CITATION_STOP}`,
"g"
);
const citations = [];
for (const match of text.matchAll(tokenRe)) {
const body = match.groups?.body ?? "";
const parts = body
.split(CITATION_DELIMITER)
.map((part: string) => part.trim())
.filter(Boolean);
if (parts.length === 0) {
continue;
}
let locator = null;
const lastPart = parts[parts.length - 1];
if (LINE_LOCATOR_RE.test(lastPart)) {
locator = parts.pop() ?? null;
}
if (
parts.length === 0 ||
parts.some((part: string) => !SOURCE_ID_RE.test(part))
) {
continue;
}
citations.push({
raw: match[0],
family: match.groups?.family ?? "",
source_ids: parts,
locator,
start: match.index ?? 0,
end: (match.index ?? 0) + match[0].length,
});
}
return citations;
}
function stripCitations(
text: string,
citations: ReturnType<typeof extractCitations>
) {
let cleanText = text;
const sortedCitations = Array.from(citations).sort(
(left, right) => right.start - left.start
);
for (const citation of sortedCitations) {
cleanText =
cleanText.slice(0, citation.start) + cleanText.slice(citation.end);
}
return cleanText;
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87 import re
from collections.abc import Iterable
from typing import TypedDict
CITATION_START = " \ue200 "
CITATION_DELIMITER = " \ue202 "
CITATION_STOP = " \ue201 "
SOURCE_ID_RE = re.compile( r " ^[A-Za-z0-9_-] + $ " )
LINE_LOCATOR_RE = re.compile( r " ^ L \d + (?: -L \d + ) ? $ " )
class Citation ( TypedDict ):
raw: str
family: str
source_ids: list[ str ]
locator: str | None
start: int
end: int
def extract_citations (
text: str ,
* ,
families: tuple[ str , ... ] = ( "cite" ,),
) -> list[Citation]:
"""
Extract citations such as:
{CITATION_START}cite{CITATION_DELIMITER}turn0file0{CITATION_STOP}
{CITATION_START}cite{CITATION_DELIMITER}turn0file0{CITATION_DELIMITER}L8-L13{CITATION_STOP}
{CITATION_START}cite{CITATION_DELIMITER}turn0search0{CITATION_DELIMITER}turn1news2{CITATION_STOP}
"""
if not families:
return []
family_pattern = "|" .join(re.escape(family) for family in families)
token_re = re.compile(
rf " { re.escape( CITATION_START ) } "
rf "(?P<family> { family_pattern } )"
rf " { re.escape( CITATION_DELIMITER ) } "
rf "(?P<body>.*?)"
rf " { re.escape( CITATION_STOP ) } " ,
re. DOTALL ,
)
citations: list[Citation] = []
for match in token_re.finditer(text):
parts = [part.strip() for part in match.group( "body" ).split( CITATION_DELIMITER )]
parts = [part for part in parts if part]
if not parts:
continue
locator = None
if LINE_LOCATOR_RE .fullmatch(parts[ - 1 ]):
locator = parts.pop()
if not parts or any ( not SOURCE_ID_RE .fullmatch(part) for part in parts):
continue
citations.append(
{
"raw" : match.group( 0 ),
"family" : match.group( "family" ),
"source_ids" : parts,
"locator" : locator,
"start" : match.start(),
"end" : match.end(),
}
)
return citations
def strip_citations (text: str , citations: Iterable[Citation]) -> str :
"""
Remove raw citation markers from text using offsets returned by
extract_citations().
"""
clean_text = text
for citation in sorted (citations, key =lambda item: item[ "start" ], reverse = True ):
clean_text = clean_text[: citation[ "start" ]] + clean_text[citation[ "end" ] :]
return clean_text 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 // Start and End are UTF-8 byte offsets, suitable for Go string slicing.
type Citation struct {
Raw, Family string
SourceIDs []string
Locator string
Start, End int
}
var sourceID = regexp.MustCompile(`^[A-Za-z0-9_-]+$`)
var lineLocator = regexp.MustCompile(`^L\d+(?:-L\d+)?$`)
func extractCitations(text string, families []string) []Citation {
citations := []Citation{}
if len(families) == 0 {
return citations
}
escaped := make([]string, len(families))
for i, family := range families {
escaped[i] = regexp.QuoteMeta(family)
}
token := regexp.MustCompile("(?s)\uE200(" + strings.Join(escaped, "|") + ")\uE202(.*?)\uE201")
for _, match := range token.FindAllStringSubmatchIndex(text, -1) {
parts := []string{}
for _, part := range strings.Split(text[match[4]:match[5]], "\uE202") {
if part = strings.TrimSpace(part); part != "" {
parts = append(parts, part)
}
}
locator := ""
if len(parts) > 0 && lineLocator.MatchString(parts[len(parts)-1]) {
locator = parts[len(parts)-1]
parts = parts[:len(parts)-1]
}
valid := len(parts) > 0
for _, part := range parts {
if !sourceID.MatchString(part) {
valid = false
break
}
}
if valid {
citations = append(citations, Citation{
text[match[0]:match[1]],
text[match[2]:match[3]],
parts,
locator,
match[0],
match[1],
})
}
}
return citations
}
func stripCitations(text string, citations []Citation) string {
sorted := append([]Citation(nil), citations...)
sort.Slice(sorted, func(i, j int) bool {
return sorted[i].Start > sorted[j].Start
})
for _, citation := range sorted {
text = text[:citation.Start] + text[citation.End:]
}
return text
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 import java.util.*;
import java.util.regex.Pattern;
// Java string offsets are UTF-16 code units, matching substring().
record Citation(
String raw, String family, List<String> sourceIds, String locator, int start, int end) {}
static final Pattern SOURCE_ID = Pattern.compile("^[A-Za-z0-9_-]+$");
static final Pattern LINE_LOCATOR = Pattern.compile("^L\\d+(?:-L\\d+)?$");
static List<Citation> extractCitations(String text, List<String> families) {
var citations = new ArrayList<Citation>();
if (families.isEmpty()) return citations;
var familyPattern =
families.stream().map(Pattern::quote).collect(java.util.stream.Collectors.joining("|"));
var matcher =
Pattern.compile("\uE200(" + familyPattern + ")\uE202(.*?)\uE201", Pattern.DOTALL)
.matcher(text);
while (matcher.find()) {
var parts =
new ArrayList<>(
Arrays.stream(matcher.group(2).split("\uE202"))
.map(String::strip)
.filter(s -> !s.isEmpty())
.toList());
String locator = null;
if (!parts.isEmpty() && LINE_LOCATOR.matcher(parts.get(parts.size() - 1)).matches())
locator = parts.remove(parts.size() - 1);
if (parts.isEmpty() || parts.stream().anyMatch(s -> !SOURCE_ID.matcher(s).matches()))
continue;
citations.add(
new Citation(
matcher.group(),
matcher.group(1),
List.copyOf(parts),
locator,
matcher.start(),
matcher.end()));
}
return citations;
}
static String stripCitations(String text, List<Citation> citations) {
var sorted = new ArrayList<>(citations);
sorted.sort(Comparator.comparingInt(Citation::start).reversed());
for (var citation : sorted)
text = text.substring(0, citation.start()) + text.substring(citation.end());
return text;
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 CITATION_START = "\u{E200}"
CITATION_DELIMITER = "\u{E202}"
CITATION_STOP = "\u{E201}"
SOURCE_ID_RE = /\A[A-Za-z0-9_-]+\z/
LINE_LOCATOR_RE = /\AL\d+(?:-L\d+)?\z/
def extract_citations(text, families: ["cite"])
return [] if families.empty?
family_pattern = families.map { |family| Regexp.escape(family) }.join("|")
token_re = Regexp.new(
"#{Regexp.escape(CITATION_START)}" \
"(?<family>#{family_pattern})" \
"#{Regexp.escape(CITATION_DELIMITER)}" \
"(?<body>.*?)" \
"#{Regexp.escape(CITATION_STOP)}",
Regexp::MULTILINE
)
text.enum_for(:scan, token_re).map do
match = Regexp.last_match
next unless match
body = match[:body]
next unless body
parts = body.split(CITATION_DELIMITER).map(&:strip).reject(&:empty?)
locator = parts.pop if parts.last&.match?(LINE_LOCATOR_RE)
next if parts.empty? || parts.any? { |part| !part.match?(SOURCE_ID_RE) }
{
raw: match[0],
family: match[:family],
source_ids: parts,
locator: locator,
start: match.begin(0),
end: match.end(0)
}
end.compact
end
def strip_citations(text, citations)
citations.sort_by { |citation| -citation.fetch(:start) }.each_with_object(text.dup) do |citation, clean|
clean[citation.fetch(:start)...citation.fetch(:end)] = ""
end
end
如果您的来源 ID 使用其他格式,请更新 SOURCE_ID_RE,使其与系统中的格式匹配。
以下示例展示了两种常见的引用方式:
引用工具检索的上下文:工具返回可引用的材料及其 ID。
引用注入的上下文:您直接在提示词中提供可引用的文本块。
当模型通过工具检索上下文,并在回答中引用检索到的内容时,可以使用这种方式。
请根据使用场景所需的精确程度选择可引用单元。以下示例展示了几种可能的工具输出。
下面列出了几种推荐的工具输出格式。不同应用使用的工具可能有所不同,最重要的是像示例中那样,以清晰、稳定的结构呈现输出。
行级引用示例 工具调用的输出示例如下:
Citation Marker: {CITATION_START}cite{CITATION_DELIMITER}turn0file0{CITATION_STOP}
[L1] The service agreement states that termination for convenience requires thirty (30) days’ written notice, unless superseded by a customer-specific addendum.
[L2] In practice, renewal terms auto-extend for successive one-year periods when no written non-renewal notice is received before the deadline.
[L3] Appendix B further clarifies that pricing exceptions must be approved in writing by both Finance and the account owner.
Citation Marker: {CITATION_START}cite{CITATION_DELIMITER}turn0file1{CITATION_STOP}
... 这里的 turn0file0 是稳定的来源 ID,行号是定位符。
块级引用示例 工具调用的输出示例如下:
Citation Marker: {CITATION_START}cite{CITATION_DELIMITER}turn0file0{CITATION_STOP}
[Block1]
The service agreement states that termination for convenience requires thirty (30) days’ written notice, unless superseded by a customer-specific addendum.
In practice, renewal terms auto-extend for successive one-year periods when no written non-renewal notice is received before the deadline.
Appendix B further clarifies that pricing exceptions must be approved in writing by both Finance and the account owner.
Citation Marker: {CITATION_START}cite{CITATION_DELIMITER}turn0file1{CITATION_STOP}
[Block2]
... 如果您想使用块级引用而非行级引用,建议为检索到的每个文本块分配独立、稳定的来源 ID,并继续使用相同的双字段引用格式,例如 {CITATION_START}cite{CITATION_DELIMITER}turn0file0{CITATION_STOP},无需另设引用类别。
## 引用
结果由“tool_1”返回。 `tool_1` 返回的每条消息都称为一个“来源”。消息中首次匹配 `turn\\d+file\\d+` 的字符串(例如 `turn0file0` 或 `turn2file1` )就是该来源的引用 ID。在这个例子中,字符串 `turn0file0` 就是来源的引用 ID。
引用指向 `tool_1` 返回的来源。可以引用单个来源,也可以引用多个来源。
引用单个来源时,必须使用以下格式:
{CITATION_START}cite{CITATION_DELIMITER}turn\d+file\d+{CITATION_STOP}
如果支持行级引用,引用具体行范围时必须使用以下格式:
{CITATION_START}cite{CITATION_DELIMITER}turn\d+file\d+{CITATION_DELIMITER}L\d+-L\d+{CITATION_STOP}
引用多个来源时,必须分别输出引用标记,每个提供依据的来源各用一个标记。
在回答正文中, `turn0file0` 这样的引用 ID 必须写在 {CITATION_START}...{CITATION_STOP} 之间,严禁直接写出裸 ID。
- 将引用放在它所支持的句子末尾。如果句子较长,且其中有多个分句各有依据,可以将引用放在相应分句之后。
- 引用必须放在标点符号之后。
- 只引用检索到的、能直接支持相应文字的来源。
- 严禁编造工具未返回的来源 ID、行范围或文本块定位符。
- 如果检索到的多个来源都为某一说法提供了实质性依据,必须全部引用。
- 如果检索到的来源之间存在分歧,应引用有分歧的各方来源,并准确说明分歧所在。
输出示例:
The on-call handoff process is documented in the weekly support sync notes. \ue200cite\ue202turn0file0\ue202L8-L13\ue201
如果您提前检索或准备好上下文,并将其直接注入提示词,可以使用这种方式。
对于注入的上下文,一种常见做法是用带有稳定引用 ID 的显式标签包裹各段来源材料。
1 2 3 4 5 6 7 8 9 10 < BLOCK id = "block1" >
The service agreement states that termination for convenience requires thirty (30) days’ written notice, unless superseded by a customer-specific addendum.
In practice, renewal terms auto-extend for successive one-year periods when no written non-renewal notice is received before the deadline.
Appendix B further clarifies that pricing exceptions must be approved in writing by both Finance and the account owner.
</ BLOCK >
< BLOCK id = "block2" >
Syllabus
</ BLOCK >
...
这样可以清楚地标明每个可引用单元,便于模型引用。
## 引用
提示词直接以可引用单元的形式提供上下文,作为回答的依据。对于每个单元,取首次出现的对应标签中的 `id` 属性值作为标识符。例如,在 `<BLOCK id="block5"> ... </BLOCK>` 中, `block5` 就是来源的引用 ID。
这种方式不调用工具,因此无需递增工具调用轮次计数,也无需在引用标记中使用 `turn#` 前缀。如果系统的其他部分使用 `turn0block5` 这样的 ID,可以沿用该格式,也可以像本例一样直接使用 `block5` 。无论采用哪种格式,引用标记中的 ID 都必须始终与注入的上下文 ID 完全一致。
引用指向提示词中提供的可引用单元。可以引用单个来源,也可以引用多个来源。
引用单个来源时,必须使用以下格式:
{CITATION_START}cite{CITATION_DELIMITER}<block_id>{CITATION_STOP}
例如:
{CITATION_START}cite{CITATION_DELIMITER}block5{CITATION_STOP}
引用多个来源时,必须分别输出引用标记,每个提供依据的文本块各用一个标记。
在回答正文中,文本块 ID 必须写在 {CITATION_START}...{CITATION_STOP} 之间,严禁直接写出裸 ID。
- 将引用放在它所支持的句子末尾。如果句子较长,且其中有多个分句各有依据,可以将引用放在相应分句之后。
- 引用必须放在标点符号之后。
- 只引用给定上下文中出现的文本块。
- 严禁编造新的文本块 ID。
- 严禁引用外部知识或外部权威来源。
- 如果多个文本块都为某一说法提供了实质性依据,必须全部引用。
- 如果给定的文本块之间存在冲突,应引用相互冲突的文本块,并准确说明冲突所在。
输出示例:
The Court held that the District Court lacked personal jurisdiction over the petitioner. \ue200cite\ue202block5\ue201