<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.5">Jekyll</generator><link href="keelveedhi.com/feed.xml" rel="self" type="application/atom+xml" /><link href="keelveedhi.com/" rel="alternate" type="text/html" /><updated>2024-07-08T03:09:33+00:00</updated><id>keelveedhi.com/feed.xml</id><title type="html">Sriram Keelveedhi</title><subtitle>This is my personal website. I write about AI Security, AI Privacy, and Cryptography.</subtitle><entry><title type="html">Data Minimization in ML: Clean Room Basics [Part 3]</title><link href="keelveedhi.com/data/minimization/2024/03/23/cleanrooms.html" rel="alternate" type="text/html" title="Data Minimization in ML: Clean Room Basics [Part 3]" /><published>2024-03-23T00:00:00+00:00</published><updated>2024-03-23T00:00:00+00:00</updated><id>keelveedhi.com/data/minimization/2024/03/23/cleanrooms</id><content type="html" xml:base="keelveedhi.com/data/minimization/2024/03/23/cleanrooms.html"><![CDATA[<h2 id="overview">Overview</h2>
<p>Data minimization is minimizing the amount and sensitivity of data is collected and processed for a given purpose. This is a broad topic with lots of sub-problems, but it is particularly interesting and pertinent when models are trained on user data.</p>

<p>In this series of articles, we will set up a framework for how to approach data minimization specifically in the context of training ML models. We will break this problem into well-defined sub-problems and explore solutions for each one. In this article, we explore the basics of clean rooms, specifically in the context of training. The code corresponding to this article can be found at the <a href="https://github.com/sriramkr/justgarble-golang">JustGarble</a> repo.</p>

<h2 id="training-in-untrusted-environments">Training in untrusted environments</h2>
<p>Let’s start by defining the setting. There are two entities here, the <em>model provider</em> and the <em>data provider</em>.</p>
<ul>
  <li>The <em>model provider</em> provides a base model and is interested in getting a fine-tuned model. Both the base and fine-tuned models are proprietary and the model provider does not wish to share them with anyone.</li>
  <li>The <em>data provider</em> contains some sensitive data needed to fine-tuned model. The data provider does not want to provide raw access to this data to anyone.</li>
</ul>

<p><img src="/assets/crsetting.png" alt="Clean Room Setting" style="display:block; margin-left:auto; margin-right:auto" /></p>

<p>Here is a vaguely real world example of this scenario. Let’s say that the model provider is an enterprise who wants to produce a <a href="https://en.wikipedia.org/wiki/Convolutional_neural_network">CNN</a> that will detect instances of lung cancer by looking at x-ray images of lungs. They already have a decent model, but it does not work well in a particular setting - say a certain population group or a particular x-ray technology. So, they are looking to engage with a hospital chain to fine-tune their model on images from this setting and hence make it more accurate. The hospital chain is okay with the training outcome, but they cannot legally share individual x-ray images of patients, and the enterprise does not want to share their base model either. So, they need to find a way to do the fine-tuning without either party revealing the information they intend to keep secret.</p>

<p>Note that some amount of information will be leaked in the final model itself. Going back to the picture in the first article, this is the information in the inner circle. What we are trying to protect is the information in the outer circle, that does not end up in the final model, and hence does not have to be revealed if the training happens in a secure environment.</p>

<p><img src="/assets/training1.png" alt="Training" style="display:block; margin-left:auto; margin-right:auto" /></p>

<h2 id="cleanrooms">Cleanrooms</h2>
<p>A clean room, or more specifically a data clean room, refers to a kind of technology where some kind of processing can happen
on sensitive data and only the intended outputs can be learnt by the parties, and no information is leaked outside of that. The concept of data clean rooms has been largely coopted by the adtech industry, but the basic principles are more general than adtech.</p>

<p>Conceptually, this is similar to the idea of a <em>trusted third party (TTP)</em>, a foundational idea in the world two-party computation, as we will see in a moment. Let us say that two mutually distrusting parties want to compute something together. Here the idea is to imagine a trusted party to whom the two parties send their inputs. This party does the computation and returns back the appropriate outputs to both the parties. No other information is shared. Of course, this can extend beyond two-parties, but we will stick to the two party setting in this article.</p>

<p>In our setting around ML training, the data provider would send their data to the TTP, and the model provider would send the base model. The TTP would perform the fine-tuning operation and return the resulting model to the model provider. The model provider learns nothing about the training data, and the data provider does not learn anything about the output model.</p>

<h2 id="two-party-computation">Two-party computation</h2>
<p>Secure two-party computation (and more generally  secure multi-party computation) is a well understood area in Cryptography.
The basic idea here is to <em>emulate</em> a trusted third party using various cryptographic tools. There is a lot of nuance 
in the definitions, around what kind of computation is allowed, how much should  the parties be trusted, etc. We will not get into these details in this article. Two-party computation solutions can be built from a lot of cryptographic primitives. 
We will stick to one specific family of techniques, called Garbled Circuits, because of their generic nature and efficiency.</p>

<h2 id="garbled-circuits">Garbled Circuits</h2>
<p>Garbled Circuits are a fascinating idea <a href="https://en.wikipedia.org/wiki/Garbled_circuit">first described</a> by Yao in 1986. Since then, there has been a lot of interest in the area, around improving efficiency and adapting them to stronger adversary classes.
There are many great sources for learning about them, including this one by <a href="https://vitalik.eth.limo/general/2020/03/21/garbled.html">Vitalik Buterin</a>. We will be using the flavor of garbled circuits from one of my old
papers, <a href="https://eprint.iacr.org/2013/426.pdf">BKR13</a>. These are particularly efficient, and can be extended easily.</p>

