When a filter cloth 🏳️ is needed rather than a simple RAG 🏴☠
Deployment, Stats, & License
What is it?
Muzlin merges classical ML with advanced generative AI to efficiently filter text in the context of NLP and LLMs. It answers key questions in semantic-based workflows, such as:
Does a RAG/GraphRAG have the right context to answer a question?
Is the topk retrieved context too dense/sparse?
Does the generated response hallucinate or deviate from the provided context?
Should new extracted text be added to an existing RAG?
Can we detect inliers and outliers in collections of text embeddings (e.g. context, user question and answers, synthetic generated data, etc…)?
Note: While production-ready, Muzlin is still evolving and subject to significant changes!
Quickstart
Install Muzlin using pip:
pip install muzlinCreate text embeddings with a pre-trained model:
import numpy as np from muzlin.encoders import HuggingFaceEncoder # Ensure torch and transformers are installed encoder = HuggingFaceEncoder() vectors = encoder(texts) # texts is a list of strings vectors = np.array(vectors) np.save('vectors', vectors)Build an anomaly detection model for filtering:
from muzlin.anomaly import OutlierDetector from pyod.models.pca import PCA vectors = np.load('vectors.npy') # Load pre-saved vectors od = PCA(contamination=0.02) clf = OutlierDetector(mlflow=False, detector=od) # Saves joblib moddel clf.fit(vectors)Filter new text using the trained model:
from muzlin.anomaly import OutlierDetector from muzlin.encoders import HuggingFaceEncoder import numpy as np clf = OutlierDetector(model='outlier_detector.pkl') # Load the model encoder = HuggingFaceEncoder() vector = encoder(['Who was the first man to walk on the moon?']) vector = np.array(vector).reshape(1, -1) label = clf.predict(vector)
Integrations
Muzlin integrates with a wide array of libraries for anomaly detection, vector encoding, and graph-based setups.
Anomaly Detection |
Encoders |
Vector Index |
|---|---|---|
|
|
|
Simple Schematic Implementation
Resources
Example Notebooks
Notebook |
Description |
|---|---|
Basic semantic vector-based outlier detection |
|
Selecting optimal thresholds using various methods |
|
Cluster-based filtering for question answering |
|
Using graph-based anomaly detection for semantic graphs like GraphRAG |
What Else?
Looking for more? Check out other useful libraries like Semantic Router, CRAG, and Scikit-LLM
Contributing
Muzlin is still evolving! At the moment their are major changes being done and the structure of Muzlin is still being refined. For now, please leave a bug report and potential new code for any fixes or improvements. You will be added as a co-author if it is implemented.
Once this phase has been completed then ->
Anyone is welcome to contribute to Muzlin:
Please share your ideas and ask questions by opening an issue.
To contribute, first check the Issue list for the “help wanted” tag and comment on the one that you are interested in. The issue will then be assigned to you.
If the bug, feature, or documentation change is novel (not in the Issue list), you can either log a new issue or create a pull request for the new changes.
To start, fork the dev branch and add your improvement/modification/fix.
To make sure the code has the same style and standard, please refer to detector.py for example.
Create a pull request to the dev branch and follow the pull request template PR template
Please make sure that all code changes are accompanied with proper new/updated test functions. Automatic tests will be triggered. Before the pull request can be merged, make sure that all the tests pass.
Metadata
Release files for muzlin 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| muzlin-0.0.6.tar.gz | 32.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| muzlin-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 71.3 kB
Release files / muzlin-0.0.6.tar.gz
| Download URL | muzlin-0.0.6.tar.gz |
|---|---|
| Size | 32.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f53950eeedd3fa42ffd242d415756abff4ca58dc344a2f8d451540803d282a33
|
|
BLAKE2b-256 checksum How to use checksums |
376f2a184c8e9073ccbc9bda1048e584034dc6fd8aef518f1f822f6354d2faff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Release files / muzlin-0.0.6-py3-none-any.whl
| Download URL | muzlin-0.0.6-py3-none-any.whl |
|---|---|
| Size | 38.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47f8f33e5fa1d4fc0b3f338ca9d23aaada96419ab5218bb672d858adec50bcd2
|
|
BLAKE2b-256 checksum How to use checksums |
2574be5e48745ccd82d017604f9d504a18f9a45fea5b5c9a8682a9abd0d7a1d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|