<?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 Kartik G Bhat on Medium]]></title>
        <description><![CDATA[Stories by Kartik G Bhat on Medium]]></description>
        <link>https://medium.com/@kartikganapathi?source=rss-a9ba97f100d9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Lv76u0ZuDbRTxnIC-0F1Lg.jpeg</url>
            <title>Stories by Kartik G Bhat on Medium</title>
            <link>https://medium.com/@kartikganapathi?source=rss-a9ba97f100d9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 19:09:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kartikganapathi/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[Building a Multi-Agent Research Intelligence Platform with Google Cloud Run]]></title>
            <link>https://medium.com/@kartikganapathi/building-a-multi-agent-research-intelligence-platform-with-google-cloud-run-0cc60f160efc?source=rss-a9ba97f100d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/0cc60f160efc</guid>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[multiagent-system]]></category>
            <category><![CDATA[agent-development-kit]]></category>
            <category><![CDATA[google-adk]]></category>
            <category><![CDATA[google-cloud-run]]></category>
            <dc:creator><![CDATA[Kartik G Bhat]]></dc:creator>
            <pubDate>Tue, 11 Nov 2025 00:34:56 GMT</pubDate>
            <atom:updated>2025-11-11T00:34:56.257Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This article was created for the Google Cloud Run Hackathon — AI Agents Category</em></p><p><strong>The Challenge: Information Overload in Academic Research</strong></p><p>The AI/ML research landscape produces 200–275 papers daily on arXiv alone. Traditional keyword-based alerting systems fail to capture the semantic complexity of research interests. Researchers need systems that understand conceptual relationships, not just lexical matches.</p><p>I built a production-grade multi-agent system to solve this problem, deploying the entire architecture on Google Cloud Run’s serverless infrastructure.</p><p><strong>System Overview</strong></p><p><strong>Research Intelligence Agents</strong> is a serverless, event-driven platform that transforms passive literature search into active intelligence gathering through natural language understanding and automated knowledge graph construction.</p><p><strong>Core Capabilities</strong></p><p><strong>Semantic Watch Rules</strong>: Users define research interests in natural language rather than keywords. The system uses large language models</p><p>to match incoming papers against these semantic criteria, enabling queries like “papers contradicting specific findings” or “work extending particular methodologies.”</p><p><strong>Automated Knowledge Graph Construction</strong>: The platform builds a directed graph of research paper relationships, automatically detecting conceptual connections (extends, supports, contradicts) between papers. Current metrics: 52 indexed papers, 172 detected relationships, 12.7% graph density.</p><p><strong>Confidence-Scored Q&amp;A</strong>: A multi-agent pipeline generates answers with citation tracking and confidence scoring (0–1 scale), providing transparent reasoning about answer quality.</p><p><strong>Live Demo</strong>: <a href="https://frontend-up5qa34vea-uc.a.run.app/">https://frontend-up5qa34vea-uc.a.run.app</a></p><p><strong>Architecture: Cloud Run at Scale</strong></p><p>The system leverages all three Cloud Run resource types in a microservices architecture optimized for independent scaling and cost efficiency.</p><p>Services Layer (4 Microservices)</p><p><strong>Frontend Service</strong> (Public-facing)</p><p>- Static asset serving via Nginx</p><p>- D3.js-based interactive graph visualization</p><p>- Temporal snapshot interface for demonstration purposes</p><p><strong>API Gateway Service</strong> (Public endpoint)</p><p>- Request routing with dynamic service discovery</p><p>- CORS policy enforcement</p><p>- Single point of ingress for backend services</p><p><strong>Orchestrator Service</strong> (Internal)</p><p>- Multi-agent coordination using Google Agent Development Kit (ADK)</p><p>- Pipeline orchestration for Q&amp;A workflows</p><p>- Answer generation and confidence scoring coordination</p><p><strong>Graph Service</strong> (Internal)</p><p>- Knowledge graph query processing</p><p>- Relationship traversal and path finding</p><p>- Graph density and connectivity metrics</p><p>Jobs Layer (3 Batch Processors)</p><p><strong>ArXiv Watcher Job</strong></p><p>- Scheduled execution: Daily at 06:00 UTC</p><p>- Fetches new papers via arXiv API</p><p>- Publishes candidates to Pub/Sub topic</p><p><strong>Intake Pipeline Job</strong></p><p>- Parallel task execution: 5 concurrent workers</p><p>- Entity extraction and metadata enrichment</p><p>- Firestore persistence layer integration</p><p><strong>Graph Updater Job</strong></p><p>- Scheduled execution: Daily at 02:00 UTC</p><p>- Parallel task execution: 3 concurrent workers</p><p>- Relationship detection using multi-agent analysis</p><p>Worker Layer (1 Event Processor)</p><p><strong>Alert Worker</strong></p><p>- Event-driven consumption from Pub/Sub</p><p>- Asynchronous alert processing</p><p>- Email delivery via SendGrid integration</p><p><strong>Deployment Footprint</strong>: 8 Cloud Run resources utilizing all 3 resource types</p><p><strong>Multi-Agent Architecture</strong></p><p>The system implements six specialized agents using Google’s Agent Development Kit (ADK) with Gemini 2.5 Pro as the underlying language model.</p><p><strong>Agent Specialization</strong></p><p><strong>Entity Agent</strong>: Extracts structured metadata (authors, methodologies, datasets) and infers categorical classifications from unstructured paper content.</p><p><strong>Relationship Agent</strong>: Detects conceptual relationships between papers using large language model reasoning. Implements temporal constraint validation (papers can only reference earlier work).</p><p><strong>Answer Agent</strong>: Generates responses to natural language queries with explicit citation tracking and source attribution.</p><p><strong>Confidence Agent</strong>: Evaluates answer quality using multi-dimensional scoring criteria, producing calibrated confidence estimates.</p><p><strong>Graph Query Agent</strong>: Translates natural language graph queries into structured traversal operations.</p><p><strong>Alert Matching Agent</strong>: Performs semantic similarity matching between papers and user-defined watch rules, generating relevance explanations.</p><p>All agents use ADK primitives (LlmAgent, Runner, InMemorySessionService) for consistent lifecycle management and state handling.</p><p>Inter-agent communication occurs through Firestore as a shared data layer.</p><p><strong>Key Technical Challenge: Semantic Filtering Failure</strong></p><p>Hypothesis</p><p>Initial architecture used semantic embedding similarity as a pre-filtering step for relationship detection. The assumption: papers with high semantic similarity are more likely to have conceptual relationships.</p><p>This would reduce computational overhead by limiting LLM comparisons to semantically proximate paper pairs.</p><p>Empirical Result</p><p>The optimization <strong>degraded performance</strong>. Semantic filtering at various similarity thresholds (cosine similarity &gt; 0.7, 0.8, 0.9) consistently removed valid relationship candidates.</p><p><strong>Root Cause Analysis</strong>: Semantic embeddings capture topical and lexical similarity. Conceptual relationships often exist between papers in different subfields or using different terminology. LLMs excel at detecting these cross-domain conceptual links that embedding spaces miss.</p><p><strong>Example</strong>: Reinforcement learning papers extending supervised learning techniques showed low embedding similarity but strong conceptual relationships.</p><p>Solution: Brute Force with Selective Thresholds</p><p>- Full N×N comparison matrix (no semantic pre-filtering)</p><p>- Temperature parameter tuning: 0.3 → 0.7 for increased output diversity</p><p>- Relationship-type-specific confidence thresholds:</p><p>- Contradicts: 0.7 (requires high confidence due to claim severity)</p><p>- Extends/Supports: 0.5 (permits more exploratory relationships)</p><p>- Union strategy: Multiple LLM passes with result aggregation</p><p><strong>Performance Improvement</strong>: 66% increase in graph density (7.7% → 12.7%), 91% increase in detected relationships (90 → 172)</p><p><strong>Key Insight</strong>: Semantic similarity and conceptual relationship are orthogonal dimensions. LLMs provide superior performance for conceptual reasoning tasks.</p><p><strong>Cloud Run: Production Considerations</strong></p><p><strong>Architectural Advantages</strong></p><p><strong>Independent Service Scaling</strong>: Each microservice scales based on its specific load profile. Graph Service can handle query bursts independently of Orchestrator agent coordination load.</p><p><strong>Cost Optimization Through Scale-to-Zero</strong>: Services consume resources only during active request processing. Jobs execute on schedule without idle compute costs. Worker scales to zero during low message volume periods.</p><p><strong>Estimated monthly cost</strong>: $10–20 for light production usage.</p><p><strong>Deployment Velocity</strong>: Single-command deployment with automatic container building and service provisioning. No infrastructure configuration required.</p><p><strong>Service Discovery Pattern</strong>: Dynamic URL resolution at deployment time. API Gateway discovers backend service URLs programmatically, enabling infrastructure-as-code deployment without hardcoded endpoints.</p><p><strong>Deployment Optimization</strong></p><p><strong>Challenge</strong>: Initial build-deploy cycles required 15–20 minutes, impeding development iteration speed during the hackathon.</p><p><strong>Solution</strong>: Multi-stage Docker builds with pre-built base images containing Python dependencies. Application code changes trigger minimal rebuilds.</p><p><strong>Result</strong>: 8–10x deployment speedup (15–20 minutes → 1–2 minutes)</p><p>This optimization was critical for rapid iteration during compressed development timeline.</p><p><strong>Development Methodology: Incremental Complexity</strong></p><p>The system was developed using a phased approach prioritizing end-to-end validation before adding complexity.</p><p>Phase 1: Crawl</p><p>- Established basic ingestion pipeline</p><p>- Implemented simple Q&amp;A with citation tracking</p><p>- Validated core entity extraction</p><p>- <strong>Objective</strong>: Prove technical feasibility end-to-end</p><p>Phase 2: Walk</p><p>- Implemented knowledge graph construction</p><p>- Developed proactive alerting system</p><p>- Integrated multi-agent orchestration</p><p>- Added confidence scoring mechanisms</p><p>- Optimized graph density through parameter tuning</p><p>- <strong>Objective</strong>: Add intelligence and trust layers</p><p>Phase 3: Run</p><p>- Production deployment to Cloud Run</p><p>- Interactive visualization development</p><p>- Service health monitoring implementation</p><p>- Demo mode for presentation purposes</p><p>- <strong>Objective</strong>: Production readiness and demonstrability</p><p><strong>Technical Achievements</strong></p><p>Microservices Implementation</p><p>- Clear service boundaries with single responsibility principle</p><p>- API Gateway pattern for unified ingress</p><p>- Internal service isolation (orchestrator, graph-service unexposed)</p><p>- Dynamic service discovery for deployment flexibility</p><p>Cloud Run Resource Type Coverage</p><p>- <strong>Services</strong>: Real-time synchronous request handling</p><p>- <strong>Jobs</strong>: Scheduled batch processing with parallel execution</p><p>- <strong>Workers</strong>: Asynchronous event-driven processing via Pub/Sub</p><p>Multi-Agent Orchestration</p><p>- Domain-specialized agents with focused responsibilities</p><p>- Shared state management via Firestore</p><p>- Temperature parameter optimization (0.7) for output diversity</p><p>- Relationship-type-specific confidence thresholds for precision-recall optimization</p><p>Operational Monitoring</p><p>- Service health checks and status monitoring</p><p>- Structured logging with Cloud Logging integration</p><p>- Job execution history and failure tracking</p><p>- Performance metrics collection</p><p><strong>Lessons Learned</strong></p><p>Semantic Embeddings: Task-Specific Limitations</p><p>Embedding-based semantic similarity is effective for retrieval tasks but insufficient for conceptual reasoning. LLMs demonstrate superior performance in detecting cross-domain conceptual relationships that embedding spaces cannot capture.</p><p><strong>Implication</strong>: Use embeddings for information retrieval, reserve LLMs for reasoning tasks.</p><p>Multi-Agent Architecture: Specialization Benefits</p><p>Domain-specialized agents with focused prompts outperform general-purpose agents. The architecture enables independent prompt engineering per agent, simplifying optimization and debugging.</p><p><strong>Communication Pattern</strong>: Asynchronous communication via shared state (Firestore) provides loose coupling and independent scalability.</p><p>LLM Temperature: Diversity-Performance Tradeoff</p><p>Temperature parameter significantly impacts relationship detection recall. Higher temperature (0.7 vs 0.3) increased detected relationships by 91% while maintaining precision through confidence filtering.</p><p><strong>Strategy</strong>: Multiple inference passes with union aggregation compensates for stochastic variation at higher temperatures.</p><p>Deployment Optimization: Build Time Impact</p><p>Deployment velocity directly impacts development iteration speed. Build time optimization (15–20 min → 1–2 min) was critical for rapid prototyping during compressed timelines.</p><p><strong>Approach</strong>: Pre-built base images with dependency caching for minimal incremental rebuilds.</p><p><strong>Future Directions</strong></p><p><strong>Multi-Modal Analysis</strong>: Integration of Gemini vision capabilities for table and chart extraction from PDFs, enabling richer semantic understanding.</p><p><strong>Hybrid Search</strong>: Combination of keyword, vector, and graph-based retrieval for large-scale corpus queries (&gt;100 papers).</p><p><strong>Citation Network Analysis</strong>: Graph analytics for identifying influential papers, emerging trends, and research gap detection.</p><p><strong>Personalization</strong>: User-specific knowledge graphs tracking reading history and research context for personalized recommendations.</p><p><strong>Citation Verification</strong>: Claim-level verification with exact quote extraction and page number attribution for hallucination detection.</p><p><strong>Conclusion</strong></p><p>Building a production-ready multi-agent system in four days required serverless infrastructure that abstracted operational complexity. Cloud Run enabled deployment of 8 resources (4 services, 3 jobs, 1 worker) without infrastructure management overhead.</p><p>The project’s key technical finding: semantic similarity-based optimization degraded performance for conceptual reasoning tasks. LLMs demonstrate superior cross-domain relationship detection compared to embedding-based approaches.</p><p>Cloud Run + Google ADK + Gemini 2.5 Pro provides a powerful foundation for serverless AI agent systems requiring minimal operational overhead.</p><p>The platform provides intelligent, proactive literature monitoring that understands conceptual relationships rather than keyword matches.</p><p>— -</p><p><strong>Technical Specifications</strong></p><p><strong>Purpose</strong>: Google Cloud Run Hackathon — AI Agents Category</p><p><strong>Technology Stack</strong>:</p><p>- LLM: Google Gemini 2.5 Pro</p><p>- Framework: Google Agent Development Kit (ADK)</p><p>- Infrastructure: Cloud Run (4 services, 3 jobs, 1 worker)</p><p>- Database: Firestore (native mode)</p><p>- Messaging: Pub/Sub</p><p>- Notifications: SendGrid</p><ul><li>Visualization: D3.js force-directed graphs</li></ul><p><strong>Production Deployment</strong>: <a href="https://frontend-up5qa34vea-uc.a.run.app/">https://frontend-up5qa34vea-uc.a.run.app</a></p><p><strong>Source Code</strong>: <a href="https://github.com/kar-ganap/research-intelligence-agents">https://github.com/kar-ganap/research-intelligence-agents</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0cc60f160efc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Some important papers in LLM evolution — Part 1]]></title>
            <link>https://medium.com/@kartikganapathi/some-important-papers-in-llm-evolution-part-1-1cbbda9d2127?source=rss-a9ba97f100d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cbbda9d2127</guid>
            <category><![CDATA[attention]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[literature-review]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Kartik G Bhat]]></dc:creator>
            <pubDate>Thu, 13 Jul 2023 19:49:46 GMT</pubDate>
            <atom:updated>2023-07-29T17:30:51.748Z</atom:updated>
            <content:encoded><![CDATA[<h3>Some important papers in LLM evolution — Part 1</h3><p>In this multi-part series, I will summarize my key takeaways from some of the classic, seminal, and important papers leading up to present-day large language models (LLMs). Thanks to Sebastian Raschka for his amazing <a href="https://magazine.sebastianraschka.com/p/understanding-large-language-models">reading list</a> that I intend to follow along in this course. This is meant to serve as a complementary reading (to the original articles) for folks trying to get their feet wet in this field, like me, and do not mind <em>reasonable-but-somewhat-speculative</em> what-ifs! Without further ado, let’s get started.</p><ol><li><a href="https://arxiv.org/pdf/1409.0473.pdf"><strong>Neural Machine Translation by Jointly Learning to Align and Translate </strong>(ICLR 2015)</a>: With ~30 K citations already, it’s unlikely I’ll say something novel. However, to summarize some of the points I personally found subtle:</li></ol><p>i) <strong>Can a longer context vector help?</strong>: While an important part of the hypothesis of the authors is that the restriction of fixed-length encodings (present in the then SOTA encoder-decoder models) is a severe one that the <em>attention </em>overcomes by dynamically choosing optimal alignment for each target position, I’d have liked to see a clearer empirical evidence. To wit, notwithstanding higher computational cost, can a longer (position-independent) context vector match the performance of soft, dynamic attention-based alignment i.e., when looking at sentences of at most <em>n </em>words, will a context vector of length, say, 3x that of attention model get closer to its performance than at matched lengths, as shown in Figure2? I suspect the answer is in the affirmative despite not being practically useful over its attention counterpart.</p><p>ii) <strong>Attention is weakly order-dependent</strong>: Consider a) <em>I do not like you, because…</em> and b) <em>I do like you, not because…</em> which contain the same words ordered differently and where we expect what follows to be semantically vastly different. The relative importance of the constituent words in determining the next word would be captured mainly in the differences in <em>h</em>_{j}s in the two cases. While contexts <em>c</em>_{i}s depend on the ordering indirectly through <em>e</em>_{ij}s being function of <em>s</em>_{i-1}s, the fractional change in resulting α_{ij}s, I hypothesize, wouldn’t be significant. In essence, the attention would be more-or-less similarly placed but the resulting contexts would be different due to different annotations (<em>h</em>s).</p><p>iii) <strong>What’s the deal with alignment not being a latent variable model?</strong>: The authors refer to alignment model <em>a </em>not being a latent variable model (p4). To understand this comment, one needs to appreciate why previously the community had tried latent variable models. Please refer to <a href="https://arxiv.org/pdf/1812.06834.pdf">this tutorial</a> for a detailed exposition.</p><p>As a brief summary: a) latent variable models can be a means to introduce inductive biases into a generative model since declarative knowledge can be incorporated by means of a specific factorization of the joint probability distribution of data and latent variables; b) in some of those cases, we can even assign interpretability to the latent variables wherein we’d like to infer the most likely values given data; c) while argmax(Pr(<em>z</em>|<em>x</em>;<em>θ</em>)) = argmax(Pr(<em>x</em>, <em>z</em>|<em>θ</em>)) (<em>x</em>,<em>z</em> are data and latent variables resp.), computing Pr(<em>z</em>|<em>x</em>;<em>θ</em>) = Pr(<em>x</em>, <em>z</em>|<em>θ</em>)/Pr(<em>x</em>|<em>θ</em>)) could be intractable since denominator could either involve an integral (over <em>z</em>) that’s hard to compute when <em>z </em>is continuous or #possible paths in the directed acyclic graph (DAG) between <em>x</em> and <em>z </em>grows exponentially with token# when <em>z</em> is discrete; d) although c) looks like a problem during inference alone, it can be shown that maximizing the log likelihood of data (log(Pr(<em>x</em>|<em>θ</em>))) during training requires one to estimate Pr(<em>z</em>|<em>x</em>;<em>θ</em>) because gradient can be expressed as computation of expected value under the distribution Pr(<em>z</em>|<em>x</em>;<em>θ</em>); e) the most common approach to deal with this intractability is using <em>variational inference</em> where one intends to find a parametric probability distribution over <em>z </em>that maximizes <em>evidence lower bound</em> (ELBO) defined as the -ve of the KL divergence between itself and Pr(<em>x</em>, <em>z</em>|<em>θ</em>); f) in practice, maximizing ELBO is also pretty prohibitive, leading to alternating <em>K</em>:1 updates of variational parameter <em>λ</em> (E-step at constant <em>θ</em>) and <em>θ </em>(M-step at constant <em>λ</em>) are done in a coordinate ascent/EM-like manner; g) finally, in f), one still has a different latent variable for each data point, and, hence a different <em>λ. </em>This can be further optimized by using shared parameter vector <em>ϕ</em> such that <em>λ</em>_{i} = <em>f</em>(<em>ϕ</em>,<em>x</em>_{i}) which is learned via back propagation simultaneously along with <em>θ</em> (in an approach known as <em>amortized stochastic variational inference, ASVI</em>).</p><p>With the above in mind, my reading of authors’ comment is that the alignment model is similar to ASVI that overcomes many of the computational challenges of inference in traditional latent variable models. Interpreting <em>e</em>_{ij}s as 𝒪(<em>T</em>²) discrete latent variables (where <em>T</em> is the #words in a sentence), even with a simple DAG could lead to c) above and amortizing computation of <em>e</em>_{ij}<em>s </em>through the alignment network sharing parameters across all ij is critical to avoiding it.</p><p>iv) <strong>Is there such a thing as many-word attention?</strong>: An open question in my mind, following authors’ use of energy metaphor for e_{ij}s, is whether it’d be possible to define α terms over &gt;2 indices. Currently we interpret α_{ij} as a pairwise relationship between target <em>i</em> and source <em>j — </em>amount of attention needed on <em>j</em>-th source word to generate <em>i</em>-th target word. While this is the simplest relationship, drawing inspiration from <a href="https://en.wikipedia.org/wiki/Green%27s_function_(many-body_theory)">many-body physics</a>, is it reasonable to talk about, say, α_{ijk} that is irreducible to an effective 2-index representation upon summing over the third index? I suspect at least in sentences where multiple, disparate chunks are eventually tied together, such notions will be useful e.g., <strong><em>composition-ability</em></strong><em>, which is the ability of a speaker to meaningfully string together multiple known concepts in a coherent manner, </em><strong><em>analogiz-ability</em></strong><em>, which refers to one’s facility to find simpler objects that contain same essential properties as the ones the speaker wishes to talk about, and, </em><strong><em>modulation</em></strong><em>, which is the art of varying amplitude and frequency in an intentional way to maximize the effect of the content are </em><strong><em>three qualities </em></strong><em>that make a good public speaker great</em>—with attention points spaced far apart from each other.</p><p>2. <a href="https://arxiv.org/pdf/1706.03762.pdf"><strong>Attention Is All You Need</strong> (NIPS 2017)</a>: In the previous paper, the role of <em>attention </em>was primarily in determining which words in the input should the output “attend” to i.e., the concept of attention was applied at the word- (technically, word-embedding-) level. While enabling the flexibility to soft-align was the key innovation, it still suffered from the problem of sequential computation that is the consequence of underlying recurrent neural nets (RNNs) which rely on <em>h</em>_{t-1} to compute <em>h</em>_{t} (needed to determine the context). This paper proposes eliminating the use of RNNs altogether (hence the <em>all you need</em> in the title) thus removing the bottleneck to parallelizability. The points I believe are worthy of highlighting are:</p><p>i) <strong>Self-attention</strong>: The notion of self-attention is not novel to this paper — <a href="https://arxiv.org/pdf/1703.03130.pdf">Lin et al. (ICLR 2017)</a> talk about self-attention as a way to generate interpretable sentence-level embeddings. Intuitively this seems reasonable since highlighting which parts/words of the sentence are closely related with one another is likely a useful task-agnostic representation to learn. While the specific expression for attention is simpler than that of Lin et al., here the authors use self-attention more extensively — input to attend to itself in the encoder, output (masked+shifted input in case of language modeling) to attend to itself in decoder, and output to attend to input in the second attention sublayer of decoder. In addition, more abstract features are also similarly attended to by stacking multiple (<em>N</em>) encoder-decoder layers.</p><p>ii) <strong>Dimensions of different matrices</strong>: Since it’s not mentioned explicitly in the paper, I will summarize the dimensions as it is critical to understanding Table1 of the paper which conveys the key observation of the paper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nFIWtpbGtXNGLW_SaQ-n9A.png" /><figcaption>Figure 1: Summary of dimensions of key matrices in both Vaswani et al. and Bahdanau et al. expressed in the notation of former to enable clear comparison (to be precise, s_{i-1} is actually of size d_{model}/2 but using d_{model} is fine for determining the computational complexity).</figcaption></figure><p>In case of RNNs (Bahdanau et al.), the computational complexity in determining <em>c</em>_{i} is <em>n</em>𝒪(<em>d</em>_{model}²) since determining each of <em>h</em>_{<em>i</em>} needs 𝒪(<em>d</em>_{model}²) (corresponding to matrix-vector product) as the linear projection of <em>h</em>_{i-1} is on to a space of 𝒪(<em>d</em>_{model}). On the other hand, in case of transformers (Vaswani et al.), by noting that the computational complexity of a single attention head is close to that of the multi-head for simplicity, we see that the multiplication of <em>softmax(QK^⊤) </em>(<em>n×n</em>) and <em>V </em>(<em>n×d_{v}</em>) is 𝒪(<em>n²d_{model}</em>) (since <em>d</em>_{v} is 𝒪(<em>d</em>_{model}).</p><p>iii) <strong>Role of second attention-head in the decoder</strong>: Note that the “cross-attention” between input and output occurs in this sublayer. As for the specific choices of <em>signal routing</em> i.e., <em>K</em> and <em>V</em> from the output of the corresponding encoder and <em>Q </em>from the output of the first attention-head of the decoder, we note that <em>Q </em>is similar to <em>h</em>_{j} in the first paper, <em>K </em>is analogous to s_{i-1}. By using <em>V </em>from the encoder, it seems like the expression for attention herein differs qualitatively from that of previous paper in that the annotations come from output rather than input. However, provided enough expressivity I believe this should be OK since the compatibility — the key determinant in creating correct attention maps — is still being evaluated using a dot product between encoder and decoder.</p><p>iv) <strong>Positional encoding</strong>: While as <a href="https://arxiv.org/pdf/1703.03130.pdf">Liu at al.</a> note that preserving semantics across all time-steps is not necessary for a good sentence embedding, we know that a sentence is not a bag of words and, hence, retaining some positional information of words/tokens would be necessary. This is the authors’ motivation for adding positional encoding to inputs, since projection of <em>Q</em>, <em>K</em>, <em>V</em> without this would remove all temporal information. The choice of closed-form expressions is a neat one because, as the authors note, it enables extrapolation to sentences longer than ones seen during training. The introduction of both sine and cosine is likely motivated by the fact of being able to refer to relative positions using absolute ones in a simple manner i.e., sin(<em>A+B</em>) = sin(<em>A</em>)cos(<em>B</em>)+cos(<em>A</em>)sin(<em>B</em>) and cos(<em>A+B</em>) = cos(<em>A</em>)cos(<em>B</em>) — sin(<em>A</em>)sin(<em>B</em>) (refer to <a href="https://timodenk.com/blog/linear-relationships-in-the-transformers-positional-encoding/">this blog post</a> for more details). While the authors hypothesize but do not prove that being able to refer to relative positions aids learning, it’s likely true since connecting to multiple different parts eventually involves transforming to relative offsets even if one were to start from absolute positions. Lastly the specific form of wavelength (2π×<strong>10000</strong>^{2<em>i</em>/<em>d</em>_{model}}) allows for using a wide range of values (owing to geometric progression) and hence to incorporate encodings in case of very long sentences.</p><p>v) <strong>Diversity of learned representations</strong>: Unlike <a href="https://arxiv.org/pdf/1703.03130.pdf">Liu at al.</a> who introduce an attention-based loss term that explicitly penalizes attentions that are similar, thereby encouraging different attention-heads to focus on different parts and/or aspects of a sentence, in this paper the authors do not use such regularizations. They, however, use dropout and label-smoothing regularizations which are not specific to self-attention mechanism. So it remains unclear how diverse the resultant attention heads are, and, if by using above-mentioned technique one could further improve the model performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cbbda9d2127" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Model compression in reinforcement learning — Part 2]]></title>
            <link>https://medium.com/@kartikganapathi/model-compression-in-reinforcement-learning-part-2-8e57269c8386?source=rss-a9ba97f100d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e57269c8386</guid>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[literature-review]]></category>
            <category><![CDATA[model-compression]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[multi-task-learning]]></category>
            <dc:creator><![CDATA[Kartik G Bhat]]></dc:creator>
            <pubDate>Fri, 23 Jun 2023 15:18:09 GMT</pubDate>
            <atom:updated>2023-06-23T15:34:53.727Z</atom:updated>
            <content:encoded><![CDATA[<h3>Model compression in reinforcement learning — Part 2</h3><p>This is the second of the two-part post on review of couple of papers on model compression, specifically distillation in the multi-task setting, in reinforcement learning (part 1 covering related previous work is <a href="https://medium.com/p/91970a84a24a">here</a>).</p><ol><li><a href="https://arxiv.org/pdf/2210.02240.pdf"><strong>On Neural Consolidation for Transfer in Reinforcement Learning</strong> (IEEE ADPRL 2022)</a>: This work builds on the work presented in ICLR 2016 paper on <a href="https://arxiv.org/pdf/1511.06342.pdf">Actor-Mimic Network</a> (AMN) in the context of transfer learning. Specifically it empirically studies how model distillation could affect the transfer learning objective (i.e., trainability of new tasks). Additionally it clarifies how certain hyper-parameter choices affect the performance of the distilled network in multitask learning, thus guiding algorithm design. One key difference w.r.t. AMN is that herein the expert network too is trained in an interleaved manner together with AMN i.e., in two phases that the authors refer to as active and passive phases. In this, it resembles the online learning setting discussed in the <a href="https://arxiv.org/pdf/1511.06295.pdf">policy distillation paper</a> but for multitask learning. Additionally the active phases (training experts) are initialized with AMN weights from the previous passive phase (training AMN). Another difference is that it’s the expert policies that generate the new trajectories like in the policy distillation paper. Some of the interesting observations from the paper are:</li></ol><p>i) <strong>Design choices for multitask training</strong>: Two important questions to answer in training AMN are: a) whether to consider a loss function that’s the sum of those of individual tasks (and use it for all tasks) or to use a loss function corresponding to the particular task when experience from that specific task is being sampled, and, b) at what granularity should one switch between tasks in any given epoch (e.g., every time-step of each game, entire trajectory or somewhere in-between at fixed number of time-steps). For a), the paper shows that the two approaches do not show significant difference although the variance seems higher for the composite loss (Figure 1). It is worth examining gradients from individual tasks and evolution of learned representations in both cases to see what regions of game-space are being explored. For b), switching after an entire episode of the game leads to faster training (Figure 2). This could be because of the detrimental effect Q values from a different task (which could also be vastly differently in scale), and hence the updates to Q values of current task, could have mid-episode thus leading the trajectory astray.</p><p>ii) <strong>Distillation as a filtering mechanism for knowledge transfer</strong>: Figure 6 of the paper shows that the distilled AMN, even if not converged as far the distillation goes, still learns useful features of task(s) to help transfer learning to a new task. Figure 7 that, in effect, shows the results of the control experiment wherein the weights of one expert network are directly cloned to initialize weights for a new task suggests that without distillation the transfer effect could either be positive or negative. However distillation preserves the positive transfer and seems to inhibit the negative one. I’d have been more convinced of the latter if the authors were to have shown all (7) possible combinations of distilling 3 games considered in Figure 6.</p><p>I found the results in Figures 3 and 4 taken together somewhat puzzling. While the former shows that a trained AMN can effectively jumpstart the training of the same expert it was distilled from, the latter suggests that the features of trained AMN (I believe the expert network had access to features from all layers of AMN) do <strong>not</strong> seem to provide any advantage in training the next phase of the expert network. I am inclined to think that it is the node weights and not the features (layer outputs), that are critical to ensure transferability. This is also in sync with earlier results from Parisotto et al. where feature regression objective did not seem to help better transfer-learn in most cases. While transferring weights might, at first glance, seem too restrictive in terms of architecture choices for the new network, since in most cases we’d like to use the same distilled network for a new task, this will likely not limit the usefulness of distillation.</p><p>2. <a href="https://arxiv.org/pdf/2210.02224.pdf"><strong>Neural Distillation as a State Representation Bottleneck in Reinforcement Learning</strong> (CoLLAs 2022)</a>: This paper focuses on the state representation in RL and how distilling from multiple tasks/experts could serve as a means of retaining positive transfer effects. In essence, this is a more detailed treatment of #2 from the paper above wherein what constitutes a good state representation is clearly laid out and an AMN student network is judged along those lines. Concretely, two properties of good representation are: i) they retain attention on important features in the data and filter out unimportant, confounding, redundant and noisy ones; ii) those corresponding to similar optimal actions are closer. <em>Although the third property of performance robustness mentioned in section 3.1 is obviously a useful one, given that it’d also depend on the similarity of the new task to the ones seen during distillation, it’ll need to be more carefully defined</em>.</p><p>I particularly liked the approach of creating the toy inverted pendulum problem to measure the goodness of resultant state representations. Two key results from this study are: i) the AMN (when 4 or more experts were distilled) was able to emphasize the true underlying variables and deemphasizing other derived ones across all tasks even while the individual expert networks were unable to do so; ii) as t-SNE plots showed, AMN states displayed more <em>homophily</em> than did the expert networks. Finally given that the new levels were constructed using a process similar (i.e., augmenting original variables with different set of linear combination of weights for indices 4 to 13) to the ones using for training the student network, the distilled network generalizes well to unseen levels as well.</p><p>While the results of distilled network performance are impressive, the exact mechanism of distillation still needs further investigation. What lends the student network greater robustness than the teacher, particularly since latter is only learning to imitate the former, remains unclear. In other words, why does minimizing the KL divergence of the student policy w.r.t. that of teacher “regularize” the former’s state representation is intriguing. I suspect part of the answer lies in the multi-task nature of student’s learning although one could very well have thought doing so should make learning any one task harder (than it is for the corresponding expert).</p><p>Some future directions to pursue could be in understanding if : i) examining gradient plots (as in Figures 2 and 3) through epochs midway could shed light on when and how the transfer and inhibition of important and unimportant features respectively occurs; ii) whether swapping the roles of student and teacher (and training the latter further) helps improve the representations of the latter; iii) distillation serves as a good bottleneck for feature selection for redundancies and confounding beyond the linear combination kind discussed here; iv) some notion of similarity of states and actions between current and new task(s) can be formalized to know <em>a priori</em> if we’ve reasons to expect good transferability of learned embeddings.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e57269c8386" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Model compression in reinforcement learning — Part 1]]></title>
            <link>https://medium.com/@kartikganapathi/model-compression-in-reinforcement-learning-part-1-91970a84a24a?source=rss-a9ba97f100d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/91970a84a24a</guid>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[literature-review]]></category>
            <category><![CDATA[model-compression]]></category>
            <dc:creator><![CDATA[Kartik G Bhat]]></dc:creator>
            <pubDate>Mon, 19 Jun 2023 00:12:45 GMT</pubDate>
            <atom:updated>2023-06-23T15:21:11.169Z</atom:updated>
            <content:encoded><![CDATA[<h3>Model compression in reinforcement learning — Part 1</h3><p>In a two-part post, I would like to review a couple of recent papers on model compression/distillation in reinforcement learning (RL). In the first part covering preliminaries, I will review four papers that help provide context and set the stage for <a href="https://medium.com/p/8e57269c8386">part 2</a>.</p><ol><li><a href="https://arxiv.org/pdf/1503.02531.pdf"><strong>Distilling the Knowledge in a Neural Network </strong>(NIPS 2014 Workshop)</a>: This paper generalizes the work by <a href="https://www.cs.cornell.edu/~caruana/compression.kdd06.pdf">Caruana et al.</a> which showed that a smaller model can generalize (close to) the same degree as an ensemble of large models if it were to be trained to match the predictions of the latter as opposed to training on the raw data directly. As highlighted by both the authors and Caruana et al., this process does not need ground-truth-labeled data unlike the original training of the larger model.</li></ol><p>It is worth noting that the term distillation used here is more than as a pure metaphor — by observing that a) when logits that are output by the neural net are interpreted as <em>energies</em>, softmax is a special case of Boltzmann distribution where the <em>temperature </em>= 1, and, b) by matching the softmax predictions of original and distilled networks at higher <em>temperature</em> during training the latter and subsequently using the distilled network at <em>temperature</em> = 1 during inference, we are emulating <a href="https://en.wikipedia.org/wiki/Distillation">distillation</a>. One of the key insights from the paper is that <strong>the ability of the large model(s) to accurately predict class probabilities for non-target classes too is closely related to its(their) ability to generalize, and hence, the distilled model could benefit from mimicking this behavior</strong>, which running the training at higher temperatures encourages. Some of the important results from the paper are:</p><p>i)<strong> Matching logits as a special case of distillation</strong> (section 2.1): The authors show that at high temperatures distillation amounts to matching logits, provided for each instance the logits for the two networks are centered around zero, thus establishing correspondence with earlier results from Caruana et al. I spent some time making sense of Eq. (2) since expression for <em>C </em>is not spelt out (which I furnish below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CixDktpDCTaCKyQUp-zZGQ.png" /></figure><p>ii) <strong>Soft targets as regularizers</strong>: As mentioned above, the logits corresponding to classes we don’t care much about still contain useful information that determines model generalizability. The authors claim that this information cannot be encoded using hard targets (i.e., raw class labels). This is shown empirically using a large model that overfits a small training data when using latter but does not when using the former in case of audio encoder. The authors note that an interesting application of this is in training specialist models for confusable subclasses of data — which are useful when training ensemble of large models is expensive — that are very likely to be overfit due to data sparsity can be regularized using soft targets of irrelevant classes.</p><p>2. <a href="https://arxiv.org/pdf/1511.06342.pdf"><strong>Actor-Mimic: Deep multitask and transfer reinforcement learning</strong> (ICLR 2016)</a>: While the Mnih et al. paper (discussed below) used the same network architecture for training on different tasks, there was one separate network trained for each game. This paper builds on to explore if the same network can be used to train multiple tasks simultaneously and if such a network can generalize well to a similar-but-previously-unseen task.</p><p>The main idea for the first part (multitask learning) is to imitate the actions of the expert trained at a given task, rather than learning individual task-policies directly. This imitation learning is more involved in RL settings than in supervised learning cases because the samples drawn are not i.i.d. but are part of a Markov decision process. <a href="https://arxiv.org/pdf/1011.0686.pdf">Ross and Bagnell</a> point out that ignoring this aspect leads to a quadratic regret in time because the effect of an incorrect prediction is compounded by the fact that the agent could subsequently potentially encounter a particularly different distribution of states than is present in the training data. The solution proposed is an extension of DAGGER algorithm by <a href="https://arxiv.org/pdf/1011.0686.pdf">Ross and Bagnell</a> to the multitask case and rests on the performance guarantees made by the same (Theorem 3.2 of Ross and Bagnell). For reference, DAGGER relies on finding the best policy on an aggregated dataset — consisting of trajectories starting with those generated under expert policy and appended by those from successive policies that best mimic the expert on the cumulated set of all trajectories under all policies encountered so far — that is likely to be seen by itself. The salient points of the paper are:</p><p>i) <strong>Policy regression objective</strong>: This is the surrogate loss for the actor-mimic network (AMN) defined as the cross-entropy between expert-policy and AMN-predicted policy (the expert policies are obtained by soft-max-ing Q values after training each network separately using the deep Q network in the Mnih et al. paper). Following Hinton et al. above, they introduce a temperature (<em>τ</em> in Eq. (3))<em> </em>in the softmax; however, <em>τ</em> is set to 1 in all their experiments. During AMN training, the expert networks are frozen. Similar to Mnih et al., a replay buffer is used for every game; while not stated explicitly, I believe samples from buffer of each game are drawn in some round-robin-like manner to update the shared weight <em>θ </em>so that AMN becomes simultaneously adept at playing all the games. Couple of things to note are: a) unlike DAGGER, the dataset is not necessarily fully aggregated since the replay buffer used is of fixed size; b) no-regret algorithm guarantees apply to the case when loss is strictly convex; however, the cross entropy loss is only convex. Also, as a minor aside, <em>I believe the</em> <em>proposition 1 on page 5 is incorrect — the sub-optimality in the t-step reward for any action needed to be </em><strong><em>upper bounded</em></strong><em> by u and not lower bounded. </em>The key result from the multitask part of the paper is that for 7 out of 8 games, the AMN network reaches close-to-expert performance in ~1/10th of epochs together with lower reward variance (Figure 1).</p><p>ii) <strong>Feature regression objective</strong>: A additional loss term is proposed — defined as the L2-norm of the difference between activations of penultimate layer of AMN (linearly transformed to match dimensions) and that of the respective expert network — in the hope that minimizing this will lead to <em>matching expert predictions for the same reasons as the expert.</em> While an attractive idea, the results do not seem as promising as seen in Figure 7 where only in 1 out of 7 games is there a benefit seen in terms of training speed-up. Also, in most cases, the performance is worse than when using the policy objective alone for reasons not articulated.</p><p>iii) <strong>Multitask comparison with other architectures</strong>: The authors make an interesting comparison with two other network architectures to drive home the superiority of AMNs (Appendix C). In particular, I found the observations in Figure 3 very striking, wherein despite only sharing convolutional layers and having separate learning-head for each game, the performance was considerably worse than that of AMN (and comparable to that of a network that directly tries to learn policies for all games simultaneously (Figure 2)), suggesting AMN architecture is better for distilling the policies from multiple expert networks. I would have liked to see the training curves for these control networks for normalized epoch# (since AMNs benefit from the training done on expert networks that these don’t) since that’s the true computational cost of AMNs (if one is only concerned with multitask learning and not transfer learning).</p><p>3. <a href="https://arxiv.org/pdf/1511.06295.pdf"><strong>Policy Distillation</strong> (ICLR 2016)</a>: This paper has many similarities w.r.t. AMN paper above by Parisotto et al although this paper does not focus on transfer learning. The key differences w.r.t. former are: a) the use of teacher policy to generate training trajectories as opposed to the student policies in case of AMN. The authors do not provide any convergence guarantees. However, my understanding is that the Theorem1 in AMN paper holds for either distributions, so this is probably justified; b) use of very low temperature, <em>τ</em> = 0.01; the authors mention that interpreting <em>Q </em>values — not logits as in standard supervised learning setting — as energies leads us to cool instead of heat to make the distributions sharper (and hence increase the contrast between actions with nearby Q values). I suspect this leads to an interesting scenario —while going to higher temperature enables secondary knowledge transfer between teacher and the student, in this case it likely inhibits the primary knowledge transfer. Also, while the authors call the process distillation, the expression for L_{KL} on page 4 shows that the temperature of teacher network alone is changed. c) surprisingly good single-task model compression where even a 15x smaller model is shown to match the performance of the original network. Similar to AMN, the multitask distilled agent performs pretty well (90% over 10 games) compared to corresponding single-task networks, although the distilled model is 4x larger than any of the single models.</p><p>4. <a href="https://www.nature.com/articles/nature14236"><strong>Human-level control through deep reinforcement learning</strong> (Nature 2015)</a>: This is a classic paper with over 12000 citations that the latest version of <a href="http://incompleteideas.net/book/RLbook2020.pdf">Sutton and Barto’s textbook</a> discusses as a case study (16.5, pp. 436–441) since it showed that a single architecture can be used to train multiple tasks (Atari 2600 suite), even with the same hyperparameters (<em>as a side-note, the equation on page 440 of Barto’s textbook is incorrect; the target is compute not from w_{t} but an earlier version</em>). However, I want to summarize the important algorithmic changes compared to standard Q-learning that the paper introduced:</p><p>i) <strong>Replay buffer</strong>: Experiences sampled by the agent are stored in a memory of fixed size, which is then sampled uniformly randomly for computing the target. The advantages are: a) each sample is used for multiple weight updates increasing sample efficiency (<strong><em>while the paper states this, I am not entirely clear on this one. Considering a fixed-size FIFO implementation of the buffer, a sample, in expectation, takes part in only one weight update — 1/N probability of being chosen at each instant and a total of N chances before it leaves the buffer</em></strong>); b) consecutive updates are uncorrelated thereby reducing variance; c) breaking the feedback between current weights and immediately next action — while <em>ϵ</em>-greediness of the behavioral policy blunts the blow to certain degree even if one were to not do this, it’s imaginable that this has clear advantages in terms of avoiding oversampling certain bad trajectories as the paper claims.</p><p>The entry into the buffer is unconditional; I suspect if the agent were to have a internal model of the game, a better strategy would be to use the simulated model to decide if a sample should make it to the buffer or not based on estimated improvement to value of the corresponding (state, action) pair. It’s possible that the <em>prioritized sweeping </em>the authors refer to effectively amounts to this. Personally I’ve noticed that whenever my understanding is challenged in the face of a question, I go back and revisit the concepts that <em>I believe</em> are most closely related and where my perceived understanding is the weakest (this could be complementary to the consolidation of knowledge that happens in during rest/sleep through interactions with basal ganglia and hippocampus — refs. 21, 22 and 29).</p><p>ii) <strong>Target/duplicate network</strong>: Cloning the online network periodically and using the clone to generate the target is a neat approach to reduce instability associated with off-policy methods using functional approximation. Please refer to section 11.2 of Sutton and Barto for details on the problem statement. In short, the instability arises because unlike on-policy methods, the behavior policy (that’s different from the policy being learned) lacks the negative feedback wherein the effect of an inflated <em>Q</em>(<em>s</em>_{<em>t</em>+<em>1</em>},<em>a</em>) would be corrected if (<em>s</em>_{<em>t</em>+<em>1</em>},<em>a</em>) happens to have a low probability under target policy after the update. By delaying the time between when a sample is encountered and it contributes to weight updates, the chances of this happening are reduced.</p><p>iii) <strong>Error clamping</strong>: Clamping the error term outside of (-1,1) interval to -1 and 1 respectively is reported to further improve the stability of the algorithm. My impression is that this is more relevant in RL settings than in supervised learning because the targets themselves are not constants but depend on the parameters.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91970a84a24a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI and meaning]]></title>
            <link>https://medium.com/@kartikganapathi/ai-and-meaning-d28d622771dc?source=rss-a9ba97f100d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d28d622771dc</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[multidisciplinary]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[understanding]]></category>
            <category><![CDATA[meaning]]></category>
            <dc:creator><![CDATA[Kartik G Bhat]]></dc:creator>
            <pubDate>Sun, 11 Jun 2023 22:21:27 GMT</pubDate>
            <atom:updated>2023-06-11T22:21:27.575Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I like to summarize things that caught my attention from the talks at the Santa Fe Institute (SFI) workshop on <a href="https://wiki.santafe.edu/index.php/AI_and_the_Barrier_of_Meaning_2">AI and the barrier of meaning</a> held late April this year. The focus was primarily on large language models (LLMs) and <em>understanding. </em>True to <a href="https://www.santafe.edu/about/operating-principles">SFI spirit</a>, the event brought together researchers from diverse disciplines such as computer science, psychology, neuroscience, linguistics, philosophy to name a few. The <a href="https://youtu.be/SIWN00FjIxY?t=538">key question</a> posed to the presenters was whether: a) it is grossly wrong to even talk about understanding in case of LLMs, or b) do they have compact representations similar to what we term as understanding in case of humans or c) are the statistical correlations of LLMs <em>functionally equivalent</em> to human understanding and is the distinction worth making? Since <em>understanding</em> is a broad term, most speakers tried to address defining it first before giving their take on the question. While the amount of scholarship behind the talks is very large and I haven’t studied almost all of them, I hope to capture the essence of some that piqued my interest without turning out to be a <em>stochastic parrot</em> myself!</p><ol><li>Josh Tenenbaum <a href="https://youtu.be/gzaIrD3jki8?t=1291">defined understanding</a> as a meta-knowledge (knowledge = <em>justified</em> true belief) that helps sustain and grow knowledge in a changing world, either by enabling novel, higher level plans to acquire more of it by interacting with the world or by building it socio-culturally through communication via language.</li><li>He thought that the world model of current LLMs is not robust (although there are <a href="https://arxiv.org/pdf/2303.12712.pdf">glimpses of it</a>) because they were trained on natural language which only a byproduct of human understanding. Further he gave a glimpse of upcoming work on <a href="https://youtu.be/gzaIrD3jki8?t=2219">using LLMs to generate probabilisitic programs</a> as a means to imbibe world knowledge in them, motivated by i) the observation that writing code is where LLMs seem to be doing well and ii) the latter represents a unified framework of reasoning on real-world and abstract knowledge.</li><li>He also noted that since human brains were built for understanding the ever-evolving world around them, human intelligence cannot be reduced to behaviors on a set of tasks, even if that set is very large and diverse. He cited the <a href="https://youtu.be/gzaIrD3jki8?t=781">OpenAI result on performance on difficult coding problems</a> to justify that the asymptote of the behavior on such narrow tasks is not intelligence.</li><li>Blaise Agüera y Arcas took the minority view that people are sequence models like LLMs and there’s no more secret sauce needed to be added to transformers to imbue them with understanding. This stems from <a href="https://arxiv.org/pdf/2212.07677.pdf">one of the recent papers</a> (Figure1 in particular) he <a href="https://youtu.be/uwUgYLaWTXc?t=1571">cites</a> that suggests that a single layer of the transformer is, effectively, implementing a gradient descent step thereby doing an efficient on-the-fly/few-shot learning; and, the role of pre-training is to simply set the stage for such generalization to occur.</li><li>Anna Ivanova showed <a href="https://youtu.be/KKuu57FXd0g?t=398">evidence from neuroscience</a> on how different parts of the brain are engaged while processing different aspects of real-world knowledge the language refers to. She seemed to suggest that similar deconstruction of LLMs might be in order (because, focusing narrowly on functional equivalence, i.e., part c) of the originally posed question, might not suffice since there might be differences in generalizability, factual accuracy, consistency etc.).</li><li>Tal Linzen’s talk mostly focused on an <em>ideal</em> language model (i.e., one which can accurately compute the probability of utterance of any sentence the language it is modeling can produce). His <a href="https://arxiv.org/pdf/2209.12407.pdf">claim</a> was that if <em>meaning</em> means inferring entailment semantics (i.e., noting <em>X</em> follows from <em>Y</em> whenever <em>X</em> is entailed by <em>Y</em>), then an ideal language model can <em>mean</em>, under the assumption that the language is not a bag of sentences but generated by speakers who intend to be informative, truthful and relevant (Gricean). His <a href="https://youtu.be/prJ-e71i6Ho?t=889">results on GPT-3</a> answering <a href="https://paperswithcode.com/dataset/multinli">MNLI</a> entailment questions highlighted two shortcomings: i) real language has redundancy (e.g., theorems contain <em>X </em>and <em>Y </em>but the whole point of proof, assuming both are correct, is to take readers step-by-step through the reasoning process; but also more mundanely a large corpus invariably will have some redundancies) and ii) real models like GPT-3 might not be able accurately model low probability sentences due to sparseness in training.</li><li>However, his point on language models being able to <em>refer </em>(“Kartik” refers to me, the person who exists in real world) assuming reference as the benchmark of meaning seemed interesting. Since the association of, say, “coconuts” &lt;-&gt; coconuts, is a matter of provenance in the evolution of language, grounding is immaterial i.e., one could use “coconuts” in a sentence even if all their beliefs about coconuts are false. However I think grounding is important since otherwise the association is not really “coconuts” &lt;-&gt; coconuts but “coconuts” &lt;-&gt; <em>coconuts</em>, an imagined entity that the speaker’s language is truly referring to.</li><li>Tom McCoy argued that a) since natural language (which conveys meaning to us) has compositional structure, the learned vector representations that do well on natural language tasks also have similar structure, specifically the <a href="https://youtu.be/bLJRT1qMJtw?t=488">encoded vectors are tensor products</a> (of word and positional embeddings), and, b) <a href="https://youtu.be/bLJRT1qMJtw?t=934">distilling inductive biases</a> by meta-learning many probability distributions implied by a given directed acyclic graph (whose structure we want to imbibe in the neural network) helps generalize much faster. My impressions were: i) it’s neither necessary nor sufficient that vectors that are tensor products are good representations for a task at hand; perhaps the linearity requirement is too restrictive as seen by <a href="https://youtu.be/bLJRT1qMJtw?t=720">poor accuracy in some cases</a>. ii) it’s unclear if inductive bias distillation preserves the tensor product representation (wasn’t shown in the talk); iii) overall, the evidence seemed somewhat weak to suggest this corresponds to how either humans or LLMs currently learn.</li><li>Yann LeCun’s <a href="https://youtu.be/_JfEScYyVCE">talk</a> was filled with so many contrarian ideas that I recommend watching it in its entirety. His primary theses were that: a) prediction is the true test of understanding; b) current LLMs (autoregressive LLMs as he calls them) do not have robust world models and hence predictive capability, and, perhaps most damningly c) they are <strong>unfixable without major redesign</strong> because they have finite #steps between input and output and, thus, cannot reason and plan (which invariably require variable amount of computation depending on the problem-difficulty).</li><li>Next, he said while predicting the actual output (next word) is the right thing in the context of language, it might not be so in physical world, where there might be several irrelevant aspects that can (and should be) be abstracted away — e.g., to predict the speed of a ball, we needn’t know its color; therefore minimizing the encoding of input with some embedded representation of output is the right cost term as far as prediction error goes; he calls this <em>Joint Embedding Predictive Architecture</em> (JEPA).</li><li>In addition he proposed that the cost function of a JEPA world-model ought to contain three more terms: information content in i) encoding of the input signal; ii) encoding of output; iii) latent variable that represents the things we don’t know about the world (i), ii) are maximized and iii) minimized). He noted that minimizing an <em>energy function</em> derived from this cost evaluated at observed data points should be suffice (unlike the <em>probabilistic models</em> that require this to correspond to some log likelihood). Finally he suggested that contrastive methods — which rely on using fictitious, non-data points representing high energy — should be abandoned in favor of regularization methods (specifically he proposed <a href="https://youtu.be/_JfEScYyVCE?t=1303">VICReg</a>, which stands for variance, invariance and covariance regularization where variance and covariance refer to those of terms i) and ii)).</li><li>Perhaps the highlight of the talk was his proposal of hierarchical JEPA for planning where JEPA layers can be stacked creating progressively higher levels of representations that can make longer term predictions; the state of the higher level representation and the action of the lower level ones constitute the cost function thereby guidance flows higher → lower levels which result in more immediate actions achieving abstract goals eventually. This is critical because any complex task will invariably need to be broken into smaller ones but one cannot expect to explicitly design cost functions for intermediate steps since it’s not clear what should such a reward signal look like.</li><li>Ida Momennejad focused on the ability of LLMs to reason about graph-like representation of relationships among entities based on the <a href="https://youtu.be/FQiAm5eSBIc?t=141">claims in the literature</a> that transformers can create <a href="https://en.wikipedia.org/wiki/Cognitive_map">cognitive maps</a> (which hippocampus is responsible for in humans). The key results were that while for simple graphs, <a href="https://youtu.be/FQiAm5eSBIc?t=1109">GPT-4 could reason accurately</a> various questions relating to shortest path, consequences of rewiring some edges, changing some rewards etc., it had problems when it came to graphs that had <a href="https://youtu.be/FQiAm5eSBIc?t=1530">loops and community structures</a> (although for the shortest path, it could write correct code).</li><li>John Krakauer took the view that there are parts of <em>System2 </em>behaviors that <strong>cannot</strong> be learned by LLMs unlike the <em>System1 </em>tasks that they are currently excelling at, based on <a href="https://youtu.be/zGc2A5FEjeM?t=688">some interesting experiments</a> he had done a while ago showing how the two have different objectives. However it was unclear to me what concretely about <em>System2 </em>it is that cannot be cached/automatized. For what it’s worth, I’m in the LeCun camp that thinks System2 tasks can be broken down into series of System1 tasks — irrespective of whether or not current LLMs are suitable for doing that.</li><li>Zenna Tavares’ talk showed how current LLMs lack counterfactual reasoning capability that is necessary for building a causal model of the world. His explanation was that meta-reasoning (reasoning about one’s own reasoning) is something that cannot be present in any training data and hence we cannot expect LLMs to be able to do it. Similar to Josh, he believed that being able to train models that can write code to express causal relationship between entities is crucial to imbibe real-world-knowledge.</li><li>A cool thing his talk showed was <a href="https://youtu.be/ZgvZegfdFsI?t=1603">extending the idea of abstract data structures to neural network primitives</a>. Learning these neural data structures was his proposal to incorporate declarative knowledge, usually represented in symbolic form, into models in contrast to Tom’s idea above of inductive bias distillation.</li><li>David Krakauer defined human understanding in the Feynman sense i.e., the ability to come up with universal laws of nature which are highly compressed world representations and likened LLMs to <a href="https://plato.stanford.edu/entries/chinese-room/">Searle’s Chinese room</a> (and hence represent non-understanding), making him an advocate of option a) on the original question, in my view. He made a case for a) synergy between individual (whose goal is Feynman-like understanding) and cultural tools, of which LLMs are a part of; division of labor being necessary to make any reasonable progress on difficult problems, and b) existence of understanding not in individuals but in culture as a whole, using the <a href="https://youtu.be/Oy7Jv8DxzTU?t=1321">progress in Rubik’s cube solving</a> has been made over the years as an example. To me, the interesting aspect was this delineation, which is somewhat obfuscated when we try to dissect behavior of LLMs and compare/contrast it with what happens in human brain. It’s not clear to me whether we should give up on LLMs of the future to produce novel physical laws; while they seem anthropocentric, they’re in some sense extremely interpretable providing us confidence that their conclusions are, indeed, right (much like proof of a theorem).</li><li>David Chalmers’ talk in some way summarized the entire event. He broke down understanding into various types of understanding — broadly, phenomenal, explanatory and useful. Phenomenal (having an <em>aha </em>moment, understanding that you’ve understood something, like in the Searle’s Chinese room argument) understanding requires consciousness and therefore current LLMs lack this. There’s a reasonable case to be made that LLMs do possess explanatory understanding (on most things they know, they also know the why). The usefulness axis can be further subdivided into behavior, verbal and reasoning based understanding. Text-based LLMs do not behavioral understanding since much of this needs embodiment (although multimodal LLMs could be said to possess some degree of it). Along verbal and reasoning lines, they seem to exhibit some loci of understanding although, as many talks in the workshop showed, they’re far from matching humans. However, he seemed to believe that there are <strong>no zero barriers</strong> (i.e., that prevents taking off from the ground at all) for future LLMs; whether there exist some non-zero barriers along any of these axes remains to be seen.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d28d622771dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ML and brain-computer interface]]></title>
            <link>https://medium.com/@kartikganapathi/ml-and-brain-computer-interface-df176fed9ec5?source=rss-a9ba97f100d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/df176fed9ec5</guid>
            <category><![CDATA[futuristic]]></category>
            <category><![CDATA[neuralink]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[brain-computer-interface]]></category>
            <category><![CDATA[cognition]]></category>
            <dc:creator><![CDATA[Kartik G Bhat]]></dc:creator>
            <pubDate>Wed, 07 Jun 2023 07:49:30 GMT</pubDate>
            <atom:updated>2023-06-07T07:49:30.100Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I want to explore the possibilities made accessible by a high bandwidth brain-computer interface (BCI) in the context of AI-human coevolution as Neuralink envisions. While visual and sensorimotor prothesis benefits are quite plausible in the near-term, the longer term trajectory of what could be achieved remains open to debate and speculation. One of the <a href="https://www.youtube.com/live/YreDYmXTYi4?feature=share">stated goals of Neuralink BCI</a> is to achieve human-AI-aligned future in the benevolent AI scenario. As with most aspects of life, the devil is in the details; although I remain cautiously optimistic of the range of possibilities, I examine a few strands of underlying reasoning below.</p><p>The current focus of Neuralink N1 is on accessing areas on the brain surface that are responsible for, using the terminology popularized by Daniel Kahneman, <em>System1 </em>(intuitive)<em> </em>actions that include the ones mentioned above. However, to achieve a meaningful synergy with AI (or even otherwise), it’s reasonable to conceive that one’ll need to go beneath and beyond to interface with regions governing <em>System2 </em>(deliberative) behavior.</p><ol><li><strong>High-density connections</strong>: When we’ll have had success in determining the neural correlates of such modes of cognition, we might discover that, say, a moment of <em>aha</em> or deep insight corresponds to either a <em>sparse-graph</em>-like excitation of multiple areas in the brain or a <em>contrastive </em>(smooth spatiotemporal gradient) firing pattern in a localized, perhaps task-dependent, area. Coverage and specificity of stimulation become key in such cases. There are ~ 100 B neural connections in the human brain. A 0.1% coverage, i.e., 100 M, corresponds to a density of one electrode per 2500 μm² (assuming a surface area of 2500 cm²). While the tip of the thread is still over an order-of-magnitude smaller, fundamentally different ways of placement (than what Neuralink R1 surgical robot currently does) would necessary from a surgery time viewpoint. Secondly, although each electrode can pick up (and, hence symmetrically, stimulate) neural activity within 60 μm, the flip side of this would be lack of specificity/crosstalk between nearby neurons.</li><li><strong>Edge inference</strong>: It is fair to imagine that either due to the higher volume of neuronal inputs and/or increased model-complexity needed for these tasks, <em>in situ</em> computational requirements will only increase. Approaches such as <a href="https://www.qualcomm.com/news/onq/2022/09/the-future-of-model-efficiency-for-edge-ai">floating-point to integer conversion</a> will be needed in order to reduce the power consumption during inference at the edge. Also, strict self-heating specs would mean innovations in the thermal conductivity engineering of chip-casing or pushing the energy-efficiency boundaries of edge AI would be critical.</li><li><strong>Model generalization</strong>: Generalizability will likely become harder to achieve due to two main factors: i) <a href="https://www.youtube.com/live/YreDYmXTYi4?feature=share">daily changes in the baseline neuron firing rates</a> (~53:20) will only make it harder to gain enough statistics on sparingly-used cognitive processes than, say, walking; ii) transfer learning, based on training on somebody else’s data, might turn out to be poorer since spike rasters associated with contemplation, planning, reasoning etc. are going to be stronger functions of individual’s existing world-view and associated representations. Consequently, there will need to be some degree of fine-tuning needed which will only exacerbate the problems discussed in the inference section above. Additionally, for high-density channels, even to offload most of the training heavy-lifting to cloud, model compression would be necessary.</li><li><strong>Borrowing embeddings?</strong>: A possible solution to some of the generalization-related issues would be if embeddings of concepts could be borrowed from a database where other could choose to share representations of their learned concepts to ensure good initialization. While this could truly redefine humans’ conception of what it means to learn, issues of privacy will be central and advances in distributed ML, like federated learning, would become essential.</li><li><strong>What kind of synergy/alignment with AI?</strong>: At a philosophical/policy level, what kind and degree of synergy would be beneficial to the health of the society (e.g., people finding meaning in work) and who gets to decide what needs thinking through. My guess is that (at least initially), exploration of and interaction with the <em>physical</em> world would be the place humans would be most suited for, given our trajectory of biological evolution. To a large degree this should help artificial intelligence as a whole since the problem of simulating the environment boils down to learning humans’ internal representations of it, all the while leaving a great deal agency with them.</li></ol><p>In summary, I believe most of the technical challenges we’d face in making a leap to using BCI for <em>system2 </em>tasks hinge upon whether or not the number and pattern of neural firings differs significantly from that of <em>system1 </em>ones; advances in neuroscience toward this end would be worth the wait.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df176fed9ec5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI in electronic design automation]]></title>
            <link>https://medium.com/@kartikganapathi/ai-in-electronic-design-automation-530f11c2c566?source=rss-a9ba97f100d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/530f11c2c566</guid>
            <category><![CDATA[semiconductors]]></category>
            <category><![CDATA[vlsi]]></category>
            <category><![CDATA[electronic-design]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Kartik G Bhat]]></dc:creator>
            <pubDate>Tue, 30 May 2023 13:40:43 GMT</pubDate>
            <atom:updated>2023-05-30T13:40:43.185Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I’ll present how AI is being used in electronic design automation (EDA) industry and some thoughts on what I see as the future possibilities. In a <a href="https://medium.com/p/9b388ab4c220">previous post</a>, I reviewed Google’s paper on chip placement efforts using deep reinforcement learning; here I plan to cover the entire stack. While I looked for information available on <a href="https://www.synopsys.com/">Synopsys</a>, <a href="https://www.cadence.com/en_US/home.html">Cadence</a> and <a href="https://eda.sw.siemens.com/en-US/">Siemens EDA</a> webpages, it was only on Synopsys’ blogs that I found information at some depth so the depiction of SOTA will likely be influenced by it; however, I’ll try to generalize the extrapolation to industry as a whole.</p><p>The complexities in designing modern-day chips can be broken down into three broad categories:</p><ol><li><strong>Design-space exploration (DSE)</strong>: For digital circuits, this means optimizing power, performance (speed) and area (referred to as PPA). For analog circuits, however, there could be additional figures-of-merit such as gain, bandwidth, signal-to-noise ratio. The constraints emanate from the underlying semiconductor technology node(s) being used that dictate(s) the capability of elementary building blocks (<em>standard cell library</em>) along aforementioned vectors and also how closely one can place them (<em>design rules</em>). Design-space determination can be broken into two steps: i) synthesis of gate-level netlist from behavioral description of the circuit — this is accomplished by techniques such as <a href="http://users.ece.utexas.edu/~gerstl/publications/tcad-09-10.esl.pdf">electronic system-level synthesis </a>(ESL) that are part of EDA suite; ii) converting the netlist to physical layout. While ESL appears to be well-studied, I didn’t see any efforts to apply ML methods (and I myself do not have enough appreciation for the problem to suggest how we could do better). On the other hand, similar to <a href="https://arxiv.org/pdf/2004.10746.pdf">Google’s paper</a> — where reinforcement learning (RL) was used to place macros —inroads seem to have been made in exploration of physical-design space. <a href="https://blogs.synopsys.com/from-silicon-to-software/2020/07/22/ai-soc-design-for-better-chips/">Success stories</a> have come from multiple application domains like chips for AI accelerator, automobile etc. showing between ~5–30% improvement one or more PPA metrics with considerably lower (6–9x) turnaround time.</li></ol><p><strong>Looking ahead</strong>: While I’m not aware of the proprietary details of the tools, as noted in the Google paper, finding a <em>surrogate reward signal</em> that does not rely on EDA tools for assessing the quality of placement would nonetheless be critical for attaining speed-up in any RL-based tool. For PPA, it’s reasonable that heuristics like wirelength would serve as good proxies since they’re (somewhat) grounded in physics (though not all regions in the PPA simplex might be equally easy to reach, as we saw in the Google paper). However, for analog designs, it’s <strong>not</strong> clear what the counterparts would be. Given analog metrics are more sensitive to layout parasitics, one might suspect the placement would need to happen on a finer grid, thus increasing the action-space dimension. Finally, a richer representation of the netlist metadata might be in order since gain, bandwidth etc. are likely to be more sensitive to the transistor operating point in the linear current-voltage characteristics, although this will probably be the easier part.</p><p>2. <strong>Verification</strong>: With 30% of the design time spent on verification, it’s one of the key determinants of time-to-results in chip design. Static analysis, formal verification and simulation are the three main components of standard EDA workflow, accounting respectively for roughly 10, 20 and 65% of bugs caught (with remaining 5% caught during in-silicon testing). In case of static analysis, unsupervised methods like clustering are being used to aggregate design rule violations to help do a more structured root-cause analysis. Equivalence checking is the workhorse of formal verification; it’s not clear to me if these would be amenable to SOTA ML methods.</p><p>Simulation of large-scale circuit presents challenge in terms of coverage due to <a href="https://en.wikipedia.org/wiki/Curse_of_dimensionality">curse of dimensionality</a>. As noted <a href="https://www.synopsys.com/content/dam/synopsys/verification/white-papers/vso-ai-wp.pdf">here</a>, defining cross-coverage of combination of points is traditionally done manually. Additionally, growth of coverage with test-time saturates since unlike in initial phase — where even typical inputs end up exercising a large fraction of the unexercised design—later on, targeted stimuli would be needed to test atypical blocks that are harder to generate. Synopsys seems to address the former by training on historical data (including earlier versions of the same design during the course of design life-cycle) to infer new coverages. The latter is addressed by adaptive test-pattern optimization to use patterns that provide highest ROI for coverage first, although they don’t mention what ML methods are being used to this end.</p><p><strong>Looking ahead</strong>: The adaptive test-pattern generation problem is ripe for an RL formulation (if not already being done so) with reward for a particular test-pattern proportional to coverage and using discounting to learn optimal ordering of tests. The computational cost associated with determining reward signal might present a challenge since one’d need to run regression. The problem of cross-coverage definition (likely using supervised learning methods) already appears to be on solid grounds — a richer representation of code chunks will perhaps help enhance coverage.</p><p>3. <strong>Testing</strong>: During testing, the <em>device-under-test </em>receives test inputs from an <a href="https://en.wikipedia.org/wiki/Automatic_test_pattern_generation">automatic test pattern generator </a>(ATPG) and sends its output back; based comparison of the expected output for that pattern (which is engineered to bring out a particular defect) with the actual one, the testbench generates a pass or fail. ATPG problem is NP-complete and, hence, heuristics have been developed to maximize fault coverage within the budgeted test-time.</p><p>Synopsys <a href="https://www.synopsys.com/content/dam/synopsys/solutions/ai/tso-ai-ds.pdf">seems to be using ML methods</a> as a meta-optimizer — to fine-tune numerous settings and values of ATPG tool to achieve maximal coverage with fewest patterns. Since I’ve not used an ATPG tool myself and the details in the above white paper are scant, I will refrain from speculating what lies under the hood. However, I’m curious to understand if an ML-based ATPG tool that <em>directly</em> learns representations of both fault models and netlist will provide any greater advantage either on the same design or in transferability.</p><p>In my view, some of the questions to consider as AI adoption in EDA increases are:</p><ol><li>What would it take to create an <strong>end-to-end AI-based EDA? </strong>By this I mean going beyond today’s full stack EDA solutions that address design-space exploration, verification and testing independently. Specifically, since <strong>time-to-results </strong>is the ultimate figure-of-merit, how could we bring that<strong> into the optimization space more directly during DSE itself, on an equal footing with PPA</strong>? This would require reward-signal modeling capturing verifiability and testability. Similarly, the available computational budget and engineer-hours would need to be incorporated to minimize design costs.</li><li>How could advances in <strong>AI interpretability inform DSE</strong>?As we saw in case of the Google paper, AI-optimized designs could look drastically different from those created by human engineers. This poses new challenges in downstream tasks of verification and testing with humans in the loop. One possible solution would be to add a <strong><em>thou-shall-not-design-that-which-you-cannot-explain</em> </strong>dictum to the exploration phase; this would effectively get relaxed as strides in interpretability are made.</li><li>How could <strong>AI benefit from human designs</strong>? Generally designs created by engineers are modular in part due to how a project gets broken down to be effectively tackled by a team. While when viewed narrowly through PPA lens these might be suboptimal, holistically there could positives in terms of reusability, portability among others. Running best-in-class human designs through inverse reinforcement learning (IRL) could be one way of identifying what is being optimized therein. This would subsequently inform augmenting reward signals for circuits that were previously intractable or where gains due to AI were modest.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=530f11c2c566" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Notes on chip placement using deep reinforcement learning]]></title>
            <link>https://medium.com/@kartikganapathi/notes-on-chip-placement-using-deep-rl-9b388ab4c220?source=rss-a9ba97f100d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b388ab4c220</guid>
            <category><![CDATA[vlsi]]></category>
            <category><![CDATA[hardware]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[electronic-design]]></category>
            <dc:creator><![CDATA[Kartik G Bhat]]></dc:creator>
            <pubDate>Fri, 26 May 2023 07:06:22 GMT</pubDate>
            <atom:updated>2023-05-26T19:09:14.867Z</atom:updated>
            <content:encoded><![CDATA[<h3>Review of chip placement with deep reinforcement learning</h3><p>In this post, I’d like to summarize my takeaways from <a href="https://arxiv.org/pdf/2004.10746.pdf"><strong>Chip Placement with Deep Reinforcement Learning</strong></a> (eventually published in <a href="https://www.nature.com/articles/s41586-021-03544-w">Nature</a>) from Google on placement of VLSI circuits using deep reinforcement learning. As someone looking to gain better understanding of SOTA RL using its application to a problem in electronic design automation (EDA), I found the problem interesting since it’s an adjacency to my current line of work in semiconductor industry. I encourage you to read the original paper and check out some of the video summaries by <a href="https://www.youtube.com/watch?v=gSBYf25bWyo">authors</a>, <a href="https://www.youtube.com/watch?v=PDRtyrVskMU">Yannic Kilcher</a>, <a href="https://www.youtube.com/watch?v=Z3XtWuuTHz4">Aleksa Gordić</a>, and <a href="https://www.youtube.com/watch?v=EKjlr2k_wBM&amp;t=1s">Young-Joon Lee</a>. Here, however, I will synthesize aspects of the paper that caught my attention.</p><p>Placing different components of a chip is a resource allocation problem on the hypergraph — we’re interested in laying out the circuit in as less an area as possible (subject to manufacturability-driven constraints on routing the connections between constituent sub-circuits) while optimizing metrics such as power, speed etc. At a high level, before getting into the details, physical design engineers would testify that placement of <a href="https://en.wikipedia.org/wiki/Netlist">netlist</a> is a labor-intensive process with several engineer-weeks spent on each circuit. Given this the primary result i.e., turnaround time of 6 hours to either match or improve over performance of existing methods, and, equally importantly, demonstrating transferability to new designs is impressive.</p><p>Moving on to specifics:</p><ol><li><strong>Hybrid approach for placement</strong>: The standard cells (clusters of simple gates) are placed in the penultimate step (after <em>macros i.e., </em>more complex design pieces<em>, </em>are placed using the learned policy) using the <a href="https://dl.acm.org/doi/pdf/10.1145/103724.103725">force-directed methods</a>. While the authors mention this was done to save time, it’s not clear whether the objective of this placement would be similar to that of the rest. It seems to me <em>these methods could emphasize avoiding congestion but might </em><strong><em>not </em></strong><em>do much in terms of reducing wirelength</em>. The standard-cell clusters are created by graph partitioning techniques with normalized min-cut as the objective which reduces the #wires but not necessarily wirelength.</li><li><strong>Half-perimeter wirelength as a proxy for power and performance</strong>: It’s interesting to note while it appears mainly like an area-metric, it captures power and performance as well. The latter is intuitive since the <em>RC</em> delay of the interconnect increases with wirelength (although we don’t quite know if the wires connecting macros carry limiting/worst-case signals). Similarly one can expect the <em>I</em>^{2}<em>R</em> too to correlate with wirelength (the power dissipated within the macros should be independent of placement quality).</li><li><strong>Topological sort for determining the order of placement: </strong>The paper mentions that in addition to size of the macros, <a href="https://en.wikipedia.org/wiki/Topological_sorting">topological sort</a> is used to determine the order. In a circuit that includes sequential logic, it’s possible that we have directed hyper-edges running in both directions in which case I’m not sure how one would sort the two macros. Reading their final version of the Nature paper, I see that undirected adjacency matrix is created at the macro level in which case I do not know what topological sort means.</li><li><strong>Learning high quality embeddings key to efficient transfer learning:</strong> Perhaps the most important ingredient of the model is what the authors call an <em>edge graph neural network </em>since before training the policy network begins in full earnestness, this network that acts as an encoder to the policy network (i.e., decoder) is trained in a supervised learning framework to ensure the policy network trains in reasonable amount of time. Being a graph NN novice, I wasn’t able to appreciate the novel aspects of it beyond noting that, as the name suggests, while both nodes and edges are represented by their features, it’s the latter that’s more important since the former are derived by averaging the edges they’re part of. This supervised learning was done on <em>synthetic data</em> (of 10000 placements) created by a vanilla policy network trained with the objective of predicting wirelength and congestion (as opposed to the true placement objective eventually). Note that in this imitation learning, the emphasis is on spanning the entire regime of possible rewards (good and bad) to learn robust representations of input graph, macros and netlist metadata.</li><li><strong>Wirelength harder to optimize than congestion?: </strong>Based on Table1, we can infer that the natural scales of the two metrics are ~20x different i.e., <em>λ</em> = 0.05 in Eq. (4) would’ve given equal weightage to both. However, even with <em>λ</em> = 0.01, we observe greater improvement in congestion than in wirelength. While the authors don’t delve into this, I’m curious if there’s an explanation.</li><li><strong>Qualitatively different placement than human designers: </strong>To me, the most striking result from the paper is in Figure7. Despite not being a physical design engineer myself, it’s easy to see the rationale behind human designs — we like simple, contained subproblems that can be worked upon independently by several team members before eventually collating them all on a canvas. Y-J Lee refers to some recent work by his team on manual designs inspired by RL. It’s natural we’ll see more co-designed solutions in the future; I’m not sure, however, if we have humans in the loop for downstream processes (verification and testing, in addition to routing that has been factored into the reward signal) to what extent, if any, would the above benefits be diluted.</li><li><strong>Placement cost stuck in a local optima?: </strong>While it’s hard to know this, Figure4 tells an interesting story. The fine-tuning of a pre-trained policy network showing modest improvement (~20%) that plateaus out soon could either be taken as a sign that the encoder network did learn very useful representations during training or that policy network has stopped training during fine-tuning. That the training from scratch also converges to a similar cost might be some assurance that the latter isn’t quite true, would’ve been good if the authors had commented on this.</li><li><strong>Generalizability across semiconductor technologies:</strong> One aspect that wasn’t addressed in the paper was the robustness of learned embeddings across different technologies. Since many of the netlist metadata is a function of underlying semiconductor technology node(s), it might be worthwhile investigating this given the offerings by foundries might differ in subtle-but-important ways and not needing to fine-tune individually might be a nice-to-have while evaluating vendors.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b388ab4c220" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Senate hearing on AI oversight: takeaways]]></title>
            <link>https://medium.com/@kartikganapathi/senate-hearing-on-ai-oversight-takeaways-12d99f5394c?source=rss-a9ba97f100d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/12d99f5394c</guid>
            <category><![CDATA[policy]]></category>
            <category><![CDATA[ai-safety]]></category>
            <category><![CDATA[ai-risk]]></category>
            <category><![CDATA[governance]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Kartik G Bhat]]></dc:creator>
            <pubDate>Sun, 21 May 2023 08:42:34 GMT</pubDate>
            <atom:updated>2023-05-21T17:17:53.768Z</atom:updated>
            <content:encoded><![CDATA[<p>As someone who is interested in how the policy around AI will shape up, I watched the senate hearing on AI oversight that <a href="https://www.judiciary.senate.gov/committee-activity/hearings/oversight-of-ai-rules-for-artificial-intelligence">happened earlier this week</a>. Few of my takeaways are:</p><ol><li>There seems to be general consensus among senators that too little was done too late in regulating <em>social media; </em>they don’t want it repeated in case of AI where potential risks are higher. The suggestions were, broadly speaking, around: i) mandating <em>nutritional labels/datasheets </em>delineating what’s gone into creating a given foundational LLM; ii) licensing (for models above a certain capability threshold), safety oversight (both pre- and post-deployment) and audits; iii) deliberating if <a href="https://en.wikipedia.org/wiki/Section_230">Section 230</a> should <strong>not</strong> apply to AI; iv) US leading the way to creating an international <em>regulatory/standards </em>body (I thought, however, the lawmakers’ body language suggested they didn’t think much would come out of it).</li><li>A lot of time was spent on asking witnesses how they think AI could be misused in changing public opinions and, hence, undermine democracy. The cynic in me thinks politicians just wanted to know what it means to their job-security; however, in any case, it’s the right thing to be worried about given how we’ve chosen to organize our society at large. There were some concerns raised about how to deal with copyright for content created with help from generative AI (but inspired by previous work of artists). I’m not sure how this will be addressed in the future but I think the answer will again come from technology — e.g., an <em>evaluator AI</em> external to the generator AI that recommends royalty to the original artist based on <em>degree of inspiration.</em></li><li><a href="https://en.wikipedia.org/wiki/Sam_Altman">Sam Altman</a> believes AI will take away <strong>tasks but not jobs </strong>— it’s not clear what’s the time-scale of the validity of this belief is since later in the course of the hearing he also mentions we might need to start talking about the longer term (existential?) risks too. Also, he seems to believe that for training truly large foundational models, there might only be room for a hand-few players (like Microsoft, Google etc.) given the computational resources. While I understand that’s how things <em>are</em>, I’m divided on whether that’s how things <em>ought to be</em> — on the one hand, it’s easier to regulate and mitigate large-scale risks if the market is consolidated; on the other hand, it also becomes easier to lobby (and harder to democratize).</li><li>Unsurprisingly the <a href="https://futureoflife.org/open-letter/pause-giant-ai-experiments/">moratorium idea</a> was shot down citing fears of losing the global arms race (to China).</li></ol><p>While I’m happy the discussion has been kicked off, it did not address the key questions around explainability and provable safety. I’m no expert in this myself (although I plan to learn and summarize the SoTA in a future post) but I suspect much of the calls around transparency and audits will not mean much if the scientific community has no good answers there.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12d99f5394c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A review of UT Austin online masters in data science]]></title>
            <link>https://medium.com/@kartikganapathi/a-review-of-ut-austin-online-masters-in-data-science-6b161506af64?source=rss-a9ba97f100d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b161506af64</guid>
            <category><![CDATA[online-master-degree]]></category>
            <category><![CDATA[ut-austin]]></category>
            <category><![CDATA[ai-and-ml-course]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[continuing-education]]></category>
            <dc:creator><![CDATA[Kartik G Bhat]]></dc:creator>
            <pubDate>Fri, 19 May 2023 22:43:36 GMT</pubDate>
            <atom:updated>2023-05-20T20:01:12.451Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I’ll review the <a href="https://ms-datascience.utexas.edu/">UT Austin online masters program in data science</a> (MSDS) that I recently graduated from in the hope that it might be useful for someone on the same boat as I was circa late 2021.</p><p><strong>Background</strong>: No prior experience in AI research / ML development but a reasonably good quantitative background (PhD from EECS, UC Berkeley with thesis at the intersection of physics + EE) and a keen interest in theoretical aspects of AI/ML. Previously I had taken quite a few online courses in data science, ML etc. but ended up either spreading myself too thin or had my engagement taper off due to lack of rigor in many courses. I had acceptance from <a href="https://cs.illinois.edu/academics/graduate/professional-mcs/online-master-computer-science-data-science">UIUC’s program</a> too, but the coursework being more in sync with my interests (closer to SoTA ML + greater theory component), tilted the decision in UT’s direction.</p><p><strong>Overview</strong>: A few points to note are:</p><ol><li>It’s a joint program between departments of statistics and computer science with 50–50 split between courses offered from each.</li><li>Similar UT programs to consider are: <a href="https://www.cs.utexas.edu/graduate-program/masters-program/online-option/courses">MS in CS</a> (although if you’re interested in AI/ML alone, you can cover almost all (if not all) relevant courses in MSDS too) that requires an undergraduate degree in CS; an upcoming <a href="https://cdso.utexas.edu/msai">MS in AI</a> (from what I gather, ethics in AI and an reinforcement-learning-like planning course are the only additions compared to what’s offered in MSDS).</li><li>Lectures are recorded in the 2019–20 timeframe (depending on the course), and in rapidly developing fields like Deep Learning, Natural Language Processing, Reinforcement Learning etc., an update might be in order.</li><li>Class discussions on Piazza are a mixed-bag — for more burning questions related to clarifications to HW, lectures etc., the response is great both from the cohort and instructors; for open-ended discussions like where the field is headed, or deeper implications of results covered, the response is generally weak.</li><li>Engagement of professors during the semester varies — some are active on Piazza answering questions on a daily basis, some do so sporadically, a hand-few never; most have office hours by appointment, but in rare cases, those are offered by TAs only (which they do so over weekends too to accommodate folks working full-time).</li></ol><p>As with everything in life, what you get out of the coursework is largely dictated by how much work you put into it, but just as a point of reference, I spent roughly 3-5, 7–10, 12–15 hours per week for courses I deemed as easy, moderate and hard respectively with which I could cover lectures, homework(+peer assessments), occasional skimming of optional reading list (most courses provide plenty of references to original papers as is customary in graduate coursework, although getting through all of them might be onerous if you’re taking &gt;1 course per semester) and some contribution to discussion on Piazza.</p><p><strong>Coursework</strong>: Below is my feedback on specific courses. Please note that my rating is both a function of how well I thought it was taught and how much it helped improve my skills (in my own assessment):</p><ol><li><a href="https://ms-datascience.utexas.edu/courses/causal-inference"><strong>Causal Inference</strong></a><strong> </strong>(Hard): Arguably one of the best courses in the program. The focus is on developing counterfactual reasoning that is at the heart of modern causal inference. While there is fair bit of R programming involved in analyses, it is no substitute to the need to think deeply and critically about experiments, observational studies and the assumptions that were made in the process. Assignments and exams are both geared to test these skills in new settings with wordings as confusing as they can get. <strong>Rating:</strong> <strong>4.5/5</strong></li><li><a href="https://www.cs.utexas.edu/graduate-program/masters-program/online-option/courses/reinforcement-learning"><strong>Reinforcement Learning</strong></a> (Moderate): Lectures are meant to complement/augment the material in <a href="http://incompleteideas.net/book/the-book-2nd.html">textbook</a> which is required to be read before the lectures. A free-form summary of one’s takeaways, questions, interpretations etc. is expected for each chapter, as part of the assessment. Programming assignments are implementations of standard RL algorithms such as SARSA, Q-, TD-learning, REINFORCE etc. Homework — easy; Exam — moderate. The Piazza discussion could be elevated considerably with professors’ engagement which was mostly absent. <strong>Rating: 4/5</strong></li><li><a href="https://www.cs.utexas.edu/graduate-program/masters-program/online-option/courses/online-learning"><strong>Online learning and Optimization</strong></a><strong> </strong>(Moderate): Not part of MSDS but I was able to audit it and fits into the theme of ML courses. Two almost disparate sections covered by two different professors; the former is primarily focused on bandits— stochastic and adversarial — and associated algorithms for online settings while the latter is a series on slew of optimization algorithms available for convex problems. Assignments are implementation of these algorithms; the optimization part is harder since no structure is provided and it’s left to the student to make right choices to highlight the good and bad aspects of each algorithm while the online learning part has lot of skeleton provided. Exams — hard (optimization) and easy (online learning). Little to no engagement of professors on Piazza; the TAs were good. <strong>Rating: 3.5/5</strong></li><li><a href="https://www.cs.utexas.edu/graduate-program/masters-program/online-option/courses/optimization"><strong>Optimization</strong></a> (Hard): Focus is on using convex functions and sets as the playground to enhance students’ mathematical maturity (beyond studying them for their own utility to ML problems). The first half focuses on linear programs in detail covering duality, KKT conditions etc while the second half is a summary on gradient and Newton methods. Assignments in the first half focus on proofs while second half is a mix of proofs and algorithms from scratch. Exams are hard and need a very nuanced understanding of the material. The lectures are very thorough (albeit long) in covering subtleties and applications. <strong>Rating: 4/5</strong></li><li><a href="https://www.cs.utexas.edu/graduate-program/masters-program/online-option/courses/natural-language-processing"><strong>Natural Language Processing</strong></a> (Moderate): <a href="https://www.cs.utexas.edu/people/faculty-researchers/greg-durrett">Prof. Durrett</a> is one of the most enthusiastic professors who cares a lot about teaching. He’s very active on Piazza and takes keen interest in setting the project guidelines and exams for each edition of the course offering. The assignments are implementations of transformers, language models etc. mostly from scratch — the performance criteria are not too hard to meet. Exam — moderate; project — easy. The first half of the course (traditional NLP) borrows heavily from linguistics — as someone encountering them for the first time, I found it hard. <strong>Rating: 4/5</strong></li><li><a href="https://www.cs.utexas.edu/graduate-program/masters-program/online-option/courses/deep-learning"><strong>Deep Learning </strong></a>(Moderate): Unfortunately this is one of the poorly taught courses in the program — i) managed by TAs alone (although they do their best); ii) all DL applications other than vision receiving a step-motherly treatment; iii) in all-but-one assignment (which is about training a very deep network using all the tricks in the bag) including the project, the focus is less on DL and more on optimizing the network output for downstream use; iv) less-than-crisp statements in the lectures about the theoretical underpinnings of algorithms. <strong>Rating: 2/5</strong></li><li><a href="https://ms-datascience.utexas.edu/courses/principles-of-machine-learning"><strong>Machine Learning</strong></a> (Moderate): The first part is on <a href="https://en.wikipedia.org/wiki/Probably_approximately_correct_learning">probably approximately correct</a> framework of ML while the second part is on statistical methods for ML; the former is distinctly conceptually harder, as seen in homework and midterm, than the latter. The mathematical arguments presented are both precise and crisp. The TAs were very good. Exams were easy. <strong>Rating: 3.5/5</strong></li><li><a href="https://ms-datascience.utexas.edu/courses/predictive-models"><strong>Advanced Predictive Models</strong></a> (Easy): Unfortunately another poorly taught course in the program. I can see the class having originated from good intentions to cover variety of topics central to today’s diverse data “types” such time-series, geospatial, matrix and graph etc. However the breadth becomes its enemy as the class turns into a hodgepodge of sorts. The assignments are lengthy and the instructors are litigious about presentation (and its peer assessment) but all-in-all I felt much of it is wasted effort. <strong>Rating: 2.5/5</strong></li><li><a href="https://ms-datascience.utexas.edu/courses/exploration-and-visualization"><strong>Data exploration and visualization</strong></a> (Easy): Although a relatively easy course, it’s taught well. <a href="https://clauswilke.com/">Prof. Wilke</a> is very active on Piazza as are the TAs. The course made me appreciate several aspects of aesthetics and visualization which I hadn’t paid much attention to before, although I routinely create plots of data in my day job. The assignments get more open-ended as the course progresses. The only quibble I have is that while most of the principles discussed are independent of the tool used for creation for illustration purposes (R in this case) as the professor claims, I still felt in some cases we were delving too much into the specific utilities R offers (but, say, matplotlib doesn’t). <strong>Rating: 3.5/5</strong></li><li><a href="https://ms-datascience.utexas.edu/courses/data-structures"><strong>Data structures and algorithms</strong></a> (Easy): An exceptionally well-taught course that goes beyond the obvious of specific data structures discussed (that one can usually get by referring to a standard textbook). <a href="https://www.cs.utexas.edu/people/faculty-researchers/calvin-lin">Prof. Lin</a> and his TAs are very active on Piazza and it makes for a very good learning experience. The assignments are of moderate complexity. The quizzes are tricky that are intended to test a nuanced understanding of data structures. <strong>Rating: 4/5</strong></li><li><a href="https://ms-datascience.utexas.edu/courses/probability"><strong>Probability and Inference</strong></a> (Easy): A foundational course that’s taught well. Equal weightage is given to both analytical methods for computing probabilities and simulation-based inference of point and interval estimates. <a href="https://web.ma.utexas.edu/users/parker/">Prof. Parker</a> is very active on Piazza although I felt at times her answers were not as crisp as <a href="https://web.ma.utexas.edu/users/pmueller/">Prof. Mueller</a>’s statements in lectures. <strong>Rating: 3.5/5</strong></li><li><a href="https://ms-datascience.utexas.edu/courses/foundations-of-regression"><strong>Regression</strong></a> (Easy): A foundational course that’s taught extremely poorly. While I appreciate why something as basic as regression could merit a full course, particularly for newcomers to statistics, it’s taught in a fairly insipid way making it mostly an exercise in mathematical manipulations without caring much about the “so what” of each formulation. The assignments are fairly easy. The official R solutions to problems are horribly written (variables named as <em>a, aa, aaa </em>etc.) I’ve sensed a tinge of agitation/irritation/anger in professor’s responses on Piazza when he either feels challenged or when students (mostly incorrectly) point to some “mistakes” in his slides. <strong>Rating: 1/5</strong></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b161506af64" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>