Home /Modules/artificial-intelligence/README.md

README.md

artificial-intelligence/large-language-models/basis/README.md · 59 line(s) · markdown

LLM Basis: Exemplar AI Cases

Ten terminal-started examples of LLM-driven application behavior, each implemented in C11 and C++17. Every source file has its own main(); startup arguments select a model, generation settings, and task input.

Cases

CaseC11C++17
Conversational assistant01-chat.c01-chat.cpp
Document summarization02-summarize.c02-summarize.cpp
Question answering03-question-answer.c03-question-answer.cpp
Text classification04-classify.c04-classify.cpp
Structured information extraction05-structured-extraction.c05-structured-extraction.cpp
Translation06-translate.c06-translate.cpp
Code review assistant07-code-review.c07-code-review.cpp
Context-grounded response08-context-grounded.c08-context-grounded.cpp
Sentiment and tone analysis09-sentiment.c09-sentiment.cpp
Step-by-step tutor10-tutor.c10-tutor.cpp

Runtime contract

A provider adapter must implement that function and return a valid sllm_backend connected to an actual local or hosted model runtime. The adapter descriptor, callbacks, and user data must remain alive for the engine's lifetime. No provider SDK, API key, network client, model weights, or fabricated model response is included. Generation requires a real adapter.

Build integration

Compile the parent C implementation as C11 and its C++ facade as C++17, then link the selected provider adapter and its documented dependencies. Example link shape, assuming the build has produced these illustrative library names:

cc -std=c11 -I.. -I. 01-chat.c -L.. -lsleela_llm -lsleela_llm_provider -o 01-chat
c++ -std=c++17 -I.. -I. 01-chat.cpp -L.. -lsleela_llm_cpp -lsleela_llm -lsleela_llm_provider -o 01-chat-cpp

Use the actual library names and paths from the selected SLeeLa build and provider adapter. The provider adapter is a required link dependency.

Terminal usage

All cases use this argument shape:

./01-chat --model local-assistant --max-tokens 300 --temperature 0.4 -- "Explain recursion with a small example."

Pass the task input after --; quote option values containing spaces. Shared options are --model, --system, --context, --max-tokens, --temperature, --top-p, and --seed. --help prints usage. The parser bounds input and context buffers and rejects unknown switches or invalid numeric values.

Use --context "..." for reference material in grounded tasks. Context is explicitly labelled as untrusted in the prompt; production applications still need independent data validation and prompt-injection controls.

Notes