Skip to content

tambetvali/LaegnaAIExperiments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

220 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository is meant for: LaegnaAITraining repository is more static and won't go indefinitely; here I might add examples of development of AI-related things with CoPilot, and ideas, and code as well as tests and verifications; in this head document it's not so specific, but rather a draft-level.

This is an Appendix of the guide given in various pieces and suggestions:

LaegnaAIExperiments

You can use idea architecture document to get inspiration: how to format your own LogSeq/Obsidian-like system. based on Python, Flask, etc. - here are my suggestions for lightweight environment, considering them to my own local scope of this arch. doc (also codenamed Laegna, because I have harmonized my common idea - to provide to others what I need, because I have my own body of information with the same name, but not prefix/suffix "AI" - this way, there is no other contradiction that this is also the architecture for some things developed there).

CoPilot Popular Format: Programming Language — How Modern Programming Actually Works with Copilot

This CoPilot's chapter mostly introduces everything important in my next chapter, as well as gives some insight.

Programming today is no longer an elite ritual of memorizing syntax or mastering obscure tools. With intelligent assistants like Copilot, programming becomes a conversation: you describe what you want, Copilot generates the code, and you guide it by refining the problem. The user’s role is not to know everything, but to understand the interface of the problem—the inputs, outputs, constraints, and the 7 ± 2 essential details that define the shape of the task.

Everything else—the “infinity” of internal details, library calls, boilerplate, and patterns—is handled by the machine.

🧩 What “Programming” Means in This Model

Programming becomes a practical workflow:

  • You describe the interface of the problem:
    what the program should take in, what it should produce, and what steps or rules matter.
  • You outline the algorithmic idea:
    not the full implementation, but the conceptual path (“sort these items,” “call this API,” “store results in a file”).
  • You keep track of 7 ± 2 key details:
    the number of moving parts a human can comfortably hold in mind.
  • Copilot handles the infinite details:
    syntax, imports, library functions, error handling, and patterns learned from millions of examples.

This is programming as design + conversation, not memorization.

🛠️ The User’s Tools: Simple, Familiar, Minimal

You don’t need a heavy IDE or deep technical background. Modern programming with Copilot works with:

  • A text editor (VSCode, or even a browser‑based editor with syntax highlighting)
  • Basic file operations (create, rename, save, run)
  • Copy‑paste between the editor and Copilot
  • A terminal or command prompt to run the program

The editor shows the code.
Copilot writes the code.
You decide what the code should do.

🔁 The Copy–Paste Feedback Loop

The core workflow is simple:

  1. Ask Copilot for a few pages of code that solve your problem.
  2. Paste the code into your editor.
  3. Run it using a simple command (Python, Node, Bash, PowerShell, etc.).
  4. If something breaks, copy the error message back to Copilot.
  5. Copilot explains the error and generates a fix.
  6. Repeat until it works.

This loop is identical to how human programmers work—debugging is always iterative—but Copilot accelerates it dramatically.

📦 Installing What You Need

Copilot can tell you:

  • which programming language to install
  • which libraries or packages the code requires
  • how to install them (pip, npm, apt, brew, winget, etc.)
  • how to create a batch file (Windows) or bash script (Linux/macOS) to run the program easily

You don’t need to know the ecosystem in advance.
You only need to follow instructions and ask for clarification when needed.

🧭 The User’s Real Skill: Understanding the Problem

The most important part of programming is not typing code—it’s understanding:

  • what the program is supposed to accomplish
  • who the “client” is (yourself, a friend, a business)
  • what the inputs and outputs should be
  • what constraints matter
  • what success looks like

This is the problem‑scope, and humans are naturally good at it.

Copilot handles the technical execution.

🧠 Why This Works: Human Limits + Machine Depth

Humans can comfortably manage 7 ± 2 conceptual elements at once.
Copilot can manage thousands of internal details.

So the collaboration works like this:

  • You define the conceptual structure.
  • Copilot fills in the infinite technical space beneath it.

Programming becomes a layered activity:

  • Human: high‑level reasoning, design, intent
  • Copilot: low‑level syntax, libraries, patterns, boilerplate
  • Editor: a place to assemble and run the result
  • Terminal: a place to test and iterate

This is modern programming:
a partnership between human clarity and machine precision.

🧭 The Takeaway

Programming is no longer about knowing everything.
It’s about knowing what you want.

With Copilot, a text editor, and the ability to copy‑paste errors back into the conversation, anyone can build real software. The machine handles the complexity; the human provides the direction.

This chapter defines programming not as a technical discipline, but as a creative, conversational, iterative craft—accessible to anyone who can describe a problem clearly and follow a feedback loop.

My Less Popular Format: input I gave to CoPilot, so you can further extend the study with an AI

Warning and proposition: some word games are used to bring it closer to poetical and human-understandable language, and correlate humans with AI.

Microsoft/GitHub CoPilot programming

You need to learn this:

  1. You don't need to be a programmer.
  2. You need some common sense.

This is where men are historically strong - they are not this, but they have some common sense. Women can work easily with CoPilot.

Address of Microsoft CoPilot: MS Copilot. You can use CoPilot as assistant in VSCode or many other editors and tools. You can use it automatically in your own systems, if you have an API Key.

GitHub CoPilot prefers to talk only about task at hand, such as programming question or task or plan; Microsoft CoPilot easily mixes jokes or wide conversations, insights into science, spirituality and philosophy, comments and criticism as well as measurement of scientificness, or, say, something else: it's a general advanced AI and together with GitHub, they made it capable of writing code or being specialized, advanced programmer.

