Catalog PyPI
PACKAGE EXPLORERView in registry

abottle

PyPI

put your model into **a bottle** then you get a working server and more.

Versions collected1
Direct dependencies0From release 0.1.0
Last observed20 Oct, 17:32 UTC

README

Version 0.1.0 documentation

abottle

trition/tensorrt/onnxruntim/pytorch python server wrapper

put your model into a bottle then you get a working server and more.

Demo


import numpy as np
from transformers import AutoTokenizer


class MiniLM:
    def __init__(self):
        self.tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2")

    def predict(self, X):
        encode_dict = self.tokenizer(
            X, padding="max_length", max_length=128, truncation=True
        )
        input_ids = np.array(encode_dict["input_ids"], dtype=np.int32)
        attention_mask = np.array(encode_dict["attention_mask"], dtype=np.int32)

        outputs = self.model.infer(
            {"input_ids": input_ids, "attention_mask": attention_mask}, ["y"]
        )

        return outputs['y']


    #you can write config in class or provide it as a yaml file or yaml string
    class Config:
        class TritonModel:
            name = "minilm"
            version = "2"

you can write a class like this, and then starts with abottle

abottle main.MiniLM

with default, abottle will run as server, and server at 0.0.0.0:8081

curl localhost:8081/predict

abottle will inject an attribute named model into your class, and you don't need to care what that model runtime is. it can be Pytorch with CuDNN8 or an optimized TensorRT plan, it depends on the config you give

self.model.infer({"input1": input1_tensor, "input2": input2_tensor}, ['output_1'])

config with shell

abottle main.MiniLM --config """TritonModel:
        triton_url: localhost
        name: minilm
        version: 2
    """

config with file

abottle main.MiniLM --config <config yaml file path>
import numpy as np
import pandas as pd
from transformers import AutoTokenizer
from typing import List


class MiniLM:
    def __init__(self):
        self.tokenizer = AutoTokenizer.from_pretrained(
            "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
        )

    def cosine(self, a: List[List[float]], b: List[List[float]]) -> float:
        a, b = np.array(a), np.array(b)
        # |A|
        sqrt_sqare_A = np.tile(
            np.sqrt(np.sum(np.square(a), axis=1)).reshape((a.shape[0], 1)),
            (1, a.shape[0]),
        )
        # |B|
        sqrt_sqare_B = np.tile(
            np.sqrt(np.sum(np.square(b.T), axis=0)).reshape((1, b.shape[0])),
            (b.shape[0], 1),
        )
        # cosine similarity
        score_matrix = np.divide(np.dot(a, b.T), sqrt_sqare_A * sqrt_sqare_B)
        return score_matrix

    def predict(self, X: List[str]) -> List[List[float]]:
        encode_dict = self.tokenizer(
            X, padding="max_length", max_length=128, truncation=True
        )
        input_ids = np.array(encode_dict["input_ids"], dtype=np.int32)
        attention_mask = np.array(encode_dict["attention_mask"], dtype=np.int32)

        outputs = self.model.infer(
            {"input_ids": input_ids, "attention_mask": attention_mask}, ["y"]
        )

        return outputs["y"]

    def evaluate(self, file_path: str, batch_size: int) -> float:
        test_data = pd.read_csv(file_path, sep=", ", names=["query", "label"])
        query, label = test_data["query"].tolist(), test_data["label"].tolist()
        assert len(query) == len(label)

        query_embedding, label_embedding = [], []
        for i in range(0, len(query), batch_size):
            query_embedding += self.predict(query[i : min(i + batch_size, len(query))])
            label_embedding += self.predict(label[i : min(i + batch_size, len(label))])
        assert len(query_embedding) == len(label_embedding)

        # 分数矩阵
        score_matrix = self.cosine(query_embedding, label_embedding)
        # 算法性能
        raw_result = np.argmax(score_matrix, axis=0) == np.array(
            [i for i in range(score_matrix.shape[0])]
        )
        unique, counts = np.unique(a, return_counts=True)
        top_1_accuracy = counts[unique.tolist().index(True)] / np.sum(counts)

        return top_1_accuracy

def evaluate can be used as a tester like below

abottle main.MiniLM --as tester file_path='test.csv', batch_size=100

the arguments you defined in the evaluate function can be set in CLI args with format xxx=xxx

you can use different wrapper for your model, including:

  • abottle.ONNXModel
  • abottle.TensorRTModel
  • abottle.TritonModel
  • abottle.PytorchModel

if you want to add more wrappers you can just implement abottle.BaseModel

abottle main.MiniLM --as server --wrapper abottle.TritonModel

Configs

abottle.ONNXModel

ONNXModel:
    ort_file: 'the ort file path'

