line

Code Quality Improvement Techniques Part (opens in new tab)

Effective code design often involves shifting the responsibility of state verification from the caller to the receiving object. By internalizing "if-checks" within the function that performs the action, developers can reduce boilerplate, prevent bugs caused by missing preconditions, and simplify state transitions. This encapsulation ensures that objects maintain their own integrity while providing a cleaner, more intuitive API for the rest of the system. ### Internalizing State Verification * Instead of the caller using a pattern like `if (!receiver.isState()) { receiver.doAction() }`, the check should be moved inside the `doAction` method. * Moving the check inside the function prevents bugs that occur when a caller forgets to verify the state, which could otherwise lead to crashes or invalid data transitions. * This approach hides internal state details from the caller, simplifying the object's interface and focusing on the desired outcome rather than the prerequisite checks. * If "doing nothing" when a condition isn't met is non-obvious, developers should use descriptive naming (e.g., `markAsFriendIfNotYet`) or clear documentation to signal this behavior. ### Leveraging Return Values for Conditional Logic * When a caller needs to trigger a secondary effect—such as showing a UI popup—only if an action was successful, it is better to return a status value (like a `Boolean`) rather than using higher-order functions. * Passing callbacks like `onSucceeded` into a use case can create unnecessary dependency cycles and makes it difficult for the caller to discern if the execution is synchronous or asynchronous. * Returning a `Boolean` to indicate if a state change actually occurred allows the caller to handle side effects cleanly and sequentially. * To ensure the caller doesn't ignore these results, developers can use documentation or specific compiler annotations to force the verification of the returned value. To improve overall code quality, prioritize "telling" an object what to do rather than "asking" about its state and then acting. Centralizing state logic within the receiver not only makes the code more robust against future changes but also makes the intent of the calling code much easier to follow.

google

Deeper insights into retrieval augmented generation: The role of sufficient context (opens in new tab)

Google Research has introduced "sufficient context" as a critical new metric for evaluating Retrieval Augmented Generation (RAG) systems, arguing that simple relevance is an inadequate measure of performance. By focusing on whether a retrieved context contains all the necessary information to definitively answer a query, researchers developed an LLM-based autorater that classifies context sufficiency with 93% accuracy. This framework reveals that many RAG failures, specifically hallucinations, occur because models fail to abstain from answering when information is incomplete or contradictory. ## Defining and Measuring Sufficient Context * Sufficient context is defined as containing all information necessary to provide a definitive answer, while insufficient context is relevant but incomplete, inconclusive, or contradictory. * The researchers developed an "autorater" using Gemini 1.5 Pro, utilizing chain-of-thought prompting and 1-shot examples to evaluate query-context pairs. * In benchmarks against human expert "gold standard" labels, the autorater achieved 93% accuracy, outperforming specialized models like FLAMe (fine-tuned PaLM 24B) and NLI-based methods. * Unlike traditional metrics, this approach does not require ground-truth answers to evaluate the quality of the retrieved information. ## RAG Failure Modes and Abstention Challenges * State-of-the-art models (Gemini, GPT, Claude) perform exceptionally well when provided with sufficient context but struggle when context is lacking. * The primary driver of hallucinations in RAG systems is the "abstention" problem, where a model attempts to answer a query based on insufficient context rather than stating "I don't know." * Analyzing model responses through the lens of sufficiency allows developers to distinguish between "knowledge" (the model knows the answer internally) and "grounding" (the model correctly uses the provided context). ## Implementation in Vertex AI * The insights from this research have been integrated into the Vertex AI RAG Engine via a new LLM Re-Ranker feature. * The re-ranker prioritizes retrieved snippets based on their likelihood of providing a sufficient answer, significantly improving retrieval metrics such as normalized Discounted Cumulative Gain (nDCG). * By filtering for sufficiency during the retrieval phase, the system reduces the likelihood that the LLM will be forced to process misleading or incomplete data. To minimize hallucinations and improve the reliability of RAG applications, developers should move beyond keyword-based relevance and implement re-ranking stages that specifically evaluate context sufficiency. Ensuring that an LLM has the "right" to answer based on the provided data—and training it to abstain when that data is missing—is essential for building production-grade generative AI tools.

google

Differential privacy on trust graphs (opens in new tab)