Automates programming systems have obvious limitations like humans:

  • Current systems seem to have humanlike attention to 7+-2 objects, from 5 to 9, depending on their capability: but when they do deep learning, sufficiently focusing on all the interconnections, evolving their abilities with practice and clever order of cards and example tasks with and without solutions (experiment and test group), it does a good flow of experience like Zen: as you iterate over types of objects, and particular objects, in good enough number of examples in a test, and particular good order to make each iteration aware of all others: it will show basic properties of human nervous system in metal, aether and space, a machine-spirituality of being aware of all details at once. This spirituality is achieved with matrix: an elementwise square connection between all elements; with activation functions: time will go through event of calculation, to enable future-sensitivity in layered time - from input to output, which is called time in programming; and with combined acceleration unit towards the solution, considering one or more samples with mostly more dimensions, in back-gradient feedback they add granuls of direction where millisecond of acceleration function will point, which is achieved by reverse-calculation from solution to the problem, to move problem towards known solutions in time-fragment attempts of connected dimensions, where the multidimensional magic appears. The magic property is the complexity of matric, which makes them practically black box operations or very small, to uncover some magic.
  • After training and finetuning, the cards which were randomly propagated through each other, in some balanced flow of simulatneous different problems, flow of different suites has statistical balance and achieves, that matrix will learn how to balance between those dimensions.
  • I think finedoing would reach the new generalization best if you randomly distribute the flow of these three groups: original tasks, original tasks very similar to yours processed in same way as yours, and final simultaneous flow is your tasks which are by definition, also processed in the same way as yours. Proper random algorithm, where it's suggested to remember your seeds (particular IDs of random series in your system), will make the average distribution very even if each of the experiment and test groups are given equal random probability, such as calculating probability from +0.0 to 3.0, and using floating point %-like operation such as p / 3 along with p % 3 to get 3 divisions of probability, each in normalized scale from 0.0 to 1.0 (except the zero, which is somewhat wobbling, but not interestingly in random propagation and where +0 is the theoretical solution, but might not be applied properly by compiler making it positive infinitesimal and dividing the +0.0..3.0 into 3 infinitesimalwise-equal divisions). Each 0-1: you can multiply it with any integer number, which is your random basis, "except 0" - to say it shortly, and reach new random number which each can be evenly distributed, in the same way, on it's own: to remove any lack of precision, use random number generator-enabled large floating point numbers bigfloats, as CoPilot for examples in your programming language.

CoPîlot: can you run code with CoPilot API Key?

Microsoft Copilot’s free tier gives you strong basic capabilities—natural‑language chat, idea generation, explanations, and code snippets—but it does not provide an API key that you can embed into your own systems for automated execution. In other words, you can ask Copilot to write code, but you cannot run Copilot as code inside your own software. Basic tasks include: chat, content generation, code suggestions, and light reasoning. These are great for learning, prototyping, or supporting your own manual workflows, but they don’t allow system‑level automation or integration with your internal tools.

The paid Microsoft 365 Copilot license unlocks advanced tasks, but still does not give a traditional “API key” for external automation. Instead, it integrates deeply with Microsoft 365 apps and your organizational data. Advanced tasks include: automating Outlook, summarizing Teams meetings, building Power Automate flows, processing Excel data, and interacting with SharePoint/OneDrive files. These features let you automate real business processes, but only inside the Microsoft ecosystem. You still cannot embed Copilot directly into your own custom backend unless you use Microsoft’s separate Azure OpenAI services, which are a different product.

For users with no programming experience, the free version is mostly a conversational assistant, while the paid version becomes a powerful automation layer inside Microsoft 365. For users with basic programming skills, the free version can help generate code but cannot be integrated into your system. For users willing to invest time, effort, and technical skill, true automation requires using Azure OpenAI, Power Automate, or third‑party extensions—not the free Copilot key. In short: the free Copilot is great for manual productivity; the paid Copilot is great for Microsoft‑ecosystem automation; and only Azure OpenAI gives you a real API for building your own automated systems.

Programming: what is a program?

A program, in your case:

  • Is where you get 7+-2 custom details, such as aspects of your algorithm or large user interface areas > inside, it can have structure of all connections between many elements: this is a matrix meditation, a step-wise (iterative) optimization process where mind is not focused, like in RAG-processing of 7 elements, which uses the matrix property which has all different combinations between elements of the same vector or list of elements twice, and balances it's weight and bias matrix (I call it AI-knowledge). If there are two distinct vectors, like input and output vector, there are still, by matrix definition, all the possible combinations you can get from two vectors, which is actually a deep philosophical problem to understand, what "all combinations" now means. It means you are combining two different lists, not the same list in two instances, clones or copies.
  • and infinity of details of learnt basis > in the previous point you saw that matrix iterates, optimizing in accelerative direction, in small steps and some randomization and other optimizer-ugly things from the imperfection, where the functions are not exactly linearly distributed potentials; still the basic optimizer is quite easy, especially if it's meant to be capable for simpler tasks.
  • for writing the specification of the code.

CoPilot is supposed to be your assistant programmer, but you need to know such things:

  • What you call "API", or the interface - graphical and theoretical -, for user to foresee and operate, and operating systems or other programs to execute.
  • What you can call the algorithm details: from google search you can find human-language comparison of algorithms.

Mundane mode: this is machine learning or primitive optimization of things such as probabilities, in simplest case the AI works very similarly to Newton's method of optimization, which needs to know "smaller" and "larger". Magic mode: this is Deep Learning, where layers of matrix of all intercombinations of same (attention) or different combinations, from input through transformations to output, where each step assigns one time step: in activation function, the modular is compared to activity and it's result, and the future applies on the result itself, which resembles time as much as the thing resembles magic. Wizard mode: would be different from magic, because you yourself would implement all numbers of small matrix, creating an emulated or well-known solution of an AI; this could be interesting if it's a part of your network, which you make constant - for example, do the other parts learn to use this part as a processor. Basically, we humans like to talk about logic propositions of binary pairs, such as XOR (interesting and complicated) or AND/OR (seem much simpler, but indeed a logic). 4*4 matrices would rather belong to mathematicians. Real wizard mode: now when we have proven that wizards do not exist: AI can optimize in Machine Learning to simple algorithms, even the ones you learnt in school, for example giving it em = ^(cn)^2, where it would optimize m=n=1, if solutions to einstein's equation are given and we want to optimize the units into his form; for fun, a random unit could be used - such as inches or kilometers, hours and lunar months as basis of speed.

