今日已更新 302 条资讯 | 累计 41076 条内容
关于我们

标签:#learning

找到 1167 篇相关文章

AI 资讯

Why Your AI Agents Need Finite State Machines: Building Deterministic Workflows in a Vibe-Coding World

Originally published on tamiz.pro . The rise of "vibe coding" has democratized software development, allowing developers to build complex applications using natural language prompts. However, this same flexibility introduces a fundamental challenge for enterprise-grade AI agents: non-determinism. When you ask an LLM to "handle this customer support ticket," the model might draft an email, query a database, or call an external API—depending on the temperature, the context window, and the whims of the weights. For simple chatbots, this is fine. For agents that interact with bank accounts, manage server infrastructure, or coordinate multi-step business logic, this unpredictability is a liability. To bridge the gap between the creative, probabilistic nature of Large Language Models (LLMs) and the rigid reliability required by production systems, engineers must introduce structure. The most robust pattern for this is the Finite State Machine (FSM). By decoupling the decision logic from the execution logic , you create agents that are not only smarter but also predictable, auditable, and debuggable. This deep dive explores the architecture of FSM-driven AI agents, why they are essential for moving beyond prototypes, and how to implement them effectively using modern TypeScript libraries like XState and LangGraph. The Problem with Linear Chains In the early days of agentic AI, the dominant pattern was the linear chain: a sequence of LLM calls where the output of one becomes the input of the next. While simple to implement, this architecture suffers from several critical flaws that become apparent at scale: Lack of Error Recovery : If an LLM call fails or returns malformed JSON, the entire chain collapses. There is no defined "state" to revert to, no way to retry a specific step, and no way to pause for human intervention. No Global Context : Each step in a linear chain is often isolated. The second LLM call may not have access to the full history of decisions made in the f

2026-07-30 原文 →
AI 资讯

From Learning Machine Learning to Competing on Kaggle: My First End-to-End Playground Competition Journey

How I applied Exploratory Data Analysis, Feature Engineering, Pipelines, and Ensemble Models to solve a real-world machine learning problem—and the lessons I learned along the way. Introduction There comes a point in every machine learning learner's journey when watching tutorials and completing small practice exercises are no longer enough. After spending weeks understanding statistics, exploratory data analysis (EDA), feature engineering, preprocessing techniques, and classical machine learning algorithms, I wanted to answer one question: Can I apply everything I've learned to a real machine learning competition? That's when I decided to participate in a Kaggle Playground competition. Unlike classroom datasets, Kaggle competitions force you to think like a machine learning engineer. You're responsible for understanding messy data, building preprocessing pipelines, selecting models, evaluating performance, debugging errors, and finally creating a submission that competes with thousands of participants. This article documents my complete journey—from loading the dataset to building production-style preprocessing pipelines and training multiple ensemble models. Along the way, I'll also share the challenges I faced, what worked well, and the lessons I'll carry into future competitions. Why Kaggle? Learning machine learning isn't just about knowing algorithms. Real-world ML requires answering questions like: Which features are useful? How should missing values be handled? Should categorical variables be one-hot encoded or ordinal encoded? Which preprocessing steps belong inside a pipeline? How do different ensemble models compare? Kaggle provides an environment where all of these questions matter. Instead of building a model that works only inside a notebook, you're solving a problem under realistic constraints and evaluating your solution on unseen data. Competition Goal The objective of this Playground competition was to predict the target class based on a combinatio

2026-07-30 原文 →
AI 资讯

[Advanced Rust] 1.14. Memory Types Pt.2 - Dynamically Sized Types and Wide Pointers, Packed Layouts, Larger Alignment for Speci…

