■ PromptTemplate 클래스를 사용해 점진적 압축 요약문(Progressive Compression Summary) 프롬프트를 만드는 방법을 보여준다.
▶ 예제 코드 (PY)
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 |
from langchain.prompts import PromptTemplate promptTemplateString = """Article : {ARTICLE} You will generate increasingly concise, entity-dense summaries of the above article. Repeat the following 2 steps 5 times. Step 1. Identify 1-3 informative entities (";" delimited) from the article which are missing from the previously generated summary. Step 2. Write a new, denser summary of identical length which covers every entity and detail from the previous summary plus the missing entities. A missing entity is : - relevant to the main story, - specific yet concise (100 words or fewer), - novel (not in the previous summary), - faithful (present in the article), - anywhere (can be located anywhere in the article). Guidelines : - The first summary should be long (8-10 sentences, ~200 words) yet highly non-specific, containing little information beyond the entities marked as missing. Use overly verbose language and fillers (e.g., "this article discusses") to reach ~200 words. - Make every word count: rewrite the previous summary to improve flow and make space for additional entities. - Make space with fusion, compression, and removal of uninformative phrases like "the article discusses". - The summaries should become highly dense and concise yet self-contained, i.e., easily understood without the article. - Missing entities can appear anywhere in the new summary. - Never drop entities from the previous summary. If space cannot be made, add fewer new entities. Remember, use the exact same number of words for each summary. Answer in JSON. The JSON should be a list (length 5) of dictionaries whose keys are "Missing_Entities" and "Denser_Summary". Use only KOREAN language to reply. """ promptTemplate = PromptTemplate.from_template(promptTemplateString) |
※ pip install langchain 명령을 실행했다.