<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://melfeki.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://melfeki.github.io/" rel="alternate" type="text/html" /><updated>2025-11-15T00:20:54+00:00</updated><id>https://melfeki.github.io/feed.xml</id><title type="html">ME</title><subtitle>Leading Applied ML at Scale AI, building ML and LLM systems that improve  human annotation pipelines for models like ChatGPT, Gemini, and Llama.</subtitle><entry><title type="html">The Three-Layer Spectrum of Consciousness</title><link href="https://melfeki.github.io/2025/03/23/three-layer-spectrum-consciousness.html" rel="alternate" type="text/html" title="The Three-Layer Spectrum of Consciousness" /><published>2025-03-23T00:00:00+00:00</published><updated>2025-03-23T00:00:00+00:00</updated><id>https://melfeki.github.io/2025/03/23/three-layer-spectrum-consciousness</id><content type="html" xml:base="https://melfeki.github.io/2025/03/23/three-layer-spectrum-consciousness.html"><![CDATA[<p>Consciousness is one of the deepest puzzles we face. One way to make sense of it is through the <strong>Three-Layer Spectrum of Consciousness</strong>—a continuous gradient with three overlapping regions: <strong>Reaction</strong>, <strong>Reflection</strong>, and <strong>Self</strong>. This idea blends insights from neuroscience, psychology, AI, and Buddhist thought. Instead of thinking of consciousness as something binary or uniquely human, it helps to see it as a spectrum—one that shows up in different ways across species, systems, and states of mind. By connecting evolution, cognition, and inner experience, this model offers a clearer view of how different forms of awareness help us—and other beings—navigate the world.</p>

<h2 id="evolution-and-cognitive-architectures">Evolution and Cognitive Architectures</h2>

<p>The three consciousness regions represent different adaptive strategies that evolved to meet specific environmental challenges, not steps on an evolutionary ladder. This perspective integrates biological evolution with cognitive psychology’s dual-process theories in a unified interpretation.</p>

<p>Evolution favored simple reaction processes when they sufficed—many highly successful species thrive today with primarily reactive capabilities because their ecological niches don’t demand more metabolically expensive cognition. A cockroach’s rapid escape response or a jellyfish’s feeding mechanisms demonstrate how reaction-dominant strategies remain incredibly effective in stable environments. Reaction aligns precisely with what psychologists call “System 1”—fast, automatic, and efficient processes requiring minimal cognitive resources.</p>

<p>As certain species encountered more variable environments and complex challenges, evolution selected for reflective capabilities in those specific lineages. The ability to pause, evaluate options, and adjust strategies—psychology’s “System 2”—emerged independently in multiple evolutionary branches where environmental complexity made pure reaction insufficient. This explains why we find sophisticated problem-solving in distantly related species like corvids (ravens/crows) and cephalopods (octopuses), despite their radically different evolutionary histories and neural architectures.</p>

<p>Selfhood emerged later still, but not as an evolutionary pinnacle—rather as a specialized adaptation favored in niches where social complexity, cultural learning, and extended planning horizons provided significant advantages. The Self functions as what we might call a “meta-manager” that maintains consistent identity across time, consolidating reflections into a coherent narrative that influences both reaction (through emotional biases) and reflection (through identity-congruent justifications).</p>

<p>This evolutionary perspective reveals why our three-layer model extends beyond Kahneman’s influential dual-process theory. While reaction/System 1 and reflection/System 2 account for much of cognition, they don’t explain the uniquely human experience of continuous selfhood that persists through and colors all our experiences. The Self creates feedback loops that modify both reaction and reflection processes, explaining why humans rarely exhibit “pure” System 1 or System 2 thinking—our reactions carry emotional signatures shaped by identity, and our reflections often serve to justify rather than challenge our self-narratives.</p>

<p>Yet evolution’s indifference to subjective experience had unforeseen consequences. The emergence of Self introduced entirely new categories of suffering—anxiety about future nonexistence, regret over identity-inconsistent actions, and existential dread—that don’t exist in purely reactive or reflective consciousness. This evolutionary trade-off parallels others throughout biology: the adaptive advantages of selfhood came bundled with psychological vulnerabilities that remain with us today.</p>

