هذا المستودع مخصص لحزمة RAKU (البيانات) التي تسهل إنشاء وتخزين واسترجاع وترتيب نماذج اللغة الكبيرة (LLM).
فيما يلي مثال على استخدام لغة محددة المجال الموجه (DSL) في جوبايتر درد كوك ، [AA2 ، AAP2]:
من Zef 'Ecosystem:
zef install LLM::Prompts
من جيثب:
zef install https://github.com/antononcube/Raku-LLM-Prompts.git
قم بتحميل الحزم "LLM :: Proves" و [AAP1] و "LLM :: Functions" ، [AAP2]:
استخدم LLM :: Prodes ؛ استخدم LLM :: Functions ؛
# (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
فيما يلي مثال على استرجاع البيانات المطالبة باستخدام regex يتم تطبيقه على أسماء المطالبة:
.
# 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
وترد المزيد من أمثلة استرجاع المطالبة في القسم "البيانات المطالبة" أدناه.
قم بعمل وظيفة LLM من المطالبة المسماة "ftfy":
my & f = llm-function (llm-prompt ('ftfy')) ؛
# -> **@args, *%args { #`(Block|5411904228544) ... }
استخدم وظيفة LLM لتصحيح قواعد الجملة:
& F ("أين يعمل الآن؟")
# Where does he work now?
قم بإنشاء رمز Raku باستخدام مطالبة "Codewriter":
llm-synthesize ([llm-prompt ('codewriter') ، "محاكاة المشي العشوائي."])
RandomWalk [n_]: = تراكم [RandomChoice [{-1 ، 1} ، n]] ListlinePlot [RandomWalk [1000]]
يمكن أن يتم توسيع موجه باستخدام مطالبة Chatbook SPEC DSL الموصوفة في [SW1] باستخدام الدالة 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: All ؛ 'ما هو محرك الاحتراق الداخلي؟ #eli5 '==> llm-prompt-expand () ==> llm-synthesize () ==> wrap-peragraph () ==> 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!
فيما يلي مثال آخر باستخدام شخصية ومعدلان:
my $ prmt = llm-prompt-expand ("@southernbellespeak ما هي مسافة السفر الخفيفة إلى المريخ؟
# 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-peragraph () ==> 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
يمكن تحديد الوظائف لتطبيقها على الرسائل "السابقة" مع "!" ووضع موجه فقط مع أحد المؤشرات "^" أو "^^". السابق يعني "الرسالة الأخيرة" ، وهذا الأخير يعني "جميع الرسائل".
يمكن توفير الرسائل مع وسيطة الخيار :@messages
of llm-prompt-expand
.
على سبيل المثال:
!ShortLineIt^
فيما يلي جدول لمواصفات التوسع المذهل (أكثر أو أقل مثل تلك الموجودة في [SW1]):
المواصفات | تفسير |
---|---|
@ اسم | الدردشة المباشرة إلى شخصية |
# اسم | استخدام مطالبات المعدل |
! اسم | استخدم موجه الدالة مع إدخال الخلية الحالية |
! الاسم > | «نفس كما أعلاه» |
& name > | «نفس كما أعلاه» |
! الاسم ^ | استخدم موجه الوظيفة مع رسالة الدردشة السابقة |
! الاسم ^ ^ | استخدم موجه الوظيفة مع جميع رسائل الدردشة السابقة |
! الاسم │ بارام ... | قم بتضمين معلمات للمطالبات |
الملاحظة: يمكن أن يكون للمطالبات الدالة كل من sigils "!" و "&".
ملاحظة: التوسع السريع يجعل استخدام LLM-Chatbooks أسهل بكثير. انظر "Jupyter :: Chatbook" ، [AAP3].
فيما يلي كيف يمكن الحصول على بيانات موجهة:
llm-prompt-data.elems
# 222
فيما يلي مثال على استرجاع البيانات المطالبة باستخدام regex يتم تطبيقه على أسماء المطالبة:
.
# 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 ؛ استخدم البيانات :: تلخيص ؛ llm-prompt-dataset.pick (6) ==> to-pretty table (align => 'l' ، field-names => <name description value>)
# +-------------------+-----------------------------------------------------------------------------------------------------------------------------+----------+------------------+ # | 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 | # +-------------------+-----------------------------------------------------------------------------------------------------------------------------+----------+------------------+
فيما يلي تفاصيل فئات المطالبات:
حدد العمود (LLM-Prompt-dataset ، <valuive value>). grep ({$ _ <nariable> eq 'catevories'}) ==> السجلات
#ERROR: Do not know how to summarize the argument. # +-------------------+-------+ # | Variable | Value | # +-------------------+-------+ # | Categories => 225 | | # +-------------------+-------+
هنا يتم الحصول عليها جميع مطالبات المعدل بتنسيق مضغوط:
llm-prompt-dataset (): المعدلات: compact ==> to-pretty table (field-names => <name description catevories> ، 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 Form (WPR) ، [SW2]. جميع المطالبات من WPR في الحزمة لها المساهمين المقابلين وعناوين URL في صفحات WPR المقابلة.
مثال على مثال من Google/Bard/Palm و Openai/ChatGPT يتم إضافة باستخدام تنسيق WPR.
من الضروري أن يكون لديك القدرة على إضافة مطالبات جديدة برمجيًا. (لم يتم تنفيذه بعد - انظر قسم TODO أدناه.)
في البداية تم تنفيذ قواعد النحو DSL والإجراءات التوسع المقابلة. من المحتمل ألا يكون هناك حاجة إلى وجود قواعد نحوية ، ومن الأفضل استخدام "التوسع الفوري" (عبر بدائل قائمة على Regex.)
يمكن "توسيع" المطالبات باستخدام Sub llm-prompt-expand
.
فيما يلي مخطط انسيابي يلخص التحليل السريع والتوسيع في خلايا الدردشة من كتب الدردشة Jupyter ، [AAP3]:
مخطط انسيابي LR
Openai {{openai}}
النخيل {{palm}}
llmfunc [[llm :: functions]]]
llmprom [[LLM :: Prodes]]
CODB [(كائنات الدردشة)]
PDB [(مطالبات)]
Ccell [/خلية الدردشة/]
CRCELL [/نتائج الدردشة الخلية/]
cidq {chat id <br> محدد؟}
Cideq {chat id <br> موجود في db؟}
RECO [استرداد كائن الدردشة الموجود <br>]
coeval [رسالة <br> التقييم]
PROMPARSE [موجه <br> dsl spec parsing]
KPFQ {معروفة <br> مطالبات <br> وجدت؟}
promexp [موجه <br> التوسع]
CNCO [إنشاء كائن دردشة جديد <br>]
cidnone ["افترض معرف الدردشة <br> هو" لا شيء ""]
كتاب دردشة فرعي
ccell
crcell
نهاية
دفتر الدردشة الفرعية الخلفية
CIDQ
سيداك
cidnone
ريكو
CNCO
CODB
نهاية
المعالجة السريعة الفرعية
PDB
llmprom
promparse
KPFQ
Promexp
نهاية
تفاعل Subgraph LLM
Coeval
LLMFUNC
نخل
Openai
نهاية
Ccell -> Cidq
CIDQ -> | نعم | سيداك
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
cidnone -> cideq
Coeval -.- llmfunc
llmfunc <-.-> openai
llmfunc <-.-> النخيل
تحميلفيما يلي مثال على التوسع السريع في خلية الدردشة العامة LLM وخلية META الدردشة التي توضح محتوى كائن الدردشة المقابل:
توفر الحزمة نصًا واجهة سطر الأوامر (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).
فيما يلي مثال يحمل اسم موجه:
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 TOMATATION قالب موجه ملء.
TODO توجيه القالب ملء.
TODO DSL على أساس
TODO LLM على أساس
تم إجراء استرجاع سريع
القيام به موجه قواعد النحو والأفعال DSL
تم توسيع المواصفات السريعة
انتهى CLI لاسترجاعه السريع
ربما CLI لمجموعة البيانات المطالبة
إضافة مستخدم/مطالبات محلية
تم إضافة المزيد من المطالبات
مثال على مثال بارد من Google
تم إلغاء مثال chatgpt من Openai
Profsynapse موجه
موجه Google أو الأدوات
توثيق تودو
تم استخدام كتاب الدردشة
الاستخدام النموذجي
القيام بالاستعلام (مبتل) مطالبات
تم موجه DSL
تم نكتة يوميًا عبر CLI
تنسيق موجه
تودو على مطالبات الاختطاف
مخططات تودو
[AA1] Anton Antonov ، "سير العمل مع وظائف LLM" ، (2023) ، Rakuforprediction في WordPress.
[SW1] Stephen Wolfram ، "The New World of LLM وظائف: دمج تقنية LLM في لغة Wolfram" ، (2023) ، كتابات Stephen Wolfram.
[SW2] Stephen Wolfram ، "مطالبات للعمل واللعب: إطلاق مستودع موجه Wolfram" ، (2023) ، كتابات Stephen Wolfram.
[AAP1] Anton Antonov ، LLM :: Prods Raku Package ، (2023) ، Github/Antononcube.
[AAP2] Anton Antonov ، LLM :: وظائف Raku Package ، (2023) ، Github/Antononcube.
[AAP3] أنطون أنتونوف ، Jupyter :: Chatbook Raku Package ، (2023) ، Github/Antononcube.
[WRIR1] Wolfram Research ، Inc.