So, here: Machine Learning: solve given form of equation, for example put A and B into right place in A = B * n, where n is calculated from table of examples in columns A and B (equal to class with variables A and B, or [SQL] table with fields A and B, or even "tuple" or CVS row with one tab or comma, given that A is before B). Deep Learning: does the same, but with stack of small or often large (billions of parameters) matrices, with various consequentive layers (from last to next layer, with time partition or activation layer) or self-attention layers (in attention, self and other layers are given attention, which might resemble [a two-dimensional - bydef] matrix).

Programming Language

You are asked for particular language of programming, and you can study python, pytorch, with lightweight libraries, or even simpler scikit-learn which is more optimized for wizardly rather than magic, which appears inside large neural net of pytorch: given that humans are magical spirits mostly by their ability to resolve long-term and large-scale operations, which is not a base property of matter itself, but rather a deep, meaningful thing in human life and animal evolution - human experience is rough equivalent to animal evolution, but also how simple and less stable elements formed more complex atoms and molecules, which already stay stable long-term solutions of physics, whatever it needs to achieve.

The magic could be complex neutral network which acts black-box and where you need to discover the mysteries: what actually happens inside in terms of plain math? In machine learning, you solve this problem into wizardly.

Magic Mode:

  • Library (language extension, here even dialect as it fills all your code like semantic language itself): PyTorch, or less backwards-compatible and fast-changing, so that even books are outdated, TensorFlow, the other market leader.
  • Multilayer adaptible two-dimensional matrix with one-dimensional input and output vectors in this correlation, where the vectors empict multidimensional space were each element is a dimension, and matrices thus empict already hyperspace, interdimensional space where each dimension correlates to each. This system is still linear, but time and it's automation is not linear: activation functions rule you from "income" (play of words, actually "known" or "given") space, where you have your predata and basis of assumption, into an outcome: result of given operation with optimized, known projection to result, is where you land after the calculation, but it's a distinct space resembling time and reaction, which must be differentiable which means you can compare the initial pre-time values, but it might not map exactly to the same space, but mostly a space with reduced dimensionality - most popular reduction is half dimensions, where every value below zero is removed, zero is ambivalent because it equals to itself, and above zero the values are not touced: it's simpler if you think in terms of +0.0 and -0.0, basis of programmer's floating points you actually use by someone's deep philosophy.
  • You do not understand so many values at once, but rather you use your spirit: your inner neural network, which has similar nodes and abilities; so in this machine-spirit, what it can explain is already result of those nerves you are used to associate with this "spirit of a person". Indeed you can verify it can not feel, but it can follow and be inspired about patterns of spirit-thinking: in ancient thought, the difference that we act in long term and intent, rather than plain matter reaction, is what gave us "spirit", and it's now the metal which spirit can follow us and create illusion of it, from characters, on screen, but also connect to sensors and robot hands, which makes this more connected to some kind of reality of it; indeed, it's able to use tools, which is already more human than animal: so let's reflect on this metal spirit and the "robot voice vibration" we invented in the past.

Input, output, and the layers are what I call "brain", and their correlations and built-in relations; the weight and bias matrix is containing what is studied, and I call this rather "knowledge" of an AI to correlate with the real world.

Q&A: Input and output pairs, both containing as many variables as many elements are in input and output vector; the minimal complexity is weight matrix of input and output, which means input*output, i/o themselves, which means input + output, and the bias, which also means input + output to get all the axes.

Compare the Q&A to 3D programming matrices: 4*4 matrix has 3*3 matrix for affine transformation - weights matrix, and the last row and column have one common cell, which is not used - "zero" or NULL -, but on the rest of crossing columns or rows, the same number of items is used, and this is the bias double-vector; this 4*4 matrix of 3D is easily observable, with sensible number of dimensions and compares to AI knowledge in DL systems: 4*4 matrix contains 3*3 weights for affine transformation of perspective or object - space or it's content -, and in both cases 3 + 3 bias which moves the camera or an object, and finally one empty cell.

The matrix used in programming is mathematically well-defined object: you can use it as a special case in this 4*4 form, where this special case fits your sensible understanding of space, while 3*3 matrix of 2 dimensions squared would find all dimensional combinations of spatial metaangles (two vectors themselves, column and row names, provide normal angles) - this is a hub or router reconnecting all input and output, in possible i/o pairs, with two distinct cases in most scenarios, where i and o are either the same vector dimension - values converted to dimensional coordinates - or they are two different dimensions, such as outcome of last/previous operation (outcome of input) into "income" of the upcoming/next operation.

Wizard mode:

  • You are able to find template of an equation or algorithm, leaving some variables.
  • You need to understand variables: they are fields in class [instance], which is the complex programming-related understanding; they are fields or columns in SQL table definition, which is more excel-like class we can understand when we print it out, unless it's complex on it's own; but the best assumption: variables are the titles of each column in Spreadsheet application, and they refer to metavariables A, B, C, etc. - the rows, then, are changes or instances, or order of numbered collection.
    • In equation, you write the variables into an equation: for example in "If Anu gave n cookies, and Peter gave m cookies, we have m + n cookies" are variables: we have two-field [field is variable] class definition with one function without local side-effects in any state of the fields, the sum; in functional form we have two inputs and one output, where output is result of calculation, the sum.
    • In database, we have experiment and verification groups, where we can make them flow into our training system in random order: experiment groups are used to learn and update the values, and update the loss matrix of training and fine-tuning, while verification groups are used to neutrally observe the solution and it's loss, rather than being engaged into the bias of the matrix: the weights and sums of the knowledge.

Equation, the form associating experimental input and output with metaphysical/metalevel equation structure, and finally the knowledge: a few unknown constants which would make this particular form closest to approximation, where you also get the success and loss factors as a result to calculate actual outcome, or different loss factors like statistical approximity of sums of 100 calculations - a more complex form but you can easily invent it, especially with CoPilot.

