Sign inSign up

mimedefang/gliclass

By mimedefang

•Updated 3 days ago

GLiClass zero-shot classifier server for MIMEDefang (Mail::MIMEDefang::ML, gliclass backend)

Image
0

74

mimedefang/gliclass repository overview

⁠mimedefang/gliclass

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.

⁠Tags

  • latest, vX.Y: built from a MIMEDefang release tag, once one exists

⁠Run

docker 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

⁠Configure MIMEDefang

use Mail::MIMEDefang::ML;
$Mail::MIMEDefang::ML::Config{backend}              = 'gliclass';
$Mail::MIMEDefang::ML::Config{gliclass}{server_url} = 'http://127.0.0.1:8688';

⁠Environment

VariableDefaultMeaning
GLICLASS_MODELknowledgator/gliclass-modern-base-v2.0Hugging Face name or local path (gliclass-modern-large-v2.0 is more accurate but slower)
GLICLASS_DEVICEcpuDevice to run on, e.g. cuda:0 (with a -cuda image and --gpus all)
GLICLASS_MAX_LENGTH4096Tokens of labels plus message text read (the modern checkpoints take up to 8192)
GLICLASS_PORT8688Listening port
GLICLASS_THREADS8Requests handled at once (about the multiplexor's maximum number of workers)
GLICLASS_TORCH_THREADS2CPU threads per request (keep it at 1-2)
GLICLASS_MIN_CONFIDENCE0.55Logging threshold (match $Mail::MIMEDefang::ML::Config{min_confidence})
HF_HUB_OFFLINEunset1 stops contacting huggingface.co once the model is cached

⁠Security

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⁠

Tag summary

Content type

Image

Digest

sha256:1347220f8…

Size

404.8 MB

Last updated

3 days ago

docker pull mimedefang/gliclass