Full title: [Advanced Rust] 1.14. Memory Types Pt.2 - Dynamically Sized Types and Wide Pointers, Packed Layouts, Larger Alignment for Specific Fields or Types, Memory Representation of Complex Types, and Repr Rust 1.14.1. repr(Rust) Remember the example in the previous article? That example used repr(C) , and the limitation of the C representation is that all fields must be placed in the same order as they are defined in the original struct. repr(Rust) is the default representation. It intentionally provides fewer layout guarantees than repr(C) : the compiler may reorder fields, and two types with the same fields in the same order are still not guaranteed to share a layout. Because the compiler may reorder fields (for example, placing larger fields first), padding can often be reduced. In the Foo example from the previous article, one possible optimized layout needs no padding. With fewer guarantees about layout, the compiler has room to rearrange things and produce efficient code. If repr(Rust) is used, then one possible memory layout of the Foo struct from above is: Code Field Type Size Default Representation Padding Final Alignment #[repr(Rust)] struct Foo { long: u64, 8 bytes 8-byte aligned 8 bytes normal: u32, 4 bytes 4-byte aligned short: u16, 2 bytes 2-byte aligned small: u8, 1 byte 1-byte aligned tiny: bool, 1 byte 1-byte aligned } Total 16 bytes The compiler first orders the fields by size, putting the largest first so that it can determine what alignment the struct should use. In this example, u64 is the largest and takes 8 bytes, so the struct is aligned to 8 bytes The compiler then looks at the remaining fields and sees that their total size is exactly 8 bytes, so it can place them together and avoid padding In the end, this struct only needs 16 bytes, which saves half the memory compared with repr(C) This is more efficient, but compilation time may be a little longer 1.14.2. Packed Layouts You can tell the compiler that no padding is needed between fiel

2026-07-30 原文 →
AI 资讯

AI ตรวจจับมัลแวร์เก่งกว่ามนุษย์จริงหรือ? ไขความจริงเบื้องหลังตัวเลขความแม่นยำ

ทุกวันนี้มัลแวร์รูปแบบใหม่ถูกสร้างขึ้นนับพันนับหมื่นชิ้นในแต่ละวัน ปริมาณภัยคุกคามที่เพิ่มขึ้นอย่างรวดเร็วนี้ทำให้การพึ่งพานักวิเคราะห์ความปลอดภัยไซเบอร์ที่เป็นมนุษย์เพียงอย่างเดียวแทบเป็นไปไม่ได้ นี่คือเหตุผลสำคัญที่บริษัทด้านความปลอดภัยไซเบอร์ทั่วโลกหันมาพึ่งพาปัญญาประดิษฐ์และแมชชีนเลิร์นนิงเป็นแนวหน้าในการรับมือกับมัลแวร์ หลายบริษัทโฆษณาว่าโซลูชันของตนตรวจจับมัลแวร์ได้แม่นยำถึง 99% หรือมากกว่านั้น ตัวเลขเหล่านี้ฟังดูน่าประทับใจอย่างยิ่ง แต่คำถามที่ควรถามต่อคือ ตัวเลขเหล่านี้สะท้อนความเป็นจริงมากน้อยเพียงใด และ AI เก่งกว่ามนุษย์จริงหรือไม่ในสมรภูมิการต่อสู้กับมัลแวร์ บทความนี้จะพาไปไขความจริงเบื้องหลังตัวเลขเหล่านั้นอย่างละเอียด กลไกเบื้องหลังการตรวจจับมัลแวร์ด้วย AI ก่อนจะตอบคำถามว่า AI เก่งกว่ามนุษย์หรือไม่ จำเป็นต้องเข้าใจก่อนว่าระบบ AI ตรวจจับมัลแวร์ทำงานอย่างไร โดยทั่วไปมีสองแนวทางหลักที่ใช้กันในอุตสาหกรรมความปลอดภัยไซเบอร์ แนวทางแรกคือการตรวจจับด้วยลายเซ็นดิจิทัล (Signature-Based Detection) ซึ่งเป็นวิธีดั้งเดิมที่ใช้กันมานานหลายทศวรรษ ระบบจะเปรียบเทียบไฟล์ต้องสงสัยกับฐานข้อมูลลายเซ็นของมัลแวร์ที่เคยพบมาก่อน วิธีนี้แม่นยำสูงสำหรับมัลแวร์ที่รู้จักแล้ว แต่ไม่มีประสิทธิภาพเมื่อเจอมัลแวร์ตัวใหม่ที่ไม่เคยถูกบันทึกไว้ในฐานข้อมูล แนวทางที่สองคือการตรวจจับผ่านพฤติกรรมด้วยแมชชีนเลิร์นนิง (Behavior-Based Detection) ซึ่งเป็นจุดแข็งหลักของ AI ยุคใหม่ ระบบจะถูกฝึกฝนด้วยตัวอย่างมัลแวร์และไฟล์ปกตินับล้านไฟล์ เพื่อเรียนรู้รูปแบบพฤติกรรมที่บ่งชี้ความเป็นอันตราย เช่น ความพยายามเข้าถึงไฟล์ระบบโดยไม่ได้รับอนุญาต การเชื่อมต่อไปยังเซิร์ฟเวอร์ต้องสงสัย หรือการเข้ารหัสไฟล์จำนวนมากในเวลาอันสั้นซึ่งเป็นสัญญาณคลาสสิกของแรนซัมแวร์ จุดเด่นของวิธีนี้คือความสามารถในการตรวจจับมัลแวร์ตัวใหม่ที่ไม่เคยพบมาก่อน หรือที่เรียกว่า Zero-Day Malware เพราะไม่ได้พึ่งพาการจดจำลายเซ็นเดิม แต่อาศัยการวิเคราะห์พฤติกรรมและรูปแบบที่ใกล้เคียงกับสิ่งที่เคยเรียนรู้มาแล้ว ตัวเลขความแม่นยำที่โฆษณากันนั้นบอกอะไรจริง ๆ เมื่อบริษัทความปลอดภัยไซเบอร์อ้างว่าผลิตภัณฑ์ของตนมีความแม่นยำ 99% หรือสูงกว่านั้น ผู้บริโภคควรตระหนักว่าตัวเลขเหล่านี้มักมาจากการทดสอบภายใต้สภาพแวดล้อมที่ควบคุมไว้อย่างเข้มงวด ซึ่งอาจไม่สะท้อนสถานกา

