Skip to content

Commit

Permalink
chore: improve extractors prompt (run-llama#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
EmanuelCampos authored Feb 1, 2024
1 parent ab9d941 commit 177b446
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/twenty-carrots-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"llamaindex": patch
---

chore: improve extractors prompt
44 changes: 25 additions & 19 deletions packages/core/src/extractors/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,56 @@ export interface DefaultNodeTextTemplate {
export const defaultKeywordExtractorPromptTemplate = ({
contextStr = "",
keywords = 5,
}: DefaultKeywordExtractorPromptTemplate) => `
${contextStr}. Give ${keywords} unique keywords for thiss
document. Format as comma separated. Keywords:
}: DefaultKeywordExtractorPromptTemplate) => `${contextStr}
Give ${keywords} unique keywords for this document.
Format as comma separated. Keywords:
`;

export const defaultTitleExtractorPromptTemplate = (
{ contextStr = "" }: DefaultPromptTemplate = {
contextStr: "",
},
) => `
${contextStr}. Give a title that summarizes all of the unique entities, titles or themes found in the context. Title:
) => `${contextStr}
Give a title that summarizes all of the unique entities, titles or themes found in the context.
Title:
`;

export const defaultTitleCombinePromptTemplate = (
{ contextStr = "" }: DefaultPromptTemplate = {
contextStr: "",
},
) => `
${contextStr}. Based on the above candidate titles and content,s
what is the comprehensive title for this document? Title:
) => `${contextStr}
Based on the above candidate titles and contents, what is the comprehensive title for this document?
Title:
`;

export const defaultQuestionAnswerPromptTemplate = (
{ contextStr = "", numQuestions = 5 }: DefaultQuestionAnswerPromptTemplate = {
contextStr: "",
numQuestions: 5,
},
) => `
${contextStr}. Given the contextual information,s
generate ${numQuestions} questions this context can provides
specific answers to which are unlikely to be found elsewhere.
Higher-level summaries of surrounding context may be provideds
as well. Try using these summaries to generate better questionss
that this context can answer.
) => `${contextStr}
Given the contextual informations, generate ${numQuestions} questions this context can provides specific answers to which are unlikely to be found elsewhere.Higher-level summaries of surrounding context may be provideds as well.
Try using these summaries to generate better questions that this context can answer.
`;

export const defaultSummaryExtractorPromptTemplate = (
{ contextStr = "" }: DefaultPromptTemplate = {
contextStr: "",
},
) => `
${contextStr}. Summarize the key topics and entities of the section.s
Summary:
) => `${contextStr}
Summarize the key topics and entities of the sections.
Summary:
`;

export const defaultNodeTextTemplate = ({
Expand Down

0 comments on commit 177b446

Please sign in to comment.