<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts on Saltfish's Blog</title><link>https://blog.saltfish.org/posts/</link><description>Recent content in Posts on Saltfish's Blog</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 09 Mar 2026 16:56:20 -0400</lastBuildDate><atom:link href="https://blog.saltfish.org/posts/index.xml" rel="self" type="application/rss+xml"/><item><title>Raft Stage2</title><link>https://blog.saltfish.org/posts/raft-stage2/</link><pubDate>Sat, 07 Mar 2026 14:19:03 -0500</pubDate><guid>https://blog.saltfish.org/posts/raft-stage2/</guid><description>&lt;p>Last time, we finished the first stage of Raft, sucessfully electing a leader without logs. In stage 2, which is the most difficult stage I think, we need to implement the log replication. Leader will receive the command from the client, append it to its log, and then send AppendEntries RPC to the followers. Followers will append the entries to their logs and reply with success or failure.&lt;/p></description></item><item><title>The Number of Good Subsets</title><link>https://blog.saltfish.org/posts/the-number-of-good-subsets/</link><pubDate>Fri, 20 Feb 2026 16:22:49 -0500</pubDate><guid>https://blog.saltfish.org/posts/the-number-of-good-subsets/</guid><description>&lt;p>&lt;a href="https://leetcode.com/problems/the-number-of-good-subsets/description/" target="_blank" rel="noreferrer">Link&lt;/a>&lt;/p>
&lt;h2 id="problem" class="relative group">Problem &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100">&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#problem" aria-label="Anchor">#&lt;/a>&lt;/span>&lt;/h2>&lt;p>You are given an integer array nums. We call a subset of nums good if its product can be represented as a product of one or more distinct prime numbers.&lt;/p>
&lt;p>For example, if &lt;code>nums = [1, 2, 3, 4]&lt;/code>:&lt;br>
&lt;code>[2, 3]&lt;/code>, &lt;code>[1, 2, 3]&lt;/code>, and &lt;code>[1, 3]&lt;/code> are good subsets with products &lt;code>6 = 2*3&lt;/code>, &lt;code>6 = 2*3&lt;/code>, and &lt;code>3 = 3&lt;/code> respectively.&lt;br>
&lt;code>[1, 4]&lt;/code> and &lt;code>[4]&lt;/code> are not good subsets with products &lt;code>4 = 2*2&lt;/code> and &lt;code>4 = 2*2&lt;/code> respectively.&lt;br>
Return the number of different good subsets in nums modulo 1e9 + 7.&lt;/p></description></item><item><title>Raft Stage1</title><link>https://blog.saltfish.org/posts/raft-stage1/</link><pubDate>Sat, 14 Feb 2026 19:21:01 -0500</pubDate><guid>https://blog.saltfish.org/posts/raft-stage1/</guid><description>&lt;h1 id="raft" class="relative group">Raft &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100">&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#raft" aria-label="Anchor">#&lt;/a>&lt;/span>&lt;/h1>&lt;p>This time we are following the &lt;a href="https://raft.github.io/raft.pdf" target="_blank" rel="noreferrer">Raft paper&lt;/a> and implementing the first stage of Raft, which is leader election. We will implement the leader election algorithm in a simple way, without any optimizations.
We will explain all detailed explanation about raft paper in another posts.
Our basic code structure is provided by 6.824.
So we will not provide the code here, but we will explain the main idea of the leader election algorithm.&lt;/p></description></item><item><title>Merge Two Binary Tree</title><link>https://blog.saltfish.org/posts/merge-two-binary-tree/</link><pubDate>Sat, 14 Feb 2026 19:04:39 -0500</pubDate><guid>https://blog.saltfish.org/posts/merge-two-binary-tree/</guid><description>&lt;p>Link &lt;a href="https://leetcode.com/problems/merge-two-binary-trees/description/" target="_blank" rel="noreferrer">Merge Two Binary Trees&lt;/a>&lt;/p>
&lt;h2 id="problem" class="relative group">Problem &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100">&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#problem" aria-label="Anchor">#&lt;/a>&lt;/span>&lt;/h2>&lt;p>You are given two binary trees root1 and root2.&lt;/p>
&lt;p>Imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge the two trees into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of the merged node. Otherwise, the NOT null node will be used as the node of the new tree.&lt;/p></description></item><item><title>Stone Game</title><link>https://blog.saltfish.org/posts/stone-game/</link><pubDate>Fri, 13 Feb 2026 19:46:40 -0500</pubDate><guid>https://blog.saltfish.org/posts/stone-game/</guid><description>&lt;p>Link: &lt;a href="https://leetcode.com/problems/stone-game/" target="_blank" rel="noreferrer">Stone Game&lt;/a>&lt;/p>
&lt;h2 id="problem" class="relative group">Problem &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100">&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#problem" aria-label="Anchor">#&lt;/a>&lt;/span>&lt;/h2>&lt;p>Alice and Bob play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones &lt;code>piles[i]&lt;/code>.&lt;/p>
&lt;p>The objective of the game is to end with the most stones. The total number of stones across all the piles is odd, so there are no ties.&lt;/p></description></item><item><title>Usage of Entry Level GPU</title><link>https://blog.saltfish.org/posts/usage-of-entry-level-gpu/</link><pubDate>Thu, 12 Feb 2026 18:16:43 -0500</pubDate><guid>https://blog.saltfish.org/posts/usage-of-entry-level-gpu/</guid><description>&lt;p>&lt;strong>Our chat system collapsed under 20 concurrent requests&lt;/strong>&lt;/p>
&lt;p>Currently, I&amp;rsquo;m working on a RAG(Retrieval Augmented Generation) project, while most of the process is done by calling api, the only computation intensive part is the reranking process, which is a method to rank the retrieved documents based on their relevance to the query. In this step we called &lt;code>BAAI/bge-reranker-v2-m3&lt;/code> model locally.&lt;/p></description></item><item><title>Split a String in Balanced Strings</title><link>https://blog.saltfish.org/posts/split_a_string_in_balanced_strings/</link><pubDate>Thu, 12 Feb 2026 18:06:47 -0500</pubDate><guid>https://blog.saltfish.org/posts/split_a_string_in_balanced_strings/</guid><description>&lt;p>Problem Link: &lt;a href="https://leetcode.com/problems/split-a-string-in-balanced-strings" target="_blank" rel="noreferrer">Split a String in Balanced Strings&lt;/a>&lt;/p>
&lt;h2 id="problem" class="relative group">Problem &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100">&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#problem" aria-label="Anchor">#&lt;/a>&lt;/span>&lt;/h2>&lt;p>Balanced strings are those that have an equal quantity of &amp;lsquo;L&amp;rsquo; and &amp;lsquo;R&amp;rsquo; characters.&lt;/p>
&lt;p>Given a balanced string &lt;code>s&lt;/code>, split it into some number of substrings such that:&lt;/p>
&lt;p>Each substring is balanced.
Return the maximum number of balanced strings you can obtain.&lt;/p></description></item><item><title>Stone Game II</title><link>https://blog.saltfish.org/posts/stone-game-ii/</link><pubDate>Wed, 11 Feb 2026 16:57:25 -0500</pubDate><guid>https://blog.saltfish.org/posts/stone-game-ii/</guid><description>&lt;h1 id="stone-game-ii" class="relative group">Stone Game II &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100">&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#stone-game-ii" aria-label="Anchor">#&lt;/a>&lt;/span>&lt;/h1>&lt;p>Link: &lt;a href="https://leetcode.com/problems/stone-game-ii/" target="_blank" rel="noreferrer">Stone Game II&lt;/a>&lt;/p>
&lt;h2 id="problem" class="relative group">Problem &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100">&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#problem" aria-label="Anchor">#&lt;/a>&lt;/span>&lt;/h2>&lt;p>Alice and Bob continue their games with piles of stones. There are a number of piles arranged in a row, and each pile has a positive integer number of stones piles[i]. The objective of the game is to end with the most stones.&lt;/p></description></item><item><title>How to use Microsoft AI Foundry with Langchain</title><link>https://blog.saltfish.org/posts/ms-ai-foundry/</link><pubDate>Tue, 10 Feb 2026 14:53:56 -0500</pubDate><guid>https://blog.saltfish.org/posts/ms-ai-foundry/</guid><description>&lt;p>In Microsoft&amp;rsquo;s AI Foundry, it might be a bit tricky to get it work with Langchain at first.
What need to be specified is different model provider has different service endpoint and need to use different class to call the API.&lt;/p>
&lt;h2 id="azure-openai" class="relative group">Azure OpenAI &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100">&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#azure-openai" aria-label="Anchor">#&lt;/a>&lt;/span>&lt;/h2>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-python" data-lang="python">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">from&lt;/span> langchain_openai &lt;span style="color:#f92672">import&lt;/span> AzureChatOpenAI
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>llm &lt;span style="color:#f92672">=&lt;/span> AzureChatOpenAI(
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> azure_deployment&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;gpt-5.2-chat&amp;#34;&lt;/span>, 
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> azure_endpoint&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;https://&amp;lt;your-service&amp;gt;.cognitiveservices.azure.com/&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> api_version&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;2024-05-01-preview&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> api_key&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;&amp;lt;your-api-key&amp;gt;&amp;#34;&lt;/span>, 
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> max_tokens&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#ae81ff">4096&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>&lt;code>api_key&lt;/code> use &lt;code>AZURE_OPENAI_KEY&lt;/code> environment variable or pass it directly&lt;/li>
&lt;li>&lt;code>azure_endpoint&lt;/code> use &lt;code>AZURE_OPENAI_ENDPOINT&lt;/code> environment variable or pass it directly&lt;/li>
&lt;/ul>
&lt;h2 id="anthropic" class="relative group">Anthropic &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100">&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#anthropic" aria-label="Anchor">#&lt;/a>&lt;/span>&lt;/h2>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-python" data-lang="python">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">from&lt;/span> langchain_anthropic &lt;span style="color:#f92672">import&lt;/span> AnthropicChat
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>llm &lt;span style="color:#f92672">=&lt;/span> AnthropicChat(
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> base_url&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;https://&amp;lt;your-service&amp;gt;.services.ai.azure.com/anthropic/&amp;#34;&lt;/span>, 
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> api_key&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;&amp;lt;your-api-key&amp;gt;&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> model&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;claude-sonnet-4-5&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>&lt;code>api_key&lt;/code> use &lt;code>ANTHROPIC_API_KEY&lt;/code> environment variable or pass it directly&lt;/li>
&lt;li>&lt;code>base_url&lt;/code> use &lt;code>ANTHROPIC_API_URL&lt;/code> then &lt;code>ANTHROPIC_BASE_URL&lt;/code> environment variable or pass it&lt;/li>
&lt;/ul>
&lt;h2 id="aichat" class="relative group">AIChat &lt;span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100">&lt;a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style="text-decoration-line: none !important;" href="#aichat" aria-label="Anchor">#&lt;/a>&lt;/span>&lt;/h2>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-python" data-lang="python">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">from&lt;/span> langchain_azure_ai &lt;span style="color:#f92672">import&lt;/span> AzureAIChatCompletionModel
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>llm &lt;span style="color:#f92672">=&lt;/span> AzureAIChatCompletionModel(
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> azure_endpoint&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;https://&amp;lt;your-service&amp;gt;.services.ai.azure.com/models&amp;#34;&lt;/span>,
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> azure_deployment&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;gpt-5.2-chat&amp;#34;&lt;/span>, 
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> api_version&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;2024-05-01-preview&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>Need to set &lt;code>AZURE_AI_ENDPOINT&lt;/code> to &lt;code>https://&amp;lt;your-service&amp;gt;.services.ai.azure.com/models&lt;/code>&lt;/li>
&lt;li>API key use &lt;code>AZURE_AI_CREDENTIAL&lt;/code> environment variable&lt;/li>
&lt;/ul>
&lt;p>Actually, this method is not recommended, because it does not support some features and have poor compatibility to the langchain ecosystem.&lt;/p></description></item><item><title>My First Post</title><link>https://blog.saltfish.org/posts/my-first-post/</link><pubDate>Mon, 09 Feb 2026 22:47:43 -0500</pubDate><guid>https://blog.saltfish.org/posts/my-first-post/</guid><description>&lt;p>Start using hugo to write down some tehc blogs!&lt;/p>
&lt;p>I will try my best to keep it 100% human written!&lt;/p></description></item></channel></rss>