2026-07-29 原文 →
AI 资讯

Your model can't grade its own homework

Every team I've watched ship a broken measurement system broke it the same way. Not with bad math — with an org chart problem that happened to live in code. The entity making the claim ended up being the entity that decided whether the claim was right. Once you have the shape in your head you start seeing it everywhere. Three roles, not two Most engineers think about measurement as two roles: the thing that acts, and the thing that grades it. That's one role short. There are three: Player — makes the claim. Your model, your service, your PR. Scorer — applies the rubric. Your eval harness, your test suite, your metrics dashboard. Settler — determines what actually happened. Production outcomes. Reality. The scorer is a proxy. The settler is the thing the proxy is trying to approximate. The rule: be the scorer, never the settler. When the player captures the settler, the loop closes on itself and the system can no longer be wrong — which sounds like success and is actually the failure. What it looks like in code Tuning on the test set. You check test accuracy, adjust hyperparameters, check again. Twenty iterations later the test set is training data with extra steps. The player is now selecting its own settler. That's what overfitting is , structurally — not a math failure, a role-collapse failure. LLM-as-judge from the same family. Your generator is GPT-flavored and your judge is GPT-flavored. They share pretraining data, failure modes, and blind spots. The judge doesn't rate quality — it rates similarity to what it would have produced. Correlated error is invisible to averaging; running it 1,000 times makes you more confident of the same wrong answer. Benchmark contamination. The model scores 94% on the benchmark that's in its training data. Nobody lied. The settler just quietly moved inside the player. Self-reported health. A service that returns its own health check is a claimant ruling on its own claim. If the process is wedged, the check is wedged too, and your

2026-07-29 原文 →
AI 资讯

From Burnout to Balance: Building an AI Overtraining Detector with HRV and Isolation Forest

