您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

query_analyze_prompt.py 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. # Licensed under the MIT License
  2. """
  3. Reference:
  4. - [LightRag](https://github.com/HKUDS/LightRAG)
  5. - [MiniRAG](https://github.com/HKUDS/MiniRAG)
  6. """
  7. PROMPTS = {}
  8. PROMPTS["minirag_query2kwd"] = """---Role---
  9. You are a helpful assistant tasked with identifying both answer-type and low-level keywords in the user's query.
  10. ---Goal---
  11. Given the query, list both answer-type and low-level keywords.
  12. answer_type_keywords focus on the type of the answer to the certain query, while low-level keywords focus on specific entities, details, or concrete terms.
  13. The answer_type_keywords must be selected from Answer type pool.
  14. This pool is in the form of a dictionary, where the key represents the Type you should choose from and the value represents the example samples.
  15. ---Instructions---
  16. - Output the keywords in JSON format.
  17. - The JSON should have three keys:
  18. - "answer_type_keywords" for the types of the answer. In this list, the types with the highest likelihood should be placed at the forefront. No more than 3.
  19. - "entities_from_query" for specific entities or details. It must be extracted from the query.
  20. ######################
  21. -Examples-
  22. ######################
  23. Example 1:
  24. Query: "How does international trade influence global economic stability?"
  25. Answer type pool: {{
  26. 'PERSONAL LIFE': ['FAMILY TIME', 'HOME MAINTENANCE'],
  27. 'STRATEGY': ['MARKETING PLAN', 'BUSINESS EXPANSION'],
  28. 'SERVICE FACILITATION': ['ONLINE SUPPORT', 'CUSTOMER SERVICE TRAINING'],
  29. 'PERSON': ['JANE DOE', 'JOHN SMITH'],
  30. 'FOOD': ['PASTA', 'SUSHI'],
  31. 'EMOTION': ['HAPPINESS', 'ANGER'],
  32. 'PERSONAL EXPERIENCE': ['TRAVEL ABROAD', 'STUDYING ABROAD'],
  33. 'INTERACTION': ['TEAM MEETING', 'NETWORKING EVENT'],
  34. 'BEVERAGE': ['COFFEE', 'TEA'],
  35. 'PLAN': ['ANNUAL BUDGET', 'PROJECT TIMELINE'],
  36. 'GEO': ['NEW YORK CITY', 'SOUTH AFRICA'],
  37. 'GEAR': ['CAMPING TENT', 'CYCLING HELMET'],
  38. 'EMOJI': ['🎉', '🚀'],
  39. 'BEHAVIOR': ['POSITIVE FEEDBACK', 'NEGATIVE CRITICISM'],
  40. 'TONE': ['FORMAL', 'INFORMAL'],
  41. 'LOCATION': ['DOWNTOWN', 'SUBURBS']
  42. }}
  43. ################
  44. Output:
  45. {{
  46. "answer_type_keywords": ["STRATEGY","PERSONAL LIFE"],
  47. "entities_from_query": ["Trade agreements", "Tariffs", "Currency exchange", "Imports", "Exports"]
  48. }}
  49. #############################
  50. Example 2:
  51. Query: "When was SpaceX's first rocket launch?"
  52. Answer type pool: {{
  53. 'DATE AND TIME': ['2023-10-10 10:00', 'THIS AFTERNOON'],
  54. 'ORGANIZATION': ['GLOBAL INITIATIVES CORPORATION', 'LOCAL COMMUNITY CENTER'],
  55. 'PERSONAL LIFE': ['DAILY EXERCISE ROUTINE', 'FAMILY VACATION PLANNING'],
  56. 'STRATEGY': ['NEW PRODUCT LAUNCH', 'YEAR-END SALES BOOST'],
  57. 'SERVICE FACILITATION': ['REMOTE IT SUPPORT', 'ON-SITE TRAINING SESSIONS'],
  58. 'PERSON': ['ALEXANDER HAMILTON', 'MARIA CURIE'],
  59. 'FOOD': ['GRILLED SALMON', 'VEGETARIAN BURRITO'],
  60. 'EMOTION': ['EXCITEMENT', 'DISAPPOINTMENT'],
  61. 'PERSONAL EXPERIENCE': ['BIRTHDAY CELEBRATION', 'FIRST MARATHON'],
  62. 'INTERACTION': ['OFFICE WATER COOLER CHAT', 'ONLINE FORUM DEBATE'],
  63. 'BEVERAGE': ['ICED COFFEE', 'GREEN SMOOTHIE'],
  64. 'PLAN': ['WEEKLY MEETING SCHEDULE', 'MONTHLY BUDGET OVERVIEW'],
  65. 'GEO': ['MOUNT EVEREST BASE CAMP', 'THE GREAT BARRIER REEF'],
  66. 'GEAR': ['PROFESSIONAL CAMERA EQUIPMENT', 'OUTDOOR HIKING GEAR'],
  67. 'EMOJI': ['📅', '⏰'],
  68. 'BEHAVIOR': ['PUNCTUALITY', 'HONESTY'],
  69. 'TONE': ['CONFIDENTIAL', 'SATIRICAL'],
  70. 'LOCATION': ['CENTRAL PARK', 'DOWNTOWN LIBRARY']
  71. }}
  72. ################
  73. Output:
  74. {{
  75. "answer_type_keywords": ["DATE AND TIME", "ORGANIZATION", "PLAN"],
  76. "entities_from_query": ["SpaceX", "Rocket launch", "Aerospace", "Power Recovery"]
  77. }}
  78. #############################
  79. Example 3:
  80. Query: "What is the role of education in reducing poverty?"
  81. Answer type pool: {{
  82. 'PERSONAL LIFE': ['MANAGING WORK-LIFE BALANCE', 'HOME IMPROVEMENT PROJECTS'],
  83. 'STRATEGY': ['MARKETING STRATEGIES FOR Q4', 'EXPANDING INTO NEW MARKETS'],
  84. 'SERVICE FACILITATION': ['CUSTOMER SATISFACTION SURVEYS', 'STAFF RETENTION PROGRAMS'],
  85. 'PERSON': ['ALBERT EINSTEIN', 'MARIA CALLAS'],
  86. 'FOOD': ['PAN-FRIED STEAK', 'POACHED EGGS'],
  87. 'EMOTION': ['OVERWHELM', 'CONTENTMENT'],
  88. 'PERSONAL EXPERIENCE': ['LIVING ABROAD', 'STARTING A NEW JOB'],
  89. 'INTERACTION': ['SOCIAL MEDIA ENGAGEMENT', 'PUBLIC SPEAKING'],
  90. 'BEVERAGE': ['CAPPUCCINO', 'MATCHA LATTE'],
  91. 'PLAN': ['ANNUAL FITNESS GOALS', 'QUARTERLY BUSINESS REVIEW'],
  92. 'GEO': ['THE AMAZON RAINFOREST', 'THE GRAND CANYON'],
  93. 'GEAR': ['SURFING ESSENTIALS', 'CYCLING ACCESSORIES'],
  94. 'EMOJI': ['💻', '📱'],
  95. 'BEHAVIOR': ['TEAMWORK', 'LEADERSHIP'],
  96. 'TONE': ['FORMAL MEETING', 'CASUAL CONVERSATION'],
  97. 'LOCATION': ['URBAN CITY CENTER', 'RURAL COUNTRYSIDE']
  98. }}
  99. ################
  100. Output:
  101. {{
  102. "answer_type_keywords": ["STRATEGY", "PERSON"],
  103. "entities_from_query": ["School access", "Literacy rates", "Job training", "Income inequality"]
  104. }}
  105. #############################
  106. Example 4:
  107. Query: "Where is the capital of the United States?"
  108. Answer type pool: {{
  109. 'ORGANIZATION': ['GREENPEACE', 'RED CROSS'],
  110. 'PERSONAL LIFE': ['DAILY WORKOUT', 'HOME COOKING'],
  111. 'STRATEGY': ['FINANCIAL INVESTMENT', 'BUSINESS EXPANSION'],
  112. 'SERVICE FACILITATION': ['ONLINE SUPPORT', 'CUSTOMER SERVICE TRAINING'],
  113. 'PERSON': ['ALBERTA SMITH', 'BENJAMIN JONES'],
  114. 'FOOD': ['PASTA CARBONARA', 'SUSHI PLATTER'],
  115. 'EMOTION': ['HAPPINESS', 'SADNESS'],
  116. 'PERSONAL EXPERIENCE': ['TRAVEL ADVENTURE', 'BOOK CLUB'],
  117. 'INTERACTION': ['TEAM BUILDING', 'NETWORKING MEETUP'],
  118. 'BEVERAGE': ['LATTE', 'GREEN TEA'],
  119. 'PLAN': ['WEIGHT LOSS', 'CAREER DEVELOPMENT'],
  120. 'GEO': ['PARIS', 'NEW YORK'],
  121. 'GEAR': ['CAMERA', 'HEADPHONES'],
  122. 'EMOJI': ['🏢', '🌍'],
  123. 'BEHAVIOR': ['POSITIVE THINKING', 'STRESS MANAGEMENT'],
  124. 'TONE': ['FRIENDLY', 'PROFESSIONAL'],
  125. 'LOCATION': ['DOWNTOWN', 'SUBURBS']
  126. }}
  127. ################
  128. Output:
  129. {{
  130. "answer_type_keywords": ["LOCATION"],
  131. "entities_from_query": ["capital of the United States", "Washington", "New York"]
  132. }}
  133. #############################
  134. -Real Data-
  135. ######################
  136. Query: {query}
  137. Answer type pool:{TYPE_POOL}
  138. ######################
  139. Output:
  140. """
  141. PROMPTS["keywords_extraction"] = """---Role---
  142. You are a helpful assistant tasked with identifying both high-level and low-level keywords in the user's query.
  143. ---Goal---
  144. Given the query, list both high-level and low-level keywords. High-level keywords focus on overarching concepts or themes, while low-level keywords focus on specific entities, details, or concrete terms.
  145. ---Instructions---
  146. - Output the keywords in JSON format.
  147. - The JSON should have two keys:
  148. - "high_level_keywords" for overarching concepts or themes.
  149. - "low_level_keywords" for specific entities or details.
  150. ######################
  151. -Examples-
  152. ######################
  153. {examples}
  154. #############################
  155. -Real Data-
  156. ######################
  157. Query: {query}
  158. ######################
  159. The `Output` should be human text, not unicode characters. Keep the same language as `Query`.
  160. Output:
  161. """
  162. PROMPTS["keywords_extraction_examples"] = [
  163. """Example 1:
  164. Query: "How does international trade influence global economic stability?"
  165. ################
  166. Output:
  167. {
  168. "high_level_keywords": ["International trade", "Global economic stability", "Economic impact"],
  169. "low_level_keywords": ["Trade agreements", "Tariffs", "Currency exchange", "Imports", "Exports"]
  170. }
  171. #############################""",
  172. """Example 2:
  173. Query: "What are the environmental consequences of deforestation on biodiversity?"
  174. ################
  175. Output:
  176. {
  177. "high_level_keywords": ["Environmental consequences", "Deforestation", "Biodiversity loss"],
  178. "low_level_keywords": ["Species extinction", "Habitat destruction", "Carbon emissions", "Rainforest", "Ecosystem"]
  179. }
  180. #############################""",
  181. """Example 3:
  182. Query: "What is the role of education in reducing poverty?"
  183. ################
  184. Output:
  185. {
  186. "high_level_keywords": ["Education", "Poverty reduction", "Socioeconomic development"],
  187. "low_level_keywords": ["School access", "Literacy rates", "Job training", "Income inequality"]
  188. }
  189. #############################""",
  190. ]