<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Raphael De Lio on foojay.io - Friends of OpenJDK</title><link>https://foojayio.github.io/website/today/author/raphael-delio/</link><description>Articles written by Raphael De Lio on foojay.io - Friends of OpenJDK</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Thu, 07 Aug 2025 06:58:07 +0000</lastBuildDate><atom:link href="https://foojayio.github.io/website/today/author/raphael-delio/index.xml" rel="self" type="application/rss+xml"/><item><title>Semantic Caching with SpringBoot &amp; Redis</title><link>https://foojayio.github.io/website/today/semantic-caching-with-springboot-redis/</link><pubDate>Thu, 07 Aug 2025 06:58:07 +0000</pubDate><guid>https://foojayio.github.io/website/today/semantic-caching-with-springboot-redis/</guid><description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; You&amp;rsquo;re building a semantic caching system using Spring AI and Redis to improve LLM application performance.&lt;/p&gt;
&lt;p&gt;Unlike traditional caching that requires exact query matches, semantic caching understands the meaning behind queries and can return cached responses for semantically similar questions.&lt;/p&gt;
&lt;p&gt;It works by storing query-response pairs as vector embeddings in Redis, allowing your application to retrieve cached answers for similar questions without calling the expensive LLM, reducing both latency and costs.&lt;/p&gt;</description></item><item><title>Agent Memory with Spring AI &amp; Redis</title><link>https://foojayio.github.io/website/today/agent-memory-with-spring-ai-redis/</link><pubDate>Wed, 23 Jul 2025 16:34:04 +0000</pubDate><guid>https://foojayio.github.io/website/today/agent-memory-with-spring-ai-redis/</guid><description>&lt;h3 id="h3-0-you-re-building-an-ai-agent-with-memory-using-spring-ai-and-redis-unlike-traditional-chatbots-that-forget-previous-interactions-memory-enabled-agents-can-recall-past-conversations-and-facts-it-works-by-storing-two-types-of-memory-in-redis-short-term-conversation-history-and-long-term-facts-and-experiences-as-vectors-allowing-agents-to-provide-personalized-context-aware-responses"&gt;&lt;strong&gt;You&amp;rsquo;re building an AI agent with memory using Spring AI and Redis.&lt;/strong&gt; &lt;strong&gt;Unlike traditional chatbots that forget previous interactions, memory-enabled agents can recall past conversations and facts.&lt;/strong&gt; &lt;strong&gt;It works by storing two types of memory in Redis: short-term (conversation history) and long-term (facts and experiences as vectors), allowing agents to provide personalized, context-aware responses.&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;LLMs respond to each message in isolation, treating every interaction as if it&amp;rsquo;s the first time they&amp;rsquo;ve spoken with a user. They lack the ability to remember previous conversations, preferences, or important facts.&lt;/p&gt;</description></item><item><title>How I Improved Zero-Shot Classification in Deep Java Library (DJL) OSS: Enhancing Machine Learning Model Translators</title><link>https://foojayio.github.io/website/today/how-i-improved-zero-shot-classification-in-deep-java-library-djl-oss/</link><pubDate>Wed, 09 Jul 2025 10:51:16 +0000</pubDate><guid>https://foojayio.github.io/website/today/how-i-improved-zero-shot-classification-in-deep-java-library-djl-oss/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Did you know the Deep Java Library (DJL) powers Spring AI and Redis OM Spring? DJL helps you run machine learning models right inside your Java applications.&lt;/p&gt;
&lt;p&gt;Check them out:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Spring AI with DJL: &lt;a href="https://docs.spring.io/spring-ai/reference/api/embeddings/onnx.html" target="_blank" rel="noopener noreferrer"&gt;https://docs.spring.io/spring-ai/reference/api/embeddings/onnx.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Semantic Search with SpringBoot &amp;amp; Redis: &lt;a href="https://foojayio.github.io/website/today/semantic-search-with-spring-boot-redis/"&gt;https://foojay.io/today/semantic-search-with-spring-boot-redis/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h2 id="h2-0-tl-dr"&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;You&amp;rsquo;re doing zero-shot classification in a Java app using DJL.&lt;/li&gt;
&lt;li&gt;DJL didn&amp;rsquo;t handle some models well &amp;mdash; like DeBERTa. It missed support for token_type_ids, assumed wrong label positions, and oversimplified the softmax implementation.&lt;/li&gt;
&lt;li&gt;It was fixed by reading the model config files and adjusting DJL&amp;rsquo;s translator logic.&lt;/li&gt;
&lt;li&gt;Now DJL gives correct results across different models &amp;mdash; just like the Transformers library does in Python.&lt;/li&gt;
&lt;li&gt;The fix is merged and will probably be released with version 0.34.0.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="h2-1-what-s-zero-shot-classification-and-why-it-matters"&gt;What&amp;rsquo;s Zero-Shot Classification (and Why It Matters)&lt;/h2&gt;
&lt;p&gt;Zero-shot classification is a machine learning technique that allows models to classify text into categories they haven&amp;rsquo;t explicitly seen during training. Unlike traditional classification models that can only predict classes they were trained on, zero-shot classifiers can generalize to new, unseen categories.&lt;/p&gt;</description></item><item><title>How to send prompts in bulk with Spring AI and Virtual Threads</title><link>https://foojayio.github.io/website/today/how-to-send-prompts-in-bulk-with-spring-ai-and-java-virtual-threads/</link><pubDate>Wed, 21 May 2025 09:18:45 +0000</pubDate><guid>https://foojayio.github.io/website/today/how-to-send-prompts-in-bulk-with-spring-ai-and-java-virtual-threads/</guid><description>&lt;blockquote&gt;
&lt;p&gt;TL;DR: You&amp;rsquo;re building an AI-powered app that needs to send lots of prompts to OpenAI.&lt;/p&gt;
&lt;p&gt;Instead of sending them one by one, you want to do it in bulk &amp;mdash; efficiently and safely.&lt;/p&gt;
&lt;p&gt;This is how you can use Spring AI with Java Virtual Threads to process hundreds of prompts in parallel.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;When calling LLM APIs like OpenAI, you&amp;rsquo;re dealing with a high-latency, network-bound task. Normally, doing that in a loop slows you down and blocks threads. But with Spring AI and Java 21 Virtual Threads, you can fire off hundreds of requests in parallel without killing your app.&lt;/p&gt;</description></item><item><title>Semantic Search with Spring Boot &amp; Redis</title><link>https://foojayio.github.io/website/today/semantic-search-with-spring-boot-redis/</link><pubDate>Mon, 05 May 2025 15:35:55 +0000</pubDate><guid>https://foojayio.github.io/website/today/semantic-search-with-spring-boot-redis/</guid><description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; &lt;strong&gt;You&amp;rsquo;re building a semantic search app using Spring Boot and Redis. Instead of matching exact words, semantic search finds meaning using Vector Similarity Search (VSS). It works by turning movie synopses into vectors with embedding models, storing them in Redis (as a vector database), and finding the closest matches to user queries.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;"&gt;
			&lt;iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/o3XN4dImESE?autoplay=0&amp;amp;controls=1&amp;amp;end=0&amp;amp;loop=0&amp;amp;mute=0&amp;amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"&gt;&lt;/iframe&gt;
		&lt;/div&gt;

