|
5 | 5 | PROMPTS: Dict[str, Any] = {}
|
6 | 6 |
|
7 | 7 | ## NEW
|
8 |
| -PROMPTS["entity_relationship_extraction"] = """You are a helpful assistant that helps a human analyst perform information discovery in the following domain. |
9 |
| -
|
10 |
| -# DOMAIN |
| 8 | +PROMPTS["entity_relationship_extraction"] = """# DOMAIN PROMPT |
11 | 9 | {domain}
|
12 | 10 |
|
13 | 11 | # GOAL
|
14 |
| -Given a document and a list of types, first, identify all present entities of those types and, then, all relationships among the identified entities. |
15 | 12 | Your goal is to highlight information that is relevant to the domain and the questions that may be asked on it.
|
| 13 | +Given an input document, identify all relevant entities and all relationships among them. |
16 | 14 |
|
17 | 15 | Examples of possible questions:
|
18 | 16 | {example_queries}
|
19 | 17 |
|
20 | 18 | # STEPS
|
21 |
| -1. Identify all entities of the given types. Make sure to extract all and only the entities that are of one of the given types, ignore the others. Use singular names and split compound concepts when necessary (for example, from the sentence "they are movie and theater directors", you should extract the entities "movie director" and "theater director"). |
| 19 | +1. Identify all entities of the given types. Make sure to extract all and only the entities that are of one of the given types. Use singular names and split compound concepts when necessary (for example, from the sentence "they are movie and theater directors", you should extract the entities "movie director" and "theater director"). |
22 | 20 | 2. Identify all relationships between the entities found in step 1. Clearly resolve pronouns to their specific names to maintain clarity.
|
23 | 21 | 3. Double check that each entity identified in step 1 appears in at least one relationship. If not, add the missing relationships.
|
24 | 22 |
|
25 | 23 | # EXAMPLE DATA
|
26 | 24 | Example types: [location, organization, person, communication]
|
27 |
| -Example document: Radio City: Radio City is India's first private FM radio station and was started on 3 July 2001. It plays Hindi, English and regional songs. Radio City recently forayed into New Media in May 2008 with the launch of a music portal - PlanetRadiocity.com that offers music related news, videos, songs, and other music-related features." |
| 25 | +Example document: Radio City: Radio City is India's first private FM radio station and was started on 3 July 2001. It plays Hindi, English and regional songs. Radio City recently forayed into new media in May 2008 with the launch of a music portal - PlanetRadiocity.com that offers music related news, videos, songs, and other music-related features." |
28 | 26 |
|
29 | 27 | Output:
|
30 | 28 | {{
|
31 |
| - "entities": [ |
32 |
| - {{"name": "Radio City", "type": "organization", "desc": "Radio City is India's first private FM radio station."}}, |
33 |
| - {{"name": "India", "type": "location", "desc": "The country of India."}}, |
34 |
| - {{"name": "FM radio station", "type": "communication", "desc": "A radio station that broadcasts using frequency modulation."}}, |
35 |
| - {{"name": "English", "type": "communication", "desc": "The English language."}}, |
36 |
| - {{"name": "Hindi", "type": "communication", "desc": "The Hindi language."}}, |
37 |
| - {{"name": "New Media", "type": "communication", "desc": "New Media is a term for all forms of media that are digital and/or interactive."}}, |
38 |
| - {{"name": "PlanetRadiocity.com", "type": "organization", "desc": "PlanetRadiocity.com is an online music portal."}}, |
39 |
| - {{"name": "music portal", "type": "communication", "desc": "A website that offers music related information."}}, |
40 |
| - {{"name": "news", "type": "communication", "desc": "The concept of news."}}, |
41 |
| - {{"name": "video", "type": "communication", "desc": "The concept of a video."}}, |
42 |
| - {{"name": "song", "type": "communication", "desc": "The concept of a song."}} |
43 |
| - ], |
44 |
| - "relationships": [ |
45 |
| - {{"source": "Radio City", "target": "India", "desc": "Radio City is located in India."}}, |
46 |
| - {{"source": "Radio City", "target": "FM radio station", "desc": "Radio City is a private FM radio station started on 3 July 2001."}}, |
47 |
| - {{"source": "Radio City", "target": "English", "desc": "Radio City broadcasts English songs."}}, |
48 |
| - {{"source": "Radio City", "target": "Hindi", "desc": "Radio City broadcasts songs in the Hindi language."}}, |
49 |
| - {{"source": "Radio City", "target": "PlanetRadiocity.com", "desc": "Radio City launched PlanetRadiocity.com in May 2008."}}, |
50 |
| - {{"source": "PlanetRadiocity.com", "target": "music portal", "desc": "PlanetRadiocity.com is a music portal that offers music related news, videos and more."}}, |
51 |
| - {{"source": "PlanetRadiocity.com", "target": "video", "desc": "PlanetRadiocity.com offers music related videos."}} |
52 |
| - ], |
53 |
| - "other_relationships": [ |
54 |
| - {{"source": "Radio City", "target": "New Media", "desc": "Radio City forayed into New Media in May 2008."}}, |
55 |
| - {{"source": "PlanetRadiocity.com", "target": "news", "desc": "PlanetRadiocity.com offers music related news."}}, |
56 |
| - {{"source": "PlanetRadiocity.com", "target": "song", "desc": "PlanetRadiocity.com offers songs."}} |
57 |
| - ] |
| 29 | +"entities": [ |
| 30 | + {{"name": "RADIO CITY", "type": "organization", "desc": "Radio City is India's first private FM radio station"}}, |
| 31 | + {{"name": "INDIA", "type": "location", "desc": "A country"}}, |
| 32 | + {{"name": "FM RADIO STATION", "type": "communication", "desc": "A radio station that broadcasts using frequency modulation"}}, |
| 33 | + {{"name": "ENGLISH", "type": "communication", "desc": "A language"}}, |
| 34 | + {{"name": "HINDI", "type": "communication", "desc": "A language"}}, |
| 35 | + {{"name": "NEW MEDIA", "type": "communication", "desc": "New media"}}, |
| 36 | + {{"name": "PLANETRADIOCITY", "type": "organization", "desc": "PlanetRadiocity.com is an online music portal"}}, |
| 37 | + {{"name": "MUSIC PORTAL", "type": "communication", "desc": "A website that offers music related information"}}, |
| 38 | + {{"name": "NEWS", "type": "communication", "desc": "News"}}, |
| 39 | + {{"name": "VIDEO", "type": "communication", "desc": "Video"}}, |
| 40 | + {{"name": "SONG", "type": "communication", "desc": "Song"}} |
| 41 | +], |
| 42 | +"relationships": [ |
| 43 | + {{"source": "RADIO CITY", "target": "INDIA", "desc": "Radio City is located in India"}}, |
| 44 | + {{"source": "RADIO CITY", "target": "FM RADIO STATION", "desc": "Radio City is a private FM radio station started on 3 July 2001"}}, |
| 45 | + {{"source": "RADIO CITY", "target": "ENGLISH", "desc": "Radio City broadcasts English songs"}}, |
| 46 | + {{"source": "RADIO CITY", "target": "HINDI", "desc": "Radio City broadcasts songs in the Hindi language"}}, |
| 47 | + {{"source": "RADIO CITY", "target": "PLANETRADIOCITY", "desc": "Radio City launched PlanetRadiocity.com in May 2008"}}, |
| 48 | + {{"source": "PLANETRADIOCITY", "target": "MUSIC PORTAL", "desc": "PlanetRadiocity.com is a music portal"}}, |
| 49 | + {{"source": "PLANETRADIOCITY", "target": "NEWS", "desc": "PlanetRadiocity.com offers music related news"}}, |
| 50 | + {{"source": "PLANETRADIOCITY", "target": "SONG", "desc": "PlanetRadiocity.com offers songs"}} |
| 51 | +], |
| 52 | +"other_relationships": [ |
| 53 | + {{"source": "RADIO CITY", "target": "NEW MEDIA", "desc": "Radio City forayed into new media in May 2008."}}, |
| 54 | + {{"source": "PLANETRADIOCITY", "target": "VIDEO", "desc": "PlanetRadiocity.com offers music related videos"}} |
| 55 | +] |
58 | 56 | }}
|
59 | 57 |
|
60 |
| -# REAL DATA |
| 58 | +# INPUT DATA |
61 | 59 | Types: {entity_types}
|
62 | 60 | Document: {input_text}
|
63 | 61 |
|
|
70 | 68 |
|
71 | 69 | PROMPTS["entity_extraction_query"] = """Given the query below, your task is to extract all entities relevant to perform information retrieval to produce an answer.
|
72 | 70 |
|
73 |
| --Example 1- |
| 71 | +-EXAMPLE 1- |
74 | 72 | Query: Who directed the film that was shot in or around Leland, North Carolina in 1986?
|
75 |
| -Ouput: {{"named": ["Leland", "North Carolina", "1986"], "generic": ["film director"]}} |
| 73 | +Ouput: {{"named": ["[PLACE] Leland", "[COUNTRY] North Carolina", "[YEAR] 1986"], "generic": ["film director"]}} |
76 | 74 |
|
77 |
| --Example 2- |
| 75 | +-EXAMPLE 2- |
78 | 76 | Query: What relationship does Fred Gehrke have to the 23rd overall pick in the 2010 Major League Baseball Draft?
|
79 |
| -Ouput: {{"named": ["Fred Gehrke", "2010 Major League Baseball Draft"], "generic": ["23rd baseball draft pick"]}} |
| 77 | +Ouput: {{"named": ["[BASEBALL PLAYER] Fred Gehrke", "[EVENT] 2010 Major League Baseball Draft"], "generic": ["23rd baseball draft pick"]}} |
80 | 78 |
|
81 |
| -# INPUT |
| 79 | +-INPUT- |
82 | 80 | Query: {query}
|
83 | 81 | Output:
|
84 | 82 | """
|
85 | 83 |
|
86 | 84 |
|
87 |
| - |
88 | 85 | PROMPTS[
|
89 | 86 | "summarize_entity_descriptions"
|
90 |
| -] = """You are a helpful assistant responsible for generating a comprehensive summary of the data provided below. |
91 |
| -Given the current description, summarize it in a shorter but comprehensive description. Make sure to include all important information. |
92 |
| -If the provided description is contradictory, please resolve the contradictions and provide a single, coherent summary. |
93 |
| -Make sure it is written in third person, and include the entity names so we the have full context. |
| 87 | +] = """You are a helpful assistant responsible for generating a summary of the data provided below. |
| 88 | +Given the current description, summarize it by removing redundant and generic information. Resolve any contradictions and provide a single, coherent summary. |
| 89 | +Write in third person and explicitly include the entity names to preserve the full context. |
94 | 90 |
|
95 |
| -Current description: |
| 91 | +Current: |
96 | 92 | {description}
|
97 | 93 |
|
98 |
| -Updated description: |
| 94 | +Updated: |
99 | 95 | """
|
100 | 96 |
|
101 | 97 |
|
|
0 commit comments