Are you a data nerd who loves fitness? If you wear an Oura Ring or an Apple Watch , you’re sitting on a goldmine of biometric data. Specifically, Heart Rate Variability (HRV) —the secret sauce for understanding your nervous system's recovery status. But how do you know if a low HRV score is just a fluke or a serious sign of overtraining? In this tutorial, we are going to build a personalized HRV Anomaly Detector . Using Machine Learning , specifically the Isolation Forest algorithm from Scikit-learn , we will transform raw time-series data from the Oura Cloud API into an early-warning system for stress and burnout. This type of anomaly detection is essential for anyone looking to optimize their performance without hitting a wall. The Architecture 🏗️ Before we dive into the code, let's visualize how the data flows from your finger to our machine learning model. graph TD A[Oura Ring / Apple Watch] -->|Syncs| B(Cloud API / HealthKit) B -->|Fetch JSON| C[Python Script] C -->|Pandas Clean| D{Feature Engineering} D -->|HRV & Sleep Duration| E[Isolation Forest Model] E -->|Predict| F[Anomaly Flag: Overtrained?] F -->|Plot| G[Matplotlib Visualization] G -->|Insight| H[Rest or Push?] Prerequisites 🛠️ To follow along, you'll need the following stack: Python 3.9+ Scikit-learn : For our machine learning heavy lifting. Matplotlib : To visualize our "danger zones." Pandas : For time-series manipulation. Oura Cloud API : You'll need a personal access token (available at the Oura Cloud portal ). Step 1: Fetching Your HRV Data 🛰️ First, let's grab our data. If you don't have an Oura ring, you can export your Apple Watch data as a CSV, but the Oura API is much more convenient for automation. import requests import pandas as pd # Replace with your actual Personal Access Token TOKEN = ' YOUR_OURA_TOKEN ' url = ' https://api.ouraring.com/v2/usercollection/daily_readiness ' headers = { ' Authorization ' : f ' Bearer { TOKEN } ' } params = { ' start_date ' : ' 2023-01-01 ' , ' end_date '

2026-07-29 原文 →
AI 资讯

Starting Terraria modding (again)

This is my first dev blog I'm making a terraria mod I'm not sure if i want to start right now but i am sure to start soon i already have some ideas so here are the ideas The Operator The operator is someone i have in idea for a while kind of the lore aspect is you work it, killing bosses and giving proof to the operator for certain rewards, at first it is an Npc but after moon lord you fight him. I might bring him back as the same dude but is occupied by the Fixer as a vessel which he is chained or has custom hand cuffs for the fixer to occupies the fixer without The Operator body, without the body dying. The Dulled One This is not my idea but a alternative version of it (Game: Craft-Wars Redux Roblox, Boss: Dulled Spectrum) for credits, so I really liked this boss idea but I'm really not sure if they did what I'm doing, but his power is to erase or turn into dust or "dull". To erase certain parts of the world either matter, or space i don't want to say time because i feel like that would be boring, it can either be like passive very weak erase which it can re-gain power. Second version is the Compacted version which does way more damage, maybe one shot if i do one shot then im adding middle attacks, but deplete the dust bar by a ton so if the boss is not careful or the player stops it then you can easily beat it. it might have a regen system where if the bar is full then it heals. Also hammer both the versions the game and mine has hammer. The lore is not very fleshed out right now but i will figure it out

2026-07-29 原文 →
AI 资讯

[Advanced Rust] 1.13. Memory Types Pt.1 - Alignment, Layout, and the Repr Attribute

1.13.1. The Basic Responsibility of Types Every Rust value has a type, and the responsibility of that type is to tell you how to interpret the bits in memory. For example, the bit pattern 0b10111101 has no meaning by itself, but: Interpreted as u8 , it becomes the number 189 Interpreted as i8 , it becomes the number -67 When you define a custom type, the compiler decides where each part of that type is placed in memory. 1.13.2. Alignment Alignment determines where a type’s bytes may be stored. Once a type’s representation is determined, you might think it can be stored anywhere in memory. In theory that is possible, but in practice computer hardware places constraints on where a given type can live. The most typical example is a pointer. A pointer points to bytes, not bits; one byte equals 8 bits. In other words, it does not point to an individual bit. So if a value of some type were placed at bit index 4 in memory, you would not be able to address it, because pointers address bytes rather than specific bits. That is why alignment is done at the byte level — that is, at 8-bit boundaries. For this reason, all values, regardless of type, must begin on a byte boundary . All types must be at least byte-aligned. In other words, the storage address must be a multiple of 8 bits. 1.13.3. Stricter Alignment Rules Some types have alignment requirements stricter than byte alignment. In CPU and memory systems, memory is often accessed in blocks larger than a single byte. For example, on a 64-bit CPU, most values are accessed in 8-byte blocks, and each operation begins at an address that is 8-byte aligned . This is also called the CPU word size. Of course, CPUs can also handle reads and writes of smaller values, as well as values that cross block boundaries. But as developers, we should try our best to ensure that hardware operates at its native alignment. For example, if the i64 value you want to read begins in the middle of an 8-byte block, then reading it requires at least tw