&lt;br /&gt;
&lt;p&gt;A traditional searching system works by matching the words a user types with the words stored in a database or document collection. It usually looks for exact or partial matches without understanding the meaning behind the words.&lt;/p&gt;</description></item><item><title>Sliding Window Counter Rate Limiter (Redis &amp; Java)</title><link>https://foojayio.github.io/website/today/sliding-window-counter-rate-limiter-redis-java/</link><pubDate>Tue, 25 Feb 2025 21:21:11 +0000</pubDate><guid>https://foojayio.github.io/website/today/sliding-window-counter-rate-limiter-redis-java/</guid><description>&lt;blockquote&gt;
&lt;p&gt;This content is also available on YouTube. &lt;a href="https://youtu.be/Wvm_u0IR69M" target="_blank" rel="noopener noreferrer"&gt;Check it out!&lt;/a&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;The Sliding Window Counter offers a more efficient way to handle rate limiting compared to the Sliding Window Log. While the Sliding Window Log keeps an exact log of timestamps for each request, allowing precise tracking over a rolling time period, this precision comes at the cost of higher memory usage and computational overhead as the number of requests increases.&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Sliding Window Log Rate Limiter (Redis &amp; Java)</title><link>https://foojayio.github.io/website/today/sliding-window-log-rate-limiter-redis-java/</link><pubDate>Tue, 04 Feb 2025 12:21:56 +0000</pubDate><guid>https://foojayio.github.io/website/today/sliding-window-log-rate-limiter-redis-java/</guid><description>&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://youtu.be/bCYzRg0oQjY" target="_blank" rel="noopener noreferrer"&gt;This article is also available on YouTube. Check it out!&lt;/a&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;The Sliding Window Log is a &lt;em&gt;more precise&lt;/em&gt; way to handle rate limiting. Instead of splitting time into fixed intervals like the &lt;a href="https://foojayio.github.io/website/wp-admin/post.php?post=115337"&gt;Fixed Window Counter&lt;/a&gt;
 , it keeps a log of timestamps for each request. This allows it to track requests over a rolling time period, like the last second or minute, without abrupt resets at the end of an interval.&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Token Bucket Rate Limiter (Redis &amp; Java) - Raphael De Lio</title><link>https://foojayio.github.io/website/today/token-bucket-rate-limiter-redis-java/</link><pubDate>Tue, 28 Jan 2025 07:07:08 +0000</pubDate><guid>https://foojayio.github.io/website/today/token-bucket-rate-limiter-redis-java/</guid><description>&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://youtu.be/cfF6nXIpDwE" target="_blank" rel="noopener noreferrer"&gt;This article is also available on YouTube!&lt;/a&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The &lt;strong&gt;Token Bucket&lt;/strong&gt; algorithm is a flexible and efficient rate-limiting mechanism.&lt;/p&gt;