Researchers from Google have introduced Trust Graph Differential Privacy (TGDP), a framework that models privacy based on varying trust relationships between users represented as vertices in a graph. By allowing users to share data with trusted neighbors who then aggregate and privatize the information, TGDP bridges the gap between the highly accurate central DP model and the high-privacy local DP model. This approach enables more practical and accurate data analysis in scenarios where users exhibit nuanced privacy preferences rather than binary trust assumptions. ## Defining Trust Graph DP * The model represents users as vertices and mutual trust as edges, ensuring that a user’s data remains statistically indistinguishable to any party they do not trust. * This guarantee holds even if non-trusted parties pool their data or collaborate with a user's trusted neighbors to attempt re-identification. * TGDP serves as a mathematical interpolation: a "star graph" topology corresponds to the central DP model, while a fully unconnected graph corresponds to the local DP model. ## Private Aggregation and Error Metrics * The research evaluates TGDP through the fundamental task of private aggregation, where the goal is to estimate the sum of all users' private values ($\Sigma x_i$). * Accuracy is quantified using mean-squared error, allowing researchers to establish theoretical upper and lower bounds for algorithm performance. * These bounds demonstrate that the utility of a privacy-preserving algorithm is directly tied to the specific structure of the trust relationships within the network. ## The Dominating Set Algorithm * The proposed algorithm utilizes the concept of a "dominating set"—a subset of users $T$ such that every user in the graph is either in $T$ or adjacent to someone in $T$. * In this mechanism, each user sends their raw data to a trusted neighbor within the dominating set. * The members of the dominating set aggregate the data they receive and add specific statistical noise to satisfy differential privacy before sharing the results. * This method reduces the total noise required compared to the local model, as the number of noise-adding entities is limited to the size of the dominating set rather than the entire population. By leveraging existing trust networks, TGDP provides a rigorous way to optimize the trade-off between privacy and utility. This framework suggests that identifying small dominating sets within a community can significantly improve the accuracy of data analytics and machine learning without requiring a single, universally trusted central curator.

line

How to evaluate AI-generated images? (opens in new tab)

LY Corporation is developing a text-to-image pipeline to automate the creation of branded character illustrations, aiming to reduce the manual workload for designers. The project focuses on utilizing Stable Diffusion and Flow Matching models to generate high-quality images that strictly adhere to specific corporate style guidelines. By systematically evaluating model architectures and hyperparameters, the team seeks to transform subjective image quality into a quantifiable and reproducible technical process. ### Evolution of Image Generation Models * **Diffusion Models:** These models generate images through a gradual denoising process. They use a forward process to add Gaussian noise via a Markov chain and a reverse process to restore the original image based on learned probability distributions. * **Stable Diffusion (SD):** Unlike standard diffusion that operates in pixel space, SD works within a "latent space" using a Variational Autoencoder (VAE). This significantly reduces computational load by denoising latent vectors rather than raw pixels. * **SDXL and SD3.5:** SDXL improves prompt comprehension by adding a second text encoder (CLIP-G/14). SD3.5 introduces a major architectural shift by moving from diffusion to "Flow Matching," utilizing a Multimodal Diffusion Transformer (MMDiT) that handles text and image modalities in a single block for better parameter efficiency. * **Flow Matching:** This approach treats image generation as a deterministic movement through a vector field. Instead of removing stochastic noise, it learns the velocity required to transform a simple probability distribution into a complex data distribution. ### Core Hyperparameters for Output Control * **Seeds and Latent Vectors:** The seed is the integer value that determines the initial random noise. Since Stable Diffusion operates in latent space, this noise is essentially the starting latent vector that dictates the basic structure of the final image. * **Prompts:** Textual inputs serve as the primary guide for the denoiser. Models are trained on image-caption pairs, allowing the U-Net or Transformer blocks to align the visual output with the user’s descriptive intent. * **Classifier-Free Guidance (CFG):** This parameter adjusts the weight of the prompt's influence. It calculates the difference between noise predicted with a prompt and noise predicted without one (or with a negative prompt), allowing users to control how strictly the model follows the text instructions. ### Practical Recommendation To achieve consistent results that match a specific brand identity, it is insufficient to rely on prompts alone; developers should implement automated hyperparameter search and black-box optimization. Transitioning to Flow Matching models like SD3.5 can provide a more deterministic generation path, which is critical when attempting to scale the production of high-quality, branded assets.

google

