> For the complete documentation index, see [llms.txt](https://docs.everinfer.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.everinfer.ai/examples/bert-with-zero-overhead.md).

# BERT With Zero Overhead

In this tutorial we're going to demonstrate how you can deploy one of the fastest NLP models, BERT, to remote GPUs and maintain decent latency.

## Why BERT?

BERT encoder is extremely fast, running at 1.5ms on local GPU (tested on Nvidia T4). Deploying that model to remote machines and maintaining low latency is hard.&#x20;

Everinfer is highly optimized and will allow you to run that model on remote machines while keeping up with its speed.&#x20;

## How to deploy BERT on Everinfer

Install Everinfer and HuggingFace transformers library.

Convert the model to ONNX format:

```
!python3 -m transformers.onnx --model=distilbert-base-uncased onnx/
```

Authenticate on Everinfer using your API key, upload the model, and create inference engine:

```python
from everinfer import Client
client = Client('my_api_key')
pipeline = client.register_pipeline('bert', ['onnx/model.onnx'])
runner = client.create_engine(pipeline['uuid'])
```

You are ready to go!

Since HuggingFace tokenizers are fully compatible with Everinfer expected input format, you can feed tokenizer outputs directly to the deployed model:

```python
from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
inputs = tokenizer("Everinfer is fast af", return_tensors="np")
```

After applying tokenizer to input text, running the model is as simple as:

```python
preds = runner.predict([inputs]) 
```

## Performance&#x20;

Remote GPU access overhead is virtually zero!&#x20;

<figure><img src="/files/KrIMERIKbAxsvNx094H9" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
You could deploy that code to AWS Lambda to go fully serverless, or use it as a part of your self-hosted web app.&#x20;
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.everinfer.ai/examples/bert-with-zero-overhead.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