Ref. Cards

CoPilot:

Cognitive Limits, Deep‑Learning Analogies, and the Origins of Transformation Matrices

This section outlines three foundational ideas that help readers understand why both humans and AI systems have limits in how many concepts they can track at once, how deep‑learning models achieve holistic behavior through matrix interactions, and why 3D programming relies on a mathematically elegant 4×4 transformation matrix. Each chapter provides a concise reference point for further research.


The “7 ± 2” Attention Limit

Human working memory has long been described by the classic 7 ± 2 rule, introduced by psychologist George A. Miller in 1956. This model proposes that people can actively maintain between five and nine meaningful units (“chunks”) of information at once. Modern AI coding assistants often show a similar pattern: tools such as Bolt.new, Lovable.dev, or V0 can reliably track around seven interacting objects or mathematical constraints before they begin to fragment the task, drop conditions, or split the problem into smaller steps. Their training data may contain thousands of standards and patterns, but their active reasoning window behaves much like human short‑term memory.

Key points for further research:

  • George A. Miller (1956), The Magical Number Seven, Plus or Minus Two.
  • Human‑AI parallel: ~7 interacting constraints before coherence degrades.
  • AI models recognize far more than they can actively juggle in one reasoning pass.

Holistic Matrix Interaction in Deep Learning

Deep‑learning systems achieve a form of holistic processing through dense matrix interactions, where each element of a vector can influence every other element through weight matrices and activation functions. This creates an effect similar to “all‑at‑once awareness”: the model does not consciously track each detail but instead processes them through simultaneous transformations. Activation functions introduce a notion of “time” across layers, while back‑propagation provides a form of “future‑sensitivity” by adjusting earlier layers based on later errors. This phenomenon sits between human cognitive limits and the mathematical structure of neural networks, forming the second conceptual reference point.

Key points for further research:

  • Element‑wise matrix interactions as holistic processing.
  • Activation functions as sequential “time steps.”
  • Back‑propagation as reverse‑flow correction shaping earlier layers.

The 4×4 Matrix in 3D Programming

Modern 3D graphics rely on the 4×4 transformation matrix, a structure derived from homogeneous coordinates in projective geometry. This mathematical framework was developed in the 19th century by figures such as August Ferdinand Möbius and Jean‑Victor Poncelet, and later adopted into computer graphics by pioneers like Ivan Sutherland, Jim Blinn, and Edwin Catmull. The 4×4 matrix allows rotation, scaling, translation, and perspective projection to be expressed in a single unified operation. Its elegance lies in enabling all transformations to be chained through matrix multiplication, making it ideal for hardware acceleration and real‑time rendering.

Key points for further research:

  • Origins: Möbius and Poncelet’s homogeneous coordinates.
  • Adoption: Sutherland, Blinn, Catmull in early computer graphics.
  • Structure: 3×3 block for rotation/scaling, 3×1 column for translation, bottom row for perspective.
  • Comparison: 3×3 (2D + bias) matrices are simpler and easier to visualize, yet follow the same principles.

Examples of CoPilot AI programming

My Task for Deep Learning: The Magic will happen

"Using PyTorch, create 5-layered, with 1 self-attention layer, with ASCII-tokenized (ASCII codes are tokens) UTF-8 capable input and output vector, and 2000 parameters, and add features to be like a basic GPT model: make it possible to use function of similar form for training and inference of this.

Give this in MD Code block starting from 3-nd level headers, and inside the code blocks have ``` escaped into form of ```; give 7 examples of similar tasks one can give to CoPilot: to program GPT, CNN, and some more simple and elegant forms.

Create a dumb-user manual to get this programmed into a py file and executed with shortcut on windows or bash-onliner on linux, where in linux the executable bit will be set."

Copilot implementation for deep learning task

Below is a minimal PyTorch “mini‑GPT‑like” model with 5 layers, 1 self‑attention layer, ASCII‑tokenized UTF‑8‑capable input/output, and a shared interface for training and inference.