Bringing 3D shoppable products online with generative AI (opens in new tab)

Google has developed a series of generative AI techniques to transform standard 2D product images into immersive, interactive 3D visualizations for online shopping. By evolving from early neural reconstruction methods to state-of-the-art video generation models like Veo, Google can now produce high-quality 360-degree spins from as few as three images. This progression significantly reduces the cost and complexity for businesses to create shoppable 3D experiences at scale across diverse product categories. ## First Generation: Neural Radiance Fields (NeRFs) * Launched in 2022, this initial approach utilized NeRF technology to synthesize novel views and 360° spins, specifically for footwear on Google Search. * The system required five or more images and relied on complex sub-processes, including background removal, XYZ prediction (NOCS), and camera position estimation. * While a breakthrough, the technology struggled with "noisy" signals and complex geometries, such as the thin structures found in sandals or high heels. ## Second Generation: View-Conditioned Diffusion * Introduced in 2023, this version addressed previous limitations by using a diffusion-based architecture to predict unseen viewpoints from limited data. * The model utilized Score Distillation Sampling (SDS), which compares rendered 3D models against generated targets to iteratively refine parameters for better realism. * This approach allowed Google to scale 3D visualizations to the majority of shoes viewed on Google Shopping, handling more diverse and difficult footwear styles. ## Third Generation: Generalizing with Veo * The current advancement leverages Google’s Veo video generation model to transform product images into consistent, high-fidelity 360° videos. * By training on millions of synthetic 3D assets, Veo captures complex interactions between light, texture, and geometry, making it effective for shiny surfaces and diverse categories like electronics and furniture. * This method removes the need for precise camera pose estimation, increasing reliability across different environments. * While the model can generate a 3D representation from a single image by "hallucinating" missing details, using three images significantly reduces errors and ensures high-fidelity accuracy. These technological milestones mark a shift from specialized 3D reconstruction toward generalized AI models that make digital products feel tangible and interactive for consumers.

line

Code Quality Improvement Techniques Part 1 (opens in new tab)

Maintaining a clear separation of concerns between software layers requires avoiding implicit dependencies where one layer relies on the specific implementation details of another. When different components share "hidden" knowledge—such as a repository fetching extra data specifically to trigger a UI state—the code becomes fragile and difficult to maintain. By passing explicit information through data models, developers can decouple these layers and ensure that changes in one do not inadvertently break the other. ### The Risks of Implicit Layer Dependency When layers share implicit logic, such as a repository layer knowing the specific display requirements of the UI, the architecture becomes tightly coupled and prone to bugs. * In the initial example, the repository fetches `MAX + 1` items specifically because the UI needs to display a "+" sign if more items exist. * This creates a dependency where the UI logic for displaying counts relies entirely on the repository's internal fetching behavior. * Code comments that explain one layer's behavior in the context of another (e.g., `// +1 is for the UI`) are a "code smell" indicating that responsibilities are poorly defined. ### Decoupling Through Explicit State The most effective way to separate these concerns is to modify the data model to carry explicit state information, removing the need for "magic numbers" or leaked logic. * By adding a boolean property like `hasMoreItems` to the `StoredItems` model, the repository can explicitly communicate the existence of additional data. * The repository handles the logic of fetching `limit + 1`, determining the boolean state, and then truncating the list to the correct size before passing it up. * The UI layer becomes "dumb" and only reacts to the provided data; it no longer needs to know about the `MAX_COUNT` constant or the repository's fetching strategy to determine its display state. ### Strategic Placement of Logic and Constants Determining where constants like `ITEM_LIST_MAX_COUNT` should reside is a key architectural decision that impacts code reuse and clarity. * **Business Logic Layer:** Placing such constants in a dedicated Domain or Use Case layer is often the best approach for maintaining a clean architecture. * **Model Classes:** If a separate logic layer is too complex for the project scale, the constant can be housed within the model class (e.g., using a companion object in Kotlin). * **Dependency Direction:** Developers must ensure that functional logic does not leak into generic data models, as this can create confusing dependencies where a general-purpose model becomes tied to a specific feature's algorithm. Effective software design relies on components maintaining a "proper distance" from one another. To improve code quality, favor explicit flags and clear data contracts over implicit assumptions about how different layers of the stack will interact.

google

A new light on neural connections (opens in new tab)

