Track communities in one place and catch the highest-signal posts faster.
r/technology +2
Weekr/machinelearning · u/unknown · 11h
Is KV Cache in a high dimensional vector space? [D]
I've been doing some research on this question: At inference time a large part of a model's working memory lives in the KV cache, plus whatever external memory the harness bolts on. I've been poking at the storage-and-retrieval side of this, treating that cache as an index, and what stands out is that it isn't a flat list. It's a structured set of vectors with a navigable geometry, since the keys carry the model's learned sense of what relates to what. Because that geometry is navigable, attention over it is really a similarity search: the query scores against the stored keys and blends the matching values. Full attention just runs that search exhaustively, scanning everything on every step. Full attention effectively searches that geometry exhaustively. Every query scores broadly against the available keys and retrieves from the corresponding values. Once you stop treating the KV cache as a flat array and start treating it as a search space, indexing becomes possible. That means you can organize old KV into regions, route a query toward likely regions, and only run local attention over a subset. The interesting part is that relevance is not uniformly distributed. Queries tend to concentrate on relatively small neighborhoods of old context. So the engineering question becomes less “how do I store all of this?” and more “how do I navigate to the right part cheaply?” I'm new here and don't want to break rules around self promotion or span so not posting any links atm. Would be cool to get other peoples thoughts on this. submitted by /u/Electrical_Offer5667 [link] [comments]
↑ 0 · 💬 0
r/machinelearning · u/unknown · 16h
Mapping intrinsic rank and informational gravity in complex tabular data: I developed a non-parametric, model-agnostic, information-theoretic diagnostic to bypass the limits of linear, rank, and Euclidean baselines. [R]
Links: Preprint: https://doi.org/10.5281/zenodo.22028087 Entropic Scree Function v1.0.0 / GitHub: https://github.com/tjleestjohn/Entropic-Scree TL;DR: Standard PCA fundamentally fractures non-linear dependencies into "Spurious Orthogonal Dimensions," drastically overestimating the true rank of complex tabular systems. Meanwhile, non-linear alternatives like Kernel PCA and Euclidean nearest-neighbor estimators suffer structural collapse when generative roots are entangled or sparse. I’m sharing the methodology and code here for anyone dealing with these complex tabular data nightmares. The method and open-source framework use Normalized Mutual Information to compress spurious expansions back towards their true generative roots. It also Maps the underlying "informational gravity" of the roots, offering insight into overall average stability, as well as which specific roots can be most reliably extracted; Estimates the data's overall ratio of shared signal to unshared idiosyncratic informational variance (noise); Serves as a powerful exploratory map that separates unrelated clusters of variables, allowing you to easily identify decoupled sub-networks. A Modern ML Architectural Blueprint: Far beyond a mere update to legacy factor analysis workflows, identifying this exact intrinsic rank allows you to explicitly size neural bottlenecks for downstream non-parametric manifold extractors (like autoencoders). The Problem with Standard Baselines: When trying to map the intrinsic dimensionality of a dataset, standard practice usually dictates reaching for PCA, its non-linear kernel extensions, or Euclidean nearest-neighbor estimators. But if your tabular environment has mixed data types, heavy non-linearities, entangled roots, or more features than samples ($m > N$), these established baselines don't just lose precision. They suffer a structural collapse. The core issue with our standard baselines: Standard PCA drives Dimensional Inflation. Because it only measures linear covariance, it perceives a polynomial expansion or a non-linear interaction (like $X_1 X_2$) as an entirely independent variable. It is forced to fabricate new, spurious orthogonal dimensions to map them. Kernel PCA (RBF) suffers Structural Collapse. Projecting into a Hilbert space doesn't fix this. KPCA artificially folds even-polynomials into independent axes. Furthermore, because its infinite-dimensional space lacks a finite-sample boundary, sparse combinatorial noise smears into an elevated tail that obscures the structural elbow. If the underlying generative roots are even mildly entangled, KPCA suffers a total structural collapse. Topological Estimators (Euclidean) fail in sparse regimes. Estimators like TWO-NN or MLE rely on Euclidean distance metrics. In asymmetric, feature-rich environments ($m > N$), they suffer from distance concentration (the ratio between nearest and farthest neighbors converges to 1). This renders local neighborhood calculations structurally degenerate across mixed-data margins. Introducing the Entropic Scree: To solve this, I built the Entropic Scree. It throws out linear and spatial variance entirely and evaluates pure probability mass. Here is how it works under the hood: The Metric Space: It evaluates pairwise dependencies using Information-Theoretic Jaccard Similarity (Variation of Information). Because this relies on Shannon entropy, it’s invariant to marginal shape mismatches (like mixing continuous waves with binary flags). Bypassing the Rank Ceiling: Standard PCA is algebraically capped at $N-1$. By moving to a double-centered topological information space, we map true overlapping redundancy and completely bypass the algebraic sample-size ceiling. Compressing the Manifold: The algorithm acts as a bivariate filter. It inherently compresses the primary overlapping probability mass of non-linear combinations back towards the Intrinsic Generative Rank. It shears off the unique synergistic variance, leaving behind residuals that form a bounded Extended Signal Tail, cleanly separating the true drivers from the unstructured Idiosyncratic Informational Variance. Quantifying Informational Gravity: Beyond just extracting a discrete rank, the framework decouples rank from probabilistic volume by introducing Informational Gravity (AIG/FSIG). By systematically rebundling the residual variance sheared off by the bivariate filter, it translates abstract matrix properties into actionable, "variable-equivalent" footprints. Empirical Stress Test: To demonstrate the theoretical bounds, I built a highly entangled synthetic dataset with 20 pure generative roots expanded into 5th-order combinatorics across 20,000 proxies, but only 10,000 samples ($m > N$). To truly simulate messy, real-world contexts, I also heavily injected idiosyncratic structural noise and measurement error into the data. Standard PCA hit the rank ceiling, linearly fractured the expansions, and falsely extracted ~5,700 dimensions. Kernel PCA (RBF) & Spearman Rank structurally folded and yielded a liberal overestimation of the rank by 100%. When root entanglement was introduced, they completely lost their elbows and suffered total structural collapse. The Entropic Scree correctly mapped the intrinsic rank at exactly 20. It successfully isolated a mere 1.45% of active shared signal from an overwhelming 98.55% bulk of unstructured Idiosyncratic Informational Variance. Furthermore, the residuals formed an Extended Signal Tail that perfectly aligned with the deterministic limits of the global hypergeometric design space. Mapping Hidden Topology: Using Factor-Specific Informational Gravity (FSIG), the framework successfully reverse-engineered the simulation's hidden architecture. The topology profile diagnosed a large primary dimension ($FSIG_1 \approx 74.5$ variable equivalents) mapping the network's global combinatorial hub, followed immediately by a flat plateau across the remaining 19 dimensions ($\sim 11.5$ each), confirming a democratically distributed root system beneath the extreme entanglement. Feedback / Discussion: How are you currently handling intrinsic rank extraction in these messy, complex tabular environments? If you are wrestling with sample-starved, heavily non-linear generative datasets where standard PCA and other baseline tools just aren't cutting it, I’d love for you to pull the Entropic Scree repo and test it yourself. I'm completely open to feedback, so let me know how it performs for you and I'm happy to discuss the mechanics. submitted by /u/Chocolate_Milk_Son [link] [comments]
↑ 0 · 💬 0
r/machinelearning · u/unknown · 18h
Resizing images from Flutter Camera Stream for TFLite modle [P]
Hi everyone. So I built a CNN modle using MobileNetv3 then converted it into TFLite. It performed well during training but once I integrated it into my application, it is making large errors. From flutter, the camera stream sends frames and those are processed before the model makes predictions, but it is still quite large. Is there any way I can solve this? This is my code to preprocess and resize the image (224 x 224 x RGB): import 'package:camera/camera.dart'; import 'package:image/image.dart' as img; class ImageProcessor { // converting to rgb img.Image convertYUVToRGB(CameraImage camImg) { final width = camImg.width; final height = camImg.height; final yPlane = camImg.planes[0]; final uPlane = camImg.planes[1]; final vPlane = camImg.planes[2]; final yBytes = yPlane.bytes; final uBytes = uPlane.bytes; final vBytes = vPlane.bytes; final yRowStride = yPlane.bytesPerRow; final uRowStride = uPlane.bytesPerRow; final vRowStride = vPlane.bytesPerRow; final uPixelStride = uPlane.bytesPerPixel ?? 1; final vPixelStride = vPlane.bytesPerPixel ?? 1; final image = img.Image( width: width, height: height, ); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { final yIndex = y * yRowStride + x; final uvX = x ~/ 2; final uvY = y ~/ 2; final uIndex = uvY * uRowStride + uvX * uPixelStride; final vIndex = uvY * vRowStride + uvX * vPixelStride; final yValue = yBytes[yIndex]; final uValue = uBytes[uIndex]; final vValue = vBytes[vIndex]; // YUV -> RGB final r = ( yValue + 1.402 * (vValue - 128) ).round().clamp(0, 255); final g = ( yValue - 0.344136 * (uValue - 128) - 0.714136 * (vValue - 128) ).round().clamp(0, 255); final b = ( yValue + 1.772 * (uValue - 128) ).round().clamp(0, 255); image.setPixelRgb( x, y, r, g, b, ); } } return image; } /// resize images to 224 224 img.Image resizeImage(img.Image image) { return img.copyResize( image, width: 224, height: 224, interpolation: img.Interpolation.linear, ); } List<List<List<List<double>>>> imageToTensor( img.Image image, ) { return [ List.generate( 224, (y) => List.generate( 224, (x) { final pixel = image.getPixel(x, y); return [ pixel.r.toDouble(), pixel.g.toDouble(), pixel.b.toDouble(), ]; }, ), ), ]; } // do all processing List<List<List<List<double>>>> processFrame( CameraImage camImg, ) { final rgbImage = convertYUVToRGB(camImg); final resizedImage = resizeImage(rgbImage); final input = imageToTensor(resizedImage); return input; } }import 'package:camera/camera.dart'; import 'package:image/image.dart' as img; class ImageProcessor { // converting to rgb img.Image convertYUVToRGB(CameraImage camImg) { final width = camImg.width; final height = camImg.height; final yPlane = camImg.planes[0]; final uPlane = camImg.planes[1]; final vPlane = camImg.planes[2]; final yBytes = yPlane.bytes; final uBytes = uPlane.bytes; final vBytes = vPlane.bytes; final yRowStride = yPlane.bytesPerRow; final uRowStride = uPlane.bytesPerRow; final vRowStride = vPlane.bytesPerRow; final uPixelStride = uPlane.bytesPerPixel ?? 1; final vPixelStride = vPlane.bytesPerPixel ?? 1; final image = img.Image( width: width, height: height, ); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { final yIndex = y * yRowStride + x; final uvX = x ~/ 2; final uvY = y ~/ 2; final uIndex = uvY * uRowStride + uvX * uPixelStride; final vIndex = uvY * vRowStride + uvX * vPixelStride; final yValue = yBytes[yIndex]; final uValue = uBytes[uIndex]; final vValue = vBytes[vIndex]; // YUV -> RGB final r = ( yValue + 1.402 * (vValue - 128) ).round().clamp(0, 255); final g = ( yValue - 0.344136 * (uValue - 128) - 0.714136 * (vValue - 128) ).round().clamp(0, 255); final b = ( yValue + 1.772 * (uValue - 128) ).round().clamp(0, 255); image.setPixelRgb( x, y, r, g, b, ); } } return image; } /// resize images to 224 224 img.Image resizeImage(img.Image image) { return img.copyResize( image, width: 224, height: 224, interpolation: img.Interpolation.linear, ); } List<List<List<List<double>>>> imageToTensor( img.Image image, ) { return [ List.generate( 224, (y) => List.generate( 224, (x) { final pixel = image.getPixel(x, y); return [ pixel.r.toDouble(), pixel.g.toDouble(), pixel.b.toDouble(), ]; }, ), ), ]; } // do all processing List<List<List<List<double>>>> processFrame( CameraImage camImg, ) { final rgbImage = convertYUVToRGB(camImg); final resizedImage = resizeImage(rgbImage); final input = imageToTensor(resizedImage); return input; } } Please advise! I need to finish this project within the next wee and I'm really struggling here! I tested the images from Flutter against TFLite and it worked well but something is clearly wrong with the preprocessing. Pls help and give me any advice. Thank you so much! submitted by /u/Defiant-Ad3530 [link] [comments]
↑ 0 · 💬 0
r/machinelearning · u/unknown · 18h
AI-generated code detection in CI/CD — looking for approaches and real-world experience [D]
I'm working on a system to estimate whether code committed to a repository was generated with AI coding tools. My current approach is based on Git/commit-level signals such as AI-related commit trailers, commit metadata, LOC changes, number of files changed, addition/deletion patterns, etc. The problem I'm running into is confidence and calibration. For example, a commit containing 500+ new lines isn't necessarily AI-generated. A developer can also modify or remove the metadata that would make an AI-assisted commit identifiable. Once the code leaves the IDE and reaches Git, much of the original provenance can be lost. This has led me to a few questions: Are there Git/CI-level signals that you've found to be genuinely useful for detecting AI-assisted development? Is it better to treat this as a probabilistic/risk-scoring problem rather than trying to classify commits as AI vs human? How would you calibrate thresholds for signals such as large LOC changes, addition/deletion ratios, commit frequency, etc.? Are there better approaches for preserving provenance earlier in the development workflow, rather than trying to infer it after the code has already been committed? Has anyone worked on AI-code provenance/detection systems in CI/CD and can point me toward useful research, projects, or approaches? I'm particularly interested in approaches that can work at the pipeline/repository level rather than relying solely on source-code style analysis. I'm not looking for a perfect AI detector — even a reliable way of estimating “this commit has a high probability of AI assistance” with measurable false-positive/false-negative rates would be useful. Would appreciate any experiences, papers, open-source projects, or approaches people have tried. submitted by /u/Ancient_Mango_1576 [link] [comments]
↑ 0 · 💬 0












