<p>The code in the <a href="https://github.com/sriramkr/justgarble-golang">JustGarble</a> repo provides a basic implementation of this system in Golang.</p>

<h2 id="whats-next">What’s Next</h2>
<p>In this article, we described the concept of clean rooms as applied to training models, and showed how the cryptographic technique of two-party computation is a natural fit with them. We introduced the concept of Garbled Circuits as a way of
realizing two-party computation. In the following article, we will how to build a basic ML training solution on top of a
Garbled Circuit setup.</p>]]></content><author><name></name></author><category term="data" /><category term="minimization" /><summary type="html"><![CDATA[Overview Data minimization is minimizing the amount and sensitivity of data is collected and processed for a given purpose. This is a broad topic with lots of sub-problems, but it is particularly interesting and pertinent when models are trained on user data.]]></summary></entry><entry><title type="html">Demystifying AI Governance: Access Control [Part 4]</title><link href="keelveedhi.com/ai/governance/2024/03/15/ai-governance-4.html" rel="alternate" type="text/html" title="Demystifying AI Governance: Access Control [Part 4]" /><published>2024-03-15T18:43:19+00:00</published><updated>2024-03-15T18:43:19+00:00</updated><id>keelveedhi.com/ai/governance/2024/03/15/ai-governance-4</id><content type="html" xml:base="keelveedhi.com/ai/governance/2024/03/15/ai-governance-4.html"><![CDATA[<h3 id="overview">Overview</h3>
<p>AI governance involves providing guardrails for safely using AI systems. This can seem like an obtuse topic, but once we start approaching it systematically, we find that it breaks into concrete subproblems. A lot of these map to well-understood problems in cybersecurity, with a few twists here and there; the rest are novel, but can be framed as clear requirements.</p>

<p>The first three articles in this series, we broke down AI governance into a set of specific problems and covered the wrapper+collector solution framework. In this final article, we will go over access control.</p>

<h3 id="why-access-control">Why access control</h3>
<p>Access Control is a foundational component of AI governance. 
If we cannot control which principals (i.e. users and services) can access
which AI systems, it gets really tricky to impose visibility and control measures.
Conversely, if we can limit access to AI systems to a small set of trusted, 
well-understood principals, then we can get away with not-so-onerous solutions for 
other AI governance problems.</p>

<p>Access control can look very different depending on whether the AI system is internal or external
to the enterprise. Internal solutions, especially those offered by the cloud platform, can benefit
from the native IAM (Identity and Access Manangement) primitives provided by the platform. 
This does not solve the problem completely - we need to make sure that the access permissions are not
overly broad, but it starts things off from a good baseline. External vendors on the other hand,
almost always leverage API keys for access control.</p>

<h3 id="api-keys-the-problems">API keys: The problems</h3>
<p>API keys are simple to start using. The external AI system vendor provides one or more API keys, usually from
the admin portal. The onus is on the enterprise to manage these API keys carefully. And this is a hard problem
for a bunch of reasons.</p>

<p>First off, API keys, or more generally, shared secrets, break the access control model. In the cloud setting, 
access to resources is captured in IAM, in what is commonly called the Identity graph. This <em>graph</em>, which can be constructed from all the IAM policies defined in the enterprise’s cloud platform account, captures which principals
can access which resources. However, API keys/shared secrets circumvent this, because access to the external AI system in question does not get captured in this identity graph. Any entity who has seen the API key at some point can access this resource.</p>

<p>Second, storing and retrieving API keys is tricky. Some mature enterprises leverage secret management mechanisms to carefully control access to secrets, but more often than not, secrets get stored in all kinds of insecure locations such as configs/code, leading to them being compromised.</p>

<p>Finally, API keys make it hard to audit access, and attribute actions back to specific principals. All we know is that someone in possession of a given API key performed an action.</p>

<h3 id="abstracting-away-api-keys">Abstracting away API keys</h3>
<p>We can avoid the above issues with API keys by abstracting them away and capturing access to external AI systems within the identity graph. The basic idea here is to model the API key as a resource that the IAM system understands, and use access to this resource as a proxy for the external AI system, i.e., a principal can access the external AI system if and only if they can access this resource.</p>

<p>A simple way to do this is to store the key as an object in the controller S3 bucket. The key is stored alongside all the configs, logs, and other data in the bucket, but access to the key is tightly controlled via IAM policies set on the bucket. Now, to specify which users/principals have access to the API, we just need to add them to the policy corresponding to this object. To make this really effective, we should couple this with a tight rotation mechanism that ensures that API key lifetimes are limited. Using a <em>blue-green</em> rotation strategy can avoid downtimes during rotation.</p>

<h4 id="access-control-as-a-chokepoint">Access Control as a chokepoint</h4>
<p>The final piece of the puzle is using access to the API keys as a way to build an effective chokepoint.
This is easier to visualize with a centralized gateway. If we ensure that API keys to an external AI system is restricted to the gateway, then all calls to this system have to go through the gateway, thereby making the gateway
an effective chokepoint. With internal AI systems, the logic is similar, except that here the idea is to ensure that the gateway is the only principal that can access the AI system.</p>

<p>We can extend this idea to distributed wrappers. With external AI systems, the wrapper obtains the API key from the controller (assuming that the calling service has the privilege to do so). This API key should not be made available outside the wrapper. With internal services, one simple way to do this is via a layer of indirection. The AI system is accessible only by a specific role, and this role is to be assumed only within the wrapper. 
Note that because the wrapper runs in the same security context as the calling service, fundamentally, the wrapper cannot have any <em>extra</em> privileges than the calling service. In other words, there is no way to restrict a secret to stay within the wrapper. However, this restriction is not a particular issue in this context, building an effective chokepoint by controlling access to the API key.  We are not trying to protect against a malicious developer who we’re worried would steal and leak the API key; if so, we should employ other mechanisms to guard against that threat.</p>

<h3 id="recap-and-next-steps">Recap and Next Steps</h3>
<p>In this article, we covered why access control is a core part of AI governance, how API keys can be problematic, and how we can turn this
around and leverage API keys and more broadly access control as a way
to stand up chokepoints from where we can implement various AI governance
mechanisms.</p>

<p>In this series of articles on AI governance,</p>
<ul>
  <li>we have broken down 
AI governance into distinct subproblems which map to well understood problems in cybersecurity.</li>
  <li>realized how we can target these problems by a logical chokepoint that
intercepts all access to AI systems, and</li>
  <li>built a simple but effective chokepoint with the wrapper + controller design, leveraging access control.</li>
</ul>

<p>All of this is available in code in the <a href="https://github.com/sriramkr/aigov">aigov</a> repository. The code is simple and extensible, so clone it and play around as you like!</p>]]></content><author><name></name></author><category term="ai" /><category term="governance" /><summary type="html"><![CDATA[Overview AI governance involves providing guardrails for safely using AI systems. This can seem like an obtuse topic, but once we start approaching it systematically, we find that it breaks into concrete subproblems. A lot of these map to well-understood problems in cybersecurity, with a few twists here and there; the rest are novel, but can be framed as clear requirements.]]></summary></entry><entry><title type="html">Demystifying AI Governance: Wrappers [Part 3]</title><link href="keelveedhi.com/ai/governance/2024/03/15/ai-governance-3-copy.html" rel="alternate" type="text/html" title="Demystifying AI Governance: Wrappers [Part 3]" /><published>2024-03-15T05:45:01+00:00</published><updated>2024-03-15T05:45:01+00:00</updated><id>keelveedhi.com/ai/governance/2024/03/15/ai-governance-3%20copy</id><content type="html" xml:base="keelveedhi.com/ai/governance/2024/03/15/ai-governance-3-copy.html"><![CDATA[<h3 id="overview">Overview</h3>
<p>AI governance involves providing guardrails for safely using AI systems. This can seem like an obtuse topic, but once we start approaching it systematically, we find that it breaks into concrete subproblems. A lot of these map to well-understood problems in cybersecurity, with a few twists here and there; the rest are novel, but can be framed as clear requirements.</p>

<p>The first two articles in this series covered the basics, breaking down AI governance into a set of specific problems, and sketching a wrapper+collector solution framework. This article goes deeper into the design of the wrapper and controller.</p>

<p>The wrapper code is in the <code class="language-plaintext highlighter-rouge">wrapper</code> directory in the <a href="https://github.com/sriramkr/aigov/tree/main/wrapper">repo</a>.</p>

<h3 id="wrapper-basics">Wrapper basics</h3>
<p>To recap, the basic idea with building wrappers is to take the functionality that a gateway would provide, and have that run along with the service calling the AI system. This avoids the security and reliability issues of having a separate gateway intercepting all traffic to all AI systems. Wrappers can be of many shapes, but we will start with the simplest form, an externally vended library that the developer should include into their calling service before accessing an AI system. With Python being the most popular language for AI systems, let us star with a Python library, vended via <code class="language-plaintext highlighter-rouge">pip</code>.</p>

<p>The wrapper should intercept requests and responses between the calling service and the AI system. This can be done as an explicit step(s), or via <a href="https://en.wikipedia.org/wiki/Monkey_patch">monkey patching</a> at some point in the call chain, all the way down to the base http call. Let’s pick a middle ground, where we require the developer to add an explicit step, but use monkey patching to make the step as simple as possible. Note that monkey patching has its downsides, and making the interception of requests/responses overly implicit also has downsides, especially when it comes to debugging. The right choice here might depend on the desired developer experience.</p>

<p>We are going to take the middle ground here, and provide a simple but visible <a href="https://github.com/sriramkr/aigov/blob/3e3c4a7b6d8961dbe2af83aeb8eb1d7990c3747d/wrapper/aigov.py#L224">interface</a>.</p>

<p>The wrapper should have read/write access to the S3 bucket that will serve as the controller. More specifically, the wrapper should not have any innate access, 
but the calling service should have access that the wrapper inherits. The natural way to do this is by leveraging AWS IAM to let the role of the calling service (or IAM user, as the case may be) have appropriate access on the S3 bucket. We will explore this in more detail in the next article. For now, let’s assume that the wrapper has access to the controller S3 bucket.</p>

<h3 id="putting-the-wrapper-to-work">Putting the wrapper to work</h3>
<p>Now that we have a basic mechanism to intercept requests and responses, as well as a bi-directional communication path between the wrapper and the controller, we are ready to
start implementing some AI governance features.</p>

<h4 id="data-loss-prevention">Data Loss Prevention</h4>
<p>Let’s start with a simple one, Data Loss Prevention, or DLP. The idea here is to prevent the loss of sensitive information to external parties (in this case external AI vendors).
The sensitive information is usually captured as keywords and specific patterns, such as 
phone numbers, SSNs, etc. To implement DLP, the requests being sent to the AI system should be scanned for presence of sensitive information. Instead of building a scanner from
scratch, we can use a standard open source tool, such as <a href="https://microsoft.github.io/presidio/">Microsoft Presidio</a>. Every enterprise would have their own unique DLP requirements. We can capture these requiurements as a <em>dlp config</em>, stored at the controller. The wrapper will fetch and cache these configs, and inject them into the DLP tool being used. Requests that contain sensitive inputs can be rejected/sanitized.</p>

<h4 id="abusive-content-detection">Abusive Content Detection</h4>
<p>This is similar to DLP, but here, the idea is to analyze the inputs and outputs for abusive/inappropriate content. As with DLP, what constitutes abusive/inappropriate content
depends on the enterprise and the situation. But we can implement a baseline level of filtering with open source tools. We will use the <a href="https://pypi.org/project/detoxify/">Detoxify</a> library.</p>

<h4 id="audit-logs">Audit Logs</h4>
<p>The wrapper sends logs of all the requests and responses to the controller, including the ones that were blocked by DLP and abuse detection filters. These logs contain all the relevant metadata, including details of the environment of the calling service. We can write these logs directly to S3, or leverage <a href="https://aws.amazon.com/cloudwatch/">CloudWatch</a>. Along with audit logs, we can record metrics of various events, also using CloudWatch.</p>

<h4 id="anomaly-detection">Anomaly Detection</h4>
<p>Once access logs and metrics are available, we can scan them via async processes for anomalies, and act on them as needed. We can build our own anomaly detection systems, or leverage AWS tools such as <a href="https://aws.amazon.com/macie/">Macie</a> and <a href="https://aws.amazon.com/guardduty/">GuardDuty</a>.</p>

<h3 id="extending-the-controller">Extending the controller</h3>
<p>What we described above was a simple setup, with a basic controller leveraging S3 and some other AWS tools. Now let us explore how to open up the controller, by first making it easy to configure, and then enabling integrations with other security tools.</p>

<h4 id="configuring">Configuring</h4>
<p>Leveraging S3 to hold all the configs vended by the controller is a good idea -  S3 is extremely reliable, and comes with built-in access control mechanisms. However, manipulating these configs directly on S3 can be awkward and error-prone. We can avoid this by providing a simple UI/CLI that updates the configs in this bucket behind the scenes.</p>

<h4 id="extending-to-other-observability-and-security-systems">Extending to other observability and security systems</h4>
<p>The setup so far is constrained w.r.t what tools we can use for audit logs, anomaly detection, etc. To open this up, let’s leverage <a href="https://opentelemetry.io/">OpenTelemetry</a>, an open, well-supported standard for telemetry. Speficially, the wrappers will leverage OpenTelemetry for audit logs and metrics. OpenTelemetry comes with its own client library, which the wrapper can use for transmitting logs and metrics. OpenTelemetry also comes with its own collector, which can be run as a standard HTTP/gRPC service. This service will receive telemetry data from client libraries and can be configured to export this data to <a href="https://opentelemetry.io/ecosystem/registry/">other systems</a> , such as Prometheus, DataDog, Splunk, NewRelic, etc. Once we have a basic OpenTelemetry-based controller set up, adding new systems that support OpenTelemetry is fairly straightforward.</p>

<p>In the repo, we have a basic OpenTelemetry collector defined in the
<a href="https://github.com/sriramkr/aigov/tree/main/otel-collector">otel-collector</a> directory. It is fairly straightforward to extend this to support other systems. Consult the OpenTelemetry docs for more info.</p>

<h3 id="recap-and-next-steps">Recap and Next Steps</h3>
<p>In this article, we explored how a simple wrapper + controller setup with a Python libarary
and S3 can get us off the ground by providing AI governance features such as Audit Logs, 
Anomaly Detection, Data Loss Prevention, and Abusive Content Filtering. To open things up
even further, we can leverage OpenTelemetry, which supports a vast number of security and 
observability solutions out of the box.</p>

<p>In the next article, we will explore access control, and see how we can leverage it to  turn our wrappers into effective chokepoints.</p>]]></content><author><name></name></author><category term="ai" /><category term="governance" /><summary type="html"><![CDATA[Overview AI governance involves providing guardrails for safely using AI systems. This can seem like an obtuse topic, but once we start approaching it systematically, we find that it breaks into concrete subproblems. A lot of these map to well-understood problems in cybersecurity, with a few twists here and there; the rest are novel, but can be framed as clear requirements.]]></summary></entry><entry><title type="html">Demystifying AI Governance: Chokepoints [Part 2]</title><link href="keelveedhi.com/ai/governance/2024/03/12/ai-governance-2.html" rel="alternate" type="text/html" title="Demystifying AI Governance: Chokepoints [Part 2]" /><published>2024-03-12T16:13:00+00:00</published><updated>2024-03-12T16:13:00+00:00</updated><id>keelveedhi.com/ai/governance/2024/03/12/ai-governance-2</id><content type="html" xml:base="keelveedhi.com/ai/governance/2024/03/12/ai-governance-2.html"><![CDATA[<h3 id="overview">Overview</h3>
<p>AI governance involves providing guardrails for safely using AI systems. This can seem like an obtuse topic, but once we start approaching it systematically, we find that it breaks into concrete subproblems. A lot of these map to well-understood problems in cybersecurity, with a few twists here and there; the rest are novel, but can be framed as clear requirements.</p>

<p>The first article in this series covered the basics, breaking down AI governance into a set of specific problems. This article dives deeper into building a solution framework.</p>

<h3 id="the-setting">The Setting</h3>
<p>Before diving into the solution, let’s describe the setting. Because we want a comprehensive AI governance solution that covers all use cases, 
we should keep the setting as generic as possible. We are looking at an enterprise setting, with a production infrastructure (<em>prod</em>), consisting of services running on a  cloud platform,
and a corporate infrastructure (<em>corp</em>), consisting of employee devices (laptops, phones, etc.).</p>
<ul>
  <li>
    <p><strong>AI System</strong>: This is our abstraction for covering all shapes of AI related systems, including internal models and external, vendor-provided models. 
These systems will interact with corp and prod services across the infrastructure.</p>
  </li>
  <li>
    <p><strong>Calling Service</strong>: This is the service interacting with the AI system. It makes requests to the AI system and gets back responses, 
i.e., the AI system is a remote service from the perspective of the calling service. 
These interactions could be part of the training phase, inference phase, or some other operational activity. 
This service might be running in production, 
or on an employee laptop. It could even be a chatbot-type application running in the browser. This abstraction extends to all these settings.</p>
  </li>
</ul>

<p><img src="/assets/setting1.png" alt="Setting" style="display:block; margin-left:auto; margin-right:auto" /></p>

<h3 id="chokepoints">Chokepoints</h3>

<p>The first article introduced the paradigm of <em>visibility and control</em>, i.e., all the component problems that fall within AI governance 
essentially involve gaining visibility or control over some aspect of an AI system - this could be the model itself, training data,
inference inputs and outputs, identity and permissions of the caller, etc.</p>

<p>A natural mechanism for achieving this type of visibility and control is a <strong>chokepoint</strong>. If we can ensure that all interactions with all AI systems in an enterprise passed through a single (logical) chokepoint, that would give us a way to bootstrap various visibility and control mechanisms.</p>

<p><img src="/assets/chokepoint1.png" alt="Setting" style="display:block; margin-left:auto; margin-right:auto" /></p>

<p>Of course, building a pervasive chokepoint that wraps all AI systems is no easy challenge. If done wrong, this could easily become a  point of failure and compromise for the overall infrastructure. Our goal with AI governance is ultimately reducing AI-related risks for the business, and a badly designed chokepoint might be a net negative from this perspective.</p>

<h3 id="design-criteria">Design Criteria</h3>
<p>The top-level goal here is to materialize a chokepoint that is comprehensive enough to cover all the 
problems within AI governance, but at the same time, robust and secure enough that it does not become a point of failure or compromise. Moreover, we want to minimize the incremental <em>cost</em> of AI governance as much as possible and to that end reuse existing solutions wherever we can. From these top-level goals, we can frame some concrete design goals:</p>
<ul>
  <li>The solution should work with <em>all</em> AI systems - either out of the box, or with minimal extra work.</li>
  <li>No active components in any critical path.</li>
  <li>No elevated access priviliges.</li>
  <li>The solution should seamlessly integrate with existing workflows.</li>
</ul>

<p>The rest of this article and follow-up articles cover the design of such a system. For simplicity, the articles
describe a solution specific to AWS.</p>

<h3 id="wrappers--controller">Wrappers + Controller</h3>
<p>Realizing the chokepoint in a centralized manner, say, via a Gateway, is a good thought exercise, but it does not work in practice - such a gateway would be a single point of failure and compromise. An alternative to this is to imagine such a gateaway, but have it run along with the calling service, as a wrapper or a sidecar. In other words, every call to an AI system should be <em>wrapped</em> by a layer of logic that essentially does the same checks the gateway would have done. But now, this logic lives alongside the caller, instead of an external location. The simplest version of such a wrapper would be a library - for instance a Python library vended via <code class="language-plaintext highlighter-rouge">pip</code>. Developers can then add this a dependency in their service.</p>

<p>The wrapper code is in the <code class="language-plaintext highlighter-rouge">wrapper</code> directory in the <a href="https://github.com/sriramkr/aigov/tree/main/wrapper">repo</a>. We will explore this in more detail in the coming articles.</p>

<p><img src="/assets/wrapper.png" alt="Setting" style="display:block; margin-left:auto; margin-right:auto" /></p>

<p>These wrappers cannot function in isolation. They need to be hydrated with relevant configs and metadata, and they need a sink where they can send data and telemetry. Both these functions are performed by a centralized entity, the <em>controller</em>. In the simplest case, this controller can be a passive component, such as an S3 bucket. The wrappers pick up the configs they need from this bucket, and write back audit logs and event information to the same bucket. Controllers can get more complicated than this, and we will explore them in a later article, but for now, a simple S3 bucket will be sufficient for our purposes.</p>

<p>This simple <code class="language-plaintext highlighter-rouge">pip</code>-vended Python library and a S3 bucket might not seem like much, but it in the next article we show that it gives us a lot of the visibility and control we need.</p>

<h3 id="recap-and-next-steps">Recap and Next Steps</h3>
<p>We started with the idea that AI government boils down to visibility and control, and then argued that a well-designed pervasive chokepoint is a great way to get visibility and control over a set of systems, such
as all the AI systems in an enterprise. We then sketched how such a chokepoint can be implemented as a wrapper/controller design, and realized by simple components, such as a simple Python library acting as the wrapper and an S3 bucket acting as the controller.</p>

<p>In the next article, we show how this simple Python library + S3 bucket based implementation can solve a bunch of AI governance features. Following that, we show auth and access control can be used to ensure that this wrapper/controller chokepoint is pervasive.</p>]]></content><author><name></name></author><category term="ai" /><category term="governance" /><summary type="html"><![CDATA[Overview AI governance involves providing guardrails for safely using AI systems. This can seem like an obtuse topic, but once we start approaching it systematically, we find that it breaks into concrete subproblems. A lot of these map to well-understood problems in cybersecurity, with a few twists here and there; the rest are novel, but can be framed as clear requirements.]]></summary></entry><entry><title type="html">Demystifying AI Governance: The Basics [Part 1]</title><link href="keelveedhi.com/ai/governance/2024/03/10/ai-governance-1.html" rel="alternate" type="text/html" title="Demystifying AI Governance: The Basics [Part 1]" /><published>2024-03-10T20:09:26+00:00</published><updated>2024-03-10T20:09:26+00:00</updated><id>keelveedhi.com/ai/governance/2024/03/10/ai-governance-1</id><content type="html" xml:base="keelveedhi.com/ai/governance/2024/03/10/ai-governance-1.html"><![CDATA[<h3 id="overview">Overview</h3>
<p>AI governance involves providing guardrails for safely using AI systems. This can seem like an obtuse topic, but once we start approaching it systematically, we find that it breaks into concrete subproblems. A lot of these map to well-understood problems in cybersecurity, with a few twists here and there; the rest are novel, but can be framed as clear requirements.</p>

<p>This article, the first in a series on demystifying AI governance, gives a high-level overview of the area. Our eventual goal is to build a simple but extensible AI governance platform. The code is available <a href="https://github.com/sriramkr/aigov">here</a>, and we’ll keep referencing specific parts of it as we go.</p>

<h3 id="life-of-a-model">Life of a Model</h3>

<p>The best place to start towards demystifying AI Governance is understanding how AI models are used in enterprises. Models can be built from scratch (e.g. simple neural nets), or pre-trained with some later fine-tuning (e.g. ResNet family). They can be on-prem (e.g. HuggingFace models) or hosted at a vendor (e.g. GPTs). They can be used to power customer-facing features and/or internal tools. Here are some of the stages within a model’s lifecycle in an enterprise.</p>

<p><strong>Model Introduction</strong>: A model starts becoming a concern when it is being used as part of some functionality, especially if it involves sensitive customer/user/employee data. All models have associated risks - security, privacy, ethics, etc., but some models are safer than others, especially in certain situations. </p>

<p><strong>Training</strong>: The data used to train models can lead to restrictions on how the model is used. For instance, applications built on models trained on raw user data must include mechanisms to respect data subject rights, such as the right to be forgotten. </p>

<p><strong>Inference</strong>: Models can represent an alternate plane of access to the data they were trained on. For instance, a model trained on internal documents and made available to all employees invalidates whatever access control policies were applied on the docs. Model outputs can contain abusive, inaccurate, or inappropriate information, and usually need to be filtered.</p>

<p><strong>Continued Operation</strong>: Models can start showing degraded performance over time, a phenomenon known as model drift. This can affect the safety properties of the models. </p>

<p><strong>Vendor-hosted models</strong>: With vendor-hosted models, there are additional issues, as vendors are external third parties. Preventing sensitive data from reaching the vendor via model inputs at training/inference time is important. Preventing abusive prompts is also important and usually stipulated as a contractual requirement by the vendor.</p>

<h3 id="breaking-into-subproblems">Breaking into subproblems</h3>
<p>We can breakdown AI governance into sub-problems by analyzing the
security issues in each of the stages in the model lifecycle sketched above.</p>

<p>A common joke in cybersecurity is that every problem can be framed as either monitoring or controlling access to something. 
Monitoring/ visibility type solutions are usually easy to implement but cannot prevent bad outcomes. Nevertheless, they might be sufficient in some cases. Control solutions have to be more robust, and are hence more expensive to build. AI governance is no different in this regard.</p>

<p>The following picture takes the problems sketched in the previous section and frames them as problems around visibility/control.</p>

<p><img src="/assets/aigov.jpg" alt="AI Governance" /></p>

<p>Let us look at these problems in more detail.</p>

<p><strong>Model Discovery</strong> is about finding the models that are in use within the enterprise. It parallels familiar problems such as Data Mapping and Vendor Discovery. Solutions include manual information gathering from engineering teams or automated methods like Code Scanning.</p>

<p><strong>Model Provenance</strong> refers to standardizing the ways in which models can be procured (both on-prem and vendor-provided models). This is a subcategory of supply chain security and solutions follow a similar template - have a centralized repository of approved components (in this case models) and control how components are added/updated within this repository.</p>

<p><strong>Model Risk Assessment</strong> ensures that model risks remain within acceptable bounds. This is one of the more unique subproblems within AI governance, although it bears some similarities to black box testing, pen testing, and other offensive security techniques.</p>

<p><strong>Data Mapping</strong> entails creating a map of sensitive data locations within the infrastructure. It is a foundational challenge in privacy and a prerequisite for addressing other issues. In the context of AI governance, the additional complexity lies in tracking which data sources are utilized to train specific models.</p>

<p><strong>Data Minimization</strong> covers a broad family of techniques including pseudonymization, anonymization and synthetic data generation. In this context, data minimization serves a specific purpose, to unlink the training data from the underlying users and hence reduce restrictions on the resultant models. </p>

<p><strong>Model Access Control</strong> involves controlling which principals (users, services, etc.) get access to which models. This maps to internal or third-party access control, depending on whether the model in question is on-prem or vendor-hosted. The challenge is in avoiding creating shadow access planes, and instead capture these rules in the existing IAM graph(s) in the org.  </p>

<p><strong>Model Audit Logs</strong> capture the details of the training and inference operations with the models. These logs are invaluable for meeting regulatory requirements and for incident forensics. Audit Logs in general are a fairly well understood problem. The challenge is around leveraging these existing tools for AI models instead of creating new, incongruent tooling.</p>

<p><strong>Data Loss Prevention</strong> is about ensuring that sensitive data belonging to the enterprise does not get inadvertently shared with AI vendors, or otherwise becomes part of the training corpora of internal models. This is also a well understood problem in general, with extensive solutions. The challenge is in adapting these existing tools to AI-specific use cases such as training and inference, and ensuring consistent usage across the organization.</p>

<p><strong>Abusive Prompt Filtering</strong> is a novel problem with AI systems, especially LLMs. It involves detecting and preventing abusive/inappropriate prompts reaching the model. </p>

<p><strong>Output Filtering</strong>, i.e., ensuring that model outputs adhere to the policies of the organization and larger regulations, is a new problem with AI applications. Our understanding of this problem as well as the solution landscape are both evolving. The best approach here is adopting a viable solution among the available options and watching the landscape for advancements.</p>

<p><strong>Drift Monitoring</strong> is another novel AI problem and involves continuously monitoring model safety performance metrics and acting when these metrics drop below acceptable thresholds.</p>

<h3 id="what-next">What Next</h3>

<p>The tldr; of this post is that AI Governance can be broken into sub-problems which map to well-understood problems in cybersecurity. In the next post, we’ll take this one level further and explore how we can extend existing solutions for these sub-problems to the AI governance use-cases.</p>]]></content><author><name></name></author><category term="ai" /><category term="governance" /><summary type="html"><![CDATA[Overview AI governance involves providing guardrails for safely using AI systems. This can seem like an obtuse topic, but once we start approaching it systematically, we find that it breaks into concrete subproblems. A lot of these map to well-understood problems in cybersecurity, with a few twists here and there; the rest are novel, but can be framed as clear requirements.]]></summary></entry><entry><title type="html">Data Minimization in ML: Rethinking Anonymization and De-Identification [Part 2]</title><link href="keelveedhi.com/data/minimization/2024/02/07/anonymization.html" rel="alternate" type="text/html" title="Data Minimization in ML: Rethinking Anonymization and De-Identification [Part 2]" /><published>2024-02-07T00:00:00+00:00</published><updated>2024-02-07T00:00:00+00:00</updated><id>keelveedhi.com/data/minimization/2024/02/07/anonymization</id><content type="html" xml:base="keelveedhi.com/data/minimization/2024/02/07/anonymization.html"><![CDATA[<h2 id="overview">Overview</h2>

<p>Data minimization is minimizing the amount and sensitivity of data is collected and processed for a given purpose. 
This is a broad topic with lots of sub-problems, but it is particularly interesting and pertinent when models are trained on user data.</p>

<p>In this series of articles, we will set up a framework for how to approach data minimization specifically in the context of training new ML models. We will break this problem into well-defined sub-problems and explore solutions for each one. In this article, we are going to dive deeper into anonymization.</p>

<p>A note about terminology: anonymization is a loaded word and has a precise definition when used in the context of regulatory frameworks like GDPR. Here, we are using the term a bit more loosely, to mean removing sensitive information in a broad sense. We could have picked a different term, such as de-identification or PII removal, but they have specific meanings as well, and are a lot weaker than what we are trying to accomplish.</p>
<h2 id="basics">Basics</h2>
<p>The goal of anonymization is to remove all sensitive information from the training data. If we remove sensitive information right at the source, it has no way of making it into the final model, which 
is a great situation for privacy. The challenge is in being able to do this effectively, and without affecting the quality of the contextual information too much.</p>

<p><img src="/assets/training2.png" alt="Anonymization" style="display:block; margin-left:auto; margin-right:auto" /></p>

<h2 id="current-approaches">Current Approaches</h2>
<p>Current approaches to anonymization are simplistic. They rely on pattern matching and regular expressions to identify and redact PII in the text. Slightly more sophisticated tools use techniques like <em>Named Entity Recognition</em> to go beyond pattern identification. However, this falls short too, as they are not effective at detecting all occurrences of the entities, especially when abbreviations and alternate names are used. Moreover, they can end up damaging a lot of useful contextual information in this process.</p>
<h2 id="whats-missing">What’s missing?</h2>

<p><strong>Context</strong>: The current approaches are falling short because they have no semantic understanding of the text. There are two levels to this. The first is building a semantic model of the text, including the various objects mentioned in the text and their relationships. The second level is being able to understand how sensitive each of these objects are as well as how much useful context they provide.</p>

<p><strong>Best Effort</strong>: The current approach involves making a pass over the text and returning a new blob of text as the output. There is no concept of reporting how well the anonymization process worked, or even whether it was a success or failure.</p>

<p><strong>Configurability</strong>: The right level of anonymization depends on the context of the application. However, the current approaches do not provide any levers to configure <em>how much</em> anonymization is needed for a particular use case.</p>

<h2 id="deep-context-anonymization">Deep Context Anonymization</h2>
<p>The above realizations lead us to a new approach to anonymization: deep context anonymization. Here the goal is to build a semantic understanding of the text. With this and a rich model of the world we can approach anonymization from a completely different perspective, by asking: <em>how would a reasonable huaman rewrite this text to make it anonymous?</em>
This is of course an open-ended subjective question with no definitive answer. But this also gives us flexibility in terms of how much anonymization we need, and how sensitive we are to loss of contextual information.</p>

<h3 id="leveraging-llms">Leveraging LLMs</h3>
<p>LLMs are a natural fit for deep context anonymization. They are good at <em>understanding</em> natural language and can be instructed to modify the text in the desired manner. However, using a zero-shot approach with a generic model is not likely to yield the best results. We need to experiment with different models, fine-tune them if needed, and try different multi-shot approaches.</p>

<h3 id="the-testbed">The Testbed</h3>
<p>If we want to try out and compare different models and operating conditions, we need a way to compare them objectively. That’s where the <a href="https://github.com/sriramkr/synth">testbed</a> project comes in.  The repo contains the details of how this works, but at a basic level, the idea is to create synthetic <em>stories</em> of people involving specific sensitive and contextual properties. We can then test how well a given approach is, at removing sensitive information without affecting contextual information.</p>

<h3 id="current-status">Current Status</h3>
<p>From experiments with the testbed, we can get surprisingly good deep context anonymization solutions by leveraging LLMs like GPT-4 and Mistral in a few shot approach, and by breaking the task into multiple steps involving generating structured properties
and reasonging about their likelihood of containing sensitive information. These techniques lead to significantly better results
than the ones mentioned in the Current Approaches section. The next step is to build fine-tuned models specifically for the purpose of anonymization.</p>]]></content><author><name></name></author><category term="data" /><category term="minimization" /><summary type="html"><![CDATA[Overview]]></summary></entry><entry><title type="html">Data Minimization and Model Training: The Basics [Part 1]</title><link href="keelveedhi.com/data/minimization/2024/02/03/datamin.html" rel="alternate" type="text/html" title="Data Minimization and Model Training: The Basics [Part 1]" /><published>2024-02-03T00:00:00+00:00</published><updated>2024-02-03T00:00:00+00:00</updated><id>keelveedhi.com/data/minimization/2024/02/03/datamin</id><content type="html" xml:base="keelveedhi.com/data/minimization/2024/02/03/datamin.html"><![CDATA[<h2 id="overview">Overview</h2>

<p>Data minimization is minimizing the amount and sensitivity of data is collected and processed for a given purpose. 
This is a broad topic with lots of sub-problems, but it is particularly interesting and pertinent when models are trained on user data.</p>

<p>In this series of articles, we will set up a framework for how to approach data minimization specifically in the 
context of training ML models. We will break this problem into well-defined sub-problems and explore solutions for each one.</p>

<h2 id="training-models-on-user-data">Training models on user data</h2>
<p>Building models on user data is a common scenario in a variety of contexts such as personalization, advertising, communication assistance, etc.
 It is also fraught with dangers, both for the customer, in terms of privacy risks, loss of sensitive information, etc., and for the enterprise that is building the model, due to security and regulatory reasons. We can visualize this better with a simple albeit simplistic mental model - let us say that the user data in question has two kinds of features.</p>

<ul>
  <li><strong>Sensitive information</strong> that is not needed for the purpose of the application,
 but is harmful if it makes its way into the model or otherwise gets leaked to attackers.</li>
  <li><strong>Contextual information</strong> that is actually relevant for the purpose of the application.</li>
</ul>

<p>To make this more concrete, let us say we are building a shopping assistant app that learns about the user’s preferences from
their social media posts. For this application, understanding the socio-economic situation of the user is helpful. To that end,
let us say that the following sentence is part of the training data:</p>

<blockquote>
  <p>I drove my Ferrari from my house in Beverly Hills to my office in Santa Monica.</p>
</blockquote>

<p>On the one hand, this sentence provides a lot of information about the socio-economic status of the user. But on the other
hand, this information is so specific that it can be used to effectively dox the person, or at least get quite close. 
We want to find ways to extract the useful context in a piece of information without bringing in the overly-specific details 
that do not add any useful context anyway. For instance, a sentence like the one below will give us more or less the same level
of contextual information, but without revealing sensitive information about the user.</p>

<blockquote>
  <p>I drove expensive luxury car from my house in an upscale coastal neighborhood to my office located closeby.</p>
</blockquote>

<p>Stepping back, the fundamental question we are interested in solving is: 
<strong>“How can we build models from user data that are rich in contextual information but have minimal amounts of sensitive data?”</strong></p>

<p>From the framing of this question, it should be clear that we are looking at a <em>harm reduction</em> approach here. We accept that models built on user data will have some amount of sensitive information in them. But we can drive this down to a meaningful extent.</p>

<h3 id="training-and-inference">Training and Inference</h3>

<p>If we think about this question carefully, we can see that there are two aspects to it, centered around what happens at training time, and what happens at inference time.</p>

<p>At training time, we should be worried about how much sensitive information is in the training data. This information is available to the training environment (which might be untrusted or semi-trusted), and might be available to attackers who compromise the
training infrastructure.</p>

<p>Post training, we should be worried about how much sensitive information has made it into the final model, and is hence available to malicious users and other types of attackers who do not have access to the training data, but do have access to the final model.</p>

<p>The following picture helps visualize the two issues.</p>

<p><img src="/assets/training1.png" alt="Training" style="display:block; margin-left:auto; margin-right:auto" /></p>

<h2 id="solutions">Solutions</h2>
<p>In the rest of the articles in this series, we are going to look at two broad classes of solutions: <em>anonymization</em> and <em>clean rooms</em>.</p>

<p>Anonymization involves processing the training data so that the sensitive information is removed. 
There is some prior work around this, but as we explore further, we will find that the existing approaches are too basic, and that there is value in exploring <em>deep context anonymization</em>, by which we mean getting rid of sensitive information while keeping an eye on the loss of useful context. In the picture above, the purpose of anonymization is reducing the number of red dots
before starting the training process.
<em>Note: Anonymization is a loaded word and has a precise definition when used in the context of regulatory frameworks like GDPR. Here, we are using the term a bit more loosely, to mean removing sensitive information in a broad sense.</em></p>

<p>Clean rooms are applicable in the setting where the training environment is untrusted/semi-trusted. 
This is relevant if the data involved is particularly sensitive, such as medical data, and when the entity that wants to build and use the model is different from the entity that provides the data.
The data provider does not want to share their data in its entirety, but they are okay with  some context seeping into the model. In other words, they are okay with sharing the inner circle in the diagram above but not the outer circle.
Clean rooms are a well-studied context as well, but when we tailor the setting to model training, we find that we can build solutions that are more efficient and simpler.</p>]]></content><author><name></name></author><category term="data" /><category term="minimization" /><summary type="html"><![CDATA[Overview]]></summary></entry></feed>