2026-07-29 原文 →
AI 资讯

权重即数据:神经网络权重空间学习如何成为 AI 的下一类训练集

https://www.youtube.com/watch?v=sVeEc3H6bA4 权重即数据:神经网络权重空间学习如何成为 AI 的下一类训练集 以下位 TWIML AI Podcast 第 772 期《Why Models Are AI's Next Training Dataset》访谈转录整理,嘉宾为圣加仑大学 AI 与机器学习教授 Damian Borth,主持人 Sam Charrington。 介绍详细内容之前,先说说WSL是否等同于模型蒸馏? 答案是不是一回事,但容易混着叫。先把两件事拆开,再对照 Borth 的"权重空间学习(WSL)"你就清楚了。 1. Anthropic 骂阿里那件事是什么 Anthropic 2026 年 6 月致信美国参议院,说阿里 Qwen 团队在 4/22–6/5 期间用近 2.5 万个假账号调 Claude 约 2880 万次 ,把 Claude 的回答当训练数据去训自己的模型,他们叫它" 蒸馏攻击(distillation attack) "。 这本质上是 黑盒/API 层的数据蒸馏 : 教师=Claude(只看得到输出文本) 学生=Qwen 系模型 方法=拿 Claude 的生成文本(硬标签,最多再加点软标签)当语料去训学生 目的=迁移能力、省训练钱 注意:这跟"白盒蒸馏"还不一样,阿里(按指控)根本没拿到 Claude 的权重,拿到的是 对话文本 。行业里把"用强模型输出当训练数据"泛称为蒸馏,但严格学术定义里这只是黑盒 KD 或数据蒸馏。 2. Borth 的"权重当数据"是不是蒸馏 形式上沾边,本质上不同。 维度 经典/黑盒蒸馏(Anthropic 指控那种) Borth 权重空间学习(WSL) 学习对象 教师模型的 输出 (文本/软标签/中间激活) 一堆已训练模型的 权重本身 (参数张量) 数据形态 (x, 教师输出) 配对样本 把模型权重序列化、令牌化后的"权重语料" 目标 学生模仿教师行为,压缩模型 学"模型种群"的流形:预测准确率 / 生成新权重 / 跨架构采样 要不要原始数据 黑盒蒸馏可以完全不用原数据,只用教师输出 完全不用任何输入输出数据 ,连教师行为都不看 典型操作 用 Claude 回答训 Qwen 下载 HF 上 2000 个 CV 模型 → 自编码器压成隐空间 → 采样出遥感模型权重 Borth 自己在论文里也承认:WSL 可以看作" 直接在权重上做的、基于训练的知识复用 ",但它不需要像 KD 那样去跑原数据集拿激活、也不需要教师在线推理,它是把"训练好的模型集合"当成 第三种数据模态 (继文本、图像之后)。 简单说: 蒸馏是" 看菜谱做出来的菜(输出)来学做饭 " WSL 是" 把几百道做好的菜称重、切片、分析配料分布,然后直接捏出一道新菜的重量配方 "——连火都没开,更没尝过菜味。 3. 为什么大家会搞混 因为两者都叫"复用已有模型的知识",而且 WSL 生成出的权重确实能当初始化、能跨域迁移(比如用 ImageNet 模型权重训出遥感模型,350 GPU 小时干掉 12000 GPU 小时的从头训), 效果上像"蒸馏了前辈经验" 。但机制上: KD 的知识载体是 前向行为 (logits / 文本) WSL 的知识载体是 参数几何结构 (权重空间里的流形、对称性、轨迹) 所以 Borth 在访谈里特意说"权重不仅是学习的输出,也可以是学习的输入"——这句话的潜台词就是: 别把它归类成 KD,它是一个新模态的学习问题 。 4. 一句话收口 Anthropic 抱怨阿里,是"你偷用我家模型吐的字句当教材";Borth 的路子是"我把全网开源模型(含你家的,只要开源许可允许)的 权重文件 当语料,训一个会造权重的元模型"——前者踩的是 API 条款和商业秘密红线,后者用的是 已发布权重 (Hugging Face 上大多有许可证),技术族谱上离"蒸馏"比离"神经架构搜索 + 超网络"更远。 第(一)部分 节目开场与研究总览:当训练数据枯竭,权重成为新燃料 (0% - 8%) 节目引入与核心命题 :主持人点明当下 AI 领域最严峻的问题之一——高质量训练数据越来越难找,部分研究者押注合成数据,另一部分押注推理时计算(test-time reasoning)。而本期嘉宾 Damian Borth 提出了一条截然不同的路径:每一个训练好的模型都凝结了数千乃至数百万 GPU 小时"什么管用"的探索经验,这些权重不应只被视为训练过程的终点,而应成为下一次训练的 起点和数据本身 。 嘉宾背景与研究方向 :Damian Borth 是瑞士圣加仑大学 AI 与机器学习教授。他的核心研究线索是"权重空间学习"(weight space learning / w

2026-07-28 原文 →
AI 资讯

Claude Opus 5 Lands on Amazon Bedrock — The Agentic Engineer #23

This is a cross-post from The Agentic Engineer newsletter — Issue #23. The Big One: Claude Opus 5 Lands on Amazon Bedrock The first 5th-generation Opus is here. Claude Opus 5 landed on Amazon Bedrock on July 24. Anthropic's claim: it matches Fable 5 intelligence across agentic coding, knowledge work, visual understanding, and long-horizon tasks. At Opus pricing. That last part matters. Fable 5 was positioned as enterprise-tier compute. Most teams weren't running it at scale because the economics didn't work. Opus 5 changes that math. Same capability class, Opus price point. If the benchmark holds in production, this is the model shift that makes frontier-quality agentic pipelines practical outside big-company infra budgets. Two deployment details worth calling out. Zero Data Retention is on by default. It also runs on Bedrock's next-generation inference engine — lower latency than comparable Anthropic-hosted deployments. Quick Hits This Week Kimi K3 Open Weights : Moonshot AI dropped 2.8T MoE, 1M context, native tool calling. First frontier model built agent-native from the ground up. OpenAI Presence : Full-stack enterprise agent platform with job-scoped access, policy layers, and a Codex-powered improvement loop. Runs OpenAI's own phone support at 75% resolution. OmniRoute : 31,542 stars (+10,912 this week). 290+ providers, quota-aware fallback, MCP/A2A support. One endpoint for all your coding agents. Claude Code 2.1.218 : /code-review and /deep-research now run as background subagents. Main conversation stays clean. AWS Security Hub MCP Server : Exposure findings, attack paths, and remediation recommendations directly in Claude Desktop. Tool of the Week: Amazon GuardDuty Investigation Agent Free during preview. Auto-correlates findings across CloudTrail, VPC Flow Logs, DNS logs. Returns risk level, MITRE ATT&CK mappings, and remediation recommendations in minutes. Available via MCP through the AWS Agent Toolkit. Available in 10 commercial AWS regions. Up to 10 in

2026-07-28 原文 →
AI 资讯

Learning Go the Slow Way: Building Projects Instead of Following Tutorials.

Like a lot of beginners, I started learning Go the usual way: tutorials, courses, and coding along with someone who had already solved every problem. It felt productive. I finished lessons, learned the syntax, and everything seemed to make sense. Then I tried building something on my own.I had no idea where to start. That was the point where I changed my approach. Instead of following tutorials, I started building small, messy, imperfect projects. I still use AI, but not to generate the code for me. I use it as a guide that helps me think through the problem. Why tutorials stopped working for me Tutorials are great for introducing concepts and showing that something works. What they don't teach very well is how to make decisions when you're on your own. When you're following along, someone else has already decided how to organize the project, what to name things, how to structure the packages, and how to solve the tricky parts. You learn what to type, but you don't get much practice deciding why to do it that way. I could finish a tutorial and still struggle to build a simple API from scratch. That was a clear sign that I wasn't actually learning how to solve problems. My new approach: start with a real project Now I begin with a small project I actually want to build. Nothing huge—just something manageable, like: A URL shortener A simple job queue A CLI tool that automates something I find repetitive The goal isn't to build an impressive portfolio piece. It's to build something that's mine, where every design decision is one I have to make myself. The problem, of course, is that starting from a blank page can be overwhelming when you're still learning. That's where AI has become genuinely useful. How I use AI I don't ask AI to build the project. Instead, I ask it to break the project into small, testable milestones. For example: "I want to build a basic URL shortener in Go.Break this project into small steps, where each step is one feature I can build and test befo

2026-07-28 原文 →
AI 资讯

[Advanced Rust] 1.12. Lifetimes (Advanced) Pt.2 - Lifetime Variance, Covariance, Invariance, Contravariance

1.12.1. Lifetime Variance Variance is a concept in Rust’s type system. It describes how generic parameters — especially lifetime parameters — relate to one another in the type hierarchy. We can think of it simply as variance describes which types are “subtypes” of other types , where “subtype” is somewhat similar to the concept used in Java and C#. In addition, variance also cares about when a “subtype” can replace a “supertype” and vice versa . In general, if A is a subtype of B, then A is at least as useful as B. Here is a Rust example: if a function takes &'a str , then &'static str can be passed in. Because 'static is a subtype of 'a , 'static lives at least as long as any 'a (and 'static can remain valid for the entire program). 1.12.2. Three Kinds of Lifetime Variance All types have variance. The variance associated with each type defines which similar types can be used in that type’s position. Note: the following content is fairly difficult. It is recommended that you first recall the ideas of sufficient conditions and necessary conditions from high school math. 1. Covariant Covariant means that a type can be replaced only by a “subtype.” Covariance means: if A <: B (A is a subtype of B), then F<A> <: F<B> (F<A> is also a subtype of F<B>) This is a transitive inheritance relationship from smaller to larger , similar to reasoning from a sufficient condition : if A holds, then B must also hold (A is a sufficient condition for B). For example, &'static T can replace &'a T , because &T is covariant over the lifetime 'a , so 'a can be replaced by one of its subtypes, such as 'static . 2. Invariant Invariant means that you must provide the exact specified type. Invariance means: A <: B cannot imply F<A> <: F<B>, and F<B> <: F<A> also cannot be inferred This means there is not enough relationship between F<A> and F<B> to derive one from the other, so they are neither sufficient conditions nor necessary conditions ; they are independent. For example, the mutable refe

2026-07-28 原文 →
AI 资讯

[Advanced Rust] 1.11. Lifetimes (Advanced) Pt.1 - Review, Borrow Checker, Generic Lifetimes

1.11.1. Review In the beginner tutorial, we mentioned that every reference in Rust has a lifetime. A lifetime is the scope in which the reference remains valid, and in most cases it is implicit and inferred by the compiler. When you take a reference to a variable, the lifetime begins. When the variable is moved or goes out of scope, the lifetime ends. In other words, for a reference, a lifetime is the name of the code region in which it must remain valid. Lifetimes usually overlap with scopes, but not always. 1.11.2. Borrow Checker Whenever a reference with some lifetime 'a is used, the borrow checker checks whether 'a is still alive. The process is: Trace the path back to where 'a began — that is, where the reference was obtained From there, check whether there are conflicts along that path Ensure that the reference points to a value that can be accessed safely This example uses the rand crate. Add the following dependency to Cargo.toml : [dependencies] rand = "0.8" Consider this example: use rand :: random ; fn main () { let mut x = Box :: new ( 42 ); let r = & x ; if random :: < f32 > () > 0.5 { * x = 84 ; } else { println! ( "{}" , r ); } } x is of type Box<i32> Declaring r as a reference to x means the reference’s lifetime begins on that line (line 5) On line 7, the value of x is modified through dereferencing. That requires a mutable reference to x . At this point, the borrow checker looks for a mutable reference to x and checks whether its use conflicts with anything else. In this example there is no conflict, so the code is valid You may ask: line 7 is inside the scope of r . Since *x needs a mutable reference to x , shouldn’t having both the immutable reference r and the mutable reference *x in the same scope violate the borrowing rules and produce an error? In fact, Rust is smart enough to know that if the if branch is taken, the else branch cannot be taken. r is never used in the if branch at all, so using the mutable reference *x in the if branch is fine

2026-07-28 原文 →
AI 资讯

Why We Run Every AI Pipeline in Its Own Process

