When you replace a library, you also take over everything it did
DPOLens is an open-source MCP server that gives AI assistants the text of privacy law. Its search runs on the CPU, so it needs no GPU. The usual way to run an embedding model in Python is sentence-transformers . DPOLens doesn't use it: with PyTorch's CPU build it installs about 1 GB, against about 200 MB for ONNX Runtime , the tokenizers library and NumPy. So DPOLens calls the model through ONNX…
The DPOLens open-source MCP server provides AI assistants with the text of privacy laws. It runs on the CPU, requiring no GPU, and uses ONNX Runtime for embedding models, which installs about 1 GB compared to 200 MB for other libraries. When a library instance starts, it embeds every clause of the law, consuming significant resources.
A loading test showed this to be the heaviest task done by DPOLens. After implementing two fixes, the process became 5.1 times faster with 65% less memory, and the vectors remained consistent. The setup uses multilingual-e5-small embedding model, which embeds GDPR, the UAE's data protection law, and a sample company policy containing 1,350 clauses of various lengths.
Postgres with pgvector stores these vectors, and this happens once before the instance answers any queries. The library sorted clauses by length before batching them, leading to inefficient memory usage. The optimized code embedded clauses in the order they were stored, resulting in 114,000 tokens instead of 304,000. The memory budget was also capped, preventing excessive memory usage.
With a 2.5 CPU limit, the optimized setup took significantly less time and memory compared to the original version. The changes did not affect the vector results or search performance, as the vectors remained bit-identical or differed by a negligible amount.
Rewritten by urgent.news; may contain errors — check the original.