&lt;p&gt;It works by filling a bucket with tokens at a fixed rate (e.g., one token per second).&lt;/p&gt;
&lt;p&gt;Each request consumes a token, and if no tokens are available, the request is rejected.&lt;/p&gt;
&lt;p&gt;The bucket has a maximum capacity, so it can handle bursts of traffic as long as the burst doesn&amp;rsquo;t exceed the number of tokens in the bucket.&lt;/p&gt;</description></item><item><title>Fixed Window Counter Rate Limiter (Redis &amp; Java)</title><link>https://foojayio.github.io/website/today/fixed-window-counter-rate-limiter-redis-java/</link><pubDate>Mon, 20 Jan 2025 16:34:18 +0000</pubDate><guid>https://foojayio.github.io/website/today/fixed-window-counter-rate-limiter-redis-java/</guid><description>&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://youtu.be/Ki3WKSNpdRU" target="_blank" rel="noopener noreferrer"&gt;This article is also available on YouTube!&lt;/a&gt;

The &lt;strong&gt;Fixed Window Counter&lt;/strong&gt; is the simplest and most straightforward rate-limiting algorithm. It divides time into fixed intervals (e.g., seconds, minutes, or hours) and counts the number of requests within each interval. If the count exceeds a predefined threshold, the requests are rejected until the next interval begins. Looking for a more precise algorithm? Take a look at the &lt;a href="https://foojayio.github.io/website/today/sliding-window-log-rate-limiter-redis-java/"&gt;Sliding Window Log implementation&lt;/a&gt;
.&lt;/p&gt;</description></item><item><title>Rate limiting with Redis: An essential guide</title><link>https://foojayio.github.io/website/today/rate-limiting-with-redis-an-essential-guide/</link><pubDate>Mon, 13 Jan 2025 18:23:26 +0000</pubDate><guid>https://foojayio.github.io/website/today/rate-limiting-with-redis-an-essential-guide/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=YV4ePyW3DO8" target="_blank" rel="noopener noreferrer"&gt;This article is also available on YouTube!&lt;/a&gt;
 Rate limiting &amp;mdash; it&amp;rsquo;s something you&amp;rsquo;ve likely encountered, even if you haven&amp;rsquo;t directly implemented one. For example, have you ever been greeted by a &amp;ldquo;429 Too Many Requests&amp;rdquo; error? That&amp;rsquo;s a rate limiter in action, protecting a resource from overload. Or maybe you&amp;rsquo;ve used a service with explicit request quotas based on your payment tier &amp;mdash; same concept, just more transparent. &lt;img src="https://cdn-images-1.medium.com/max/3412/1*YKz05kbmkzQdws-DUsvhdw.png" alt="ChatGPT warning user that they have reached the limit of messages they can send in 24 hours." loading="lazy"&gt;
 Rate limiting isn&amp;rsquo;t just about setting limits; it serves a variety of purposes. Take Figma, for instance. Their rate limiter, built with Redis, saved them from a spam attack where bad actors sent massive document invitations to random email addresses. Without it, Figma could have faced skyrocketing email delivery costs and damaged reputation. Or look at Stripe: as their platform grew, they realized they couldn&amp;rsquo;t just throw more infrastructure at the problem. They needed a smarter solution to prevent resource monopolization by misconfigured scripts or bad actors. These stories show just how versatile rate limiting is. It prevents abuse, ensures fair access, manages load, cuts costs, and even protects against downtime. But here&amp;rsquo;s the kicker: the hard part isn&amp;rsquo;t knowing &lt;em&gt;why&lt;/em&gt; you need a rate limiter. The real challenge is building one that&amp;rsquo;s both efficient and tailored to your needs.&lt;/p&gt;</description></item></channel></rss>