Metadata-Version: 2.1
Name: wafl-llm
Version: 0.1.0
Summary: A hybrid chatbot - LLM side.
Home-page: http://github.com/fractalego/wafl_llm
Author: Alberto Cetoli
Author-email: alberto@fractalego.io
Classifier: License :: OSI Approved :: MIT License
Description-Content-Type: text/markdown
Requires-Dist: vllm (==0.4.2)
Requires-Dist: flash-attn (==2.5.8)
Requires-Dist: transformers (==4.41.0)
Requires-Dist: sentencepiece (==0.1.98)
Requires-Dist: accelerate (==0.28.0)
Requires-Dist: bitsandbytes (==0.41.3)
Requires-Dist: optimum (==1.8.6)
Requires-Dist: onnx (==1.13.0)
Requires-Dist: datasets (==2.8.0)
Requires-Dist: mpi4py (==3.1.4)
Requires-Dist: torchserve (==0.7.1)
Requires-Dist: torch-model-archiver (==0.7.1)
Requires-Dist: torch-workflow-archiver (==0.2.6)
Requires-Dist: nvgpu (==0.9.0)
Requires-Dist: fairseq (==0.12.2)
Requires-Dist: g2p-en (==2.1.0)
Requires-Dist: sentence-transformers (==2.7.0)
Requires-Dist: einops (==0.6.1)

# WAFL-llm

WAFL is built to run as a two-part system.
Both can be installed on the same machine.
This is the LLM side of the [WAFL project](https://github.com/fractalego/wafl).

![The two parts of WAFL](images/two-parts.png)


## LLM side (needs a GPU)

This is a model server for the speech-to-text model, the LLM, the embedding system, and the text-to-speech model.

#### Installation
In order to quickly run the LLM side, you can use the following installation commands:
```bash
pip install wafl-llm
wafl-llm start
```
which will use the default models and start the server on port 8080.

The installation will require MPI and Java installed on the system.
One can install both with the following commands
```bash
sudo apt install libopenmpi-dev
sudo apt install default-jdk
```

#### Configuration
A use-case specific configuration can be set by creating a `config.json` file in the path where `wafl-llm start` is executed.
The file should look like this (the default configuration)
```json
{
  "llm_model": "fractalego/wafl-phi3-mini-4k",
  "speaker_model": "facebook/fastspeech2-en-ljspeech",
  "whisper_model": "fractalego/personal-whisper-distilled-model",
  "sentence_embedder_models": "TaylorAI/gte-tiny",
  "device": "cuda",
  "quantization": false
}
```

The models are downloaded from the HugggingFace repository. Any other compatible model should work.
The `device` can be set to `cuda` or `cpu`. 
The `quantization` can be set to `true` or `false` and uses the vLLM `fp8` option. This will only work if your GPU supports it.
Each model can be set to `null` to deactivate it (and save memory). 
This is useful if you only want to use the LLM model, for example.


#### Docker
Run the following

```bash
docker/build.sh
docker run -p8080:8080 --env NVIDIA_DISABLE_REQUIRE=1 --gpus all wafl-llm
```