abottle.TensorRTModel

TensorRTModel:
    trt_file: 'TensorRT plan file path'

abottle.TritonModel

TritonModel:
    name: "your model's name on triton server"
    version: "your model's version on triton server"
    triton_url: "triton server's host without schema, it means http://xxx is invalid"

abottle.PytorchModel(not fully implemented)

PytorchModel:
    model: 'pytroch importable name'

Motivation

as a DL model creator, you don't need to focus on how to serve or test the performance of a model on a target platform or how to optimize your model and don't lose accuracy, just find a bottle and put your logic code into it, the DL engineer people can do those things for you, all you need to do is export your model to a onnx file, and write logic code like above examples.

Feature

we will build this bottle as strong as possible, make this bottle become a standardization interface of the MLOps cycles, you can see more and more scenarios like optimization, graph fusing, performance test, deployment, data gathering, etc using this bottle.

Downloads & popularity

5downloads
1-day window · source-reported counts19 Oct 2026
46230
2026-07-22: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-07-22–2026-07-222026-07-23: 2 · observed 2026-10-20T22:51:13.6415439Z · period 2026-07-23–2026-07-232026-07-28: 2 · observed 2026-10-20T22:51:13.6415439Z · period 2026-07-28–2026-07-282026-07-29: 14 · observed 2026-10-20T22:51:13.6415439Z · period 2026-07-29–2026-07-292026-08-01: 2 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-01–2026-08-012026-08-02: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-02–2026-08-022026-08-03: 6 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-03–2026-08-032026-08-04: 3 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-04–2026-08-042026-08-05: 3 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-05–2026-08-052026-08-06: 2 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-06–2026-08-062026-08-09: 8 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-09–2026-08-092026-08-14: 5 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-14–2026-08-142026-08-17: 4 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-17–2026-08-172026-08-18: 46 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-18–2026-08-182026-08-19: 2 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-19–2026-08-192026-08-20: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-20–2026-08-202026-08-22: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-22–2026-08-222026-08-23: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-23–2026-08-232026-08-24: 3 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-24–2026-08-242026-08-25: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-25–2026-08-252026-08-31: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-08-31–2026-08-312026-09-03: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-03–2026-09-032026-09-04: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-04–2026-09-042026-09-06: 4 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-06–2026-09-062026-09-07: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-07–2026-09-072026-09-09: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-09–2026-09-092026-09-10: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-10–2026-09-102026-09-11: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-11–2026-09-112026-09-12: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-12–2026-09-122026-09-13: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-13–2026-09-132026-09-14: 2 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-14–2026-09-142026-09-15: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-15–2026-09-152026-09-16: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-16–2026-09-162026-09-18: 2 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-18–2026-09-182026-09-20: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-20–2026-09-202026-09-21: 4 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-21–2026-09-212026-09-22: 2 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-22–2026-09-222026-09-23: 2 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-23–2026-09-232026-09-24: 13 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-24–2026-09-242026-09-25: 4 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-25–2026-09-252026-09-26: 19 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-26–2026-09-262026-09-27: 5 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-27–2026-09-272026-09-28: 3 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-28–2026-09-282026-09-29: 5 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-29–2026-09-292026-09-30: 3 · observed 2026-10-20T22:51:13.6415439Z · period 2026-09-30–2026-09-302026-10-01: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-01–2026-10-012026-10-04: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-04–2026-10-042026-10-06: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-06–2026-10-062026-10-08: 37 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-08–2026-10-082026-10-09: 8 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-09–2026-10-092026-10-10: 2 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-10–2026-10-102026-10-11: 2 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-11–2026-10-112026-10-12: 5 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-12–2026-10-122026-10-13: 7 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-13–2026-10-132026-10-14: 4 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-14–2026-10-142026-10-16: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-16–2026-10-162026-10-17: 5 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-17–2026-10-172026-10-18: 1 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-18–2026-10-182026-10-19: 5 · observed 2026-10-20T22:51:13.6415439Z · period 2026-10-19–2026-10-19
22 Jul19 Oct

pypistats · 59 observations shown. Missing days are unknown. Source category: overall: without mirrors.

