GLiClass zero-shot classifier server for MIMEDefang (Mail::MIMEDefang::ML, gliclass backend)
74
mimedefang-gliclass-server keeps a
GLiClass zero-shot classifier
loaded in memory and answers classification requests from
MIMEDefang's
Mail::MIMEDefang::ML module (gliclass backend). It classifies mail from the
label texts alone, in a single forward pass. You can also serve a model
fine-tuned on your own mail with MIMEDefang's gliclass-train.
latest, vX.Y: built from a MIMEDefang release tag, once one existsdocker run -d --name gliclass -p 127.0.0.1:8688:8688 \
-v mdml-hf:/var/lib/MIMEDefang/ml/huggingface \
mimedefang/gliclass:latest
On the first start the model is downloaded from Hugging Face into the volume.
Check the server with curl http://127.0.0.1:8688/health.
To serve your own fine-tuned model, mount it and point GLICLASS_MODEL at it:
docker run -d --name gliclass -p 127.0.0.1:8688:8688 \
-v /srv/my-gliclass-model:/model:ro -e GLICLASS_MODEL=/model \
mimedefang/gliclass:latest
use Mail::MIMEDefang::ML;
$Mail::MIMEDefang::ML::Config{backend} = 'gliclass';
$Mail::MIMEDefang::ML::Config{gliclass}{server_url} = 'http://127.0.0.1:8688';
| Variable | Default | Meaning |
|---|---|---|
GLICLASS_MODEL | knowledgator/gliclass-modern-base-v2.0 | Hugging Face name or local path (gliclass-modern-large-v2.0 is more accurate but slower) |
GLICLASS_DEVICE | cpu | Device to run on, e.g. cuda:0 (with a -cuda image and --gpus all) |
GLICLASS_MAX_LENGTH | 4096 | Tokens of labels plus message text read (the modern checkpoints take up to 8192) |
GLICLASS_PORT | 8688 | Listening port |
GLICLASS_THREADS | 8 | Requests handled at once (about the multiplexor's maximum number of workers) |
GLICLASS_TORCH_THREADS | 2 | CPU threads per request (keep it at 1-2) |
GLICLASS_MIN_CONFIDENCE | 0.55 | Logging threshold (match $Mail::MIMEDefang::ML::Config{min_confidence}) |
HF_HUB_OFFLINE | unset | 1 stops contacting huggingface.co once the model is cached |
The server has no authentication, and every request carries message
content. Publish the port on 127.0.0.1, or firewall it so that only your
MIMEDefang hosts can reach it. Never expose it to the Internet.
Source: https://github.com/The-McGrail-Foundation/MIMEDefang-Docker
Content type
Image
Digest
sha256:1347220f8…
Size
404.8 MB
Last updated
3 days ago
docker pull mimedefang/gliclass