matrix-spam-ml

git clone git://archive.git.mtrnord.blog/MTRNord/matrix-spam-ml.git
Log | Files | Refs | Submodules | README | LICENSE

commit 422c7c613c3aa1349e755f42970d552c10b66a04
parent 805ee41e4368c8bb3043b84d967e885855a14f4a
Author: MTRNord <mtrnord1@gmail.com>
Date:   Tue, 27 Sep 2022 20:38:57 +0200

Add readme and fix image name

Diffstat:
M.github/workflows/build_docker.yaml | 2+-
AREADME.md | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/build_docker.yaml b/.github/workflows/build_docker.yaml @@ -7,7 +7,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + IMAGE_NAME: mtrnord/matrix-spam-ml jobs: docker: diff --git a/README.md b/README.md @@ -0,0 +1,50 @@ +# Matrix-Spam ML + +This project consists of tooling to generate a spam detection model for the Matrix protocol. + +It utilizes Tensorflow and builds the model in python and then provides a Rust server that provides some APIs to interact with the model easily and also extend it. + +The current code base is fast moving. Expect to change rapidly. + +## Usage + +### Training + +To train the model, you need to have a set of labeled data. +This data is at `./input/MatrixData`. It is a TSV file. +Please note that URLs should not be added as well as newlines. +Newlines will be stripped anyway and URLs tend to break the model result. + +To train the model, run `python3 model_v2.py`. This will train the model and save it to `./model/`. +Please make sure you installed tensorflow. + +### Running the server + +To run the server, run `cargo run --release`. This will start the server on port `3000`. + +If you dont see any log try preprending `RUST_LOG=info` to the command. + +## API + +### POST /test + +This endpoint takes a JSON body with the following format: + +```json +{ + "input_data": "This is a message to be classified" +} +``` + +It will return a JSON response with the following format: + +```json5 +{ + "input_data": "This is a message to be classified", + "score": 0.9999999999999999, # Note that this is a float +} +``` + +## Support + +For support you can join [#matrix-spam-ml:midnightthoughts.space](https://matrix.to/#/#matrix-spam-ml:midnightthoughts.space) on Matrix. +\ No newline at end of file