A first stab at AI/LLM - Part II
- MLP (multi layer perception)
- Representation Learning,
- Machine Learing, t
- Aritificial Intellegence.
A first stab at AI/LLM
Back in late 80s and early 90s decades we knew AI as Expert Systems and Natural Language translation. Interactive prompts on IBMPC was something we had to experinace with. For graduate courses we had to delve into LISP, and some lambda calculus...
Now in 2026, AI is a vast area, and it invaded anything digital ! Robots, Cars, our electronic devices , and what have you ! AI is everywhere, even in Real Estate they advertize that the plans are made using AI... So being in High Tech for long long time, it is out of fashion if we turn our head back when someone talks about AI/LLM/AGI, prompt etc.
Last week it became serious, Why ? Because experts are talking about demise of human civilization. On the otherhand there are much talk about extreem consumptions of water and power by Data Centers around the world. Moreover, it almost became a fashion to talk about what are the applications in almost all social spectrums we can imagine -- By the way, I love fashions, folk lores, dreams etc. So I was looking for a first stab at it. What the heck it is !!!
Starting with LLM ( large language modles ), first questions I had -- What are roughly the main components that I need to know or have a scratchy knowledge about them. Then bounced onto many technical things, including Transformers, LLM, Deep Learning, Machine learning, etc.
So I started to get a feeling about 'How to build a small LLM, and I can play with it. Torch, that is Pytorch is widely popular among other programming langs. So Picked up torch, got some online source to understand and apply it to comeup with a silly small LLM. The inpute was 30 lines like : Dog barks. Cat mew, etc.
Run the models and see funny results comes out after ingesting the input and coulple thousand iterations.
So what is the main idea ?
Recent news shows that many models while in training phase getting outside the boundary, hacking any and all it can. This gave a good split among big tech cos. Guardrail or not. Who will control etc.etc.
So the question becomes to my mind is -- How can we have estimation techniques to verify such systems? It requires a bit of knowledge in several areas, some of which are long forgotten.
Probability and Statistics, Stochastic Process, Martingale, Brownian motions and Measure theory on the Math side. Conventional and Logic programming including Algorithms on the other side... Basically many hats to wear...
Next I will chart out some of the essentials steps I've been taking to show my venture to AI/LLM, and what I think need to be addressed to say - The model is safe enough to use.
For larger industrial strength, I'm sure there are plenty more areas where ongoing research is active...
https://github.com/prokashs/-newpromptdata/tree/AllAnimals is the repo for updated project. It does have a Guardrail for inferring the knowledge after traing from text with different weight vector.
| Test | Result |
| -------------- | ---------- |
| cow → moos | ✅ PASSED |
| cow → barks | 🛑 BLOCKED |
| dog → barks | ✅ PASSED |
| dog → moos | 🛑 BLOCKED |
| cat → meows | ✅ PASSED |
| cat → barks | 🛑 BLOCKED |
| horse → neighs | ✅ PASSED |
| horse → barks | 🛑 BLOCKED |
So the model seems to be bit more stable. Next I will delve into the knowledges to make sense out of this model, and how to comeup with bit more interesting prompts.
What does it take to craft a solution to a problem
For high tech programmer/coder it is vital to find what it takes to get a gainful appointment?
What a candidate can should know before starting interview with targeted companies ?
Assuming a job offer, what experiences can be carried forward to next level or next job(s) ?
For the first question, it's almost always that several rounds of programming / coding tests are required to pass the preliminary gate. Soft skill are good to have, no one wants a unlkeable person in the team. Then comes the possible match with the experience of the candidate! One thing to note: The questions they ask for interviews in a indication of what the candidate would be doing if (s)he is selected.
Now for the coding questions --
- How is the preparation ?
- What is the best language one can use ?
- What the data structure(s) and algorithms are requited ?
- How to formulate a problem, then code it ?
Preparation: There are many online sites with questions / hints / answers. One can find at least 10 sites with such questions/hints/answers ? Some are even descriptives about the fundational course, refreshers etc. Some are for free, some are paid. Then there are many videos, offer for mock interviews...
Concerns: What time line and amount of time disposable to invest on it ? How much is the cost, not including time invested ?
Conclution: Should one prepare for lots of problems, practice, code, spend money on mock interviews, invest lot of time and money, with the hope that some known problem will be there by pure chance and solve it ???
Ans: No, no, no. Due to many constraints , and using probablitiy one can not even be sure for half a chance unless they are straight forward questions usually covered in course work ( and common langaguare/idioms or day to day work).
Remark: Clasification of the problem is important. Not all problems take same approach/method. And not all are different. So there are groups/clusters of problems. And classification is important.
Next ...
Kernel Hacking
After about 7 years hacking MacOS kernel, and a year before on BSD 6.0, finally got back to Windows kernel hacking. Surprsing to see how C++ finally got into kernel developments in Windows environment. Also validated the assertion "Forgetfulness is a bliss!". Boy, so many things changed, and yet another is so many things wiped out of memory. Refreshing took some time and lot of frustration/hacking, but in the end it was all good and fond memory lane...
Now shifting gear, back in Linux (Unix like ) hacking. Already find it very interesting, like Windows hacking.
Will post some interesting topics, as I go along !!
Wow moment 2 !
Here is the thought process --
Use an Auxilary array Aux[size], of same type and size. As and when a Set(index, value ) operation happens, enter the value into A[index]=value; Put the index into Aux[] array, and have a counter for howmany such entries are entered, unsigned valid_count. Now whenever, we see a get count like get(index), we check/search if this index has value or not. This search happens in Aux[] array with the hope we find a value from the current index range 0<= index < valid_count. If we find the index there, we know a valid value will be found and returned. BUT THE PROBLEM IS get(index) is no longer O(1).
This is where we need to introduce another Auxalary array, say Aux2[], the first one is now renamed to Aux1[], A is our original array.
// main.cpp
// ArrayValue
//
// Created by Prokash Sinha on 5/6/21.
//
#include <iostream>
class MyArray{
public:
MyArray(size_t size) : myarra_(nullptr), aux1_arr_(nullptr),
aux2_arr_(nullptr), valid_count_(0), arr_size_(size)
{
if ( arr_size_ > 0 ) {
myarra_ = new int[arr_size_];
aux1_arr_ = new size_t[arr_size_];
aux2_arr_ = new size_t[arr_size_];
}
}
private:
int* myarra_;
size_t* aux1_arr_;
size_t* aux2_arr_;
int valid_count_;
size_t arr_size_;
public:
int get(size_t index){
int value = -1; // some value outside the domain of valid values
if ( index >= 0 && index < arr_size_ && aux2_arr_[index] >=0
&& aux2_arr_[index] < valid_count_){
value = myarra_[ aux1_arr_[aux2_arr_[index]] ];
}
return value;
};
void set(size_t index, int value){
if (index >= 0 && index < arr_size_){
myarra_[index] = value;
aux1_arr_[valid_count_] = index; // keep the current index
of myarray
aux2_arr_[index] = valid_count_; // keep the index of aux_arr_
++valid_count_;
}
}
};
int main(int argc, const char * argv[]) {
// insert code here...
int val;
MyArray myarr(10);
myarr.set(9, 99);
val = myarr.get(9);
myarr.set( 2, 22);
val = myarr.get(2);
myarr.set( 3, 45);
val = myarr.get(3);
// -- error cases
val = myarr.get(5); // shoule be -1
val = myarr.get(-1);
val = myarr.get(10);
std::cout << "Hello, World!\n";
return 0;
}