Google and the Institute of Science and Technology Austria (ISTA) have developed LICONN, the first light-microscopy-based method capable of comprehensively mapping neurons and their connections in brain tissue. This approach overcomes the traditional reliance on expensive electron microscopy by utilizing physical tissue expansion and advanced machine learning to achieve comparable resolution and accuracy. The researchers successfully validated the technique by reconstructing nearly one million cubic microns of mouse cortex, demonstrating that light microscopy can now achieve "dense" connectomics at scale. ## Overcoming Resolution and Cost Barriers * Connectomics has traditionally relied on electron microscopy (EM) because it offers nanometer-scale resolution, whereas standard light microscopy is limited by the diffraction limit of visible light. * Electron microscopes cost millions of dollars and require specialized training, restricting high-level neuroscience research to wealthy, large-scale institutions. * LICONN provides a more accessible alternative by utilizing standard light microscopy equipment already found in most life science laboratories. ## Advanced Tissue Expansion and Labeling * The project uses a specialized expansion microscopy protocol where brain tissue is embedded in hydrogels that absorb water and physically swell. * The technique employs three different hydrogels to create interweaving polymer networks that expand the tissue by 16 times in each dimension while preserving structural integrity. * A whole-protein labeling process is used to provide the necessary image contrast, allowing for the tracing of densely packed neurites and the detection of synapses. ## Automated Reconstruction and Validation * Google applied its established suite of machine learning and image analysis tools to automate the reconstruction of the expanded tissue samples. * The team verified the accuracy of the method by tracing approximately 0.5 meters of neurites within mouse hippocampus tissue, confirming results comparable to electron microscopy. * In a large-scale validation, the researchers provided an automated reconstruction of a volume of mouse cortex totaling nearly one million cubic microns. ## Integration of Molecular and Structural Data * One of LICONN’s primary advantages over electron microscopy is its ability to capture multiple light wavelengths simultaneously. * Researchers can use fluorescent markers to visualize specific proteins, neurotransmitters, and other molecules within the structural map. * This dual-layered approach allows scientists to align molecular information with physical neuronal pathways, offering new insights into how brain circuits drive behavior and cognition. LICONN represents a significant shift in neuroscience by democratizing high-resolution brain mapping. By replacing expensive hardware requirements with sophisticated chemical protocols and machine learning, this method enables a wider range of laboratories to contribute to the global effort of mapping the brain’s intricate wiring.

discord

STAR WARS™ Makes Its Way to Discord (opens in new tab)

Discord has partnered with Lucasfilm to introduce a new Star Wars themed collection of Avatar Decorations and Profile Effects to the platform's Shop. This collaboration draws inspiration from iconic cinematic moments, such as Darth Vader’s appearance in *Rogue One*, to offer high-quality customization options for fans. The release allows users to personalize their profiles with animations that celebrate the legacy of both the light and dark sides of the Force. **Collaborative Design and Inspiration** * The collection was developed through a direct collaboration between Discord’s in-house creative team and Lucasfilm to ensure authentic representation of the franchise. * Visual designs are intended to evoke specific emotional responses, such as the tension of a Sith Lord’s presence or the inspiration of heroic Jedi. * The "Darth Vader Arrives" profile effect specifically references the ominous red glow of the hallway scene from *Rogue One: A Star Wars Story*. **Available Decorations and Effects** * **Avatar Decorations**: The shop now includes specific frame animations such as two variants of Lightsabers, R2-D2 on Tatooine, a Space Battle, the Millennium Falcon Hyperdrive, Yoda on Dagobah, and a BB-8 animation. * **Profile Effects**: These full-profile animations feature specialized visuals including two variants of Lightsaber Mastery, Entering Hyperspace, and the Darth Vader Arrives effect. * These items are designed to fit seamlessly over standard Discord profile layouts to enhance user presence in group chats and servers. **Platform Integration and Access** * The Star Wars collection is accessible via the Discord Shop on desktop or through the "You" tab on the mobile application. * Discord Nitro members receive a specialized discount on all items within the collection, and these discounts also apply when purchasing decorations or effects as gifts for others. * Users requiring technical assistance with these new assets can refer to the platform's dedicated support documentation for troubleshooting. To explore these new customization options, users should navigate to the Discord Shop on their preferred device. Nitro subscribers should ensure they are logged in before purchasing to take advantage of the member-only pricing available for this limited collection.