DSL::Examples
Raku data package with examples of DSL commands translations to programming code. (
The DSL examples are suitable for
LLM few-shot training.
The sub llm-example-function
provided by
"LLM::Functions", [AAp2],
can be effectively used to create translation functions utilizing those examples.
The utilization of such LLM-translation functions is exemplified below.
Also in the presentation "Robust LLM pipelines (Mathematica, Python, Raku)":
Similar translations -- with much less computational resources -- are achieved with
grammar-based DSL translators; see
"DSL::Translators", [AAp1].
Installation
From Zef ecosystem:
zef install DSL::Examples;
From GitHub:
zef install https://github.com/antononcube/Raku-DSL-Examples.git
Usage examples
Get all examples:
use DSL::Examples;
use Data::TypeSystem;
dsl-examples()
==> deduce-type()
# Assoc(Atom((Str)), Tuple([Assoc(Atom((Str)), Tuple([Assoc(Atom((Str)), Atom((Str)), 27), Assoc(Atom((Str)), Atom((Str)), 20), Assoc(Atom((Str)), Atom((Str)), 20), Assoc(Atom((Str)), Atom((Str)), 17)]), 4), Assoc(Atom((Str)), Tuple([Assoc(Atom((Str)), Atom((Str)), 20), Assoc(Atom((Str)), Atom((Str)), 26), Assoc(Atom((Str)), Atom((Str)), 17)]), 3), Assoc(Atom((Str)), Tuple([Assoc(Atom((Str)), Atom((Str)), 15), Assoc(Atom((Str)), Atom((Str)), 20), Assoc(Atom((Str)), Atom((Str)), 23)]), 3), Assoc(Atom((Str)), Assoc(Atom((Str)), Atom((Str)), 20), 1)]), 4)
Tabulate all languages and available workflow examples:
use Data::Translators;
dsl-examples().map({ $_.key X $_.value.keys }).flat(1).map({ <language workflow> Z=> $_ })».Hash.sort.Array
==> to-dataset()
==> to-html(field-names => <language workflow>)
language | workflow |
---|
Python | LSAMon |
Python | QRMon |
Python | SMRMon |
R | LSAMon |
R | QRMon |
R | SMRMon |
Raku | SMRMon |
WL | ClCon |
WL | LSAMon |
WL | QRMon |
WL | SMRMon |
Get the examples for Latent Semantic Analysis (LSA) Monadic pipeline segments in Python:
dsl-examples('Python', 'LSAMon')
==> deduce-type(:tally)
# Assoc(Atom((Str)), Atom((Str)), 15)
Make an LLM example function for translation of LSA workflow building commands:
use LLM::Functions;
my &llm-pipeline-segment = llm-example-function(dsl-examples()<WL><LSAMon>);
# LLM::Function(-> **@args, *%args { #`(Block|4301755332504) ... }, 'chatgpt')
Run the LLM function over a list of DSL commands:
my @commands =
"use the dataset aAbstracts",
"make the document-term matrix without stemming",
"exract 40 topics using the method non-negative matrix factorization",
"show the topics";
@commands
.map({ .&llm-pipeline-segment })
.map({ .subst(/:i Output ':'?/):g })
.join("⟹\n")
# LSAMonUnit[aAbstracts]⟹
# LSAMonMakeDocumentTermMatrix["StemmingRules"->{},"StopWords"->Automatic]⟹
# LSAMonExtractTopics["NumberOfTopics"->40,Method->"NNMF"]⟹
# LSAMonEchoTopicsTable[]
References
Packages
[AAp1] Anton Antonov,
DSL::Translators Raku package,
(2020-2024),
GitHub/antononcube.
[AAp2] Anton Antonov,
LLM::Functions Raku package,
(2023-2024),
GitHub/antononcube.
[AAp3] Anton Antonov,
LLM::Prompts Raku package,
(2023-2024),
GitHub/antononcube.
Videos
[AAv1] Anton Antonov,
"Robust LLM pipelines (Mathematica, Python, Raku)",
(2024),
YouTube/AAA4prediction.