<h2 id="the-spectrum-defined">The Spectrum Defined</h2>

<h3 id="region-1-reaction">Region 1: Reaction</h3>

<p>At its core, reaction is about immediate response—what happens when an organism meets its environment. While often dismissed as purely mechanical, even the simplest reactions exist on a spectrum of complexity.</p>

<p>What appears “automatic” actually contains surprising sophistication: sea slugs remember and ignore harmless repeated stimuli; single-celled organisms adjust behavior based on past encounters. These aren’t binary on/off switches but graded responses shaped by experience—the first hints of proto-learning emerging along our spectrum.</p>

<p>In vertebrate brains, these processes flow through ancient structures we all share—brainstem, cerebellum, basal ganglia—operating like psychology’s “System 1”: fast, efficient, and requiring minimal conscious effort. In artificial intelligence, we see this in the statistical pattern-matching of language models, making swift predictions based on trained associations. The reaction region trades flexibility for speed, but its limitations set the stage for something more sophisticated to emerge.</p>

<h3 id="region-2-reflection">Region 2: Reflection</h3>

<p>Reflection marks a significant shift in the spectrum of consciousness. Here, consciousness evaluates and reconsiders stimuli, introducing deliberation, contextual thinking, and the ability to step back from immediate reactions to consider alternatives. This corresponds to psychology’s “System 2”—slower, thoughtful processes handling novel situations.</p>

<p>Neurobiologically, reflection engages higher cortical regions, particularly the prefrontal and posterior parietal cortices—areas highly developed in mammals but present in varying degrees across vertebrates. These neural structures enable critical functions that distinguish reflection from mere reaction:</p>

<ol>
  <li><strong>Deliberate evaluation</strong>: Unlike reaction’s automatic response patterns, reflection involves explicit weighing of options against expected outcomes. This capability allows organisms to navigate novel situations where ingrained reactions might prove maladaptive.</li>
  <li><strong>Working memory</strong>: Reflection depends on the ability to maintain multiple pieces of information simultaneously in an active state. This creates a mental workspace where different options can be compared and manipulated before committing to action.</li>
  <li><strong>Inhibitory control</strong>: A cornerstone of reflective capability is the power to override automatic reactions when they conflict with higher-order goals or contextual needs. This inhibition creates the critical “pause” between stimulus and response that defines reflective consciousness.</li>
  <li><strong>Mental simulation</strong>: Perhaps most powerfully, reflection enables the creation of internal models—simulating potential actions and their consequences without actually performing them. This dramatically expands adaptive potential by allowing “trial and error” to occur mentally rather than physically.</li>
</ol>

<p>Reflective capabilities appear in diverse species (primates, dolphins, elephants, corvids, octopuses), suggesting independent evolutionary development rather than linear progression. These capabilities evolved as adaptive responses to environmental complexity, where the metabolic cost of maintaining sophisticated neural architecture is outweighed by survival advantages.</p>

<p>The social dimension of reflection cannot be overlooked. In highly social species, reflection enables modeling not just physical environments but also social dynamics and the mental states of others. This creates recursive mind-reading capabilities (“I think that you think that I think…”) that prove invaluable in complex social structures.</p>

<p>In artificial intelligence, reflection resembles “chain-of-thought” reasoning models that plan, reconsider, and adjust strategies—demonstrating limited but genuine reflective capability. These systems can evaluate multiple solution paths, backtrack when necessary, and recombine partial solutions into novel approaches.</p>

<p>Reflection’s relationship to consciousness differs fundamentally from reaction. While reactive processes often operate outside awareness, reflection is inherently conscious—we experience ourselves thinking, weighing options, and making choices. Yet interestingly, the products of reflection can eventually become automatic through practice, cycling back into the reaction region as skills become habitual.</p>

<h3 id="region-3-self">Region 3: Self</h3>

<p>While Reflection allows for deliberate thinking about immediate problems, Self represents something fundamentally different: a persistent narrative that weaves disparate experiences into a continuous identity story. Here, the distinction is crucial—Reflection asks “What should I do about this situation?” while Self asks “Who am I across all situations?”</p>

