README-work

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]. The package "LLM::Resources", [AAp4], has LLM-graphs for code generation that utilize the DSL examples of this package.

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()

Tabulate all translation languages and available workflow examples:

use Data::Translators;
dsl-examples(from => 'English').map({ $_.key X $_.value.keys }).flat(1).map({ <language workflow> Z=> $_ })Β».Hash.sort.Array
==> to-dataset()
==> to-html(field-names => <language workflow>)

Note in dsl-examples the language to translate from is specified. Currently, the package has DSL examples for Bulgarian, English, Portuguese, and Russian (being from-languages.)

Get the examples for Latent Semantic Analysis (LSA) Monadic pipeline segments in Python:

dsl-examples('Python', 'LSAMon')
    ==> deduce-type(:tally)

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>);

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")

Same workflow specified in Bulgarian:

my &llm-pipeline-segment-bg = llm-example-function(dsl-examples(from => 'Bulgarian')<WL><LSAMon>);

my @commands = 
"ΠΈΠ·ΠΏΠΎΠ»Π·Π°Π²Π°ΠΉ Π΄Π°Π½Π½ΠΈΡ‚Π΅ aAbstracts",
"Π½Π°ΠΏΡ€Π°Π²ΠΈ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚-Ρ‚Π΅Ρ€ΠΌ ΠΌΠ°Ρ‚Ρ€ΠΈΡ†Π°Ρ‚Π° Π±Π΅Π· Π΄Π° използаваш ΡΡ‚ΡŠΠ±Π»Π°Ρ‚Π° Π½Π° Π΄ΡƒΠΌΠΈΡ‚Π΅",
"Π½Π°ΠΌΠ΅Ρ€ΠΈ 40 Ρ‚Π΅ΠΌΠΈ ΠΏΠΎΠ»Π·Π²Π°ΠΉΠΊΠΈ ΠΌΠ΅Ρ‚ΠΎΠ΄Π°Ρ‚Π° Π½Π΅-ΠΎΡ‚Ρ€ΠΈΡ†Π°Ρ‚Π΅Π»Π½Π° ΠΌΠ°Ρ‚Ρ€ΠΈΡ‡Π½Π° факторизация",
"ΠΏΠΎΠΊΠ°ΠΆΠΈ Ρ‚Π΅ΠΌΠΈΡ‚Π΅";

@commands
.map({ .&llm-pipeline-segment-bg })
.map({ .subst(/:i Output ':'?/):g })
.join("⟹\n")

CLI

The package provides the Command Line Interface (CLI) script dsl-examples. Here is its usage message:

dsl-examples --help

Implementation details

There are several ways to organize the DSL examples with respect to the from-languages:

TypeCommentCurrently used
Have a separate file for each from-langaugeConvenient editing and refinementYes
One file of all examples; from-langauge is a key for each workflowCan be produces with the separate filesNo
Keep English-only DSL examples and use dictionaries of command translations to EnglishDoes not train the LLM directly with the from-languageDictionaries are kept for reference

See the Jupyter notebook "DSL-examples-dev.ipynb" with a translation workflow of the English DSL examples to other languages.

References

Packages

[AAp1] Anton Antonov, DSL::Translators, Raku package, (2020-2024), GitHub/antononcube.

[AAp2] Anton Antonov, LLM::Functions, Raku package, (2023-2026), GitHub/antononcube.

[AAp3] Anton Antonov, LLM::Prompts, Raku package, (2023-2026), GitHub/antononcube.

[AAp4] Anton Antonov, LLM::Resources, Raku package, (2026), GitHub/antononcube.

Videos

[AAv1] Anton Antonov, "Robust LLM pipelines (Mathematica, Python, Raku)", (2024), YouTube/AAA4prediction.

DSL::Examples v0.0.7

Raku data package with examples of DSL commands translations to programming code. (Suitable for LLM training.)

Authors

  • Anton Antonov

License

Artistic-2.0

Dependencies

JSON::Fast:ver<0.19+>

Test Dependencies

Provides

  • DSL::Examples

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.