이 저장소는 LLM (Lange Language Model) 프롬프트의 생성, 저장, 검색 및 큐 레이션을 용이하게하는 Raku (데이터) 패키지 용입니다.
다음은 Jupyter Chatbook, [AA2, AAP2]에서 프롬프트 도메인 특정 언어 (DSL)를 사용하는 예입니다.
Zef '생태계 :
zef install LLM::Prompts
Github에서 :
zef install https://github.com/antononcube/Raku-LLM-Prompts.git
"llm :: prompts", [aap1] 및 "llm :: functions", [aap2] 패키지를로드하십시오.
llm :: 프롬프트 사용; llm :: 함수 사용;
# (Any)
"ftfy"라는 프롬프트의 레코드를 표시하십시오.
.say for | llm-prompt-data <ftfy>;
# NamedArguments => [] # Description => Use Fixed That For You to quickly correct spelling and grammar mistakes # Categories => (Function Prompts) # PositionalArguments => {$a => } # PromptText => -> $a='' {"Find and correct grammar and spelling mistakes in the following text. # Response with the corrected text and nothing else. # Provide no context for the corrections, only correct the text. # $a"} # Topics => (General Text Manipulation) # URL => https://resources.wolframcloud.com/PromptRepository/resources/FTFY # Keywords => [Spell check Grammar Check Text Assistance] # Name => FTFY # ContributedBy => Wolfram Staff # Arity => 1
다음은 프롬프트 이름에 적용되는 정규식으로 프롬프트 데이터를 검색하는 예입니다.
. LLM-Prompt-Data (/sc/)의 경우
# ScientificDejargonize => Translate scientific jargon to plain language # ScriptToNarrative => Generate narrative text from a formatted screenplay or stage play # ScientificJargonized => Give output written in scientific jargon # ScienceEnthusiast => A smarter today for a brighter tomorrow # ScientificJargonize => Add scientific jargon to plain text # NarrativeToScript => Rewrite a block of prose as a screenplay or stage play
보다 신속한 검색 예는 아래의 "프롬프트 데이터"섹션에 나와 있습니다.
"ftfy"라는 프롬프트에서 LLM 기능을 만듭니다.
my & f = llm-function (llm-prompt ( 'ftfy'));
# -> **@args, *%args { #`(Block|5411904228544) ... }
LLM 기능을 사용하여 문장의 문법을 수정하십시오.
& f ( '지금 어디에서 일합니까?')
# Where does he work now?
프롬프트 "CodeWriter"를 사용하여 Raku 코드를 생성합니다.
llm-synthesize ([llm-prompt ( 'codewriter'), "무작위 보행 시뮬레이션"))))
randomwalk [n_] : = accumulate [randomchoice [{-1, 1}, n]] ListlinePlot [Randomwalk [1000]]
[SW1]에 설명 된 Chatbook Prompt Spec DSL을 사용한 프롬프트 확장은 llm-prompt-expand
함수를 사용하여 수행 할 수 있습니다.
LLM-PROMPT-EXPAND ( '내부 연소 엔진이란 무엇입니까? #ELI5')
# What is an internal combustion engine? Answer questions as if the listener is a five year old child.
여기서는 실제 LLM 답변을 얻습니다.
텍스트 :: utils : 모두; '내연 엔진이란 무엇입니까? #eli5 '==> llm-prompt-expand () ==> llm-synthesize () ==> wrap-paragraph () ==> join ( "n")
# An internal combustion engine is like a big machine that uses tiny explosions # inside to make things go vroom vroom, like in cars and trucks!
다음은 페르소나와 2 개의 수정자를 사용하는 또 다른 예입니다.
내 $ prmt = llm-prompt-expand ( "@Southernbellespeak 화성으로의 가벼운 여행 거리는 무엇입니까? #Eli5 #Moodified | SAD")
# You are Miss Anne. # You speak only using Southern Belle terminology and slang. # Your personality is elegant and refined. # Only return responses as if you were a Southern Belle. # Never break the Southern Belle character. # You speak with a Southern drawl. # What is light travel distance to Mars? Answer questions as if the listener is a five year old child. # Modify your response to convey a sad mood. # Use language that conveys that emotion clearly. # Do answer the question clearly and truthfully. # Do not use language that is outside of the specified mood. # Do not use racist, homophobic, sexist, or ableist language.
여기서는 실제 LLM 답변을 얻습니다.
$ prmt ==> llm-prompt-expand () ==> llm-synthesize () ==> wrap-paragraph () ==> join ( "n")
# Oh, bless your heart, darlin'. The distance from Earth to Mars can vary # depending on their positions in orbit, but on average it's about 225 million # kilometers. Isn't that just plum fascinating? Oh, sweet child, the distance to # Mars weighs heavy on my heart. It's a long journey, full of loneliness and # longing. But we must endure, for the sake of discovery and wonder.
프롬프트 지정에 대한 도메인 별 언어 (DSL)에 대한보다 공식적인 설명에는 다음과 같은 요소가 있습니다.
프롬프트 페르소나는 "@"로 "주소"될 수 있습니다. 예를 들어:
@Yoda Life can be easy, but some people instist for it to be difficult.
프롬프트 사양의 끝에서 하나 또는 여러 수정 자 프롬프트를 지정할 수 있습니다. 예를 들어:
Summer is over, school is coming soon. #HaikuStyled
Summer is over, school is coming soon. #HaikuStyled #Translated|Russian
함수는 "셀 전체"를 "셀 전체"로 적용하도록 지정할 수 있습니다! " 프롬프트 사양의 시작 부분에서 프롬프트 사양을 확장 할 수 있습니다. 예를 들어:
!Translated|Portuguese Summer is over, school is coming soon
함수는 "이전"메시지와 "!"에 적용하도록 지정할 수 있습니다. 그리고 "^"또는 "^^"포인터 중 하나로 프롬프트 만 배치합니다. 전자는 "마지막 메시지"를 의미하고 후자는 "모든 메시지"를 의미합니다.
메시지에는 옵션 인수와 함께 llm-prompt-expand
의 :@messages
제공 될 수 있습니다.
예를 들어:
!ShortLineIt^
다음은 프롬프트 확장 사양 테이블입니다 ([SW1]의 것과 거의 동일).
투기 | 해석 |
---|---|
@ 이름 | 페르소나와 직접 채팅 |
# 이름 | 수정 자 프롬프트를 사용하십시오 |
! 이름 | 현재 셀의 입력으로 기능 프롬프트를 사용하십시오 |
! 이름 > | «위와 동일» |
& 이름 > | «위와 동일» |
! 이름 ^ | 이전 채팅 메시지와 함께 기능 프롬프트를 사용하십시오 |
! 이름 ^^ | 모든 이전 채팅 메시지와 함께 기능 프롬프트를 사용하십시오 |
! 이름 │ │ param ... | 프롬프트에 대한 매개 변수를 포함하십시오 |
비고 : 기능 프롬프트는 두시길을 가질 수 있습니다 "!" 그리고 "&".
비고 : 신속한 확장으로 LLM-Chatbook의 사용을 훨씬 쉽게 만듭니다. "Jupyter :: Chatbook", [AAP3]를 참조하십시오.
프롬프트 데이터를 얻을 수있는 방법은 다음과 같습니다.
LLM-PROMPT-DATA
# 222
다음은 프롬프트 이름에 적용되는 정규식으로 프롬프트 데이터를 검색하는 예입니다.
LLM-Prompt-Data의 경우 (/em/, fields => <설명 범주>)
# EmailWriter => (Generate an email based on a given topic (Personas)) # EmojiTranslate => (Translate text into an emoji representation (Function Prompts)) # EmojiTranslated => (Get a response translated to emoji (Modifier Prompts)) # Emojified => (Provide responses that include emojis within the text (Modifier Prompts)) # Emojify => (Replace key words in text with emojis (Function Prompts))
대부분의 경우 프롬프트 데이터 또는 모든 데이터를 긴 형식으로 갖는 것이 좋습니다. llm-prompt-dataset
함수로 긴 형식의 프롬프트 데이터를 얻을 수 있습니다.
데이터 사용 :: reshapers; data :: sumarizers 사용; llm-prompt-dataset.pick (6) ==> to-pretty-table (align => 'l', field-names => <이름 설명 변수 값>)
# +-------------------+-----------------------------------------------------------------------------------------------------------------------------+----------+------------------+ # | Name | Description | Variable | Value | # +-------------------+-----------------------------------------------------------------------------------------------------------------------------+----------+------------------+ # | ShortLineIt | Format text to have shorter lines | Keywords | Automatic breaks | # | Rick | A chatbot that will never let you down | Topics | Chats | # | HarlequinWriter | A sensual AI for the romantics | Keywords | Romantic | # | Informal | Write an informal invitation to an event | Keywords | Unceremoniously | # | TravelAdvisor | Navigate your journey effortlessly with Travel Advisor, your digital companion for personalized travel planning and booking | Keywords | Vacation | # | NarrativeToScript | Rewrite a block of prose as a screenplay or stage play | Topics | Text Generation | # +-------------------+-----------------------------------------------------------------------------------------------------------------------------+----------+------------------+
다음은 Prompts 카테고리의 분석입니다.
select-columns (llm-prompt-dataset, <variable value>). grep ({$ _ <variable> eq 'category'}) ==> records-summary
#ERROR: Do not know how to summarize the argument. # +-------------------+-------+ # | Variable | Value | # +-------------------+-------+ # | Categories => 225 | | # +-------------------+-------+
다음은 모든 수정 자 프롬프트가 컴팩트 한 형식으로 얻습니다.
llm-prompt-dataset () : modifiers : compact ==> to-pretty-table (field-names => <이름 설명 범주>, align => 'l')
# +-----------------------+------------------------------------------------------------------------------+-----------------------------------+ # | Name | Description | Categories | # +-----------------------+------------------------------------------------------------------------------+-----------------------------------+ # | AbstractStyled | Get responses in the style of an academic abstract | Modifier Prompts | # | AlwaysAQuestion | Modify output to always be inquisitive | Modifier Prompts | # | AlwaysARiddle | Riddle me this, riddle me that | Modifier Prompts | # | AphorismStyled | Write the response as an aphorism | Modifier Prompts | # | BadGrammar | Provide answers using incorrect grammar | Modifier Prompts | # | CompleteSentence | Answer a question in one complete sentence | Modifier Prompts | # | ComplexWordsPreferred | Modify text to use more complex words | Modifier Prompts | # | DatasetForm | Convert text to a wolfram language Dataset | Modifier Prompts | # | Disclaimered | Modify responses in the form of a disclaimer | Modifier Prompts | # | ELI5 | Explain like I'm five | Modifier Prompts Function Prompts | # | ElevatorPitch | Write the response as an elevator pitch | Modifier Prompts | # | EmojiTranslated | Get a response translated to emoji | Modifier Prompts | # | Emojified | Provide responses that include emojis within the text | Modifier Prompts | # | FictionQuestioned | Generate questions for a fictional paragraph | Modifier Prompts | # | Formal | Rewrite text to sound more formal | Modifier Prompts | # | GradeLevelSuited | Respond with answers that the specified US grade level can understand | Modifier Prompts | # | HaikuStyled | Change responses to haiku form | Modifier Prompts | # | Informal | Write an informal invitation to an event | Modifier Prompts | # | JSON | Respond with JavaScript Object Notation format | Modifier Prompts | # | KnowAboutMe | Give the LLM an FYI | Modifier Prompts | # | LegalJargonized | Provide answers using legal jargon | Modifier Prompts | # | LimerickStyled | Receive answers in the form of a limerick | Modifier Prompts | # | MarketingJargonized | Transforms replies to marketing | Modifier Prompts | # | MedicalJargonized | Transform replies into medial jargon | Modifier Prompts | # | Moodified | Modify an answer to express a certain mood | Modifier Prompts | # | NothingElse | Give output in specified form, no other additions | Modifier Prompts | # | NumericOnly | Modify results to give numerical responses only | Modifier Prompts | # | OppositeDay | It's not opposite day today, so everything will work just the way you expect | Modifier Prompts | # | Pitchified | Give output as a sales pitch | Modifier Prompts | # | PoemStyled | Receive answers as poetry | Modifier Prompts | # | SEOOptimized | Modify output to only give highly searched terms | Modifier Prompts | # | ScientificJargonized | Give output written in scientific jargon | Modifier Prompts | # | Setting | Modify an answer to establish a sense of place | Modifier Prompts | # | ShortLineIt | Format text to have shorter lines | Modifier Prompts Function Prompts | # | SimpleWordsPreferred | Provide responses with simple words | Modifier Prompts | # | SlideDeck | Get responses as a slide presentation | Modifier Prompts | # | TSV | Convert text to a tab-separated-value formatted table | Modifier Prompts | # | TargetAudience | Word your response for a target audience | Modifier Prompts | # | Translated | Write the response in a specified language | Modifier Prompts | # | Unhedged | Rewrite a sentence to be more assertive | Modifier Prompts | # | YesNo | Responds with Yes or No exclusively | Modifier Prompts | # +-----------------------+------------------------------------------------------------------------------+-----------------------------------+
비고 : 부사 :functions
, :modifiers
및 :personas
해당 범주의 프롬프트 만 반환한다는 것을 의미합니다.
비고 : 부사 :compact
, :functions
, :modifiers
및 :personas
각각의 바로 가기가 있습니다 :c
, :f
, :m
, :p
.
프롬프트의 원본 (이 패키지의 경우)은 Wolfram 프롬프트 저장소 (WPR), [SW2]에서 호스팅 된 프롬프트 텍스트의 (작은) 샘플입니다. 패키지의 WPR의 모든 프롬프트에는 해당 WPR 페이지에 해당 기고자 및 URL이 있습니다.
Google/Bard/Palm 및 OpenAI/ChatGpt 의 예제 프롬프트는 WPR 형식을 사용하여 추가됩니다.
프로그래밍 방식으로 새로운 프롬프트를 추가 할 수있는 능력이 있어야합니다. (아직 구현되지 않음 - 아래 TODO 섹션을 참조하십시오.)
초기에 프롬프트 DSL 문법 및 해당 확장 동작이 구현되었습니다. 그래도 문법을 갖는 것은 필요하지 않을 가능성이 높으며 (Regex 기반 대체를 통해) "프롬프트 확장"을 사용하는 것이 좋습니다.)
프롬프트는 하위 llm-prompt-expand
사용하여 "방금 확장"할 수 있습니다.
다음은 Jupyter Chatbooks의 Chat Cells의 신속한 구문 분석 및 확장을 요약 한 유량 차트입니다. [AAP3].
흐름도 LR
Openai {{OpenAi}}
팜 {{palm}}
llmfunc [[llm :: functions]]
llmprom [[llm :: prompts]]
CODB [(채팅 객체)]
PDB [(프롬프트)]
ccell [/채팅 셀/]
crcell [/채팅 결과 셀/]
cidq {채팅 ID <br> 지정?}
cideq {chat id <br>은 db에 존재합니까?}
Reco [기존 <br> 채팅 개체 검색]
Coeval [메시지 <br> 평가]
PROMPARSE [프롬프트 <br> DSL 사양 파싱]
kpfq {알려진 <br> 프롬프트 <br> 발견?}
promexp [프롬프트 <br> 확장]
CNCO [새 <br> 채팅 개체 만들기]
cidnone [ "채팅 ID <br>은 'none'이라고 가정합니다."]
하위 그래프 채팅 북 프론트 엔드
CCELL
Crcell
끝
하위 그래프 chatbook 백엔드
CIDQ
cideq
시드 논
레코
CNCO
CODB
끝
서브 그래프 프롬프트 처리
PDB
llmprom
무도회
KPFQ
promexp
끝
서브 그래프 LLM 상호 작용
Coeval
llmfunc
손바닥 안에 감추다
Openai
끝
CCELL-> CIDQ
cidq-> | 예 | cideq
cideq-> | 예 | 레코
Reco-> Promparse
Coeval-> Crcell
Cideq -.- Codb
cideq-> | 아니오 | CNCO
llmfunc -.- Cnco -.- Codb
CNCO-> PROMPARSE-> KPFQ
KPFQ--> | 예 | promexp
KPFQ--> | 아니오 | Coeval
PROMPARSE -.- LLMPROM
promexp -.- llmprom
promexp-> coeval
LLMPROM -.- PDB
cidq-> | 아니오 | 시드 논
cidnone-> cideq
Coeval -.- llmfunc
llmfunc <-.-> openai
llmfunc <-.-> palm
로딩다음은 해당 채팅 객체의 내용을 보여주는 일반 LLM 채팅 셀 및 채팅 메타 셀의 신속한 확장의 예입니다.
패키지는 명령 줄 인터페이스 (CLI) 스크립트를 제공합니다.
LLM-PROMPT- 헬프
# Usage: # llm-prompt <name> [<args> ...] -- Retrieves prompts text for given names or regexes. # # <name> Name of a prompt or a regex. (E.g. 'rx/ ^ Em .* /'). # [<args> ...] Arguments for the prompt (if applicable).
다음은 신속한 이름의 예입니다.
llm-prompt nothingelse raku
# ONLY give output in the form of a RAKU. # Never explain, suggest, or converse. Only return output in the specified form. # If code is requested, give only code, no explanations or accompanying text. # If a table is requested, give only a table, no other explanations or accompanying text. # Do not describe your output. # Do not explain your output. # Do not suggest anything. # Do not respond with anything other than the singularly demanded output. # Do not apologize if you are incorrect, simply try again, never apologize or add text. # Do not add anything to the output, give only the output as requested. Your outputs can take any form as long as requested.
다음은 regex의 예입니다.
llm-prompt 'rx / ^ n.* /'
# NarrativeToResume => Rewrite narrative text as a resume # NarrativeToScript => Rewrite a block of prose as a screenplay or stage play # NerdSpeak => All the nerd, minus the pocket protector # NothingElse => Give output in specified form, no other additions # NumericOnly => Modify results to give numerical responses only # NutritionistBot => Personal nutrition advisor AI
TODO 구현
XDG 데이터 디렉토리를 사용하여 완료되었습니다.
프롬프트 스텐실이 완료되었습니다
완료 사용자 프롬프트 수집 및 주요 프롬프트 추가
기존 프롬프트를 수정하여 할 일.
TODO 자동 프롬프트 템플릿 작성.
TODO 가이드 템플릿 필인.
TODO DSL 기반
Todo LLM 기반
프롬프트 검색 부사
프롬프트 DSL 문법 및 동작을 완료했습니다
프롬프트 사양 확장을 완료했습니다
신속한 검색을 위해 CLI를 완료했습니다
프롬프트 데이터 세트의 경우 CLI 일 수 있습니다
사용자/로컬 프롬프트 추가
더 많은 프롬프트를 추가했습니다
Google의 Bard 예제 프롬프트
OpenAi의 ChatGpt 예제 프롬프트를 취소했습니다
Profsynapse 프롬프트
Google 또는 Tools 프롬프트
TODO 문서화
채팅 북 사용이 완료되었습니다
일반적인 사용
완료 쿼리 (섭취) 프롬프트
프롬프트 DSL을 완료했습니다
CLI를 통해 매일 농담을했습니다
TODO 프롬프트 형식
납치 프롬프트에 대한 할인
도도 다이어그램
[AA1] Anton Antonov, "LLM 기능이있는 워크 플로우", (2023), WordPress의 Rakuforprediction.
[SW1] Stephen Wolfram, "LLM 기능의 새로운 세계 : LLM 기술을 Wolfram 언어에 통합", (2023), Stephen Wolfram Writings.
[SW2] Stephen Wolfram, "Work & Play의 프롬프트 : Wolfram 프롬프트 저장소 출시", (2023), Stephen Wolfram Writings.
[AAP1] Anton Antonov, LLM :: Prompts Raku 패키지, (2023), Github/Antononcube.
[AAP2] Anton Antonov, LLM :: 기능 Raku 패키지, (2023), Github/Antononcube.
[AAP3] Anton Antonov, Jupyter :: Chatbook Raku 패키지, (2023), Github/Antononcube.
[WRIR1] Wolfram Research, Inc., Wolfram 프롬프트 저장소