Repositori ini adalah untuk paket Raku (data) yang memfasilitasi pembuatan, penyimpanan, pengambilan, dan kurasi model Model Bahasa Besar (LLM).
Berikut adalah contoh menggunakan Prompt Domain Spesific Language (DSL) di Jupyter Chatbook, [AA2, AAP2]:
Dari zef 'ekosistem:
zef install LLM::Prompts
Dari GitHub:
zef install https://github.com/antononcube/Raku-LLM-Prompts.git
Muat paket "llm :: prompts", [aap1], dan "llm :: functions", [aap2]:
Gunakan llm :: prompt; gunakan llm :: fungsi;
# (Any)
Tunjukkan catatan prompt bernama "ftfy":
.say untuk | 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
Berikut adalah contoh pengambilan data prompt dengan regex yang diterapkan pada nama prompt:
.Say untuk 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
Contoh pengambilan yang lebih cepat diberikan di bagian "data cepat" di bawah ini.
Buat fungsi LLM dari prompt bernama "ftfy":
my & f = llm-function (llm-prompt ('ftfy'));
# -> **@args, *%args { #`(Block|5411904228544) ... }
Gunakan fungsi LLM untuk memperbaiki tata bahasa kalimat:
& f ('Di mana dia bekerja sekarang?')
# Where does he work now?
Menghasilkan kode raku menggunakan prompt "codewriter":
llm-sintesis ([llm-prompt ('codewriter'), "simulasikan jalan acak."])
RandomWalk [n_]: = Akumulasi [randomChoice [{-1, 1}, n]] ListLineplot [RandomWalk [1000]]
Ekspansi Prompt Menggunakan Spec Prompt Spec DSL yang Dikeluarkan dalam [SW1] dapat dilakukan dengan menggunakan fungsi llm-prompt-expand
:
llm-prompt-expand ('Apa itu mesin pembakaran internal? #ELI5')
# What is an internal combustion engine? Answer questions as if the listener is a five year old child.
Di sini kita mendapatkan jawaban LLM yang sebenarnya:
Gunakan teks :: utils: all; 'Apa itu mesin pembakaran internal? #ELI5 '==> llm-prompt-expand () ==> llm-synthesize () ==> wrap-paragraph () ==> gabung ("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!
Berikut adalah contoh lain menggunakan persona dan dua pengubah:
$ prmt = llm-prompt-expand saya ("@SouthernBellespeak Apa jarak perjalanan ringan ke Mars? #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.
Di sini kita mendapatkan jawaban LLM yang sebenarnya:
$ prmt ==> llm-prompt-expand () ==> llm-synthesize () ==> wrap-paragraph () ==> gabung ("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.
Deskripsi yang lebih formal dari bahasa spesifik domain (DSL) untuk menentukan prompt memiliki elemen berikut:
Personas prompt dapat "ditangani" dengan "@". Misalnya:
@Yoda Life can be easy, but some people instist for it to be difficult.
Satu atau beberapa prompt pengubah dapat ditentukan di akhir spec prompt. Misalnya:
Summer is over, school is coming soon. #HaikuStyled
Summer is over, school is coming soon. #HaikuStyled #Translated|Russian
Fungsi dapat ditentukan untuk diterapkan "selebar sel" dengan "!" dan menempatkan spec prompt di awal spec prompt untuk diperluas. Misalnya:
!Translated|Portuguese Summer is over, school is coming soon
Fungsi dapat ditentukan untuk diterapkan pada pesan "sebelumnya" dengan "!" dan menempatkan hanya prompt dengan salah satu petunjuk "^" atau "^^". Yang pertama berarti "pesan terakhir", yang terakhir berarti "semua pesan."
Pesan dapat disediakan dengan argumen opsi :@messages
dari llm-prompt-expand
.
Misalnya:
!ShortLineIt^
Berikut adalah tabel spesifikasi ekspansi cepat (kurang lebih sama dengan yang ada di [sw1]):
Spec | Interpretasi |
---|---|
@ name | Obrolan langsung ke suatu persona |
# Nama | Gunakan prompt pengubah |
Lai nama | Gunakan fungsi prompt dengan input sel saat ini |
Lai Nama > | «Sama seperti di atas» |
& NAMA > | «Sama seperti di atas» |
Lai Nama ^ | Gunakan Fungsi Prompt dengan Pesan Obrolan Sebelumnya |
Lai Nama ^^ | Gunakan Function Prompt dengan semua pesan obrolan sebelumnya |
Lai Nama │ Param ... | Sertakan parameter untuk petunjuk |
KATAAN: Prompt fungsi dapat memiliki kedua sigil "!" Dan "&".
Komentar: Perluasan yang cepat membuat penggunaan buku-obrolan LLM jauh lebih mudah. Lihat "Jupyter :: Chatbook", [AAP3].
Berikut adalah bagaimana data prompt dapat diperoleh:
llm-prompt-data.elems
# 222
Berikut adalah contoh pengambilan data prompt dengan regex yang diterapkan pada nama prompt:
.say untuk llm-prompt-data (/em/, fields => <kategori deskripsi>)
# 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))
Dalam banyak kasus lebih baik memiliki data prompt - atau data apa pun - dalam format panjang. Data prompt dalam format panjang dapat diperoleh dengan fungsi llm-prompt-dataset
:
Gunakan data :: pembuluh darah; Gunakan data :: Summarizers; llm-prompt-dataset.pick (6) ==> to-pretty-table (align => 'l', field-names => <nama deskripsi nilai variabel>)
# +-------------------+-----------------------------------------------------------------------------------------------------------------------------+----------+------------------+ # | 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 | # +-------------------+-----------------------------------------------------------------------------------------------------------------------------+----------+------------------+
Berikut ini adalah rincian kategori prompt:
Pilih-kolom (llm-prompt-dataset, <variable value>). grep ({$ _ <variable> eq 'kategori'}) ==> Rekaman-Ringkasan
#ERROR: Do not know how to summarize the argument. # +-------------------+-------+ # | Variable | Value | # +-------------------+-------+ # | Categories => 225 | | # +-------------------+-------+
Di sini diperoleh semua prompt pengubah dalam format kompak:
llm-prompt-dataset (): pengubah: compact ==> to-pretty-table (field-names => <nama deskripsi kategori>, 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 | # +-----------------------+------------------------------------------------------------------------------+-----------------------------------+
Komentar: kata keterangan :functions
, :modifiers
, dan :personas
berarti bahwa hanya petunjuk dengan kategori yang sesuai akan dikembalikan.
Komentar: kata keterangan :compact
, :functions
, :modifiers
, dan :personas
memiliki jalan pintas masing -masing :c
, :f
, :m
, dan :p
.
Kumpulan prompt asli (untuk paket ini) adalah sampel (bukan kecil) dari teks prompt yang di -host di Wolfram Prompt Repository (WPR), [SW2]. Semua petunjuk dari WPR dalam paket memiliki kontributor dan URL yang sesuai ke halaman WPR yang sesuai.
Contoh permintaan dari Google/Bard/Palm dan OpenAI/ChatGPT ditambahkan menggunakan format WPR.
Sangat penting untuk memiliki kemampuan untuk secara terprogram menambahkan petunjuk baru. (Belum diimplementasikan - lihat bagian TODO di bawah ini.)
Awalnya tata bahasa DSL yang cepat dan tindakan ekspansi yang sesuai diimplementasikan. Memiliki tata bahasa kemungkinan besar tidak diperlukan, dan lebih baik menggunakan "ekspansi cepat" (melalui substitusi berbasis Regex.)
Prompt dapat "hanya diperluas" menggunakan llm-prompt-expand
.
Berikut adalah diagram alur yang merangkum penguraian dan ekspansi yang cepat dalam sel obrolan jupyter chatbooks, [AAP3]:
LR FOLKCHART
OpenAI {{OpenAi}}
Palm {{palm}}
Llmfunc [[llm :: functions]]
Llmprom [[llm :: prompts]]
Codb [(objek obrolan)]
PDB [(prompt)]
Ccell [/sel obrolan/]
Crcell [/sel hasil obrolan/]
Cidq {chat id <br> ditentukan?}
Cideq {chat id <br> ada di db?}
Reco [ambil <br> objek obrolan yang ada]
Coeval [pesan <br> Evaluasi]
Promparse [prompt <br> DSL spec parsing]
Kpfq {diketahui <br> meminta <br> ditemukan?}
Promexp [prompt <br> ekspansi]
CNCO [Buat objek obrolan <br> baru]
Cidnone ["Asumsikan ID obrolan <br> adalah 'tidak ada'"]
Subgraph Chatbook Frontend
Ccell
Crcell
akhir
Subgraph Chatbook Backend
CIDQ
Cideq
Cidnone
Reko
Cnco
Codb
akhir
Subgraph Prompt Process
PDB
Llmprom
Promparse
Kpfq
Promexp
akhir
interaksi subgraph llm
Sebaya
Llmfunc
Telapak
Openai
akhir
CCELL -> CIDQ
CIDQ -> | Ya | Cideq
Cideq -> | ya | Reko
Reco -> Promparse
Coeval -> crcell
Cideq -.- codb
CIDEQ -> | Tidak | Cnco
Llmfunc -.- cnco -.- codb
Cnco -> promparse -> kpfq
KPFQ -> | Ya | Promexp
KPFQ -> | Tidak | Sebaya
Promparse -.- llmprom
Promexp -.- llmprom
Promexp -> Coeval
Llmprom -.- PDB
CIDQ -> | Tidak | Cidnone
Cidnone -> cideq
Coeval -.- llmfunc
Llmfunc <-.-> Openai
Llmfunc <-.-> Palm
MemuatBerikut adalah contoh ekspansi cepat di sel obrolan LLM generik dan sel meta obrolan yang menunjukkan konten objek obrolan yang sesuai:
Paket menyediakan skrip antarmuka baris perintah (CLI):
llm-prompt --help
# 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).
Berikut adalah contoh dengan nama cepat:
llm-prompt nole-noelse 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.
Berikut adalah contoh dengan 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
Implementasi Todo
Selesai menggunakan direktori data XDG.
Selesai stensil cepat
Selesai konsumsi prompt pengguna dan penambahan ke prompt utama
TODO dengan memodifikasi petunjuk yang ada.
TODO Automatic Prompt Template Fill-in.
TODO Template dipandu mengisi.
TODO DSL Berbasis
Berbasis Todo LLM
Dilakukan kata keterangan pengambilan cepat
Selesai Tata Bahasa DSL Prompt dan Tindakan
Selesai ekspansi spesifikasi prompt
Selesai cli untuk pengambilan cepat
Mungkin CLI untuk dataset yang cepat
TODO Tambahan Prompt Pengguna/Lokal
Selesai tambahkan lebih banyak petunjuk
Selesai contoh bard google
Dibatalkan contoh chatgpt opsyded
Prompt Profsynaps
Google or-tools prompt
Dokumentasi TODO
Selesai penggunaan buku obrolan
Penggunaan khas
Selesai meminta permintaan (tertelan)
Selesai DSL Prompt
Dilakukan Lelucon Harian Melalui Cli
Format Prompt Todo
TODO pada pembajakan petunjuk
Diagram Todo
[AA1] Anton Antonov, "Alur kerja dengan fungsi LLM", (2023), rakuforprediction di WordPress.
[SW1] Stephen Wolfram, "Dunia Baru Fungsi LLM: Mengintegrasikan Teknologi LLM ke dalam Bahasa Wolfram", (2023), Tulisan Stephen Wolfram.
[SW2] STEPHEN WOLFRAM, "Dituntut untuk Bekerja & Bermain: Meluncurkan Wolfram Prompt Repository", (2023), Stephen Wolfram Writings.
[AAP1] Anton Antonov, LLM :: Meminta paket Raku, (2023), GitHub/Antononcube.
[AAP2] Anton Antonov, LLM :: Fungsi paket Raku, (2023), GitHub/Antononcube.
[AAP3] Anton Antonov, Jupyter :: Chatbook Raku Paket, (2023), GitHub/Antononcube.
[WRIR1] Wolfram Research, Inc., Wolfram Prompt Repository