Text Generator is a system for;
- Balancing multiple models on the disk, RAM and GPU
- Serving AI APIs via swapping in AI Networks.
- Using data enrichment (OCR, crawling, image analysis to make prompt engineering easier)
- Generating speech and text.
- Understanding text and speech (speech to text with whisper).
Text generator can be used via API or self hosted.
Text generator balances multiple 7B models to generate text.
Text generator also enriches web links with text summaries.
If a prompt contains links to images they are converted to text using captioning and if necessary OCR.
Please support us!
You can support us by purchasing NETW Tokens which will be a supported currency within the app.
Also checkout AIArt-Generator.art and Netwrck.com
Coming soon:
- Add support for other models and modalities like stable diffusion (done in https://github.com/netwrck/stable-diffusion-server)
- Train a classifier to first detect which model is best to use for a given piece of text.
- Add support/passthroughs to other models like ChatGPT and Palm.
Text Generator is API compatible with OpenAI (but not the ChatGPT API yet)
There's also more control of text generation via the Text-generator API, this includes;
- Early stopping based on probability (fast autocomplete the next likely parts of text)
- max_sentences (generate only a set number of sentences at most)
Text generator also has routes for speech to text and speech generation.
See https://text-generator.io/docs
cd
mkdir code
cd code
git clone 20-questions
Env vars:
GOOGLE_APPLICATION_CREDENTIALS=$HOME/code/20-questions/secrets/google-credentials.json;
PYTHONPATH=$HOME/code/20-questions:$HOME/code/20-questions/OFA
sudo apt install -y ffmpeg
sudo apt install -y tesseract-ocr
sudo apt install -y python3.9-distutils
pip install -r requirements.txt
pip install -r questions/inference_server/model-requirements.txt
pip install -r dev-requirements.txt
Using cuda is important to speed up inference.
python -m nltk.downloader punkt
Set up some environment variables in this file (fake ones are okay for local dev)
mv sellerinfo_faked.py sellerinfo.py
Download models from huggingface.
huggingface-cli download HuggingFaceTB/SmolLM-1.7B --local-dir models/SmolLM-1.7B
Text Generator models are not open source yet.
please support us to get the models
Download models and place them in the models folder.
there should be three models placed:
models/tg a general model accessible with model=multilingual models/tgz an instruct model accessible with model=instruct models/tgc a chat model accessible with model=chat
model=best is configured to figure out which model to use based on the prompt being scored based on perplexity of each model.
This needs tuning for the avg and std deviation of the perplexity as each model has different ideas about how confidenti it is. Overtrained models are more confident about all text being in the dataset (tend to generate text verbatim from the dataset).
models can be pointed to using environment variables, e.g. using models from hugginface instead for testing
WEIGHTS_PATH_TGZ=bigscience/bloomz
WEIGHTS_PATH_TGC=decapoda-research/llama-7b-hf
WEIGHTS_PATH=bigscience/bloom
The embedding model is a smaller model.
cd models
git clone https://huggingface.co/distilbert-base-uncased
whisper and STT models will be loaded on demand and placed in the huggingface cache.
run the UI
uvicorn main:app --reload --workers=1
# or
uvicorn -k uvicorn.workers.UvicornWorker -b :3004 main:app --timeout 60000 -w 1
Alternatively:
SERVER_SOFTWARE=Development/dev gunicorn -k uvicorn.workers.UvicornWorker -b :3004 main:app --timeout 60000 -w 1
Text Generator can be ran locally without docker.
install nvidia-docker2
sudo apt-get install nvidia-docker2
Text Generator is built with buildx
DOCKER_BUILDKIT=1 docker buildx build . -t questions
sudo docker run -v $(pwd)/models:/models -p 9000:8080 questions
The frontend API playground is available at https://text-generator.io and written for Google App Engine.
Run locally:
gunicorn -k uvicorn.workers.UvicornWorker -b :3030 main:app
PYTHONPATH=$(pwd):$PYTHONPATH:$(pwd)/OFA gunicorn -k uvicorn.workers.UvicornWorker -b :3030 questions.inference_server.inference_server:app
PYTHONPATH=$(pwd):$(pwd)/OFA GOOGLE_APPLICATION_CREDENTIALS=secrets/google-credentials.json gunicorn -k uvicorn.workers.UvicornWorker -b :9080 questions.inference_server.inference_server:app --timeout 180000 --workers 1
PYTHONPATH=$HOME/code/20-questions:$HOME/code/20-questions/OFA:$HOME/code/20-questions/OFA/fairseq GOOGLE_APPLICATION_CREDENTIALS=secrets/google-credentials.json gunicorn -k uvicorn.workers.UvicornWorker -b :9080 questions.inference_server.inference_server:app --timeout 180000 --workers 1
Then go to localhost:9080/docs to use the API
Just the whisper speech to text part. This isn't required as the inference server automatically balances these requests
PYTHONPATH=$(pwd):$(pwd)/OFA GOOGLE_APPLICATION_CREDENTIALS=secrets/google-credentials.json gunicorn -k uvicorn.workers.UvicornWorker -b :9080 audio_server.audio_server:app --timeout 180000 --workers 1
GOOGLE_APPLICATION_CREDENTIALS=secrets/google-credentials.json;PYTHONPATH=$HOME/code/20-questions:$HOME/code/20-questions/OFA pytest
Docker Container .tar Download
curl https://static.text-generator.io/static/resources/download_container.sh | bash
After downloading the container with either method, proceed to follow the self host instructions available for Kubernetes, Docker
See https://text-generator.io/self-hosting
Ensure tested docker locally/built one
You can setup kubernetes locally with kind if doing local kubernetes development.
k delete -f kuber/prod/deployment-gpu.yaml
k apply -f kuber/prod/deployment-gpu.yaml
k get pods
Run a shell in docker container
docker run -i -t -u root -v $(pwd)/models:/models --entrypoint=/bin/bash questions -c /bin/bash;
clone from huggingface
cd models
git clone https://huggingface.co/distilbert-base-uncased
PYTHONPATH=$(pwd):$(pwd)/OFA python questions/disbot/disbot.py
use uv pip to compile the dependencies
uv pip compile questions/inference_server/model-requirements.in --universal -o questions/inference_server/model-requirements.txt
uv pip sync questions/inference_server/model-requirements.txt
stretch your body every 30 mins with the say command...
watch -n 1800 'echo "stretch your body" | espeak -s 120'