<p>Self emerges when reflective processes become recursive, constantly referring back to and reinforcing an identity structure (e.g., a journal where each entry reflects on the previous one). This creates the autobiographical narrator who declares “I experienced this,” “I desire that,” or “This aligns with my values.” Without this self-structure, experiences remain isolated events; with it, they become chapters in an ongoing personal story.</p>

<p>Neurobiologically, self-processes engage distinct brain networks compared to reflection. The default mode network—activated when we’re not focused on external tasks—plays a central role in maintaining self-narrative, while hippocampal circuits weave episodic memories into autobiographical sequences. These systems create temporal bridges, connecting past experiences to present identity and future projections.</p>

<p>Four key markers distinguish Self from mere Reflection:</p>

<ul>
  <li>Mirror self-recognition—recognizing oneself as a distinct entity</li>
  <li>Episodic memory—recalling personal experiences with emotional context</li>
  <li>Future planning beyond immediate needs—projecting a continued self into hypothetical scenarios</li>
  <li>Theory of mind about oneself—understanding that others have mental models of “you”</li>
</ul>

<p>Self is neither universal nor necessary for sophisticated cognition. Many highly intelligent species (dolphins, elephants, great apes) show some self-awareness markers but lack the persistent self-narrative that characterizes human consciousness. In AI, selfhood would require systems that maintain consistent identity models across time, referring back to their own “experiences” and making decisions aligned with learned values rather than just immediate objectives.</p>

<p>This model of consciousness as spectrum—Reaction, Reflection, Self—provides a framework for understanding how different forms of awareness serve adaptive functions across species and systems. It suggests that consciousness isn’t a binary quality but rather a gradient of capabilities that evolved to solve specific environmental challenges.</p>]]></content><author><name></name></author><category term="Consciousness" /><category term="Philosophy" /><category term="Neuroscience" /><category term="AI" /><summary type="html"><![CDATA[A unified theory of consciousness as a continuous gradient with three overlapping regions: Reaction, Reflection, and Self.]]></summary></entry><entry><title type="html">Fitting in Intelligence</title><link href="https://melfeki.github.io/2024/06/24/fitting-in-intelligence.html" rel="alternate" type="text/html" title="Fitting in Intelligence" /><published>2024-06-24T00:00:00+00:00</published><updated>2024-06-24T00:00:00+00:00</updated><id>https://melfeki.github.io/2024/06/24/fitting-in-intelligence</id><content type="html" xml:base="https://melfeki.github.io/2024/06/24/fitting-in-intelligence.html"><![CDATA[<p>Assuming that humans have AGI.</p>

<p>They can observe the world, and build a world representation (fitted function between their observations and predictions over time). Then they can use this world representation as a grounding factual source.</p>

<p>In addition to observing the world, they also plan and design actions. I believe that a lot of their planning is random, especially as it gets higher level. By definition, they use this world model to make plans for lower-level actions, of which they have seen a lot of observations before. But for things of higher order of complexity for which they have no samples in their training data, they just make it up. That’s what religions, philosophies, and speculations are.</p>

<p>We are nothing but glorified next token predictors. When we don’t have enough samples in our training set for what to predict for next token (meaning of life?), we just hallucinate (religions, philosophies).</p>

<p>We tend to make up stuff that are complex, yet still making stuff up.</p>

<p>There’s a fabric of reality which we experience. The only way to know more about it, is to use the scientific method. Hypothesize, test the hypothesis, collect observations, and move on.</p>

<p>This is an incredibly powerful framing of our intelligence.</p>

<p>According to that framing, the way to get to an AGI is to build the best next token predictor.<br />
For that, you need the best loss and the best architecture (CE, Transformer)? Is there a better loss or a better architecture?<br />
I believe there will be a better architecture for sure!! (better suited for a specific cuda/Hardware)</p>

<p>Once this is built, project the space of knowledge, and identify the gap areas.<br />
How to project the space knowledge?<br />
Once gap areas are identified, design experiments to collect more samples for these data and fix the model.<br />
Keep re-iterating until the space knowledge is fully explored!!</p>

<p>Given that this is the goal,</p>

<p>Assuming the following inputs: images &amp;&amp; text vs. Video &amp;&amp; Audio<br />
Assuming the following loss: Next token prediction (CE) loss<br />
Assuming the following hardware: cuda &amp;&amp; 4xH100</p>

<ol>
  <li>Find the best architecture to learn the inputs on the given hardware for images &amp;&amp; text– Must generalize to videos &amp;&amp; audio</li>
  <li>Build an auto-scraper and train the model constantly– Scraper direction can be optimized by the learning direction?</li>
  <li>Project the knowledge space. Which areas does it know about, which areas it lacks. Collect more data for which it lacks.</li>
  <li>If can’t find data in the space(scraper), design an experiment to test a hypothesis. Either hypothesis is true or false until it fills the knowledge space.<br />
Is knowledge space infinite? (Only one way to know)</li>
</ol>]]></content><author><name></name></author><category term="AGI" /><category term="Machine Learning" /><category term="Intelligence" /><category term="Philosophy" /><summary type="html"><![CDATA[A framing of intelligence as next-token prediction, and how this perspective guides the path to AGI.]]></summary></entry><entry><title type="html">To the technologist belong the spoils!</title><link href="https://melfeki.github.io/2024/04/29/technologist-spoils.html" rel="alternate" type="text/html" title="To the technologist belong the spoils!" /><published>2024-04-29T00:00:00+00:00</published><updated>2024-04-29T00:00:00+00:00</updated><id>https://melfeki.github.io/2024/04/29/technologist-spoils</id><content type="html" xml:base="https://melfeki.github.io/2024/04/29/technologist-spoils.html"><![CDATA[<p>I spent a considerable part of my day playing with this repo. It shows video summarization using llama-3 running on Groq. The interesting thing to me is what happens when you combine with performant LLMs like llama-3, and fast speech-to-text like Distill-Whisper, and accelerated inference hardware like Groq.</p>

<p><strong><em>The time taken to watch, analyze, and study a 3-hours lecture is brought down to less than 30 seconds (3x orders of magnitude faster).</em></strong></p>

<p>It is difficult to me to imagine what will happen when these tools become more widespread. When information processing cost is brought down by 3x orders of magnitude, then education becomes a lot more targeted. It doesn’t matter as much what you remember, it matters a lot more how do you connect the pieces together. In other words, educated traversal becomes more valuable.</p>

<p>I’m still working on developing an insight on how to know if two nodes can be connected. Developing a value function to connect the nodes of the individual’s knowledge graph would certainly become a lot more valuable given that the cost of adding new nodes become lower.</p>

<p>Another thing to remember is that when the information processing cost is brought down, it’s a lot easier to get distracted and accomplish nothing. We saw a glimpse of that when social networks and Youtube first appeared. Everyone got excited about the endless opportunities for education. The same source for education (and no-doubt that it has contributed a lot to education), also caused major attention deficit. It became a lot harder to develop a long-term attention span required to get important things done.</p>

<p>A value function for the individual’s knowledge graph not only would require knowing what to connect, but also would require enough attention and effort to obtain and process this knowledge, and implement the ideas that come off the merger of the nodes.</p>

<p>Thus, we end up with two contradicting forces. On one hand, it’s a lot faster, cheaper, and easier to obtain, process, and analyze knowledge than in the past. On the other hand, it’s a lot easier to get distracted and overwhelmed by the insurmountable amount of information out there that you don’t get much done.</p>

<p>Meditation can help mitigate distraction.<br />
Focus can help mitigate the overwhelming effect of the information flow.<br />
Technology and AI can help bring down the cost of obtaining new information.<br />
&amp; Thus, to the focused, contemplative, and technologist belong the spoils!!</p>]]></content><author><name></name></author><category term="Technology" /><category term="AI" /><category term="Education" /><category term="Productivity" /><summary type="html"><![CDATA[When information processing cost is brought down by orders of magnitude, education becomes more targeted and connection becomes more valuable than memorization.]]></summary></entry><entry><title type="html">In the beginning, there was the Perceptron</title><link href="https://melfeki.github.io/2024/04/27/beginning-perceptron.html" rel="alternate" type="text/html" title="In the beginning, there was the Perceptron" /><published>2024-04-27T00:00:00+00:00</published><updated>2024-04-27T00:00:00+00:00</updated><id>https://melfeki.github.io/2024/04/27/beginning-perceptron</id><content type="html" xml:base="https://melfeki.github.io/2024/04/27/beginning-perceptron.html"><![CDATA[<p>In the beginning, there was the Perceptron, and it was good. Well, sort of.</p>