View observed values
Date / source periodValueObserved at
2026-10-19 – 2026-10-1952026-10-20T22:51:13.6415439Z
2026-10-18 – 2026-10-1812026-10-20T22:51:13.6415439Z
2026-10-17 – 2026-10-1752026-10-20T22:51:13.6415439Z
2026-10-16 – 2026-10-1612026-10-20T22:51:13.6415439Z
2026-10-14 – 2026-10-1442026-10-20T22:51:13.6415439Z
2026-10-13 – 2026-10-1372026-10-20T22:51:13.6415439Z
2026-10-12 – 2026-10-1252026-10-20T22:51:13.6415439Z
2026-10-11 – 2026-10-1122026-10-20T22:51:13.6415439Z
2026-10-10 – 2026-10-1022026-10-20T22:51:13.6415439Z
2026-10-09 – 2026-10-0982026-10-20T22:51:13.6415439Z
2026-10-08 – 2026-10-08372026-10-20T22:51:13.6415439Z
2026-10-06 – 2026-10-0612026-10-20T22:51:13.6415439Z
2026-10-04 – 2026-10-0412026-10-20T22:51:13.6415439Z
2026-10-01 – 2026-10-0112026-10-20T22:51:13.6415439Z
2026-09-30 – 2026-09-3032026-10-20T22:51:13.6415439Z
2026-09-29 – 2026-09-2952026-10-20T22:51:13.6415439Z
2026-09-28 – 2026-09-2832026-10-20T22:51:13.6415439Z
2026-09-27 – 2026-09-2752026-10-20T22:51:13.6415439Z
2026-09-26 – 2026-09-26192026-10-20T22:51:13.6415439Z
2026-09-25 – 2026-09-2542026-10-20T22:51:13.6415439Z
2026-09-24 – 2026-09-24132026-10-20T22:51:13.6415439Z
2026-09-23 – 2026-09-2322026-10-20T22:51:13.6415439Z
2026-09-22 – 2026-09-2222026-10-20T22:51:13.6415439Z
2026-09-21 – 2026-09-2142026-10-20T22:51:13.6415439Z
2026-09-20 – 2026-09-2012026-10-20T22:51:13.6415439Z
2026-09-18 – 2026-09-1822026-10-20T22:51:13.6415439Z
2026-09-16 – 2026-09-1612026-10-20T22:51:13.6415439Z
2026-09-15 – 2026-09-1512026-10-20T22:51:13.6415439Z
2026-09-14 – 2026-09-1422026-10-20T22:51:13.6415439Z
2026-09-13 – 2026-09-1312026-10-20T22:51:13.6415439Z
2026-09-12 – 2026-09-1212026-10-20T22:51:13.6415439Z
2026-09-11 – 2026-09-1112026-10-20T22:51:13.6415439Z
2026-09-10 – 2026-09-1012026-10-20T22:51:13.6415439Z
2026-09-09 – 2026-09-0912026-10-20T22:51:13.6415439Z
2026-09-07 – 2026-09-0712026-10-20T22:51:13.6415439Z
2026-09-06 – 2026-09-0642026-10-20T22:51:13.6415439Z
2026-09-04 – 2026-09-0412026-10-20T22:51:13.6415439Z
2026-09-03 – 2026-09-0312026-10-20T22:51:13.6415439Z
2026-08-31 – 2026-08-3112026-10-20T22:51:13.6415439Z
2026-08-25 – 2026-08-2512026-10-20T22:51:13.6415439Z
2026-08-24 – 2026-08-2432026-10-20T22:51:13.6415439Z
2026-08-23 – 2026-08-2312026-10-20T22:51:13.6415439Z
2026-08-22 – 2026-08-2212026-10-20T22:51:13.6415439Z
2026-08-20 – 2026-08-2012026-10-20T22:51:13.6415439Z
2026-08-19 – 2026-08-1922026-10-20T22:51:13.6415439Z
2026-08-18 – 2026-08-18462026-10-20T22:51:13.6415439Z
2026-08-17 – 2026-08-1742026-10-20T22:51:13.6415439Z
2026-08-14 – 2026-08-1452026-10-20T22:51:13.6415439Z
2026-08-09 – 2026-08-0982026-10-20T22:51:13.6415439Z
2026-08-06 – 2026-08-0622026-10-20T22:51:13.6415439Z
2026-08-05 – 2026-08-0532026-10-20T22:51:13.6415439Z
2026-08-04 – 2026-08-0432026-10-20T22:51:13.6415439Z
2026-08-03 – 2026-08-0362026-10-20T22:51:13.6415439Z
2026-08-02 – 2026-08-0212026-10-20T22:51:13.6415439Z
2026-08-01 – 2026-08-0122026-10-20T22:51:13.6415439Z
2026-07-29 – 2026-07-29142026-10-20T22:51:13.6415439Z
2026-07-28 – 2026-07-2822026-10-20T22:51:13.6415439Z
2026-07-23 – 2026-07-2322026-10-20T22:51:13.6415439Z
2026-07-22 – 2026-07-2212026-10-20T22:51:13.6415439Z

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.021 Mar 20220

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 17:32 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:262609669d302b102d1c1d69e4ddad0044b8bc3805c9ab065bd703cdbb59f7d5