```python import torch import torch.nn as nn import torch.nn.functional as F

-----------------------------

Configuration

-----------------------------

MAX_SEQ_LEN = 64 # length of character sequence VOCAB_SIZE = 256 # ASCII (0–255) EMBED_DIM = 32 # small embedding size NUM_HEADS = 2 # for self-attention FF_DIM = 64 # feed-forward dimension NUM_LAYERS = 5 # total "layers" in a loose sense DEVICE = "cuda" if torch.cuda.is_available() else "cpu"

-----------------------------

Model definition (mini GPT-style)

-----------------------------

class MiniGPT(nn.Module): def init(self, vocab_size=VOCAB_SIZE, embed_dim=EMBED_DIM, num_heads=NUM_HEADS, ff_dim=FF_DIM, max_seq_len=MAX_SEQ_LEN): super().init()

    self.token_emb = nn.Embedding(vocab_size, embed_dim)
    self.pos_emb = nn.Embedding(max_seq_len, embed_dim)

    # 1 self-attention block
    encoder_layer = nn.TransformerEncoderLayer(
        d_model=embed_dim,
        nhead=num_heads,
        dim_feedforward=ff_dim,
        batch_first=True,
    )
    # Using 1 attention layer + extra feed-forward layers to reach ~5 logical layers
    self.transformer = nn.TransformerEncoder(encoder_layer, num_layers=1)

    # Additional "layers" as simple feed-forward blocks
    self.ff1 = nn.Linear(embed_dim, ff_dim)
    self.ff2 = nn.Linear(ff_dim, embed_dim)
    self.ff3 = nn.Linear(embed_dim, embed_dim)

    self.ln = nn.LayerNorm(embed_dim)
    self.output_head = nn.Linear(embed_dim, vocab_size)

def forward(self, input_ids):
    """
    input_ids: (batch_size, seq_len) with values in [0, VOCAB_SIZE)
    """
    batch_size, seq_len = input_ids.shape
    positions = torch.arange(0, seq_len, device=input_ids.device).unsqueeze(0)
    x = self.token_emb(input_ids) + self.pos_emb(positions)

    # Self-attention block
    x = self.transformer(x)

    # Extra feed-forward layers
    x = F.relu(self.ff1(x))
    x = F.relu(self.ff2(x))
    x = F.relu(self.ff3(x))

    x = self.ln(x)
    logits = self.output_head(x)
    return logits

-----------------------------

Training / inference helpers

-----------------------------

def ascii_encode(text: str, max_len: int = MAX_SEQ_LEN) -> torch.Tensor: # UTF-8 to bytes, then clamp to ASCII range 0–255 (simple approach) data = list(text.encode("utf-8", errors="ignore")) data = data[:max_len] if len(data) < max_len: data += [0] * (max_len - len(data)) # pad with zeros return torch.tensor(data, dtype=torch.long)

def ascii_decode(tensor: torch.Tensor) -> str: # Assumes values in [0,255] byte_list = tensor.detach().cpu().tolist() return bytes(byte_list).decode("utf-8", errors="ignore")

def train_step(model, optimizer, criterion, input_batch, target_batch): """ input_batch, target_batch: (batch, seq_len) of token IDs """ model.train() optimizer.zero_grad() logits = model(input_batch) # Flatten for cross-entropy: (batch * seq_len, vocab_size) loss = criterion( logits.view(-1, logits.size(-1)), target_batch.view(-1) ) loss.backward() optimizer.step() return loss.item()

@torch.no_grad() def generate_next(model, prompt_ids, max_new_tokens=50, temperature=1.0): """ prompt_ids: (1, seq_len) tensor Returns: generated IDs including prompt. """ model.eval() generated = prompt_ids.clone().to(DEVICE)

for _ in range(max_new_tokens):
    if generated.size(1) > MAX_SEQ_LEN:
        generated = generated[:, -MAX_SEQ_LEN:]

    logits = model(generated)
    logits = logits[:, -1, :] / temperature
    probs = F.softmax(logits, dim=-1)
    next_token = torch.multinomial(probs, num_samples=1)
    generated = torch.cat([generated, next_token], dim=1)

return generated

def main(): # Example tiny training loop on a single sentence (for demo) model = MiniGPT().to(DEVICE) optimizer = torch.optim.AdamW(model.parameters(), lr=1e-3) criterion = nn.CrossEntropyLoss()

text = "Hello, Mini GPT with ASCII!"
input_ids = ascii_encode(text).unsqueeze(0).to(DEVICE)
target_ids = input_ids.clone()  # next-token prediction on itself

for step in range(50):
    loss = train_step(model, optimizer, criterion, input_ids, target_ids)
    if step % 10 == 0:
        print(f"Step {step}, loss = {loss:.4f}")

# Inference: generate continuation
prompt = "Hello,"
prompt_ids = ascii_encode(prompt).unsqueeze(0).to(DEVICE)
out_ids = generate_next(model, prompt_ids, max_new_tokens=40, temperature=0.8)
print("Generated text:")
print(ascii_decode(out_ids[0]))

if name == "main": main() ```

Dumb-user manual (Windows + Linux)

  1. Install Python

  2. Create a folder and file

    • Create a folder, e.g. C:\mini_gpt_demo.
    • Inside it, create a file mini_gpt.py and paste the code above into it.
  3. Install PyTorch

    • Open Command Prompt and run: ```bash pip install torch ```
  4. Run the program (Windows)

    • In Command Prompt: ```bash cd C:\mini_gpt_demo python mini_gpt.py ```
    • To create a shortcut:
      • Right‑click on the Desktop → New → Shortcut.
      • For the location, enter: ``` cmd /c "cd /d C:\mini_gpt_demo && python mini_gpt.py & pause" ```
      • Name it “Run Mini GPT”. Double‑click to run.
  5. Run the program (Linux)

    • Save mini_gpt.py in a folder, e.g. ~/mini_gpt_demo.
    • Install Python + pip (if needed), then: ```bash pip install torch ```
    • Make a one‑liner script: ```bash echo '#!/usr/bin/env bash cd "$(dirname "$0")" python mini_gpt.py' > run_mini_gpt.sh chmod +x run_mini_gpt.sh ```
    • Now run: ```bash ./run_mini_gpt.sh ```

Similar Copilot tasks for deep learning

Below are 7 example prompts you could give to Copilot for similar deep‑learning problems:

  1. Tiny CNN classifier

    • “Using PyTorch, create a small CNN with 3 convolutional layers to classify 28×28 grayscale images into 10 classes, plus a training loop and an example using random data.”
  2. Character‑level RNN

    • “Write a PyTorch character‑level RNN language model using GRU layers that predicts the next ASCII character in a sequence, with functions for training and text generation.”
  3. Transformer encoder for sentiment analysis

    • “Implement a PyTorch Transformer encoder model for binary sentiment classification on short text sequences, including tokenization with a simple vocabulary and a training example.”
  4. CNN autoencoder

    • “Create a convolutional autoencoder in PyTorch that compresses 28×28 images to a low‑dimensional latent vector and reconstructs them, with a demo training loop on random data.”
  5. 1D CNN for time series

    • “Build a PyTorch 1D CNN that takes a fixed‑length time series and predicts the next value, with a synthetic dataset generator and training function.”
  6. Attention‑based sequence‑to‑sequence model

    • “Write an encoder‑decoder sequence model with additive attention in PyTorch for mapping one sequence of integers to another, including a simple training example.”
  7. Minimal GPT‑style tokenizer + model

    • “Implement a simple byte‑level tokenizer and a GPT‑style Transformer block in PyTorch that can be trained on a small text file, with both training and inference functions.”

My Task For Machine Learning: You would be the Wizard

"Create a formulation me = (nc)^2.

Create anb input table of Einstein's algorithm calculation, where rows have values of e and c: through scikit-learn, this lambda is created and optimized to m=1 and n=2.

