Archive
A journey through everything I've published, organized over time.
This article details the plugin architecture design, technical implementation, challenges encountered, and the final decision to only plugin-ize the emoji feature while keeping other complex features built-in for Kime input method
This article describes my experiment designing and training a compact Transformer model for mobile input method predictive text functionality. I built a decode-only Transformer with 8192 vocabulary words and approximately 17MB in size after int8 quantization, addressing challenges in data quality, model parameter optimization, and implementing N-gram algorithm fusion for improved predictions.
Unable to find an input method that met my needs, I developed my own Android input method based on the Rime engine, supporting Wubi-Pinyin mixed input and radical display functionality.
Implementing a system to control home ambient lights using Rust embedded development, ESP32 microcontroller, and Xiao AI through MQTT communication with Bemfa Cloud platform.
Exploring the limitations of Tauri when developing a transparent, click-through desktop pet application with 3D models, particularly regarding mouse event handling when cursor events are ignored.
This article introduces how to use Rust for ADC analog-to-digital conversion on ESP32-S3 to read data from an XY axis joystick sensor. The article details the ADC functionality of ESP32-S3, pin configuration, code implementation (including X/Y axis analog signal reading and Z axis button detection), and how to use the esp-hal library for hardware programming.
This article introduces how to use Rust and the Ratatui library on ESP32-S3 to build a text-based user interface (TUI) for ST7789 screens, and solves common issues with fonts and display configuration.
Exploring solutions to fix screen flickering issues when redrawing on ST7789 displays using Rust embedded development, including attempts to adjust SPI clock frequency and reduce refresh area.
Guide on displaying images on ST7789 screens using Rust embedded development, including image format conversion techniques from common formats to supported formats like BMP, TGA, and QOI.
This article introduces how to display Chinese characters in resource-constrained embedded environments, especially using the embedded-graphics library. Since the library doesn't support Chinese characters by default, the article details how to use BDF font format and eg-bdf tool to generate and use Chinese font libraries, providing specific code examples and solutions.
This article details how to use Rust on ESP32S3 to read DHT11 temperature and humidity sensor data and display it on an ST7789 TFT LCD screen. It covers implementation in both C and Rust languages, with special attention to multi-core task allocation in Rust, SPI bus configuration, screen driver initialization, and avoiding screen display issues. The article also provides complete code examples and analysis of key technical points.
Documentation on how to sign Git commits with GPG, including steps for generating GPG key pairs, associating them with your GitHub account, and verifying signatures.
Detailed explanation of implementing DHT11 temperature and humidity sensor reading using Rust programming language, including single-bus communication protocol analysis, timing diagrams, and code implementation steps.
In-depth comparison of C and Rust implementations for DHT11 temperature and humidity sensor on ESP32S3 development board, detailing slow response issues encountered with the C version and the impact of CPU task scheduling, providing complete code examples and debugging experience sharing.
This article compares the implementation of controlling a WS2812 LED with ESP32-S3 using both C and Rust languages. It covers hardware setup with GPIO 48, toolchain configuration for both languages, and provides complete code examples for each approach. The comparison highlights differences in development experience, library usage, and performance considerations between traditional ESP-IDF C development and modern Rust embedded development.
Sharing experiences and insights on implementing Tencent's lightweight translation model hy-mt-1.8b using the Candle framework in Rust, including observations on its simple architecture and GPU execution.
Documenting issues encountered when running the Yolov10 model on GPU using the Rust Candle framework, specifically CUDA driver errors related to the topk function implementation.
Detailed guide on implementing a circular progress bar component in the Rust GPUI framework, including using canvas API for advanced graphics drawing and supporting both animated loading and progress display modes.
Exploring the lack of 3D operators in the Candle framework and how to simulate 3D convolution using 2D convolutions, particularly for handling video data tasks with time-dimension constraints.
Documenting equivalent operations between PyTorch and Rust Candle, including implementations of scaled dot-product attention (SDPA) and linspace functions with code examples.
This article introduces methods to significantly improve performance by replacing the default memory allocator when deploying Rust projects using musl libc, and provides specific performance comparison test data.
Exploring the similarities between GPUI's API and TailwindCSS, focusing on atomic design approach for UI styling, ElementId usage, and the differences between Render and RenderOnce traits.
Exploring useful operations with Termux on Android, including enabling file system access, setting up SSH service, and troubleshooting ADB connection issues for file transfer.
This article explores the core issues with the Tauri framework, particularly cross-platform consistency problems and its differentiated positioning compared to Electron, while also analyzing potential solutions.
A detailed introduction to deploying YOLOv10 object detection model in Rust environment using ONNX Runtime, including key steps such as model export, preprocessing, inference, and post-processing.
This article details how to use the Tauri framework to develop menu bar applications on macOS, including key technical implementations such as creating panel windows, system tray icons, panel positioning, and show/hide controls.
This article explores the technical challenges of implementing screenshot functionality in the Tauri framework, including cross-platform compatibility issues and data transmission efficiency problems, and provides corresponding solutions.
In-depth exploration of special handling on macOS platform when developing screenshot applications with Tauri, including fullscreen display issues, clipboard operation anomalies and solutions, as well as key technical details such as keyboard shortcuts and preview function optimization.
This article introduces the practical experience of developing a cross-platform file search tool using the Tauri framework, explores how to avoid performance issues caused by directly scanning the file system, analyzes the technical principles of the Everything tool on the Windows platform, and shares the implementation of an efficient indexing solution based on the MFT table of the NTFS file system.
This article explores several approaches for implementing plugin-based development in Tauri desktop applications, including technologies such as Webview, iframe, and Shadow DOM. It analyzes the pros and cons and applicable scenarios of each approach, and delves into how to build a secure sandbox environment for loading third-party untrusted resources.
This article shares some practical issues and solutions encountered when developing desktop applications with Tauri, including dynamic window detection, menu bar hiding and custom window control, handling differences across three platforms (Windows/macOS/Linux), and a comparison of development experiences between Tauri and Dioxus.
This article introduces how to properly handle duplicate window detection issues during dynamic window creation when developing desktop applications with Tauri, avoiding program crashes caused by duplicate window labels, and provides corresponding error handling solutions.
This article introduces the concept and implementation of the MCP (Model Context Protocol), explains in detail how to develop an MCP service using Rust, demonstrates the implementation process of a crate documentation query tool through actual code examples, and introduces how to configure and use an MCP Server in VS Code.
This article delves into the technical details of developing unconventional window applications (such as screenshot tools, floating windows, desktop lyrics, etc.) using Tauri v2 and Rust, including multi-window management, system permission requests (especially macOS ScreenRecording permission), and permission-window association configuration.
Exploring how to use bit masks (or bit flags) for efficient conditional checks in Rust, particularly useful for managing multiple state flags with high performance and low memory usage.
Exploring how to use JNI (Java Native Interface) to enable interaction between Java/JVM platform languages and Rust, including type mappings and implementation details.
Wrapping up the series on building a handwriting input method from scratch, discussing the complete implementation, challenges faced, and lessons learned throughout the project.
Deploying the trained handwriting recognition model to WebAssembly using Rust, enabling efficient client-side recognition in web browsers.
Implementation of handwriting recognition model inference using Rust Candle, focusing on optimizing performance and efficiency for real-time applications.
Detailed guide on processing the CASIA-HWDB dataset and training a handwriting recognition model for Chinese characters using PyTorch, including dataset preprocessing and model implementation.
Introduction to building a handwriting input method for Chinese characters from scratch, covering preparation steps, dataset selection, and technical approach using PyTorch for training, Rust Candle for inference, and WASM for deployment.
This article explains how to use FUSE to access a zip file as if it were a folder.
This article summarizes common security pitfalls in Rust development, including numeric conversions, integer overflows, array boundary access, oversized array handling, misuse of `unsafe`, time-of-check to time-of-use (TOCTOU) attacks, FFI risks, and circular references. By correctly using type-safe methods, limiting resource sizes, reducing the scope of `unsafe`, combining atomic operations, and managing memory, these issues can be effectively avoided.
This article introduces methods for converting HEIF/HEIC format images, which suffer from poor compatibility due to patent issues related to HEVC technology. In Rust, HEIF images can be decoded using `libheif-rs` and converted to other formats via the `image` crate. On the frontend, similar functionality can be achieved with `heic-convert`, focusing on constructing buffer data that meets requirements for format conversion.
This article introduces some uncommon but practical syntax features in Rust, including unions (`union`), slice pattern matching, raw pointer operations, inline assembly (`asm!`), extern blocks, loop return values, the `@` in match patterns, labeled loop control, never type (`!`), `#[repr]` attributes, and diverse macro invocation methods. These features can significantly enhance development efficiency and code flexibility in specific scenarios.
This article introduces how to implement RMBG (Remove Image Background) inference using Rust. By loading an ONNX model, it preprocesses the input image (resize, normalization), completes the model inference to generate a mask image, and uses the mask to remove the background or blend transparency. Finally, it optimizes the mask denormalization algorithm to improve background purity, suitable for use in fields like posters, games, etc.
This article summarizes some miscellaneous features in the Rust Candle framework, including custom implementations of `masked_fill`, broadcasting mechanism (`broadcast_add`), matrix multiplication (`matmul` vs. element-wise multiplication), and an alternative implementation of the module container `ModuleList`. By comparing with PyTorch, it analyzes the differences and solutions in tensor operations and model loading in Candle.
This article compares three methods of handling large files in Rust: the standard library, Tokio, and memory mapping (mmap) in terms of memory usage. The standard library, which loads files all at once, consumes the most memory. Tokio significantly reduces memory usage through chunked optimization, while mmap, leveraging memory-mapped technology, uses almost no additional memory, offering the best performance.
This article compares the similarities and differences between Rust Candle and PyTorch in the implementation of neural network layers, covering sequential containers, convolutional layers (1D/2D and transposed convolution), pooling layers (max pooling and average pooling), and common activation functions. It focuses on analyzing the correspondence between the two in terms of functionality, parameter configuration, and usage, and points out that Candle does not yet support some features such as 3D convolution.
This article compares the implementation of common neural network layers in Rust Candle and PyTorch, including normalization layers (BatchNorm, LayerNorm, RMSNorm), recurrent layers (LSTM, GRU), Transformer, linear layers, Dropout layers, embedding layers, and upsampling layers. It summarizes the functional correspondence and differences between the two frameworks and highlights Candle's support for large model inference scenarios.
This article compares the implementation differences between Pytorch and Rust Candle framework for tensor reduction operations, covering common operations such as summation, mean, maximum, minimum, etc.
This article compares the implementation differences between Pytorch and Rust Candle framework for pointwise tensor operations, covering common operations such as absolute value, trigonometric functions, exponentials, etc.
This article compares the implementation differences between Rust Candle and Pytorch in tensor indexing, slicing, concatenation, mutation, and other operations, covering common tensor operations and their equivalent methods.
This article introduces the equivalent implementations of basic tensor operations between Rust Candle and Pytorch, including tensor initialization, shape manipulation, arithmetic operations (addition, subtraction, multiplication, division), and accelerator support. It is suitable for beginners to refer to.
This article introduces how to deploy models using Rust and ONNX Runtime, taking ResNet50 as an example, detailing the entire process of model export, loading, data preprocessing, inference, and post-processing, while analyzing its advantages and disadvantages.
Rust 1.85.0 introduces new rules for RPIT (Return Position Impl Trait) lifetime capture. In Rust 2024, all generic parameters (including lifetimes) within scope are implicitly captured by default, without explicit declaration. Developers can use the `use<...>` syntax to precisely control which parameters are captured, avoiding unintended captures. This simplifies code and reduces errors, enhancing expressiveness. The new rules make RPIT usage more intuitive and safer.
Choosing Web frameworks in different programming languages, analyzing the pros and cons of 'comprehensive' and 'elegant' frameworks in domestic and international development environments, and providing recommendations based on personal experience.
This article explores how to simulate function overloading in Rust, where functions with the same name can be automatically dispatched based on parameter types or counts. Although Rust does not directly support function overloading, several techniques can achieve similar effects. The article details two methods and discusses their pros and cons.
Be cautious, you might encounter them too.
Using Rust + WASM for npm library development is an excellent choice.
The main advantages of Rust are not just performance and safety. There are other aspects that cannot be ignored.
Building efficient LLM applications using Qwen and knowledge base with RAG
MessagePack is an efficient binary serialization format. It supports multi-language data exchange. Compared to JSON, it is more compact and faster in processing.
A simple implementation of operator overloading in Rust to achieve tensor addition operations.
An advanced tutorial on converting PyTorch models to Rust Candle
Achieve single binary distribution of your application
Rust development tips
A guide on converting PyTorch models to Rust Candle models
An introduction to using Pingora
How to use declarative macros
In early versions of Rust, there were two main pointer types: Managed Box and Owned Box.
Rate limiting is a critical measure to protect systems from overload, especially when dealing with sudden traffic or malicious attacks. The Leaky Bucket and Token Bucket algorithms are two commonly used rate limiting strategies, each with its own characteristics and application scenarios. GCRA (Generic Cell Rate Algorithm) is an optimized version of the Leaky Bucket algorithm.
One of the unique aspects of axum is that it does not have its own custom middleware system but instead integrates with tower. This means that the tower ecosystem and tower-http middleware work seamlessly with axum.
The 1.5 version of Fish Speech brings several improvements and new features. This article will conduct an in-depth review of this new version and compare it with CosyVoice in detail to help readers understand the strengths and weaknesses of both products.
How to implement the MobileNetV2 neural network using Rust and the Candle framework, including the construction of the model structure and the implementation of the forward pass.
How to use Rust to bind a C library, using pdfio as an example, detailing the entire process from installing the C library, generating binding code, to encapsulation and testing.
Since lllyasviel announced the release of IC-Light V2 based on Flux in October, it has now evolved into the Vary version.
How to redesign a model to achieve video stream recognition without using any 3D operators and 5D data formats, including model design approach, two-stage training method, and loss function design
The Rust community has initiated a standard library verification competition with the primary goal of leveraging the collective power of the community to thoroughly verify the safety of the Rust standard library.