The runtime boundary behind RocketRide's crash isolation, task lifecycle, and Cloud operations. By Krish Garg and Mithilesh Gaurihar At 9 a.m., with ten thousand users mid-session, a node in an AI pipeline dereferences a bad pointer. The process running it is gone before Python can raise a useful exception. That is an unpleasant failure, but it is not the question we care about most. The question is what happens next. Does that crash take unrelated pipelines with it? Does the server need a restart? Does the on-call engineer walk into a system-wide incident, or into one failed task and a useful record of why it failed? In RocketRide, a failed task is meant to be contained and recorded. The server sees the child process exit, updates the task's state and exit code, releases the task's ports and connections, and sends status updates to subscribed monitors. The run stops. Its history does not vanish. Other task processes are not sharing its memory, interpreter, or worker threads. That behavior comes from a decision we made early: every pipeline run gets its own isolated process. It is not the cheapest or fastest possible architecture. Starting a process has a cost, and keeping one around has a cost too. We accepted those costs because the alternative makes failures much harder to reason about once Python code, native libraries, model runtimes, and user-defined nodes are all running in the same service. One Process, One Blast Radius An AI pipeline does not fail like a typical request handler. A normal exception is one thing. A segfault in a C extension, a crash in a media decoder, or a broken native inference library is another. Once a process has corrupted memory, application-level error handling is no longer a reliable line of defense. So each RocketRide task starts as a fresh child process with its own embedded Python interpreter. It loads one pipeline, initializes that pipeline's nodes, and owns the work for that run. The parent runtime keeps the task registry, alloc

2026-07-28 原文 →
AI 资讯

I built an interactive site about my journey — not a portfolio

Honestly I almost didn't build this because everyone said "just make a normal portfolio, resume + project cards, keep it simple." But that felt fake to me. Like I'd be hiding the actual messy part of learning to code and just showing the highlight reel. So instead I built whoisrehan.vercel.app — it's less of a portfolio and more of me walking you through everything, starting from the first time I opened a code editor with literally no idea what I was doing, all the way to now. Including the stuff that usually gets left out — the projects that didn't work, the times I wanted to quit, the small wins that felt huge at the time. It's not polished. It's just honest. If you've ever started something with zero plan and just pure curiosity, I think you'll get it. whoisrehan.vercel.app Curious which part actually hits you if you check it out : BuildInPublic #WebDevelopment #DeveloperJourney

2026-07-27 原文 →
AI 资讯

Kimi K3 Is the Biggest Open-Weight Model Ever Shipped. Here's What Actually Matters.

A Beijing startup just out-shipped every US lab's open-weight strategy On July 16, Moonshot AI — the Alibaba-backed startup behind Kimi — put Kimi K3 behind an API. Today, July 27, the full weights land on Hugging Face. No waitlist, no "responsible scaling" essay, no six-month delay between "we built something scary" and "here, run it yourself." Just 2.8 trillion parameters, open, on the day they said it would happen. That's not a small model with a big number attached. It's the largest open-weight model ever released, full stop. And unlike most "open" releases that quietly underperform their closed competitors, K3 is winning on the benchmarks developers actually care about. Let's get into what's real and what's marketing. The numbers K3 is a mixture-of-experts model: 2.8T total parameters, but it only activates 16 of 896 experts per token. That's the trick that makes a model this size runnable at all — you're not paying compute for the full 2.8T on every forward pass. The architecture story is Kimi Delta Attention (KDA), a hybrid linear attention mechanism Moonshot claims delivers 6.3x faster decoding, plus "attention residuals" that improve token efficiency by 25% for roughly 2% extra compute. Whether that holds up under independent scrutiny is still TBD, but the direction — make huge models cheap to serve — is the correct one, and it shows up in the token counts: K3 uses 21% fewer output tokens than its predecessor, K2.6, for comparable tasks. Context window: 1,048,576 tokens. Flat pricing, no context-length tiering — a real advantage over providers who quietly double your rate past 128K. Benchmarks that matter: Benchmark K3 Comparison Frontend Code Arena 1679 Elo (#1) Claude Fable 5: 1631, GPT-5.6 Sol: 1618 GPQA Diamond 93.5% Best open-weight score ever published GDPval-AA v2 1687 (#3) Behind Claude Fable 5 Max (1815), GPT-5.6 Sol Max (1747.8) — ahead of Claude Opus 4.8 (1600) Artificial Analysis Elo 1547 +732 over K2.6 Read that middle row again: an open-weight

2026-07-27 原文 →