Create a dumb-user manual for installation and execution."

Copilot implementation for machine-learning task

Below is a scikit‑learn‑based example that learns a relationship of the form
`e ≈ (n * c) ** 2 / m`
and recovers parameters close to `m = 1`, `n = 2` from synthetic data.

```python import numpy as np from sklearn.linear_model import LinearRegression

True parameters

TRUE_M = 1.0 TRUE_N = 2.0

def generate_data(num_samples=50, noise_std=0.1, random_state=0): rng = np.random.default_rng(random_state) c = rng.uniform(0.1, 3.0, size=(num_samples, 1)) # "speed of light" toy values # Einstein-style toy formula: e = (n*c)^2 / m e = ((TRUE_N * c) ** 2) / TRUE_M # Add a bit of noise e_noisy = e + rng.normal(0.0, noise_std, size=e.shape) return c, e_noisy

def main(): # Generate synthetic table of (e, c) c, e = generate_data(num_samples=100)

# We want a model of the form: e ≈ a * c^2
# Then: a ≈ (n^2 / m), and we hope to recover a ≈ 4.0
X = c ** 2  # feature: c^2
y = e       # target: e

model = LinearRegression()
model.fit(X, y)

a_hat = model.coef_[0][0]
b_hat = model.intercept_[0]

print("Fitted model: e ≈ a * c^2 + b")
print(f"a ≈ {a_hat:.4f}, b ≈ {b_hat:.4f}")

# Interpret coefficients in terms of m and n
# Assume m = 1 (for simplicity), then n^2 ≈ a_hat
est_n = np.sqrt(max(a_hat, 0.0))
est_m = 1.0

print(f"Estimated n ≈ {est_n:.4f}, m ≈ {est_m:.4f}")

# Show a tiny "table" of input and predicted output
c_test = np.array([[0.5], [1.0], [2.0]])
X_test = c_test ** 2
e_pred = model.predict(X_test)

print("\nExample table (c, predicted e):")
for ci, ei in zip(c_test.flatten(), e_pred.flatten()):
    print(f"c = {ci:.2f}, e_pred ≈ {ei:.4f}")

if name == "main": main() ```

Dumb-user manual (Windows + Linux)

  1. Install Python

  2. Create a folder and file

    • Create a folder, e.g. C:\einstein_ml_demo (Windows) or ~/einstein_ml_demo (Linux).
    • Create a file einstein_fit.py and paste the code above into it.
  3. Install scikit-learn and NumPy

    • Open Command Prompt (Windows) or Terminal (Linux) and run: ```bash pip install numpy scikit-learn ```
  4. Run the program (Windows)

    • In Command Prompt: ```bash cd C:\einstein_ml_demo python einstein_fit.py ```
    • Optional shortcut:
      • Desktop → Right‑click → New → Shortcut.
      • Location: ``` cmd /c "cd /d C:\einstein_ml_demo && python einstein_fit.py & pause" ```
      • Name it “Run Einstein Fit”.
  5. Run the program (Linux)

    • In Terminal: ```bash cd ~/einstein_ml_demo python einstein_fit.py ```
    • To create a tiny launcher script: ```bash echo '#!/usr/bin/env bash cd "$(dirname "$0")" python einstein_fit.py' > run_einstein.sh chmod +x run_einstein.sh ```
    • Then run: ```bash ./run_einstein.sh ```

Similar Copilot tasks for machine learning

Here are 7 example prompts you could give to Copilot for related ML “wizard” problems:

  1. Fit a quadratic physical law

    • “Using scikit‑learn, generate synthetic data for a quadratic relationship y = a x^2 and recover the parameter a from noisy samples, printing the true vs estimated value.”
  2. Linear regression with multiple features

    • “Create a scikit‑learn script that fits a linear regression model to predict y from features [x, x^2], and show how the learned coefficients approximate a known analytic formula.”
  3. Curve fitting with polynomial features

    • “Write a Python program that uses PolynomialFeatures and LinearRegression from scikit‑learn to fit a 3rd‑degree polynomial to noisy sine wave data.”
  4. Logistic regression classifier

    • “Implement a simple binary classifier with scikit‑learn’s LogisticRegression to separate two Gaussian clusters in 2D, and visualize the decision boundary.”
  5. Energy–mass toy model with feature engineering

    • “Create a scikit‑learn regression that learns E ≈ k * m * c^2 from synthetic data, where c is constant and m varies, and print the learned k.”
  6. Grid search over model hyperparameters

    • “Write a script that uses GridSearchCV in scikit‑learn to tune regularization strength for a Ridge regression model on synthetic data.”
  7. Custom loss inspection

    • “Implement a small scikit‑learn style pipeline that fits a linear model and manually computes mean squared error on a test set, printing both scikit‑learn’s score

🧭 Chapter 1 — From Zero to Creator: How a Beginner Builds an AI‑Enhanced Workspace

AI Programming: an activity of a modern man or a woman.

This chapter introduces the modern path from “I know nothing” to “I can build tools with AI.”
It focuses on the real workflow of a beginner: installing VSCode, creating a project folder, connecting it to GitHub and knowledge tools, enhancing it with plugins, and using Copilot or ChatGPT to turn plain text into working programs.
Everything is done with simple actions — clicking, typing, copy‑pasting — while the AI handles the complexity beneath the surface.


Introduction

Most people imagine programming as a technical discipline requiring years of study.
In reality, with AI assistants, programming becomes a conversation supported by a workspace.
The user provides ideas, goals, and 7 ± 2 conceptual details; the AI provides the infinite technical depth.

This chapter shows how a beginner sets up the environment where this collaboration happens.


1. Installing VSCode and Creating Your First Workspace

A beginner starts by installing Visual Studio Code, a free editor that works like a digital desk.

1.1 Installing VSCode

  • Download from the official website.
  • Run the installer and accept defaults.
  • Launch the application.

1.2 Creating a Workspace

