dream
Transformers LLM Service
Description
Service for LLMs connection from HuggingFace transformers.
Parameters
Parameter PRETRAINED_MODEL_NAME_OR_PATH
defines which model to use. Supported models are:
- "EleutherAI/gpt-j-6B" (not available via proxy
- "OpenAssistant/pythia-12b-sft-v8-7k-steps" (available via Proxy)
- "togethercomputer/GPT-JT-6B-v1" (available via Proxy)
- "lmsys/vicuna-13b-v1.3" (not available via proxy)
- Any other, if one creates a new container with the considered model name and raise it locally.
Dependencies
- When using via Proxy, depends on Proxy stability.
How to Add a New Large Language Model from Transformers into DeepPavlov Dream?
If you want to integrate a new LLM from Transformers into DeepPavlov Dream Platform, follow the instruction below. You may use the pull-request with ruGPT-3.5 integration as an example of a new LLM integration to Universal Distributions.
- Depending on the language of the LLM of interest, select either
universal_prompted_assistant
oruniversal_ru_prompted_assistant
as a distribution to add an LLM to. Let's call the selected one Universal Assistant. - In
dream/components.tsv
reserve a port for a new component which will be named astransformers-lm-modelname
. - In
docker-compose.override.yml
indream/assistant_dists/{Universal Assistant}
create a new container, name it liketransformers-lm-modelname
. In particular:- assign
PRETRAINED_MODEL_NAME_OR_PATH
to a name of the model from transformers to be integrated; - assign
SERVICE_PORT
(and its value in a command also) to a selected on the previos step; - assign
HALF_PRECISION
value to1
if you want to use a model in a half precision mode (to save computational resources); - assign
SERVICE_NAME
to atransformers_lm_modelname
(for the uniformity); - include a new component to
WAIT_HOSTS
of the agent container; - do not assign
CUDA_VISIBLE_DEVICES
to another value in this file -- you may utilize anotheryml
files for it; - You will get something like this:
transformers-lm-{modelname}:env_file: [ .env ]build:args:SERVICE_PORT: {selectedport}SERVICE_NAME: transformers_lm_{modelname}PRETRAINED_MODEL_NAME_OR_PATH: {modelnamefromtransfofmers}HALF_PRECISION: 1context: .dockerfile: ./services/transformers_lm/Dockerfilecommand: flask run -h 0.0.0.0 -p {selectedport}environment:- CUDA_VISIBLE_DEVICES=0- FLASK_APP=serverdeploy:resources:limits:memory: {max RAM in G}Greservations:memory: {max RAM in G}G - assign
- In
dev.yml
indream/assistant_dists/{Universal Assistant}
assign volumes and ports mapping for your new model:- for a container
transformers-lm-modelname
map the volumes:
volumes:- "./services/transformers_lm:/src"- "./common:/src/common"- "~/.deeppavlov/cache:/root/.cache"- for a container
transformers-lm-modelname
map the ports:
ports:- {selectedport}:{selectedport} - for a container
- Add a new container to
cpu.yml
, if necessary. - If you are a DeepPavlov employee, have access to DeepPavlov's computational resources, and want to create a proxy
for a new model, follow the steps:
- run a new container on the same server where all other proxied containers are built.
- add a new container to a
proxy.yml
transformers-lm-{modelname}:command: ["nginx", "-g", "daemon off;"]build:context: dp/proxy/dockerfile: Dockerfileenvironment:- PROXY_PASS=proxy.deeppavlov.ai:{selectedport}- PORT={selectedport} - Using Universal Assistant, one may assign generation parameters in the request body. But default parameters for a new
model must be provided anyway. Create and fill a configuration file with parameters in
folder
dream/common/generative_configs/
. - Add a new model to be considered in the universal skill in
dream/skills/dff_universal_prompted_skill/scenario/response.py
in a dictionaryENVVARS_TO_SEND
with a mapping to considered environmental variables to send to a LLM (for example, for sending API keys) as follows:
"http://transformers-lm-{modelname}:{selectedport}/respond": [],
- Add a new model to a
dream/MODELS.md
file for storing all the important info. - Now create a component cards required for
dreamtools
work:- Create a file in
dream/components/
folder, fill it in the same way as forcomponents/vdfjkhg934nflgeafgv.yml
. - Create a folder
dream/services/transformers_lm/service_configs/transformers-lm-{modelname}
, create two filesenvironment.yml
andservice.yml
in the same way as forservices/transformers_lm/service_configs/transformers-lm-rugpt35/service.yml
andservices/transformers_lm/service_configs/transformers-lm-rugpt35/environment.yml
.
- Create a file in