GithubHelp home page GithubHelp logo

thomassuedbroecker / caikit-custom-model-protofiles Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 155 KB

This project shows how to add a custom model to caikit and use the proto-files with GRCURL.

License: Apache License 2.0

Dockerfile 13.42% Python 86.58%
grpc grpcurl python caikit protofiles

caikit-custom-model-protofiles's Introduction

Caikit custom model profiles


----- UNDER CONSTRUCTION -----

1. Objective

The objective of the project is to add a custom model to caikit==v0.4.1 and use grpcurl to invoke a text generation command.

The project contains a client/server example for using GRPC.

2. Environment setup

  • Clone the project
git clone https://github.com/thomassuedbroecker/caikit-custom-model-protofiles.git
  • Create virtual environment
cd code

python3.10 -m venv caikit-env-3.10
source ./caikit-env-3.10/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pip install grpcio
python3 -m pip install grpcio-tools
python3 -m pip install grpcio-health-checking
python3 -m pip install grpcio-reflection
python3 -m pip install prometheus_client
python3 -m pip install py_grpc_prometheus
python3 -m pip install caikit.runtime.service_factory
#python3 -m caikit.runtime.dump_services protos

3. Start the server/client example

  • Simplified dependences of the client/server architecture of the example

  • Start the server in the first terminal
source ./caikit-env-3.10/bin/activate
python start_runtime.py

Output:

...
2023-08-06T11:28:10.609698 [2PCVR:DBUG] Message name: TrainingStatusResponse
2023-08-06T11:28:10.609997 [2PCVR:DBUG] Creating FileDescriptorProto
2023-08-06T11:28:10.610045 [2PCVR:DBUG] Adding Descriptors to DescriptorPool
{"channel": "SERVR-GRPC", "exception": null, "level": "info", "message": "Serving prometheus metrics on port 8086", "num_indent": 0, "thread_id": 140704560412224, "timestamp": "2023-08-06T11:28:10.623832"}
...
  • Start the client in the second terminal
source ./caikit-env-3.10/bin/activate
python client.py

3. Create protos

Execute the following command in the third terminal. The command will create a folder with the proto files on your local computer.

source ./caikit-env-3.10/bin/activate
export CONFIG_FILES=text_generation/config.yml
python3 -m caikit.runtime.dump_services protos

Use grpcurl

  • List the services
grpcurl -import-path ./protos -proto textgenerationservice.proto list

Example output:

caikit.runtime.TextGeneration.TextGenerationService
  • List the services with the grpc-server
grpcurl -import-path ./protos -proto textgenerationservice.proto -plaintext localhost:8085 list

Example output:

caikit.runtime.TextGeneration.TextGenerationService
  • Describe the service
grpcurl -import-path ./protos -proto textgenerationservice.proto -plaintext localhost:8085 describe caikit.runtime.TextGeneration.TextGenerationService

Example output:

service TextGenerationService {
  rpc HfModulePredict ( .caikit.runtime.TextGeneration.HfModuleRequest ) returns ( .text_generation.data_model.TextOutput );
}
grpcurl -import-path ./protos -proto hfmodulerequest.proto -plaintext localhost:8085 describe caikit.runtime.TextGeneration.HfModuleRequest

Example output:

message HfModuleRequest {
  //-- fields --
  .text_generation.data_model.TextInput text_input = 1;
}
  • Invoke a method of the service
MM_MODEL_ID=text_generation
grpcurl -d '{"text_input":{"text":"This is"}}' -H "mm-model-id:$MM_MODEL_ID" -import-path ./protos -proto textgenerationservice.proto -plaintext localhost:8085 caikit.runtime.TextGeneration.TextGenerationService/HfModulePredict

Container

  • Build a container image and execute a container image
docker build -f Dockerfile -t caikit-server-proto-export:v1 .
docker run -it caikit-server-proto-export:v1
  • Verify the created protos

Navigate inside the container to the protos folder.

cd protos
ls
  • Example output
hfmodulerequest.proto                textoutput.proto
modelpointer.proto                   traininginforequest.proto
producerid.proto                     traininginforesponse.proto
producerpriority.proto               trainingjob.proto
textgenerationservice.proto          trainingmanagement.proto
textgenerationtrainingservice.proto  trainingstatus.proto
textinput.proto

caikit-custom-model-protofiles's People

Contributors

thomassuedbroecker avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.