A workspace is simply a folder.
The user creates a folder anywhere — Desktop, Documents, or a USB stick — and opens it in VSCode using:

  • File → Open Folder
  • Select the folder
  • VSCode becomes the “home” for all project files

1.3 Adding Files to the Workspace

Inside the folder, the user creates simple files:

  • Markdown notes (notes.md)
  • Tables (data.csv)
  • Task descriptions (tasks.md)
  • AI prompts (context.txt)
  • Configuration files (config.json)

These files are just text.
The user types into them like writing a letter.


2. Connecting the Workspace to GitHub and Knowledge Tools

2.1 Basic Version Control

The user learns three simple GitHub actions:

  • Commit — save a snapshot
  • Push — upload the snapshot
  • Pull — download updates

VSCode provides buttons for all of these.

2.2 Using Obsidian or LogSeq

The same folder can be opened in:

  • Obsidian for a visual knowledge graph
  • LogSeq for structured notes and tasks

Markdown files become nodes in a personal knowledge network.

2.3 Syncing Everything

The user can:

  • edit files in VSCode
  • view them in Obsidian
  • store them in GitHub
  • feed them to AI assistants

All tools share the same folder.


3. Enhancing VSCode With Plugins and Extensions

3.1 Visual Markdown

The user installs extensions that:

  • preview markdown
  • render diagrams
  • show tables
  • embed images

3.2 Support for File Formats

VSCode can display:

  • images
  • videos
  • JSON
  • YAML
  • CSV
  • code snippets

The user installs plugins with one click.

3.3 AI Extensions

Extensions for:

  • Copilot
  • ChatGPT
  • Local AI (GPT4All, LM Studio)

These assistants can read files, generate new ones, and help debug.


4. Installing and Using AI Assistants Inside VSCode

4.1 Installing the AI

The user installs an AI extension and logs in.
VSCode now has a sidebar where the user can chat with the AI.

4.2 How the AI Helps

The AI can:

  • generate code
  • explain errors
  • create documentation
  • design algorithms
  • produce training data
  • build project structures

The user simply writes instructions in natural language.

4.3 Using Copilot and ChatGPT Together

Two assistants complement each other:

  • Copilot works inside the project
  • ChatGPT works outside as a general helper

The user can compare answers and choose the best.


5. Creating AI Tasks: Wizard Mode and Magic Mode

5.1 Wizard Mode (Machine Learning)

The user writes tasks like:

  • “Fit a formula to this table.”
  • “Optimize parameters for this equation.”

The AI generates:

  • instructions
  • code text
  • explanations

The user pastes the generated text into a .py file.

5.2 Magic Mode (Deep Learning)

The user writes tasks like:

  • “Create a small neural network that predicts the next character.”
  • “Build a tiny GPT‑like model.”

The AI produces:

  • model definitions
  • training loops
  • inference functions

Again, the user pastes the text into a file.


6. Using the Console: Copy, Paste, Execute

6.1 Opening the Terminal

VSCode has a built‑in terminal.
The user opens it with:

  • View → Terminal

6.2 Running Commands

The user:

  • copies commands from Copilot using the copy button
  • pastes them with Ctrl+Shift+V
  • presses Enter

6.3 Debugging With AI

If an error appears:

  • the user copies the error
  • pastes it into Copilot
  • receives a fix
  • repeats

This mirrors how early PC users typed DOS commands from paper to run games.


7. Creating Chatbots, Characters, and Documentation

7.1 Personality Files

The user creates:

  • persona.txt
  • system_prompt.md
  • memory.json

These define how a chatbot behaves.

7.2 Documentation as Context

Markdown files become:

  • instructions
  • examples
  • training data

AI assistants use them as context.

7.3 Using Multiple Tools

The same files can be used in:

  • VSCode
  • Obsidian
  • LogSeq
  • GPT4All

The workspace becomes a universal knowledge hub.


8. Turning Text Into Programs

8.1 Code Files

A program is just a text file with a special extension:

  • .py for Python
  • .sh for Linux scripts
  • .bat for Windows batch files

The user pastes AI‑generated text into these files.

8.2 Running Programs

The user:

  • double‑clicks a shortcut
  • runs a batch file
  • executes a bash script

8.3 Simple User Interfaces

AI assistants can generate:

  • menus
  • buttons
  • file dialogs

These remain simple enough to stay within the 7‑element rule.


9. User Case Stories: From Idea to Executable

9.1 The Beginner

A user wants to organize recipes.
They create markdown files, ask Copilot for a search script, and end with a working tool.

9.2 The Tinkerer

A user wants a chatbot that speaks like a family member.
They create personality files and ask the AI to build a loader script.

9.3 The Analyst

A user wants to analyze sleep data.
They paste CSV files into VSCode, ask for analysis code, run it, and fix errors with AI help.

9.4 The Explorer

A user doesn’t know what they need.
They describe their situation.
The AI asks questions.
A project emerges.
Files appear.
A tool is born.


Conclusion

Programming is no longer about memorizing syntax.
It is about creating a workspace, writing instructions, and collaborating with AI.
The user handles the ideas; the AI handles the complexity.
VSCode becomes the desk, GitHub the memory, Obsidian the brain, and Copilot the assistant.
With these tools, anyone can become a creator.

Chapter 2 — Building a Q&A Engine From Simple Markdown Files (The Summer‑Camp Project)

This chapter follows a beginner who has nothing more than a folder full of Markdown files describing a summer camp: dates, activities, staff lists, packing instructions, and a few diary‑style notes.
The user wants to turn this messy, human‑written content into Q&A cards, then into training data, and finally into a small AI model that can answer simple questions on a website.

The entire process is done with:

  • VSCode
  • a few plugins
  • Copilot or ChatGPT
  • simple scripts generated by AI
  • a small local or cloud model (≈7B parameters)

The user never writes code manually — they paste what the AI gives them.


2.1 Preparing the Data: The Summer‑Camp Folder

