Skip to main content
The serva Python package is the official client for the Serva Encoder. You install it once, create a single Serva client, and every capability hangs off that one object: encoding files to .serva, decoding them back, pushing and pulling encoded datasets on the Hugging Face Hub, and loading .serva files straight into PyTorch.
The SDK wraps the REST API and handles the multi step streaming flow for you. For most cases it is the smoothest way to work with .serva files.

Install

PyTorch ships with the package, so ServaDataset works out of the box with nothing extra to install.

The Serva client

Generate a Service API key from the dashboard (Settings → API keys), then pass it to the client or set SERVA_API_KEY in your environment.
The client accepts a few optional settings:

Encode and decode

Encoding turns a file into the portable .serva format. Decoding turns it back. Both are a single call that runs the initiate, stream, and download steps for you.
By default the output lands next to the source with a .serva suffix. Pass output= to choose the path. Rows of numbers encode the same way. They are staged as a float32 .npy and encoded as a file. An array has no filename to borrow, so pass output= to name the result:
Encoding takes no password. decode still accepts one, for a .serva issued while encoding still locked files:
The returned EncodeResult carries the details of the run:

Datasets and training

  • Hugging Face. Push encoded datasets to the Hub and pull them back, with a dataset card written for you.
  • PyTorch. Load a folder of .serva files into a training loop with ServaDataset.
A .serva does not carry the original filename, so decoding cannot restore it. Pass output= to name the decoded file; without it you get the .serva name with a .out suffix.