<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ashwin on Medium]]></title>
        <description><![CDATA[Stories by Ashwin on Medium]]></description>
        <link>https://medium.com/@angelash18092007?source=rss-95e006a3b630------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PhAmVRfjaaftULLmeZCsJQ.jpeg</url>
            <title>Stories by Ashwin on Medium</title>
            <link>https://medium.com/@angelash18092007?source=rss-95e006a3b630------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 04:09:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@angelash18092007/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Anatomy of the Hermes Agent]]></title>
            <link>https://medium.com/@angelash18092007/anatomy-of-the-hermes-agent-73ef374bc068?source=rss-95e006a3b630------2</link>
            <guid isPermaLink="false">https://medium.com/p/73ef374bc068</guid>
            <dc:creator><![CDATA[Ashwin]]></dc:creator>
            <pubDate>Sun, 12 Apr 2026 07:19:54 GMT</pubDate>
            <atom:updated>2026-04-12T07:19:54.433Z</atom:updated>
            <content:encoded><![CDATA[<p># Anatomy of the Hermes Agent: A Deep Dive into an Open-Source AI Agent Framework</p><p>*Understanding the inner workings of a self-evolving, persistent, and multi-platform AI agent*</p><p>— -</p><p>## Introduction: What Makes an AI Agent Different?</p><p>Before we dissect the Hermes Agent, let’s clarify what we mean by an “AI agent” versus a regular chatbot. A chatbot answers questions in isolation. An agent like Hermes:</p><p>- **Remembers** across conversations and sessions<br>- **Learns** from experience and saves procedures as reusable skills<br>- **Acts** on your system — running commands, editing files, browsing the web<br>- **Persists** its identity and preferences over time<br>- **Operates** autonomously when needed, not just on-demand</p><p>Hermes, created by Nous Research, is an open-source implementation of this paradigm. It’s not just another CLI tool — it’s a framework that learns and evolves with its user.</p><p>— -</p><p>## The Core Architecture: Five Pillars</p><p>Imagine the Hermes Agent as a living organism with five interconnected systems:</p><p>```<br>┌─────────────────────────────────────────────────────────┐<br>│ HERMES AGENT │<br>├─────────────┬─────────────┬─────────────┬───────────────┤<br>│ 1. BRAIN │ 2. MEMORY │ 3. SENSES │ 4. HANDS │<br>│ (LLM Core) │ (Persistent │ (Input │ (Tools &amp; │<br>│ │ Context) │ Channels) │ Actions) │<br>├─────────────┴─────────────┼─────────────┴───────────────┤<br>│ │ 5. EVOLUTION │<br>│ ┌─────────────────────┐ │ (Skills &amp; │<br>│ │ 6. GATEWAY │ │ Learning) │<br>│ │ (Platform Bridges) │ │ │<br>│ └─────────────────────┘ └─────────────────────────────┘<br>└─────────────────────────────────────────────────────────┘<br>```</p><p>### 1. The Brain: LLM Provider Agnostic Core</p><p>At its heart, Hermes uses a large language model as its reasoning engine. The clever part? It’s completely provider-agnostic. You can swap between 18+ providers mid-conversation:</p><p>- **OpenRouter** — access to hundreds of models<br>- **Anthropic** — Claude models<br>- **Nous Portal** — our own models<br>- **Local models** — via Ollama, vLLM, or llama.cpp<br>- **15+ others** — OpenAI, DeepSeek, Hugging Face, and more</p><p>This isn’t just “support for multiple providers.” The system has:<br>- **Credential pools** that rotate across multiple API keys<br>- **Smart routing** that can use cheap models for simple tasks and expensive ones for complex reasoning<br>- **Seamless switching** — type `/model claude-opus` mid-conversation to upgrade your brain</p><p>### 2. The Memory System: Living Context</p><p>This is where Hermes becomes truly different from most AI tools. The memory system has three layers:</p><p>**a) Session Memory (Short-term)**<br>Each conversation maintains its own context, including:<br>- What you’ve discussed<br>- What files you’ve edited<br>- What tools you’ve used<br>- What you’ve approved or rejected</p><p>**b) Cross-Session Memory (Long-term)**<br>The system remembers:<br>- Your preferences and working style<br>- Your environment (OS, installed tools, project structure)<br>- Lessons learned from past mistakes<br>- Your identity and communication preferences</p><p>**c) Skills (Procedural Memory)**<br>When Hermes solves a complex problem or discovers a useful workflow, it can save that knowledge as a “skill” — a reusable procedure document that loads automatically in future sessions. This is like muscle memory for an AI.</p><p>### 3. The Senses: Input Channels</p><p>Hermes doesn’t just sit and wait for your typed input. It perceives the world through:</p><p>- **CLI input** — your typed commands<br>- **Voice messages** — via speech-to-text (Whisper, Groq, or local)<br>- **Webhooks** — external systems can trigger actions<br>- **Cron jobs** — scheduled tasks that run autonomously<br>- **Platform messages** — from Telegram, Discord, Slack, etc.<br>- **File system changes** — watching for modifications<br>- **API calls** — external applications can interact with it</p><p>### 4. The Hands: Tools and Actions</p><p>The tool system is how Hermes interacts with the world. Each tool is a specific capability:</p><p>```<br>◆ File operations ◆ Terminal commands<br>◆ Web browsing ◆ Email management<br>◆ Code execution ◆ Image analysis<br>◆ Voice generation ◆ Smart home control<br>◆ Database queries ◆ API calls<br>◆ Document creation ◆ Git operations<br>```</p><p>**The Toolset Architecture:**<br>Hermes organizes tools into “toolsets” — logical groups that can be enabled/disabled:<br>- `terminal` — shell access<br>- `file` — read/write/patch files<br>- `web` — search and scrape<br>- `browser` — full browser automation<br>- `vision` — image analysis<br>- `memory` — persistent context<br>- And 10+ more</p><p>**Key insight:** Tools are only available when their requirements are met. The `check_requirements()` function ensures tools don’t appear in the LLM’s context if they can’t actually work.</p><p>### 5. The Evolution: Skills and Learning</p><p>This is perhaps the most fascinating part. Hermes has a built-in learning system:</p><p>**How Skills Work:**<br>1. You ask Hermes to solve a complex problem<br>2. It figures out a workflow (maybe through trial and error)<br>3. You say “save this as a skill”<br>4. It writes a structured document with:<br> — When to use this skill<br> — Step-by-step instructions<br> — Pitfalls and edge cases<br> — Verification steps<br>5. This skill is saved to `~/.hermes/skills/`<br>6. Next time a similar situation arises, Hermes loads the skill automatically</p><p>**Skill Categories:**<br>- **Software development** — debugging patterns, deployment workflows<br>- **Research** — literature review methodologies, data analysis<br>- **System administration** — server management, monitoring<br>- **Creative work** — writing styles, design patterns<br>- **Project-specific** — your custom workflows</p><p>### 6. The Gateway: Platform Bridges</p><p>The gateway system allows the same agent to operate across multiple platforms simultaneously:</p><p>```<br>┌─────────────────┐<br>│ HERMES CORE │<br>└────────┬────────┘<br> │<br>┌────────┴────────┐<br>│ GATEWAY │<br>├─────────────────┤<br>│ Telegram │<br>│ Discord │<br>│ Slack │<br>│ WhatsApp │<br>│ Signal │<br>│ Matrix │<br>│ Email │<br>│ SMS │<br>│ API Server │<br>└─────────────────┘<br>```</p><p>Each platform adapter translates between:<br>- Platform-specific message formats ↔ Hermes’s internal format<br>- Platform features (reactions, threads, media) ↔ Hermes capabilities<br>- User permissions and authentication ↔ Hermes’s security model</p><p>— -</p><p>## Under the Hood: The Conversation Loop</p><p>Let’s trace what happens when you send a message to Hermes:</p><p>```<br>1. INPUT PARSING<br> User message arrives (CLI, Telegram, webhook, etc.)<br> ↓<br>2. CONTEXT ASSEMBLY<br> — System prompt (personality, tools, skills)<br> — Memory context (user profile, environment)<br> — Recent conversation history<br> — Loaded skills for this situation<br> ↓<br>3. LLM CALL<br> Send assembled context to chosen provider<br> ↓<br>4. RESPONSE PARSING<br> — If text → return to user<br> — If tool calls → execute each tool<br> ↓<br>5. TOOL EXECUTION<br> — Validate parameters<br> — Run tool function<br> — Capture output<br> ↓<br>6. LOOP BACK<br> Add tool results to context, go to step 3<br> (max 90 iterations to prevent infinite loops)<br> ↓<br>7. COMPRESSION<br> When context gets too large, automatically compress<br> ↓<br>8. OUTPUT<br> Return final response to user<br>```</p><p>**The Magic Sauce — Context Management:**<br>Hermes automatically manages context to prevent hitting token limits:<br>- **Compression** — summarizes older parts of conversation<br>- **Skill selection** — only loads relevant skills<br>- **Memory pruning** — keeps important context, forgets noise<br>- **Tool context** — only includes tools that are actually available</p><p>— -</p><p>## Practical Examples: Seeing It in Action</p><p>### Example 1: Self-Improving Debugging</p><p>**Day 1:**<br>```<br>User: “My FastAPI app is returning 500 errors”<br>Hermes: *checks logs, identifies database connection pool exhaustion*<br>Hermes: *writes a diagnostic script, fixes the connection pool settings*<br>User: “Save this as a skill”<br>Hermes: *creates “fastapi-database-debugging” skill*<br>```</p><p>**Day 30:**<br>```<br>User: “My app is slow again”<br>Hermes: *loads fastapi-database-debugging skill*<br>Hermes: *runs the diagnostic script automatically*<br>Hermes: “Found the issue — same connection pool problem. Applied fix.”<br>```</p><p>### Example 2: Multi-Platform Coordination</p><p>```<br># On Telegram:<br>User: “Start a research session on quantum computing trends”<br>Hermes: *creates a new session with research tools*</p><p># On Discord (2 hours later):<br>User: “What’s the status of my quantum research?”<br>Hermes: *resumes the Telegram session*<br>Hermes: “Finished initial literature review. Found 12 key papers.”</p><p># On CLI:<br>User: “Export that research to a PDF”<br>Hermes: *accesses the research session data*<br>Hermes: *generates PDF with citations*<br>```</p><p>### Example 3: Autonomous Operation</p><p>```bash<br># Schedule a nightly backup<br>hermes cron create “0 2 * * *” “Backup the production database, verify integrity, and send me a report on Telegram”</p><p># Hermes will:<br># 1. Run at 2 AM daily<br># 2. Execute backup commands<br># 3. Verify the backup<br># 4. Generate a report<br># 5. Send via Telegram<br># 6. Log everything to sessions<br>```</p><p>— -</p><p>## For Intermediate Users: Extending Hermes</p><p>### Creating Custom Tools</p><p>Want Hermes to interact with your specific system? Create a tool:</p><p>```python<br># tools/custom_monitor.py<br>import json<br>import psutil<br>from tools.registry import registry</p><p>def check_requirements():<br> return True # Always available</p><p>def system_health_check():<br> cpu = psutil.cpu_percent(interval=1)<br> memory = psutil.virtual_memory().percent<br> disk = psutil.disk_usage(‘/’).percent</p><p>return json.dumps({<br> “status”: “healthy” if cpu &lt; 80 and memory &lt; 80 else “warning”,<br> “cpu”: cpu,<br> “memory”: memory,<br> “disk”: disk<br> })</p><p>registry.register(<br> name=”system_health”,<br> toolset=”monitoring”,<br> schema={<br> “name”: “system_health”,<br> “description”: “Check system health metrics”,<br> “parameters”: {}<br> },<br> handler=lambda args, **kw: system_health_check(),<br> check_fn=check_requirements,<br>)<br>```</p><p>### Building Skill Libraries</p><p>Skills aren’t just for Hermes to create. You can write them yourself:</p><p>```markdown<br> — -<br>name: kubernetes-debugging<br>description: Systematic approach to debugging Kubernetes deployments<br>triggers: [“k8s error”, “pod not starting”, “deployment failed”]<br> — -</p><p># Kubernetes Debugging Skill</p><p>## When to use<br>- Pods stuck in CrashLoopBackOff<br>- Services not routing traffic<br>- PersistentVolume claims failing</p><p>## Steps<br>1. Check pod status: `kubectl get pods`<br>2. Describe failing pod: `kubectl describe pod &lt;name&gt;`<br>3. Check logs: `kubectl logs &lt;pod&gt; — previous`<br>4. Verify resource limits and requests<br>5. Check network policies</p><p>## Common pitfalls<br>- Missing ConfigMaps or Secrets<br>- Incorrect image tags<br>- Resource quotas exceeded<br>```</p><p>### Multi-Agent Orchestration</p><p>For complex tasks, you can spawn multiple Hermes instances:</p><p>```bash<br># Agent 1: Backend development<br>tmux new-session -d -s backend ‘hermes -w’<br>sleep 8<br>tmux send-keys -t backend ‘Build REST API with authentication’ Enter</p><p># Agent 2: Frontend development<br>tmux new-session -d -s frontend ‘hermes -w’<br>sleep 8<br>tmux send-keys -t frontend ‘Build React dashboard for the API’ Enter</p><p># Agent 3: DevOps<br>tmux new-session -d -s devops ‘hermes -w’<br>sleep 8<br>tmux send-keys -t devops ‘Set up CI/CD pipeline’ Enter<br>```</p><p>— -</p><p>## The Philosophy: Why Hermes Works This Way</p><p>### 1. **Self-Improvement Over Static Intelligence**<br>Most AI tools are static — they have fixed capabilities. Hermes is designed to get better at your specific tasks over time. Each skill saved, each preference remembered, each workflow discovered makes it more useful.</p><p>### 2. **Persistence Over Disposability**<br>Chat interfaces are disposable. Hermes sessions are persistent artifacts that can be resumed, searched, and learned from. Your conversation history is a knowledge base, not just a chat log.</p><p>### 3. **Autonomy With Oversight**<br>Hermes can operate autonomously (via cron jobs, background processes), but always with clear boundaries and human oversight. The approval system lets you control what it can do without your direct input.</p><p>### 4. **Platform Agnosticism**<br>The same agent should work whether you’re at your terminal, on your phone, or integrating with other systems. The gateway architecture makes this possible without duplicating logic.</p><p>— -</p><p>## Getting Started: Your First Week with Hermes</p><p>### Day 1: Basic Setup<br>```bash<br># Install<br>curl -fsSL <a href="https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh">https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh</a> | bash</p><p># Configure<br>hermes setup</p><p># Try it out<br>hermes chat -q “Explain how you work”<br>```</p><p>### Day 2: Explore Tools<br>```bash<br># See what tools are available<br>hermes tools list</p><p># Try some basic operations<br>hermes chat -q “List my home directory and suggest organization improvements”<br>hermes chat -q “Search for recent papers on transformer architectures”<br>```</p><p>### Day 3: Memory and Skills<br>```bash<br># Set up your profile<br>hermes chat -q “Remember that I prefer Python over JavaScript and work on Ubuntu”</p><p># Create your first skill<br>hermes chat -q “Help me create a skill for my typical project setup workflow”<br>```</p><p>### Day 4: Multi-Platform<br>```bash<br># Set up Telegram integration<br>hermes gateway setup</p><p># Test it<br>hermes chat -q “Send me a test message on Telegram”<br>```</p><p>### Day 5: Automation<br>```bash<br># Create a daily task<br>hermes cron create “0 9 * * *” “Check my server health and send report”</p><p># Set up a webhook<br>hermes webhook subscribe github-events<br>```</p><p>— -</p><p>## Conclusion: The Living Agent</p><p>Hermes isn’t just a tool — it’s a framework for creating a personalized AI assistant that grows with you. The anatomy reveals a sophisticated system designed around a simple principle: **AI should adapt to humans, not the other way around**.</p><p>The key innovations:<br>1. **Memory that persists** — making each interaction build on the last<br>2. **Skills that evolve** — turning solutions into reusable knowledge<br>3. **Tools that connect** — bridging AI reasoning with real-world actions<br>4. **Platforms that unify** — one agent across all your communication channels<br>5. **Autonomy that respects boundaries** — independent operation with human oversight</p><p>Whether you’re a developer wanting to automate workflows, a researcher needing persistent context, or just someone who wants an AI that actually remembers your preferences, Hermes provides the architecture to make it happen.</p><p>The best way to understand Hermes isn’t to read about it — it’s to install it, give it a task, and watch it learn. Start simple, save your first skill, and experience what it’s like to work with an AI that actually gets better at helping you over time.</p><p>— -</p><p>## Resources</p><p>- **GitHub**: <a href="https://github.com/NousResearch/hermes-agent">https://github.com/NousResearch/hermes-agent</a><br>- **Documentation**: <a href="https://hermes-agent.nousresearch.com/docs/">https://hermes-agent.nousresearch.com/docs/</a><br>- **Skills Catalog**: `hermes skills browse`<br>- **Community**: <a href="https://discord.gg/nousresearch">https://discord.gg/nousresearch</a><br>- **Quick Start**: `curl -fsSL <a href="https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh">https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh</a> | bash`</p><p>— -</p><p>*”The best interface is no interface. The best assistant is one that learns.” — The Hermes Philosophy*</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73ef374bc068" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[uv build]]></title>
            <link>https://medium.com/@angelash18092007/uv-build-60999fc5482d?source=rss-95e006a3b630------2</link>
            <guid isPermaLink="false">https://medium.com/p/60999fc5482d</guid>
            <dc:creator><![CDATA[Ashwin]]></dc:creator>
            <pubDate>Mon, 16 Mar 2026 09:46:00 GMT</pubDate>
            <atom:updated>2026-03-16T09:46:00.720Z</atom:updated>
            <content:encoded><![CDATA[<h3>🐍⚡ The Ultimate `uv` Guide: From Zero to Hero</h3><p>A complete, step-by-step, actionable guide to mastering Python’s fastest project manager</p><p>📖 Table of Contents</p><ol><li>What is `uv` &amp; Why Should You Care?<br>2. Installing `uv`<br>3. Managing Python Versions<br>4. Creating Your First Project<br>5. Managing Dependencies<br>6. Running Code &amp; Scripts<br>7. Dev Dependencies &amp; Dependency Groups<br>8. Single-File Scripts (Inline Dependencies)<br>9. Running CLI Tools with `uvx`<br>10. Workspaces (Monorepos)<br>11. Building &amp; Publishing Packages<br>12. Docker Integration<br>13. Migrating from pip/Poetry<br>14. Cheat Sheet</li></ol><p>1️⃣ What is `uv` &amp; Why Should You Care?</p><p>uv is a high-performance Python package and project manager written in Rust. It was developed by Astral (the company behind the popular Ruff linter), and is designed to be the comprehensive solution for Python package management. With uv, you can replace a wide range of traditional tools in your workflow, such as:</p><ul><li>pip for installing packages<br>• pip-tools for dependency locking<br>• virtualenv/venv for environment management</li></ul><p>The Old Way (Multiple Tools)</p><p>pyenv → virtualenv → pip → pip-tools<br>4 separate tools, 4 syntaxes, slow</p><p>The `uv` Way (One Tool)</p><p>• Python versions<br>• Virtual environments<br>• Package management<br>• Dependency locking<br>• Script running<br>• Tool management<br>• Build &amp; publish</p><p>1 tool, blazing fast 🚀 (10–100x faster)</p><p>2️⃣ Installing `uv`</p><p>uv is a standalone binary that allows for a smooth installation and quick upgrades. You don’t need to have Python installed on your system to install uv.</p><p>On macOS / Linux:</p><p>curl -LsSf <a href="https://astral.sh/uv/install.sh">https://astral.sh/uv/install.sh</a> | sh</p><p>On Windows (PowerShell):<br>powershell -ExecutionPolicy ByPass -c “irm <a href="https://astral.sh/uv/install.ps1">https://astral.sh/uv/install.ps1</a> | iex”</p><p>With Homebrew:<br>brew install uv</p><p>With pip/pipx:<br>pipx install uv</p><p>✅ Verify &amp; Update:<br>uv — version<br>uv self update</p><p>3️⃣ Managing Python Versions</p><p>If Python is already installed on your system, uv will detect and use it without configuration. However, uv can also install and manage Python versions. uv automatically installs missing Python versions as needed — you don’t need to install Python to get started.</p><p>Install Python versions:<br>uv python install 3.12<br>uv python install 3.11 3.12 3.13</p><p>List available/installed versions:<br>uv python list<br>uv python list — only-installed</p><p>Pin a version for your project:<br>uv python pin 3.12</p><p>4️⃣ Creating Your First Project</p><p>This is where the magic begins! 👩</p><p>Initialize a new project:<br>uv init my-awesome-app<br>cd my-awesome-app</p><p>The main.py file contains a simple “Hello world” program. Try it out with `uv run`.</p><p>Project structure created:<br>my-awesome-app/<br>• .git/ — Git repo initialized<br>• .gitignore — Python-specific ignores<br>• .python-version — Pinned Python version<br>• README.md — Your project readme<br>• main.py — Entry point<br>• pyproject.toml — Project config &amp; dependencies</p><p>Run it immediately:<br>uv run main.py</p><p>5️⃣ Managing Dependencies</p><p>➖ Add dependencies:<br>uv add requests<br>uv add “flask&gt;=3.0”<br>uv add requests httpx rich</p><p>When you run `uv add`, it:<br>• Creates .venv/ (if not exists)<br>• Resolves dependencies (super fast!)<br>• Updates pyproject.toml<br>• Creates uv.lock (exact versions)<br>• Installs everything into .venv/</p><p>➖ Remove dependencies:<br>uv remove requests</p><p>🔄 Sync environment:<br>uv sync</p><p>🔐 Lock dependencies (without installing):<br>uv lock</p><p>📘 List installed packages:<br>uv pip list</p><p>📤 Export to requirements.txt:<br>uv export — format requirements-txt &gt; requirements.txt</p><p>6️⃣ Running Code &amp; Scripts</p><p>The `uv run` command — your new best friend:</p><p>uv run main.py<br>uv run -m pytest<br>uv run python -c “import requests; print(requests.__version__)”<br>uv run — python 3.11 main.py</p><p>Alternatively, activate the venv manually:<br>uv sync<br>source .venv/bin/activate # Linux/macOS<br># .venv\\Scripts\\activate # Windows<br>python main.py</p><p>Whenever you work on a project managed by uv, the tool will automatically detect and use the appropriate virtual environment without any additional setup.</p><p>7️⃣ Dev Dependencies &amp; Dependency Groups</p><p>uv uses the [dependency-groups] table (PEP 735) for development dependencies.</p><p>Add dev dependencies:<br>uv add — dev pytest<br>uv add — dev ruff mypy</p><p>Custom dependency groups:<br>uv add — group lint ruff<br>uv add — group test pytest pytest-cov<br>uv add — group docs sphinx</p><p>Sync specific groups:<br>uv sync # Syncs project deps + dev group<br>uv sync — group test # Also include the test group<br>uv sync — all-groups # Include ALL groups<br>uv sync — no-dev # Exclude dev (e.g., production)</p><p>Run with specific groups:<br>uv run — group test pytest<br>uv run — group lint ruff check .</p><p>8️⃣ Single-File Scripts (Inline Dependencies)</p><p>This is AMAZING for quick scripts and automation! 🔥</p><p>Inline script dependencies (PEP 723) make uv a strong choice for standalone scripts.</p><p>Create a script with inline deps:<br>uv add — script fetch_data.py requests rich</p><p>This adds a special comment header to your file:</p><p># /// script<br># dependencies = [“requests”, “rich”]<br># requires-python = “&gt;=3.12”<br># ///</p><p>import requests<br>from rich import print</p><p>response = requests.get(“<a href="https://api.github.com/zen">https://api.github.com/zen</a>&quot;)<br>print(f”[bold green]GitHub says:[/] {response.text}”)</p><p>Run it — uv handles everything:<br>uv run fetch_data.py</p><p>9️⃣ Running CLI Tools with `uvx`</p><p>uv executes and installs command-line tools provided by Python packages, similar to pipx.</p><p>Run tools instantly (without installing):<br>uvx ruff check .<br>uvx black .<br>uvx httpie GET <a href="https://httpbin.org/get">https://httpbin.org/get</a><br>uvx cowsay “uv is awesome!”</p><p>For quick, one-off tool usage without permanently installing it, uvx is your friend.</p><p>Install tools globally (persistent):<br>```py</p><p>uv tool install ruff<br>uv tool install black<br>uv tool list<br>uv tool upgrade ruff<br>uv tool upgrade — all<br>```</p><p>1️⃣️⃣ Workspaces (Monorepos)</p><p>Workspaces organize large codebases by splitting them into multiple packages with common dependencies.</p><p>Create a workspace structure:<br>my-monorepo/<br>• pyproject.toml (Workspace root)<br>• uv.lock (Shared lockfile)<br>• packages/<br> • api/ (pyproject.toml)<br> • core/ (pyproject.toml)<br> • cli/ (pyproject.toml)</p><p>Root pyproject.toml should include:<br>[tool.uv]<br>package = false</p><p>[tool.uv.workspace]<br>members = [“packages/*”]</p><p>Run commands in specific packages:<br>uv run — package my-api python -m uvicorn main:app<br>uv run — package my-cli python main.py</p><p>1️⃣️⃣ Building &amp; Publishing Packages</p><p>uv can build and publish Python packages to package repositories like PyPI.</p><p>Build your package:<br>uv build</p><p>This creates:<br>dist/<br>• my_library-0.1.0.tar.gz (Source distribution)<br>• my_library-0.1.0-py3-none-any.whl (Wheel/binary)</p><p>Publish to PyPI:<br>export UV_PUBLISH_TOKEN=pypi-xxxxxxxxxxxx<br>uv publish</p><p>Publish to a private index:<br>uv publish — index-url <a href="https://my-private-pypi.com/simple/">https://my-private-pypi.com/simple/</a></p><p>1️⃣️⃣ Docker Integration</p><p>uv’s standalone binary and fast installs make it well-suited for container builds.</p><p>Example Dockerfile:</p><p># Build Stage<br>FROM python:3.12-slim AS builder</p><p>COPY — from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv<br>WORKDIR /app<br>COPY pyproject.toml uv.lock ./<br>RUN uv sync — no-dev — frozen<br>COPY . .</p><p># Runtime Stage<br>FROM python:3.12-slim<br>WORKDIR /app<br>COPY — from=builder /app /app<br>CMD [“uv”, “run”, “ — no-sync”, “main.py”]</p><p>1️⃣️⃣ Migrating from pip / Poetry</p><p>From pip + requirements.txt:<br>cd my-existing-project<br>uv init<br>uv add -r requirements.txt<br>uv add — dev -r requirements-dev.txt</p><p>From Poetry:<br>uv reads pyproject.toml natively.<br># Remove poetry.lock, keep pyproject.toml<br>uv lock<br>uv sync</p><p>Quick command comparison:</p><p>Task | Old Way | uv Way<br>Install package | pip install requests | uv add requests<br>Install from file | pip install -r req.txt | uv add -r req.txt<br>Lock dependencies | pip-compile req.in | uv lock<br>Sync environment | pip-sync requirements | uv sync<br>Run script | python main.py | uv run main.py<br>Run tool once | pipx run ruff | uvx ruff<br>Remove package | pip uninstall requests | uv remove requests</p><p>1️⃣️⃣ The Ultimate Cheat Sheet</p><p>SETUP:<br>uv self update<br>uv python install 3.12<br>uv python pin 3.12</p><p>PROJECT:<br>uv init my-project<br>uv init — lib my-library</p><p>DEPENDENCIES:<br>uv add requests<br>uv add “flask&gt;=3.0,&lt;4”<br>uv add — dev pytest<br>uv add — group lint ruff<br>uv remove requests<br>uv lock<br>uv sync<br>uv sync — no-dev</p><p>RUNNING:<br>uv run main.py<br>uv run pytest<br>uv run — python 3.11 main.py</p><p>SCRIPTS:<br>uv add — script s.py requests<br>uv run s.py</p><p>TOOLS:<br>uvx ruff check .<br>uv tool install ruff<br>uv tool list<br>uv tool upgrade ruff</p><p>BUILD &amp; PUBLISH:<br>uv build<br>uv publish</p><p>EXPORT:<br>uv export — format requirements-txt &gt; requirements.txt</p><p>CACHE:<br>uv cache clean<br>uv cache dir</p><p>🌟 Summary: Why `uv` Changes Everything</p><p>⚡ 10–100x Faster<br>Seconds instead of minutes</p><p>📦 All-in-One<br>Replaces pip, pyenv, virtualenv, pipx, pip-tools, poetry, twine</p><p>🔐 Lockfile<br>Reproducible builds across machines</p><p>🐍 Python Management<br>Install &amp; switch versions easily</p><p>📦 Auto-venv<br>Never manually manage venvs again</p><p>📋 Inline Scripts<br>Single-file scripts with dependencies</p><p>🏇 Workspaces<br>Scale to monorepos</p><p>🐋 Docker-Friendly<br>Standalone binary, no Python needed to install</p><p>Projects created with uv remain compatible with other Python tools. You aren’t locked in. Now go build something awesome! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60999fc5482d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Single Most Impressive Thing I’ve Done]]></title>
            <link>https://medium.com/@angelash18092007/the-single-most-impressive-thing-that-ive-done-46fc51e060c4?source=rss-95e006a3b630------2</link>
            <guid isPermaLink="false">https://medium.com/p/46fc51e060c4</guid>
            <dc:creator><![CDATA[Ashwin]]></dc:creator>
            <pubDate>Tue, 05 Aug 2025 12:17:56 GMT</pubDate>
            <atom:updated>2025-08-06T07:54:15.789Z</atom:updated>
            <content:encoded><![CDATA[<p>As a curious nerd exploring paths and problems, finding solutions or ways to encounter challenges, I’ve been thinking about what should count as my most impressive achievement. It’s not easy to pinpoint just one thing.</p><p>In my opinion, it might be the contrarian math questions I’ve asked on Math Stack Exchange, rather than winning INOI Bronze’24 (though that was achieved in such a short time and was incredibly fun and impressive — but maybe not <em>the</em> most impressive).</p><p>I can’t really figure out my single most impressive thing that easily, so I’ll leave this list here for readers to judge:</p><p><strong>Potential contenders:</strong></p><p>• <strong>Starting a national Discord AI server</strong> to spread awareness for IOAI in the country long before the competition actually started. (The members who went to represent our country just two days ago were actually members of that server!)</p><p>• <strong>Cold emailing professors</strong> at each of the top universities and colleges in the country to ensure our nation’s participation in international competitions. Not sure if this should count, but it felt important.</p><p>• <strong>Taking part in the Pascal Quantum Challenge/Hackathon</strong> (got eliminated in the first stage due to an incomplete technical writeup for the solution — but the experience itself was impressive)</p><p>• <strong>A few non-trivial math questions</strong> that didn’t seem to get much appreciation in the Math Stack Exchange community:</p><ul><li><a href="https://math.stackexchange.com/questions/4656832/any-nice-way-to-find-zetan-where-n-is-any-positive-even-integer-using-inte">Complex analysis question about finding ζ(n) using integral calculus</a></li><li><a href="https://math.stackexchange.com/questions/4656789/is-there-any-valid-complex-or-just-real-solution-to-sinxcosx-2">Transcendental equation: sin(x)^cos(x) = 2</a></li><li><a href="https://math.stackexchange.com/questions/4656745/explicit-formula-for-autobiographical-numbers">Explicit formula for autobiographical numbers</a></li></ul><p>So, which one do you think should count as the most impressive?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46fc51e060c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Complete Guide to Autoencoders: From Basics to World Domination ]]></title>
            <link>https://medium.com/@angelash18092007/the-complete-guide-to-autoencoders-from-basics-to-world-domination-7709eef8c9b7?source=rss-95e006a3b630------2</link>
            <guid isPermaLink="false">https://medium.com/p/7709eef8c9b7</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[autoencoder]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[mls]]></category>
            <dc:creator><![CDATA[Ashwin]]></dc:creator>
            <pubDate>Sun, 13 Jul 2025 06:08:09 GMT</pubDate>
            <atom:updated>2025-07-13T06:08:09.146Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A comprehensive deep-dive into the neural networks that are quietly revolutionizing everything around us</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/0*QQTAr6RJ6lwRtq8K" /></figure><h3>Chapter 1: The Mind-Bending Basics 🧠</h3><h3>What the Hell is an Autoencoder Anyway?</h3><p>Imagine you’re trying to compress a 4K movie into a tiny file that still looks decent when you play it back. That’s essentially what an autoencoder does, but with data instead of movies. It’s like having a really smart compression algorithm that learns by itself.</p><p><strong>The Core Concept:</strong> An autoencoder is a neural network that tries to copy its input to its output. Sounds stupid, right? But here’s the twist — it forces the data through a narrow bottleneck in the middle, called the “latent space.” This bottleneck is like trying to squeeze an elephant through a keyhole — the network has to learn what’s REALLY important about the data to reconstruct it properly.</p><pre>Input → Encoder → Compressed Representation → Decoder → Output<br> [784]     [128]         [64]              [128]     [784]</pre><h3>The Architecture Breakdown</h3><p><strong>Encoder:</strong> The part that compresses your data into a smaller representation. Think of it as a skilled summarizer who can condense a 500-page book into a 50-page summary without losing the plot.</p><p><strong>Latent Space:</strong> The compressed representation — this is where the magic happens. It’s like DNA for your data — a compact code that contains all the essential information.</p><p><strong>Decoder:</strong> The part that reconstructs the original data from the compressed version. It’s like a skilled storyteller who can expand that 50-page summary back into a full novel.</p><h3>Why This Matters</h3><p>The beauty is that the latent space learns meaningful representations of your data. If you’re dealing with images of faces, the latent space might learn to encode things like “how much the person is smiling” or “what angle their face is at” — without anyone explicitly teaching it these concepts!</p><h3>Chapter 2: The Variant Universe 🌌</h3><h3>Vanilla Autoencoders: The OG</h3><p>These are your basic autoencoders — simple, elegant, and surprisingly powerful. They’re like the Honda Civic of neural networks: reliable, efficient, and gets the job done.</p><p><strong>Use Cases:</strong></p><ul><li>Data compression</li><li>Dimensionality reduction</li><li>Feature learning</li><li>Basic anomaly detection</li></ul><h3>Denoising Autoencoders: The Cleanup Crew</h3><p>These bad boys are trained on corrupted data and learn to reconstruct clean versions. It’s like having a neural network that’s really good at photo restoration.</p><p><strong>The Training Process:</strong></p><ol><li>Take clean data</li><li>Add random noise/corruption</li><li>Train the network to reconstruct the original clean data</li><li>Profit!</li></ol><p><strong>Real-World Applications:</strong></p><ul><li>Cleaning up old photos</li><li>Removing noise from audio recordings</li><li>Fixing corrupted datasets</li><li>Preprocessing data for other ML models</li></ul><h3>Variational Autoencoders (VAEs): The Creative Geniuses</h3><p>VAEs are like regular autoencoders but with a PhD in statistics. Instead of learning exact representations, they learn probability distributions. This means they can generate new data that looks similar to what they were trained on.</p><p><strong>The Magic:</strong></p><ul><li>Instead of encoding to a single point, they encode to a distribution</li><li>This allows for smooth interpolation between different data points</li><li>You can sample from the latent space to generate new data</li></ul><p><strong>Mind-Blowing Applications:</strong></p><ul><li>Generating new faces that don’t exist</li><li>Creating art in the style of famous painters</li><li>Drug discovery (generating new molecular structures)</li><li>Creating synthetic training data</li></ul><h3>Sparse Autoencoders: The Minimalists</h3><p>These enforce sparsity in the latent representation — meaning only a few neurons are active at any time. It’s like having a neural network that believes in “less is more.”</p><p><strong>Why Sparsity Rocks:</strong></p><ul><li>More interpretable representations</li><li>Better feature learning</li><li>Reduced overfitting</li><li>Biologically plausible (like how our brains work)</li></ul><h3>Convolutional Autoencoders: The Image Whisperers</h3><p>These use convolutional layers instead of fully connected ones, making them perfect for image data. They understand spatial relationships and can work with images of any size.</p><p><strong>Superpowers:</strong></p><ul><li>Preserving spatial structure</li><li>Translation invariance</li><li>Parameter efficiency</li><li>Perfect for image-based tasks</li></ul><h3>Chapter 3: Data Compression Revolution 📦</h3><h3>The Compression Game-Changer</h3><p>Traditional compression algorithms like JPEG and PNG are hand-crafted by humans. Autoencoders learn compression patterns directly from data, potentially achieving better results for specific types of content.</p><h3>Neural Codecs: The Future of Media</h3><p><strong>Image Compression:</strong> Companies like Google and Facebook are using autoencoder-based systems that can compress images 50% better than JPEG while maintaining quality. The network learns what parts of an image humans care about most.</p><p><strong>Video Compression:</strong> Netflix and YouTube are experimenting with neural video codecs that can:</p><ul><li>Adapt compression based on content type</li><li>Preserve important details while aggressively compressing backgrounds</li><li>Reduce bandwidth usage by up to 30%</li></ul><p><strong>Audio Compression:</strong> Spotify and other streaming services are using autoencoders for:</p><ul><li>Lossless compression of music</li><li>Real-time audio enhancement</li><li>Noise reduction in voice calls</li></ul><h3>The Technical Deep Dive</h3><p><strong>Rate-Distortion Optimization:</strong> Modern neural codecs use sophisticated loss functions that balance file size with quality:</p><pre>Loss = Distortion_Loss + λ × Rate_Loss</pre><p><strong>Perceptual Losses:</strong> Instead of just pixel-wise differences, these systems use perceptual losses that match how humans perceive quality.</p><h3>Chapter 4: The Anomaly Detection Superpower 🕵️</h3><h3>The Concept</h3><p>Autoencoders are naturally good at detecting anomalies because they learn to reconstruct “normal” data. When they encounter something weird, the reconstruction error goes through the roof.</p><h3>Cybersecurity Applications</h3><p><strong>Malware Detection:</strong></p><ul><li>Train on benign software</li><li>Malware produces high reconstruction error</li><li>Can detect zero-day attacks that signature-based systems miss</li></ul><p><strong>Network Intrusion Detection:</strong></p><ul><li>Learn patterns of normal network traffic</li><li>Detect unusual communication patterns</li><li>Identify data exfiltration attempts</li></ul><p><strong>Fraud Detection:</strong></p><ul><li>Credit card companies use autoencoders to spot unusual spending patterns</li><li>Insurance companies detect fraudulent claims</li><li>Banks identify suspicious account activities</li></ul><h3>Industrial Applications</h3><p><strong>Manufacturing Quality Control:</strong></p><ul><li>Train on images of perfect products</li><li>Automatically detect defects on assembly lines</li><li>Reduce waste and improve quality</li></ul><p><strong>Predictive Maintenance:</strong></p><ul><li>Learn normal sensor patterns from machinery</li><li>Detect early signs of equipment failure</li><li>Save millions in maintenance costs</li></ul><h3>Healthcare Anomaly Detection</h3><p><strong>Medical Imaging:</strong></p><ul><li>Detect tumors in X-rays, MRIs, and CT scans</li><li>Identify retinal diseases from eye photos</li><li>Spot skin cancer in dermatology images</li></ul><p><strong>Patient Monitoring:</strong></p><ul><li>Detect arrhythmias in ECG signals</li><li>Monitor vital signs for anomalies</li><li>Early warning systems for deteriorating patients</li></ul><h3>Chapter 5: The Creative AI Revolution 🎨</h3><h3>Generative Modeling with VAEs</h3><p>VAEs have unleashed a creative revolution in AI. They can generate entirely new content that looks realistic but never existed before.</p><h3>Art and Design</h3><p><strong>Style Transfer:</strong></p><ul><li>Take a photo and apply the style of Van Gogh</li><li>Generate infinite variations of a design</li><li>Create personalized artwork</li></ul><p><strong>Fashion Design:</strong></p><ul><li>Generate new clothing designs</li><li>Create virtual fashion shows</li><li>Personalized style recommendations</li></ul><p><strong>Architecture:</strong></p><ul><li>Generate building designs</li><li>Optimize layouts for different constraints</li><li>Create impossible architectural visualizations</li></ul><h3>Entertainment Industry</h3><p><strong>Game Development:</strong></p><ul><li>Generate infinite game levels</li><li>Create unique characters and assets</li><li>Procedural world generation</li></ul><p><strong>Movie Industry:</strong></p><ul><li>Generate realistic backgrounds</li><li>Create digital doubles of actors</li><li>Enhance special effects</li></ul><p><strong>Music Production:</strong></p><ul><li>Generate melodies and harmonies</li><li>Create backing tracks</li><li>Assist in music composition</li></ul><h3>The Technical Magic</h3><p><strong>Latent Space Interpolation:</strong> You can smoothly transition between different generated samples by interpolating in the latent space. It’s like having a smooth dial that controls the characteristics of generated content.</p><p><strong>Conditional Generation:</strong> You can control what gets generated by conditioning on additional information like text descriptions or categorical labels.</p><h3>Chapter 6: Real-World Industry Domination 🏭</h3><h3>Healthcare: Saving Lives with Math</h3><p><strong>Drug Discovery:</strong></p><ul><li>Generate new molecular structures</li><li>Predict drug interactions</li><li>Accelerate the discovery process from 10+ years to months</li></ul><p><strong>Medical Imaging:</strong></p><ul><li>Enhance low-quality scans</li><li>Detect diseases earlier than human doctors</li><li>Reduce radiation exposure by improving image quality</li></ul><p><strong>Genomics:</strong></p><ul><li>Analyze genetic sequences</li><li>Predict disease susceptibility</li><li>Personalized medicine</li></ul><h3>Finance: The Money-Making Machine</h3><p><strong>Risk Assessment:</strong></p><ul><li>Analyze market patterns</li><li>Predict financial crashes</li><li>Optimize investment portfolios</li></ul><p><strong>Algorithmic Trading:</strong></p><ul><li>Identify trading opportunities</li><li>Reduce transaction costs</li><li>Minimize market impact</li></ul><p><strong>Fraud Prevention:</strong></p><ul><li>Real-time transaction monitoring</li><li>Identity verification</li><li>Anti-money laundering</li></ul><h3>Manufacturing: The Efficiency Engine</h3><p><strong>Quality Control:</strong></p><ul><li>Automated defect detection</li><li>Reduce waste and recalls</li><li>Improve customer satisfaction</li></ul><p><strong>Supply Chain Optimization:</strong></p><ul><li>Predict demand patterns</li><li>Optimize inventory levels</li><li>Reduce costs</li></ul><p><strong>Predictive Maintenance:</strong></p><ul><li>Prevent equipment failures</li><li>Reduce downtime</li><li>Extend equipment lifespan</li></ul><h3>Retail: The Customer Experience Revolution</h3><p><strong>Recommendation Systems:</strong></p><ul><li>Personalized product suggestions</li><li>Improve customer satisfaction</li><li>Increase sales</li></ul><p><strong>Inventory Management:</strong></p><ul><li>Predict demand patterns</li><li>Optimize stock levels</li><li>Reduce waste</li></ul><p><strong>Price Optimization:</strong></p><ul><li>Dynamic pricing strategies</li><li>Maximize profit margins</li><li>Stay competitive</li></ul><h3>Chapter 7: The Cutting-Edge Frontiers 🚀</h3><h3>Multimodal Autoencoders</h3><p>These networks can handle multiple types of data simultaneously — images, text, audio, and more. They’re learning to understand the relationships between different modalities.</p><p><strong>Applications:</strong></p><ul><li>Image captioning that actually makes sense</li><li>Audio-visual speech recognition</li><li>Cross-modal search (find images using text descriptions)</li></ul><h3>Self-Supervised Learning</h3><p>Autoencoders are leading the charge in self-supervised learning, where models learn from unlabeled data. This is crucial because labeled data is expensive and time-consuming to create.</p><p><strong>Recent Breakthroughs:</strong></p><ul><li>Masked autoencoders for vision (like BERT for images)</li><li>Contrastive learning methods</li><li>Learning from video sequences</li></ul><h3>Federated Learning Applications</h3><p>Autoencoders are being used in federated learning to:</p><ul><li>Compress model updates</li><li>Preserve privacy</li><li>Enable collaborative learning without sharing raw data</li></ul><h3>Edge Computing</h3><p>Lightweight autoencoders are being deployed on mobile devices and IoT sensors for:</p><ul><li>Real-time processing</li><li>Reduced bandwidth usage</li><li>Privacy-preserving applications</li></ul><h3>Chapter 8: The Future is Autoencoded 🔮</h3><h3>Emerging Trends</h3><p><strong>Neural Architecture Search:</strong> Autoencoders are being used to automatically design better neural network architectures, potentially discovering new AI breakthroughs.</p><p><strong>Continual Learning:</strong> They’re helping AI systems learn new tasks without forgetting old ones — solving the “catastrophic forgetting” problem.</p><p><strong>Interpretable AI:</strong> The latent representations in autoencoders are becoming more interpretable, helping us understand what AI systems are actually learning.</p><h3>The Road to AGI</h3><p>As we move toward Artificial General Intelligence, autoencoders will likely play a crucial role in:</p><ul><li>Efficient representation learning</li><li>Unsupervised learning from massive datasets</li><li>Cross-modal understanding</li><li>Memory and knowledge compression</li></ul><h3>Potential Challenges</h3><p><strong>Ethical Considerations:</strong></p><ul><li>Deepfakes and misinformation</li><li>Privacy concerns with generative models</li><li>Bias in learned representations</li></ul><p><strong>Technical Limitations:</strong></p><ul><li>Mode collapse in generative models</li><li>Training instability</li><li>Computational requirements</li></ul><h3>Chapter 9: Building Your First Autoencoder 🛠️</h3><h3>The Basic Recipe</h3><p>Here’s a simple Python implementation to get you started:</p><pre>import torch<br>import torch.nn as nn<br>import torch.optim as optim</pre><pre>class SimpleAutoencoder(nn.Module):<br>    def __init__(self, input_dim, hidden_dim):<br>        super(SimpleAutoencoder, self).__init__()<br>        # Encoder<br>        self.encoder = nn.Sequential(<br>            nn.Linear(input_dim, hidden_dim),<br>            nn.ReLU(),<br>            nn.Linear(hidden_dim, hidden_dim // 2),<br>            nn.ReLU()<br>        )<br>        <br>        # Decoder<br>        self.decoder = nn.Sequential(<br>            nn.Linear(hidden_dim // 2, hidden_dim),<br>            nn.ReLU(),<br>            nn.Linear(hidden_dim, input_dim),<br>            nn.Sigmoid()<br>        )<br>    <br>    def forward(self, x):<br>        encoded = self.encoder(x)<br>        decoded = self.decoder(encoded)<br>        return decoded</pre><h3>Training Tips</h3><p><strong>Loss Functions:</strong></p><ul><li>MSE for continuous data</li><li>Binary cross-entropy for binary data</li><li>Perceptual losses for images</li></ul><p><strong>Regularization:</strong></p><ul><li>L1/L2 regularization</li><li>Dropout</li><li>Batch normalization</li></ul><p><strong>Hyperparameter Tuning:</strong></p><ul><li>Bottleneck size (compression level)</li><li>Learning rate</li><li>Architecture depth</li></ul><h3>Chapter 10: The Autoencoder Ecosystem 🌍</h3><h3>Popular Frameworks and Libraries</h3><p><strong>PyTorch:</strong></p><ul><li>Flexible and pythonic</li><li>Great for research</li><li>Dynamic computation graphs</li></ul><p><strong>TensorFlow/Keras:</strong></p><ul><li>Production-ready</li><li>Extensive ecosystem</li><li>Easy deployment</li></ul><p><strong>Specialized Libraries:</strong></p><ul><li>Pyro for probabilistic programming</li><li>Detectron2 for computer vision</li><li>Hugging Face for NLP</li></ul><h3>Pre-trained Models</h3><p><strong>Vision:</strong></p><ul><li>ImageNet-pretrained autoencoders</li><li>CLIP for multimodal understanding</li><li>DALL-E for image generation</li></ul><p><strong>NLP:</strong></p><ul><li>BERT and its variants</li><li>GPT family models</li><li>T5 for text-to-text tasks</li></ul><h3>Cloud Platforms</h3><p><strong>Google Cloud:</strong></p><ul><li>AutoML for automated model training</li><li>Vertex AI for model deployment</li><li>TPUs for fast training</li></ul><p><strong>AWS:</strong></p><ul><li>SageMaker for end-to-end ML</li><li>EC2 with GPU instances</li><li>S3 for data storage</li></ul><p><strong>Azure:</strong></p><ul><li>Azure Machine Learning</li><li>Cognitive Services</li><li>GPU-optimized VMs</li></ul><h3>Conclusion: The Autoencoder Revolution 🎯</h3><p>Autoencoders might seem like a simple concept — neural networks that try to copy their input to their output. But as we’ve seen throughout this guide, this “simple” idea has spawned a revolution that’s transforming industries, creating new forms of art, and pushing the boundaries of what’s possible with AI.</p><p>From compressing your Netflix streams to detecting cancer in medical images, from generating realistic faces to preventing credit card fraud, autoencoders are quietly working behind the scenes to make our digital world more efficient, secure, and creative.</p><p>The future of autoencoders is bright, with new applications emerging constantly. As we move toward more advanced AI systems, the fundamental principle of learning efficient representations through reconstruction will remain relevant and powerful.</p><p>Whether you’re a student just starting your AI journey, a developer looking to add new tools to your toolkit, or an entrepreneur seeking the next big opportunity, understanding autoencoders gives you a glimpse into the neural networks that are reshaping our world.</p><p>The autoencoder revolution is just beginning. Are you ready to be part of it?</p><p><em>“The best way to predict the future is to invent it.” — Alan Kay</em></p><p><em>And with autoencoders, we’re not just predicting the future — we’re compressing it, reconstructing it, and generating entirely new possibilities.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7709eef8c9b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[QServe: Making AI ChatBots Way Faster and Cheaper]]></title>
            <link>https://medium.com/@angelash18092007/qserve-making-ai-chatbots-way-faster-and-cheaper-36128e481014?source=rss-95e006a3b630------2</link>
            <guid isPermaLink="false">https://medium.com/p/36128e481014</guid>
            <category><![CDATA[gpu]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[inference-optimization]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm-applications]]></category>
            <dc:creator><![CDATA[Ashwin]]></dc:creator>
            <pubDate>Sat, 12 Jul 2025 13:32:05 GMT</pubDate>
            <atom:updated>2025-07-12T13:33:36.579Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://arxiv.org/abs/2405.04532"><strong>QServe: W4A8KV4 Quantization and System Co-design for Efficient LLM Serving</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jgSk7Q8PCsMqSeoZ" /><figcaption>Photo by <a href="https://unsplash.com/@ryunosuke_kikuno?utm_source=medium&amp;utm_medium=referral">Ryunosuke Kikuno</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Chapter 1: The Core Problem</h3><p><strong>Current State</strong>: INT4 quantization (making models 4x smaller) works great on phones/edge devices but SUCKS on cloud servers with multiple users.</p><p><strong>Why It Fails</strong>: When you compress a model to 4-bit, you need to “decompress” it back during computation. On GPUs serving many users, this decompression creates 20–90% overhead — making everything slower, not faster.</p><p><strong>Key Insight</strong>: GPU efficiency depends heavily on low-throughput CUDA cores (the “slow lanes” of GPU processing).</p><h3>Chapter 2: The QoQ Algorithm (The Smart Compression)</h3><p><strong>Name</strong>: QoQ = Quattuor-Octo-Quattuor (4–8–4 in Latin)</p><p><strong>The Recipe</strong>:</p><ul><li><strong>W4</strong>: Weights (model knowledge) → 4-bit</li><li><strong>A8</strong>: Activations (current thinking) → 8-bit</li><li><strong>KV4</strong>: Key-Value cache (conversation memory) → 4-bit</li></ul><p><strong>Why This Mix</strong>: 8-bit activations prevent accuracy loss while 4-bit weights/memory maximize speed gains.</p><h3>Chapter 3: Progressive Quantization (Smart Decompression)</h3><p><strong>Problem</strong>: Traditional methods decompress everything at once (expensive) <strong>Solution</strong>: Progressive quantization — decompress only what you need, when you need it</p><p><strong>Technical</strong>: Redesigned W4A8 GEMM (matrix multiplication) to minimize decompression overhead by doing it incrementally rather than all at once.</p><p><strong>Analogy</strong>: Instead of unzipping an entire folder to read one file, only unzip the specific file you need.</p><h3>Chapter 4: SmoothAttention (Memory Fix)</h3><p><strong>Problem</strong>: 4-bit KV cache makes attention mechanism “jumpy” and inaccurate <strong>Solution</strong>: SmoothAttention algorithm that stabilizes the attention computation</p><p><strong>How It Works</strong>: Applies smoothing techniques to prevent quantization errors from cascading through the attention mechanism.</p><p><strong>Result</strong>: Maintains model quality even with aggressive 4-bit memory compression.</p><h3>Chapter 5: System-Level Optimizations (GPU Hacks)</h3><p><strong>Three Key Optimizations</strong>:</p><ol><li><strong>Compute-Aware Weight Reordering</strong>: Rearrange model weights in memory for optimal GPU access patterns</li><li><strong>Register-Level Parallelism</strong>: Use GPU registers more efficiently to reduce decompression latency</li><li><strong>Fused Attention</strong>: Make attention operations memory-bound to fully exploit KV4 quantization benefits</li></ol><p><strong>Technical Goal</strong>: Minimize memory bandwidth bottlenecks and maximize compute utilization.</p><h3>Chapter 6: Implementation (QServe System)</h3><p><strong>Architecture</strong>: Complete inference library that integrates all optimizations <strong>Key Features</strong>:</p><ul><li>Custom CUDA kernels for W4A8 operations</li><li>Optimized attention mechanisms</li><li>Memory-efficient weight loading</li><li>Batched inference support</li></ul><h3>Chapter 7: Performance Results</h3><p><strong>Llama-3–8B</strong>:</p><ul><li>A100: 1.2x speedup</li><li>L40S: 1.4x speedup</li></ul><p><strong>Qwen1.5–72B</strong>:</p><ul><li>A100: 2.4x speedup</li><li>L40S: 3.5x speedup</li></ul><p><strong>Cost Efficiency</strong>: L40S with QServe &gt; A100 with TensorRT-LLM (3x cheaper hardware, same performance)</p><h3>Chapter 8: Why This Matters (Impact)</h3><p><strong>Technical Significance</strong>: First quantization method that accelerates large-batch cloud serving <strong>Economic Impact</strong>: 3x reduction in serving costs <strong>Industry Impact</strong>: Makes high-performance LLM serving accessible to smaller companies</p><p><strong>Breakthrough</strong>: Solves the “quantization doesn’t work in production” problem that has plagued the field.</p><h3>Key Takeaway</h3><p><a href="https://arxiv.org/abs/2405.04532">QServe</a> proves that with the right algorithm-system co-design, you can make AI models simultaneously faster AND cheaper to run at scale — a rare win-win in computer science.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36128e481014" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making LLMs Leaner: The Power of 4-bit Numeric Representation]]></title>
            <link>https://medium.com/@angelash18092007/making-llms-leaner-the-power-of-4-bit-numeric-representation-004214b02c38?source=rss-95e006a3b630------2</link>
            <guid isPermaLink="false">https://medium.com/p/004214b02c38</guid>
            <category><![CDATA[model-quantization]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[paper]]></category>
            <dc:creator><![CDATA[Ashwin]]></dc:creator>
            <pubDate>Sat, 12 Jul 2025 10:39:59 GMT</pubDate>
            <atom:updated>2025-07-12T10:39:59.326Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p8CCRaTJuK42prmjMyxUJA.png" /><figcaption>Abstract any4 quantization method</figcaption></figure><blockquote>Alright! Let me walk you through this <a href="https://arxiv.org/abs/2507.04610">paper</a> step by step, like we’re sitting down with a whiteboard and I’m explaining it to you as a curious 16-year-old who wants to understand the technical details. — Claude</blockquote><h3>Chapter 1: The Big Picture Problem</h3><h3>What Are Large Language Models?</h3><p>Think of ChatGPT, Claude, or any AI that can write essays. These are <strong>Large Language Models (LLMs)</strong>. They’re basically giant mathematical functions with billions of “knobs” (called parameters or weights) that have been adjusted to predict the next word in a sentence.</p><h3>The Storage Problem</h3><p>Here’s the issue: A 2 billion parameter model needs about 8 GB of memory just to store all those numbers. That’s like trying to fit 2,000 high-resolution photos in your phone’s RAM at once. Most regular computers can’t handle this.</p><h3>The Solution: Quantization</h3><p>Instead of storing each number with high precision (32 bits), we store them with lower precision (4 bits). It’s like going from describing colors with millions of shades to using just 16 crayons — you lose some detail, but you save massive amounts of space.</p><h3>Chapter 2: How Numbers Work in Computers</h3><h3>Bit Representation Basics</h3><pre>32-bit number: 11010001001011010110101011001010 (can represent ~4 billion values)<br>4-bit number:  1101 (can represent only 16 values: 0-15)</pre><h3>The Trade-off</h3><ul><li><strong>32-bit</strong>: Super accurate, uses lots of memory</li><li><strong>4-bit</strong>: Less accurate, uses 8× less memory</li></ul><h3>Chapter 3: The Existing 4-bit Formats</h3><h3>INT4 (Integer 4-bit)</h3><pre>Represents integers from 0 to 15 (or -8 to 7 if signed)<br>Example: 0000=0, 0001=1, 0010=2, ..., 1111=15</pre><pre>To convert a decimal number to INT4:<br>1. Scale it: scaled_value = original_value / scale_factor<br>2. Add offset: shifted_value = scaled_value + zero_point  <br>3. Round: quantized = round(shifted_value)<br>4. Clamp: final = clamp(quantized, 0, 15)</pre><p><strong>Problems with INT4:</strong></p><ul><li>Forces you to use evenly spaced levels</li><li>Wastes “slots” if your numbers aren’t evenly distributed</li></ul><h3>FP4 (4-bit Floating Point)</h3><pre>Like regular floating point, but tiny:<br>- 1 bit for sign (+ or -)<br>- 2 bits for exponent (how big/small)<br>- 1 bit for mantissa (precise value)</pre><pre>Can represent: 0, ±0.5, ±1, ±1.5, ±2, ±3, ±4, ±6, etc.</pre><p><strong>Problems with FP4:</strong></p><ul><li>Very limited precision</li><li>Gaps between representable numbers get bigger for larger values</li></ul><h3>NF4 (Normal Float 4)</h3><pre>Assumes your numbers follow a bell curve (normal distribution)<br>Uses pre-calculated optimal points for this distribution:<br>[-1.0, -0.6962, -0.5251, -0.3949, -0.2844, -0.1848, -0.0911, 0.0, <br>  0.0911, 0.1848, 0.2844, 0.3949, 0.5251, 0.6962, 1.0, and one more]</pre><p><strong>Problems with NF4:</strong></p><ul><li>What if your numbers don’t follow a normal distribution?</li><li>You’re stuck with these 16 specific values</li></ul><h3>Chapter 4: Enter any4 — The Revolutionary Approach</h3><h3>The Core Idea</h3><p>Instead of using fixed, predetermined quantization levels, <strong>let the computer figure out the best 16 values for each part of the model</strong>.</p><pre>Traditional approach: &quot;Here are 16 fixed buckets, sort your numbers into them&quot;<br>any4 approach: &quot;Let me design 16 custom buckets that fit your numbers perfectly&quot;</pre><h3>How any4 Works: The Lookup Table</h3><pre># Instead of mathematical formulas, any4 uses a lookup table<br>lookup_table = [<br>    -2.3451,  # Code 0000 maps to this value<br>    -1.8293,  # Code 0001 maps to this value  <br>    -1.2847,  # Code 0010 maps to this value<br>    -0.9234,  # Code 0011 maps to this value<br>    # ... 12 more values<br>    3.9284    # Code 1111 maps to this value<br>]</pre><pre># To dequantize (convert back to full precision):<br>def dequantize(four_bit_code):<br>    return lookup_table[four_bit_code]</pre><h3>The Learning Process</h3><pre># Step 1: Start with random 16 values<br>lut = [random_value() for _ in range(16)]</pre><pre># Step 2: For each weight in the layer<br>for iteration in range(many_iterations):<br>    # Try to represent all weights using current LUT<br>    quantized_weights = []<br>    for weight in original_weights:<br>        # Find closest value in LUT<br>        closest_index = find_closest(weight, lut)<br>        quantized_weights.append(lut[closest_index])<br>    <br>    # Measure how much error we have<br>    error = mean_squared_error(original_weights, quantized_weights)<br>    <br>    # Update LUT to reduce error (using calculus - gradients)<br>    lut = update_lut_to_reduce_error(lut, error)</pre><pre># Step 3: Keep the final optimized LUT</pre><h3>Chapter 5: Why any4 is Technically Superior</h3><h3>1. Adaptive Distribution Matching</h3><pre># For attention weights (clustered around zero):<br>attention_lut = [-0.1, -0.05, -0.02, -0.01, -0.005, 0, 0.005, 0.01, <br>                 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0]</pre><pre># For feed-forward weights (wider spread):<br>feedforward_lut = [-5.0, -3.0, -2.0, -1.5, -1.0, -0.5, 0, 0.5, <br>                   1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 7.0, 10.0]</pre><h3>2. Gradient-Based Optimization</h3><p>Unlike other methods that use heuristics, any4 uses actual calculus to find the optimal solution:</p><pre># The math behind it (simplified):<br># We want to minimize: Σ(original_weight - quantized_weight)²<br># <br># For each LUT entry lut[i], we compute:<br># gradient = ∂(error)/∂(lut[i])<br># <br># Then update: lut[i] = lut[i] - learning_rate × gradient</pre><h3>3. Per-Tensor Customization</h3><pre># Each layer/tensor gets its own custom LUT<br>model = {<br>    &#39;embedding&#39;: optimize_lut(embedding_weights),<br>    &#39;attention_q&#39;: optimize_lut(attention_q_weights),<br>    &#39;attention_k&#39;: optimize_lut(attention_k_weights),<br>    &#39;attention_v&#39;: optimize_lut(attention_v_weights),<br>    &#39;feedforward_1&#39;: optimize_lut(ff1_weights),<br>    &#39;feedforward_2&#39;: optimize_lut(ff2_weights),<br>    # ... and so on<br>}</pre><h3>Chapter 6: The Implementation — tinygemm</h3><h3>The Hardware Challenge</h3><pre>// Traditional quantization: simple math<br>result = (quantized_value - zero_point) * scale;</pre><pre>// any4: lookup operation<br>result = lookup_table[quantized_value];</pre><h3>GPU Optimization Strategy</h3><pre>// Store LUT in GPU registers (fastest memory)<br>__device__ float lut[16];  // Stored in registers, not global memory</pre><pre>// Dequantization kernel<br>__global__ void any4_dequantize(uint4* quantized, float* output, float* lut) {<br>    int idx = blockIdx.x * blockDim.x + threadIdx.x;<br>    output[idx] = lut[quantized[idx]];  // Single register lookup<br>}</pre><h3>Memory Layout Optimization</h3><pre>// Efficient memory layout for 4-bit values<br>// Pack 8 values into one 32-bit word<br>uint32_t packed = (val7 &lt;&lt; 28) | (val6 &lt;&lt; 24) | (val5 &lt;&lt; 20) | (val4 &lt;&lt; 16) |<br>                  (val3 &lt;&lt; 12) | (val2 &lt;&lt; 8)  | (val1 &lt;&lt; 4)  | val0;</pre><pre>// Extract 4-bit values efficiently<br>uint4 extract_4bit(uint32_t packed, int position) {<br>    return (packed &gt;&gt; (position * 4)) &amp; 0xF;<br>}</pre><h3>Chapter 7: The Experimental Results</h3><h3>Accuracy Improvements</h3><p>The paper shows any4 consistently beats other methods:</p><pre>Model: Llama-2-7B<br>Perplexity (lower is better):<br>- Original (32-bit): 5.47<br>- INT4: 6.23<br>- FP4: 6.89<br>- NF4: 5.92<br>- any4: 5.68  ← Best!</pre><h3>Calibration Efficiency</h3><pre># Traditional methods need lots of calibration data<br>traditional_calibration = 512_samples_from_dataset</pre><pre># any4 can work with just one good sample<br>any4_calibration = 1_carefully_chosen_sample</pre><h3>Memory Usage</h3><pre># Memory breakdown for 2B parameter model:<br>original_model = 2_billion_params * 4_bytes = 8GB<br>int4_model = 2_billion_params * 0.5_bytes = 1GB<br>any4_model = 2_billion_params * 0.5_bytes + lut_overhead ≈ 1GB + 32KB</pre><h3>Chapter 8: The Technical Advantages</h3><h3>1. No Preprocessing Required</h3><pre># Traditional advanced methods (AWQ, GPTQ):<br>calibration_data = load_representative_dataset()<br>quantized_model = expensive_calibration_process(model, calibration_data)</pre><pre># any4:<br>quantized_model = any4_quantize(model)  # Direct quantization</pre><h3>2. Flexible Bit Widths</h3><pre># The same approach works for any2, any3, any4, etc.<br>any2_lut = optimize_lut(weights, num_levels=4)    # 2-bit<br>any3_lut = optimize_lut(weights, num_levels=8)    # 3-bit<br>any4_lut = optimize_lut(weights, num_levels=16)   # 4-bit</pre><h3>3. Universal Applicability</h3><pre># Works on any model architecture<br>models = [<br>    &#39;llama2&#39;, &#39;llama3&#39;, &#39;mistral&#39;, &#39;mixtral&#39;, <br>    &#39;gpt&#39;, &#39;claude&#39;, &#39;gemini&#39;, &#39;custom_model&#39;<br>]</pre><pre>for model in models:<br>    quantized = any4_quantize(model)  # Just works</pre><h3>Chapter 9: The Limitations and Trade-offs</h3><h3>1. Quantization Time</h3><pre># INT4: Nearly instantaneous<br>int4_time = few_seconds</pre><pre># any4: Requires optimization<br>any4_time = few_minutes  # But only done once</pre><h3>2. LUT Storage Overhead</h3><pre># For very small tensors, LUT overhead matters<br>small_tensor_size = 64_parameters<br>lut_overhead = 16_values * 2_bytes = 32_bytes<br>overhead_percentage = 32/64 = 50%  # Significant!</pre><pre># For large tensors, negligible  <br>large_tensor_size = 1_million_parameters<br>overhead_percentage = 32/1_000_000 = 0.003%  # Tiny!</pre><h3>3. Implementation Complexity</h3><pre>// INT4 dequantization: 1 line<br>output = (input - zero_point) * scale;</pre><pre>// any4 dequantization: LUT management<br>output = lut[input];  // But need to manage LUTs per tensor</pre><h3>Chapter 10: Real-World Impact</h3><h3>Before any4</h3><pre># To run a 7B model, you needed:<br>gpu_memory = 14GB  # High-end GPU<br>or<br>cpu_memory = 28GB  # Lots of RAM</pre><h3>After any4</h3><pre># Same model now needs:<br>gpu_memory = 3.5GB  # Mid-range GPU<br>or  <br>cpu_memory = 7GB   # Regular computer</pre><h3>The Bigger Picture</h3><p>This means:</p><ul><li>AI models can run on gaming laptops</li><li>Faster inference for everyone</li><li>Lower costs for AI companies</li><li>More AI applications on mobile devices</li></ul><h3>Chapter 11: The Open Source Contribution</h3><h3>Code Release</h3><pre># They open-sourced everything:<br>- any4_quantization_algorithm<br>- tinygemm_optimized_kernels  <br>- benchmark_scripts<br>- model_implementations</pre><h3>Community Impact</h3><pre># Other researchers can now:<br>- Build upon their work<br>- Compare with their methods<br>- Integrate into existing frameworks<br>- Develop new applications</pre><h3>The Bottom Line</h3><p>any4 is like having a master craftsman who, instead of using a standard set of tools, creates custom tools perfectly suited for each specific job. It’s more work upfront, but the results are consistently better.</p><p>The key insight is: <strong>Why force your data into predetermined boxes when you can design boxes that fit your data perfectly?</strong></p><p>This paper represents a shift from “one-size-fits-all” quantization to “custom-tailored” quantization, and that’s why it’s getting attention in the AI community.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=004214b02c38" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[It’s Numb-ers' Time with Ruby !]]></title>
            <link>https://medium.com/@angelash18092007/whats-up-rubyists-e250802f8505?source=rss-95e006a3b630------2</link>
            <guid isPermaLink="false">https://medium.com/p/e250802f8505</guid>
            <category><![CDATA[fun]]></category>
            <category><![CDATA[education]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[math]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Ashwin]]></dc:creator>
            <pubDate>Fri, 24 Mar 2023 02:57:42 GMT</pubDate>
            <atom:updated>2023-03-24T08:20:50.958Z</atom:updated>
            <content:encoded><![CDATA[<p>Again getting bored from programming or need some new things to play with a cooler programming language ?</p><blockquote>No doubt , again we would be continuing the series with coolness of Ruby .</blockquote><h3>Let’s dive once again into the world of numbers via the ship of ruby !</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*Tx1pWt9UMhZOtRFoeQbliQ.jpeg" /><figcaption>#Numb-ers&#39; Time#</figcaption></figure><p>Hmm so even from high school we tried to find factors of a number all by hand but never thought of using common patterns or of any good algorithm for the tedious/boring task .</p><h4>So let’s see how cooler it’s implementation can be in Ruby class Integer :</h4><pre>class Integer<br>  def factors<br>    1.upto(Math.sqrt(self)).select {<br>      (self % _1).zero? <br>    }.inject([]) {<br>      _1 &lt;&lt; _2 &lt;&lt; self / _2<br>    }.uniq.sort<br>  end<br>end<br><br>pp 450.factors #=&gt; [1, 2, 3, 5, 6, 9, 10, 15, 18, 25, 30, 45, 50, 75, 90, 150, 225, 450]<br></pre><h3>#Explanation</h3><ol><li>So, first of all we are defining this factors method inside Integer class so that we can easily use it with as Integer.factors .</li><li>Inside the method we first travel(traverse) through whole number 1 to the square root of the number we wanna have factors of .</li><li>Then we filter the list to get numbers only which can divide our number i.e., self using “(self % _1).zero?” .</li><li>Then we chained it with inject method to inject numbers into factors&#39; array using “_1 &lt;&lt; _2 &lt;&lt; self / _2&quot; where _1 is the factors’array _2 and self/_2 are the factors of the numbers which are to be inserted into it .</li><li>At last we use uniq and sort method to return unique and sorted factors as an array .</li></ol><blockquote>Thanks again for spending some good time with your Rubyists articles .</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e250802f8505" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Some of the coolest things in Ruby with “prime”]]></title>
            <link>https://medium.com/@angelash18092007/some-of-the-coolest-things-in-ruby-with-prime-2a6d21df2796?source=rss-95e006a3b630------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a6d21df2796</guid>
            <category><![CDATA[cool]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[primes]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ideas]]></category>
            <dc:creator><![CDATA[Ashwin]]></dc:creator>
            <pubDate>Sat, 24 Dec 2022 10:54:04 GMT</pubDate>
            <atom:updated>2023-03-24T08:15:02.497Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Hi Rubyists and other programming enthusiasts 👋</blockquote><p>Being programmers , to get bored is common and when get bored numbers and maths can really be cool toys to play with and especially the “prime” class in ruby .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*biwkkFvFiJGqQJuW2wwEAw.jpeg" /><figcaption>#Prime Time#</figcaption></figure><p>Prime class in ruby is one of the finest and coolest creations in programming . It’s easier and a lot fun to get your hands dirty with numbers and maths using this class .</p><blockquote>So today I’m gonna share with you enthusiasts a really cool program using this strange-seeming “prime” class .</blockquote><p>#Prime Factorisation<br>Presenting a simple and sleek program in ruby to display prime-factorisation of any number .</p><pre>require &#39;prime&#39;<br>n = gets.to_i<br>#you may wrap the below code in a function too<br>if n &gt; 1<br>  puts Prime.prime_division(n).map{ <br>    _1.join(&#39;^&#39;)}<br>      .join(&quot;*&quot;)<br>      .gsub(&quot;^1&quot;,&quot;&quot;)<br>      .chomp(&quot;^1&quot;)<br>  }<br>else<br>  puts &quot;Are you crazy ?&quot;<br>end<br></pre><h4>So how have been this one ?</h4><h4>More fun or more useful ?</h4><p>For those curious minds who didn’t got that code in a shot . I’ll try to simplify stuff for them ✌️</p><blockquote>#Explanation:</blockquote><ol><li>So first of all we imported / loaded the &#39;prime&#39; class or library or module (whatever you like calling it)</li><li>Then we take user input i.e, a number (to play with)</li><li>Then if the number was greater than 0 we used Prime::prime_division method to get all the prime factors of number(n) along with their powers in a list of lists . For example :</li></ol><pre>Prime.prime_division(8)<br># it will return [2,3] as 8 = 2^3<br></pre><ul><li>Then chained it with Array::map{ _1.join(’^’) } which simply modifies lists like [2,3] into “2^3&quot;</li><li>Then joined all such parts with “ * ” in order to join and display all the prime factors raised to some powers</li><li>At the end we used String::gsub(“^1”,“”) in order to remove numbers raised to the power 1 to simply numbers like instead of “5^1” to simply “5” and also there’s String::chomp method at the end to remove any extra “^1” from the resulting string .</li><li>And after that there’s else part which displays a simple reminder if the number inputted was less than 1 .</li></ul><blockquote>Thanks for spending some good time with your rubyist’s articles !!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a6d21df2796" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>