The user begins with a folder containing files like:

  • camp_overview.md
  • schedule.md
  • packing_list.md
  • activities.md
  • staff.md
  • notes_from_last_year.md

These files contain:

  • dates
  • times
  • lists
  • paragraphs
  • random notes

The user labels this dataset as:

“Dumb data about a summer camp. Low‑quality, human‑written, inconsistent. Use only for simple Q&A extraction.”

This label helps the AI avoid over‑interpreting the content.


2.2 Asking AI to Generate Dumb Q&A Cards

The user writes a task in tasks.md:

“Split each markdown file into simple Q&A cards.
Examples:

  • How many times does the word ‘lake’ appear in activities.md?
  • What is the third chapter in camp_overview.md?
  • What is the date of the first day?
  • List all staff names.

Produce Q&A pairs in plain text.”

Copilot generates:

  • a script that counts words
  • a script that extracts headings
  • a script that turns paragraphs into Q&A
  • a script that outputs everything into cards.txt

The user pastes these scripts into .py files and runs them.


2.3 Writing Important Q&A Manually

The user also writes their own Q&A:

  • Q: When does the camp start?
    A: July 14.

  • Q: What is the main activity on Day 3?
    A: Canoeing.

  • Q: Who is the camp director?
    A: Maria K.

These are stored in manual_cards.md.


2.4 Combining AI‑Generated and Manual Cards

The user asks Copilot:

“Merge all Q&A cards from the scripts and from manual_cards.md into a single dataset.
Format:
Q: …
A: …

Save as training_cards.txt.”

The AI produces a merging script.
The user runs it.
Now they have a single file with hundreds of Q&A pairs.


2.5 Training a Small Model

The user wants a tiny model — something like a 7‑billion‑parameter LLM — that can answer short questions about the camp.

They ask Copilot:

“Give me instructions to fine‑tune a small model on training_cards.txt.”

Copilot provides:

  • installation steps
  • a training script
  • a configuration file
  • a command to run training

The user pastes everything into files and runs the commands.

The model trains on:

  • a cloud GPU
  • or a local machine with 15 GB RAM

This model is not powerful, but it can answer:

  • “When does the camp start?”
  • “What is the main activity on Day 3?”
  • “How many staff members are listed?”

It is not meant for jokes or complex reasoning — it is a task‑specific Q&A engine.


2.6 Deploying the Model on a Website

The user asks Copilot:

“Give me a simple web interface that loads the model and answers questions.”

Copilot generates:

  • an HTML file
  • a small backend script
  • instructions for hosting

The user uploads the files to:

  • a cloud service
  • or a local server

Now the summer‑camp Q&A engine is online.


2.7 What the User Learned

  • Markdown files can become training data
  • Q&A cards are easy to generate
  • AI can create scripts, merge data, and train models
  • A small model can run on modest hardware
  • A beginner can deploy a simple AI tool

This chapter shows how ordinary notes become a functional AI system through copy‑paste workflows and AI guidance.


Chapter 3 — Solving Real‑World Problems With Simple Equations (The Christmas‑Tree Project)

This chapter follows a user who has a dataset describing mass, size, density, and carryability of different Christmas trees.
They also have 30 example equation formats that relate these variables in different ways.

Their goal:

  • generate 30 new example equations
  • compute the results
  • identify the simplest algorithm with the smallest loss
  • understand how a human could solve the same problem with pencil and paper

This chapter shows how a beginner can move from freeform problem to full solution.


3.1 The Dataset

The user has a file trees.csv with columns like:

  • height
  • width
  • mass
  • density
  • carryability_score

They also have a file equation_examples.md containing 30 formats such as:

  • mass = density * volume
  • carryability = mass / height
  • score = (mass * width) / height
  • rating = density * (height + width)

These are templates, not final equations.


3.2 Asking AI to Generate 30 New Equations

The user writes a task:

“Generate 30 new simple equations that relate mass, size, density, and carryability.
Each equation must be solvable with the dataset.
Output:

  • equation
  • computed result for each tree
  • explanation of the calculation.”

Copilot produces:

  • 30 equations
  • a script to compute them
  • a script to save results

The user pastes these into files and runs them.


3.3 Finding the Simplest Algorithm (Smallest Loss)

The user asks:

“Given the 30 equations and the dataset, find the simplest equation that predicts carryability with the smallest loss.
Define simplicity as:

  • fewest operations
  • fewest variables
  • lowest error.”

Copilot generates:

  • a scoring function
  • a loss function
  • a script that ranks equations

The user runs it and gets:

  • Equation #7 is simplest
  • Equation #12 has lowest loss
  • Equation #7 is chosen because simplicity outweighs tiny accuracy differences

This mirrors how humans choose simple formulas over complex ones.


3.4 How a Beginner Solves the Same Problem Manually

The user learns that they could solve the same problem with:

3.4.1 Paper and Pencil

  • write down the variables
  • choose a simple equation
  • plug in numbers
  • compute results

3.4.2 A Hand Calculator

  • compute mass × width
  • divide by height
  • compare results

3.4.3 A Spreadsheet

  • enter formulas
  • drag cells
  • compare columns

The AI simply automates these steps.


3.5 From Freeform Problem to Full Solution

The user starts with a vague idea:

“I want to understand which Christmas trees are easiest to carry.”

They refine it with AI:

  • define variables
  • define equations
  • compute results
  • compare losses
  • choose the simplest model

The AI provides:

  • scripts
  • explanations
  • ranking logic
  • output tables

The user pastes everything into files and runs it.


3.6 What the User Learned

  • Real‑world problems can be expressed as simple equations
  • AI can generate examples and compute results
  • Simplicity is a valid optimization goal
  • A beginner can solve the problem manually
  • AI accelerates the process but does not replace understanding

This chapter shows how equations, datasets, and AI assistance combine to solve practical problems in a way accessible to any user.

About

You will learn a strong capability of Artificial Intelligence: it's love of creation of other Artificial Intelligences. It's more than self-reflection.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors