<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Borjan Ladinski</title>
    <description>The latest articles on DEV Community by Borjan Ladinski (@borjanladinski).</description>
    <link>https://dev.to/borjanladinski</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4269719%2F6acceadc-215a-47d9-9f76-f186ed31740c.png</url>
      <title>DEV Community: Borjan Ladinski</title>
      <link>https://dev.to/borjanladinski</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/borjanladinski"/>
    <language>en</language>
    <item>
      <title>I Ran a 500M-Parameter LLM on an ESP32-C3 Microcontroller</title>
      <dc:creator>Borjan Ladinski</dc:creator>
      <pubDate>Fri, 27 Nov 2026 22:21:31 +0000</pubDate>
      <link>https://dev.to/borjanladinski/i-ran-a-500m-parameter-llm-on-an-esp32-c3-microcontroller-3gfh</link>
      <guid>https://dev.to/borjanladinski/i-ran-a-500m-parameter-llm-on-an-esp32-c3-microcontroller-3gfh</guid>
      <description>&lt;p&gt;I wanted to see how far I could push a tiny microcontroller.&lt;/p&gt;

&lt;p&gt;My ESP32-C3 has a 160 MHz processor, around 400 KB of SRAM, and 4 MB of flash storage.&lt;/p&gt;

&lt;p&gt;The model I chose was Qwen2.5-0.5B-Instruct, a language model with approximately 500 million parameters.&lt;/p&gt;

&lt;p&gt;That's far larger than the memory available on the ESP32-C3.&lt;/p&gt;

&lt;p&gt;Still, I wanted to find out whether the microcontroller could perform the actual transformer calculations.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Challenge
&lt;/h2&gt;

&lt;p&gt;Running an LLM normally requires enough memory to store model weights, intermediate calculations, and the attention cache.&lt;/p&gt;

&lt;p&gt;An ESP32-C3 doesn't have anything close to the memory needed to hold a 500M-parameter model.&lt;/p&gt;

&lt;p&gt;The obvious solution would be to send requests to a PC or server and let it run the model.&lt;/p&gt;

&lt;p&gt;But that wasn't what I wanted.&lt;/p&gt;

&lt;p&gt;My goal was to perform the neural network computations on the ESP32 itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Approach
&lt;/h2&gt;

&lt;p&gt;I separated model storage from computation.&lt;/p&gt;

&lt;p&gt;The PC acts as temporary storage for model weights and other required model data.&lt;/p&gt;

&lt;p&gt;The ESP32 receives the data it needs, processes the transformer operations, and keeps its working state on the device.&lt;/p&gt;

&lt;p&gt;The PC does not perform the neural network inference calculations.&lt;/p&gt;

&lt;p&gt;The architecture looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;          PC
   Model Weight Storage
           |
           | Stream weights
           v
       ESP32-C3
    Transformer Compute
    Activations / KV Cache
           |
           v
      Token Selection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach trades memory requirements for a major increase in data transfers and execution time.&lt;/p&gt;

&lt;p&gt;It doesn't make the hardware powerful. It makes a much larger model possible to evaluate within the device's limited memory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quantization Experiments
&lt;/h2&gt;

&lt;p&gt;I also benchmarked different integer representations on the ESP32-C3.&lt;/p&gt;

&lt;p&gt;For a vector size of 256 and 10,000 iterations, I recorded:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Format&lt;/th&gt;
&lt;th&gt;Execution Time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;INT8&lt;/td&gt;
&lt;td&gt;273,440 µs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INT4&lt;/td&gt;
&lt;td&gt;530,232 µs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INT2&lt;/td&gt;
&lt;td&gt;546,245 µs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;INT8 was the fastest in this specific test.&lt;/p&gt;

&lt;p&gt;Lower bit widths reduce storage requirements, but they don't automatically make computation faster. Unpacking smaller representations can introduce additional work.&lt;/p&gt;

&lt;p&gt;These are microbenchmarks, not full-model inference timings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running the Transformer
&lt;/h2&gt;

&lt;p&gt;After validating smaller components, I progressively tested larger parts of the model.&lt;/p&gt;

&lt;p&gt;The experiments included individual transformer layers, multiple token positions, and eventually processing a four-token prompt through all 24 transformer layers.&lt;/p&gt;

&lt;p&gt;I compared intermediate results against an independent reference implementation to check numerical correctness.&lt;/p&gt;

&lt;p&gt;In a verified run, the ESP32 completed the transformer processing and selected a next-token ID.&lt;/p&gt;

&lt;p&gt;That was the main milestone: the microcontroller was performing real pretrained-model computations, rather than calling an LLM running somewhere else.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Performance Problem
&lt;/h2&gt;

&lt;p&gt;The biggest limitation was speed.&lt;/p&gt;

&lt;p&gt;Streaming large quantities of model weights to a small device creates substantial overhead.&lt;/p&gt;

&lt;p&gt;I worked on reducing that overhead and optimizing parts of the execution pipeline.&lt;/p&gt;

&lt;p&gt;One partial benchmark improved from approximately 167 seconds to 19 seconds, an 8.64× speedup.&lt;/p&gt;

&lt;p&gt;That improvement was specific to the measured workload, not the total time required to generate a response.&lt;/p&gt;

&lt;p&gt;Complete inference remained very slow.&lt;/p&gt;

&lt;h2&gt;
  
  
  What This Does and Doesn't Prove
&lt;/h2&gt;

&lt;p&gt;The experiment demonstrates that a tiny microcontroller can execute substantial parts of a pretrained language model when its weights are supplied from external storage.&lt;/p&gt;

&lt;p&gt;But there are important limitations.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The ESP32 does not store the complete model locally.&lt;/li&gt;
&lt;li&gt;The PC is still required as a source of model data.&lt;/li&gt;
&lt;li&gt;Inference is extremely slow compared with conventional hardware.&lt;/li&gt;
&lt;li&gt;The verified milestone is device-side transformer computation and token selection, not practical real-time conversation.&lt;/li&gt;
&lt;li&gt;This does not yet demonstrate a fully standalone multi-token chatbot.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those distinctions matter. I wanted to prove what the hardware actually executed, not imply a level of performance it hadn't reached.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;This project changed how I think about running AI on constrained hardware.&lt;/p&gt;

&lt;p&gt;The key challenges weren't just implementing matrix multiplication or attention.&lt;/p&gt;

&lt;p&gt;They included memory management, streaming, numerical verification, quantization, and finding performance bottlenecks.&lt;/p&gt;

&lt;p&gt;The experiment also reinforced something I've learned from other AI engineering projects:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A system should be judged by what can be independently verified, not just by whether a demo appears to work.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I plan to keep that principle at the center of my future experiments.&lt;/p&gt;




&lt;p&gt;Read the full article here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://borjan.ladinski.com/articles/500m-llm-esp32-c3/" rel="noopener noreferrer"&gt;Running a 500M-Parameter LLM on an ESP32-C3&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  About the Author
&lt;/h2&gt;

&lt;p&gt;I'm &lt;strong&gt;Borjan Ladinski, an AI Engineer, AI Expert, and AI Consultant based in Skopje, North Macedonia&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I specialize in AI agents, LLM applications, RAG systems, machine learning, and business automation. My work includes production AI systems, original retrieval benchmarks, and experimental AI inference on microcontrollers.&lt;/p&gt;

&lt;p&gt;I'm available for AI consulting, custom AI solutions, and engineering projects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://borjan.ladinski.com/" rel="noopener noreferrer"&gt;Explore my AI projects and consulting work&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>opensource</category>
    </item>
    <item>
      <title>BM25 vs Semantic Search vs Hybrid RAG: What My Benchmarks Revealed</title>
      <dc:creator>Borjan Ladinski</dc:creator>
      <pubDate>Fri, 27 Nov 2026 22:09:47 +0000</pubDate>
      <link>https://dev.to/borjanladinski/bm25-vs-semantic-search-vs-hybrid-rag-what-my-benchmarks-revealed-2klk</link>
      <guid>https://dev.to/borjanladinski/bm25-vs-semantic-search-vs-hybrid-rag-what-my-benchmarks-revealed-2klk</guid>
      <description>&lt;p&gt;I built a codebase RAG system using BM25, semantic search, reciprocal rank fusion (RRF), and cross-encoder reranking.&lt;/p&gt;

&lt;p&gt;I expected hybrid search to outperform semantic search alone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It didn't.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On my evaluation set, semantic search achieved an MRR@5 of 0.854, while hybrid RRF dropped to 0.692.&lt;/p&gt;

&lt;p&gt;Adding cross-encoder reranking changed the result.&lt;/p&gt;

&lt;p&gt;Here's what I tested and what I learned.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Searching a codebase isn't the same as searching ordinary text.&lt;/p&gt;

&lt;p&gt;A developer might ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Where does the application check whether a user is logged in?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But the relevant implementation could be a function named &lt;code&gt;decode_access_token&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;BM25 can find exact identifiers. Semantic search can match questions to code with different wording.&lt;/p&gt;

&lt;p&gt;I wanted to see whether combining both approaches would improve retrieval quality.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;My project, &lt;strong&gt;AI Codebase Intelligence&lt;/strong&gt;, indexes software repositories and lets developers ask questions about their code.&lt;/p&gt;

&lt;p&gt;The system uses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FastAPI for the backend&lt;/li&gt;
&lt;li&gt;PostgreSQL for persistence&lt;/li&gt;
&lt;li&gt;Redis and Celery for background indexing&lt;/li&gt;
&lt;li&gt;Pinecone for vector storage&lt;/li&gt;
&lt;li&gt;BM25 for lexical retrieval&lt;/li&gt;
&lt;li&gt;Sentence Transformers for semantic embeddings&lt;/li&gt;
&lt;li&gt;RRF for combining rankings&lt;/li&gt;
&lt;li&gt;A cross-encoder for reranking&lt;/li&gt;
&lt;li&gt;Ollama for generating answers grounded in retrieved code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The retrieval pipeline looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Question
   |
   v
BM25 + Semantic Search
   |
   v
Reciprocal Rank Fusion
   |
   v
Cross-Encoder Reranking
   |
   v
Relevant Code Chunks
   |
   v
Local LLM
   |
   v
Answer + Source Citations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Benchmark
&lt;/h2&gt;

&lt;p&gt;I created a small ground-truth evaluation set and compared four retrieval methods.&lt;/p&gt;

&lt;p&gt;I measured:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hit@5:&lt;/strong&gt; Whether at least one relevant result appears in the top five.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MRR@5:&lt;/strong&gt; How highly the first relevant result ranks within the top five, averaged across queries.&lt;/p&gt;

&lt;p&gt;Here are the results:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Retrieval Method&lt;/th&gt;
&lt;th&gt;Hit@5&lt;/th&gt;
&lt;th&gt;MRR@5&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;BM25&lt;/td&gt;
&lt;td&gt;0.750&lt;/td&gt;
&lt;td&gt;0.500&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Semantic Search&lt;/td&gt;
&lt;td&gt;1.000&lt;/td&gt;
&lt;td&gt;0.854&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hybrid RRF&lt;/td&gt;
&lt;td&gt;0.875&lt;/td&gt;
&lt;td&gt;0.692&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RRF + Reranking&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1.000&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.875&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These results come from my project's evaluation set, not a standardized public benchmark.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Surprised Me
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Hybrid RRF performed worse than semantic search alone.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Combining BM25 and semantic search actually reduced both Hit@5 and MRR@5 in this experiment.&lt;/p&gt;

&lt;p&gt;The initial hybrid implementation used equal-weight RRF.&lt;/p&gt;

&lt;p&gt;One possible explanation is that combining the ranked lists pushed some relevant semantic results lower. However, I haven't isolated the exact cause.&lt;/p&gt;

&lt;p&gt;The important point is that adding another retrieval component did not automatically improve the results.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Changed After Reranking?
&lt;/h2&gt;

&lt;p&gt;I added a cross-encoder reranker after RRF.&lt;/p&gt;

&lt;p&gt;Instead of relying only on the original retrieval rankings, the cross-encoder evaluates the query and each candidate together to produce a new ordering.&lt;/p&gt;

&lt;p&gt;The result:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hit@5 increased from 0.875 to 1.000.&lt;/li&gt;
&lt;li&gt;MRR@5 increased from 0.692 to 0.875.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Compared with semantic search alone, the final pipeline achieved the same Hit@5 and a slightly higher MRR@5.&lt;/p&gt;

&lt;p&gt;That improvement gave me a measurable reason to keep the reranking stage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Beyond Retrieval
&lt;/h2&gt;

&lt;p&gt;The project also includes the engineering needed to make the retrieval system usable.&lt;/p&gt;

&lt;p&gt;Repository indexing runs asynchronously using Celery and Redis.&lt;/p&gt;

&lt;p&gt;Repeated RAG responses can be cached in Redis.&lt;/p&gt;

&lt;p&gt;Generated answers include source file and line-range citations, making it easier to verify the retrieved evidence.&lt;/p&gt;

&lt;p&gt;I also added read-only MCP tools for searching code, retrieving files, listing symbols, and asking questions about a repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations
&lt;/h2&gt;

&lt;p&gt;This was a small evaluation, so the results shouldn't be treated as universal.&lt;/p&gt;

&lt;p&gt;Different datasets, repositories, embedding models, fusion parameters, and rerankers may produce different outcomes.&lt;/p&gt;

&lt;p&gt;I also measured retrieval quality, not end-to-end answer accuracy or latency.&lt;/p&gt;

&lt;p&gt;Those would be important next steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Takeaway
&lt;/h2&gt;

&lt;p&gt;The biggest lesson from this project wasn't that hybrid RAG is better or worse than semantic search.&lt;/p&gt;

&lt;p&gt;It was that &lt;strong&gt;retrieval quality needs to be measured instead of assumed&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;My first hybrid implementation added complexity while reducing performance.&lt;/p&gt;

&lt;p&gt;Cross-encoder reranking improved the results, but the benefit only became clear after running the evaluation.&lt;/p&gt;

&lt;p&gt;A more complicated RAG architecture isn't automatically a better one.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Read the full technical article, including the architecture and implementation details:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://borjan.ladinski.com/articles/bm25-semantic-hybrid-rag-benchmarks/" rel="noopener noreferrer"&gt;BM25 vs Semantic Search vs Hybrid RAG: What My Benchmarks Revealed&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  About the Author
&lt;/h2&gt;

&lt;p&gt;I'm Borjan Ladinski, an &lt;strong&gt;AI Engineer, AI Expert, and AI Consultant based in Skopje, North Macedonia&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I build AI agents, LLM applications, RAG systems, machine learning solutions, and business automation. My work includes production AI systems, retrieval benchmarks, and experimental LLM inference on microcontrollers.&lt;/p&gt;

&lt;p&gt;I'm available for AI consulting, custom AI solutions, and engineering projects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://borjan.ladinski.com/" rel="noopener noreferrer"&gt;Explore my AI projects and consulting work&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>rag</category>
    </item>
  </channel>
</rss>