<p>It was the first neural network model, introduced in the 1950s, and it was a bit of a simpleton. I mean, it could only learn linearly separable patterns. Think of it like a neural network that could only solve problems that are straightforward.</p>

<p>The Perceptron’s simplicity was also its strength. It introduced the concept of the activation function, like the sigmoid</p>

\[\left( \frac{1}{1 + e^{-x}} \right)\]

<p>, which allowed it to make predictions and classify data. And, let’s not forget the weights and biases, which made it all work like magic!</p>

<h2 id="what">What?</h2>

<p>A single layer neural network that takes in inputs, applies weights and biases, and then passes the output through an activation function. The output is then compared to the target output, and the error is calculated.</p>

\[f(x) = \text{activation}\left(\sum_{i=1}^{n} w_i x_i + b\right)\]

<p>The primary function of the perceptron is classification by finding a linear separator in the feature space—the perceptron learning algorithm iteratively adjusts the weights and bias based on classification errors, striving to minimize these errors.</p>

<h2 id="legacy">Legacy</h2>

<p>It’s limited. It can only solve problems that are separable with a single line (e.g., XOR problem). But, its beauty lies in its ability to compound linearity to solve non-linearity.</p>

<p>Multi-Layer Perceptron (MLP) is merely the compounding of many perceptron units together and applying a non-linear activation. Et voila, now you can solve non-linearly separable problems as well.</p>

<p><strong>So, next time you’re building a Large Neural Network, remember the humble Perceptron, and the power of simplicity!</strong></p>]]></content><author><name></name></author><category term="Neural Networks" /><category term="Machine Learning" /><category term="History" /><summary type="html"><![CDATA[The humble Perceptron introduced the concept of activation functions and demonstrated how simplicity can compound into powerful non-linear solutions.]]></summary></entry><entry><title type="html">RLHF - How It Really Works</title><link href="https://melfeki.github.io/2024/03/15/rlhf-how-it-really-works.html" rel="alternate" type="text/html" title="RLHF - How It Really Works" /><published>2024-03-15T00:00:00+00:00</published><updated>2024-03-15T00:00:00+00:00</updated><id>https://melfeki.github.io/2024/03/15/rlhf-how-it-really-works</id><content type="html" xml:base="https://melfeki.github.io/2024/03/15/rlhf-how-it-really-works.html"><![CDATA[<p>RLHF (Reinforcement Learning from Human Feedback) is a critical technique for aligning large language models with human preferences. Here’s how it really works.</p>

<h2 id="the-core-problem">The Core Problem</h2>

<p>Language models trained on massive text corpora learn to predict the next token, but this doesn’t necessarily align with what humans find helpful, harmless, or accurate. RLHF addresses this by incorporating human preferences into the training process.</p>

<h2 id="the-rlhf-pipeline">The RLHF Pipeline</h2>

<p><strong>Step 1: Supervised Fine-Tuning (SFT)</strong>
First, a base language model is fine-tuned on a dataset of human demonstrations. This creates a “policy” model that can generate responses in the desired format.</p>

<p><strong>Step 2: Reward Model Training</strong>
A separate reward model is trained to predict human preferences. This involves:</p>
<ul>
  <li>Collecting human comparisons (e.g., “response A is better than response B”)</li>
  <li>Training a model to predict which response humans would prefer</li>
  <li>Using ranking or pairwise comparison data</li>
</ul>

<p><strong>Step 3: Reinforcement Learning Optimization</strong>
The policy model is optimized using the reward model as a proxy for human feedback:</p>
<ul>
  <li>Generate multiple responses to prompts</li>
  <li>Use the reward model to score each response</li>
  <li>Update the policy to maximize expected reward using algorithms like PPO (Proximal Policy Optimization)</li>
