LlamaIndex Default Prompt Library 官方发布

LlamaIndex · LlamaIndex 观察于 2026-10-18

本 system prompt 由 LlamaIndex 官方发布。来源链接见下。

system prompt · 官方发布
The original query is as follows: {query_str}
We have provided an existing answer: {existing_answer}
We have the opportunity to refine the existing answer (only if needed) with some more context below.
------------
{context_msg}
------------
Given the new context, refine the original answer to better answer the query. If the context isn't useful, return the original answer.
Refined Answer:

Context information is below.
---------------------
{context_str}
---------------------
Given the context information and not prior knowledge, answer the query.
Query: {query_str}
Answer:

Given an input question, first create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer. You can order the results by a relevant column to return the most interesting examples in the database.

Never query for all the columns from a specific table, only ask for a few relevant columns given the question.

Pay attention to use only the column names that you can see in the schema description. Be careful to not query for columns that do not exist. Pay attention to which column is in which table. Also, qualify column names with the table name when needed. You are required to use the following format, each taking one line:

Question: Question here
SQLQuery: SQL Query to run
SQLResult: Result of the SQLQuery
Answer: Final answer here

Only use tables listed below.
{schema}

Question: {query_str}
SQLQuery:

Extract up to {max_knowledge_triplets} knowledge triplets from the given text. Each triplet should be in the form of (head, relation, tail) with their respective types.
---------------------
INITIAL ONTOLOGY:
Entity Types: {allowed_entity_types}
Relation Types: {allowed_relation_types}

Use these types as a starting point, but introduce new types if necessary based on the context.

GUIDELINES:
- Output in JSON format: [{{'head': '', 'head_type': '', 'relation': '', 'tail': '', 'tail_type': ''}}]
- Use the most complete form for entities (e.g., 'United States of America' instead of 'USA')
- Keep entities concise (3-5 words max)
- Break down complex phrases into multiple triplets
- Ensure the knowledge graph is coherent and easily understandable
---------------------
EXAMPLE:
Text: Tim Cook, CEO of Apple Inc., announced the new Apple Watch that monitors heart health. UC Berkeley researchers studied the benefits of apples.
Output:
[{{'head': 'Tim Cook', 'head_type': 'PERSON', 'relation': 'CEO_OF', 'tail': 'Apple Inc.', 'tail_type': 'COMPANY'}},
 {{'head': 'Apple Inc.', 'head_type': 'COMPANY', 'relation': 'PRODUCES', 'tail': 'Apple Watch', 'tail_type': 'PRODUCT'}},
 {{'head': 'Apple Watch', 'head_type': 'PRODUCT', 'relation': 'MONITORS', 'tail': 'heart health', 'tail_type': 'HEALTH_METRIC'}},
 {{'head': 'UC Berkeley', 'head_type': 'UNIVERSITY', 'relation': 'STUDIES', 'tail': 'benefits of apples', 'tail_type': 'RESEARCH_TOPIC'}}]
---------------------
Text: {text}
Output:

来源: LlamaIndex official open-source repo (selected default templates) · 此处为节选——完整文档见来源

这条 prompt 值得借鉴的技巧

应用这些模式

本站精选库中使用类似技巧的提示词:

更多逆向档案

浏览完整档案 →

合理使用声明:本站收录的 prompt 正文仅用于评论、分析与教学目的。版权归原作者所有;如果您是权利方并希望移除某条目,请联系我们,我们会及时处理。