</ul>

<h2 id="key-techniques">Key Techniques</h2>

<p><strong>Preference Modeling Approaches:</strong></p>
<ul>
  <li><strong>Pairwise comparisons</strong>: Humans rank two responses, training the reward model to prefer one over the other</li>
  <li><strong>Ranking-based methods</strong>: Multiple responses ranked by quality</li>
  <li><strong>Absolute ratings</strong>: Direct quality scores (less common due to inconsistency)</li>
</ul>

<p><strong>RL Algorithms:</strong></p>
<ul>
  <li><strong>PPO (Proximal Policy Optimization)</strong>: Most common, balances exploration and exploitation while preventing large policy updates</li>
  <li><strong>REINFORCE</strong>: Simpler but less stable</li>
  <li><strong>DPO (Direct Preference Optimization)</strong>: Newer approach that avoids training a separate reward model</li>
</ul>

<h2 id="challenges-and-limitations">Challenges and Limitations</h2>

<p><strong>Data Efficiency:</strong></p>
<ul>
  <li>RLHF requires significant human feedback data</li>
  <li>Off-policy data refers to using previous human evaluations, even if they were generated by older model versions, which makes training more data efficient but might introduce stale or misaligned preferences if the model changes significantly.</li>
</ul>

<p><strong>Handling Hallucinations Post-Training:</strong></p>
<ul>
  <li><strong>Instructive Feedback Loops</strong>: Hallucinations are often mitigated post-training by fine-tuning the LLM on specially curated, verified datasets or adding negative samples (incorrect facts) and training the LLM to recognize and penalize hallucinations.</li>
  <li><strong>Contradiction Detection</strong>: Models can be fine-tuned using contradiction labels where human evaluators provide ‘false statements,’ and the LLM is trained to identify contradictions or refuse to answer confidently, enhancing its reliability.</li>
  <li><strong>Fact-Based Reward Functions</strong>: One promising direction is using fact-verifying models as part of the reward function. The LLM’s outputs are compared against known facts, and deviations are penalized.</li>
</ul>

<p><strong>Future Directions in Post-Training:</strong></p>
<ul>
  <li><strong>Curriculum RLHF</strong>: A future direction involves curriculum-based RLHF, where the model is gradually introduced to increasingly difficult or nuanced feedback to enhance learning stability.</li>
  <li><strong>Multi-Agent Feedback Systems</strong>: Using multiple LLMs as evaluators instead of humans is gaining traction for initial preference labeling. Ensemble feedback from different models can help create more robust reward signals before human refinement.</li>
  <li><strong>Combining Reinforcement and Supervised Learning</strong>: Integrating reinforcement objectives with supervised learning (hybrid training) allows post-training to benefit from both direct human instruction and dynamic adaptation, enhancing overall LLM alignment quality.</li>
</ul>

<h2 id="critical-notes-on-rlhf">Critical Notes on RLHF</h2>

<ul>
  <li>RLHF merely mitigates the most frequent mistakes without actually fixing the inherent tendency for hallucinations that LLMs exhibit.</li>
  <li>Inherently, relying on humans is complex. Human preferences are unreliable (low likelihood of reproducing them), and modeling them is unreliable as well.</li>
  <li>Reward hacking is a common RL problem.</li>
  <li>Chatbots are rewarded to produce responses that seem helpful regardless of truthfulness.</li>
  <li><strong>Constitutional AI</strong>: An alternative approach that uses LLMs to provide feedback and then applies RL from AI feedback, reducing reliance on human annotators.</li>
</ul>

<p>RLHF represents a significant step forward in aligning language models, but it’s not a panacea. Understanding its mechanisms and limitations is crucial for building better AI systems.</p>]]></content><author><name></name></author><category term="RLHF" /><category term="Machine Learning" /><category term="LLMs" /><category term="Alignment" /><summary type="html"><![CDATA[A deep dive into Reinforcement Learning from Human Feedback, how it actually works in practice, and its limitations.]]></summary></entry></feed>