Git Product home page Git Product logo

caikit-nlp-client's Introduction

caikit-nlp client

A client library for caikit-nlp

Contributing

Set up pre-commit for linting/style/misc fixes:

pip install pre-commit
pre-commit install

This project uses nox to manage test automation:

pip install nox
nox --list  # list available sessions
nox --python 3.10 -s tests # run tests session for a specific python version

caikit-nlp-client's People

Contributors

dtrifiro avatar vaibhavjainwiz avatar z103cb avatar dependabot[bot] avatar

Watchers

 avatar  avatar

caikit-nlp-client's Issues

get a streaming model working

In conftest.py we currently can choose between a few models in the tiny_models directory:

def model_name():
"""name of the model utilized by the tests. Has to be in `tests/tiny_models`"""
# Note that this can be overridden in tests via indirect parametrization
available_models = [
"BertForSequenceClassification-caikit",
"BloomForCausalLM-caikit",
"T5ForConditionalGeneration-caikit",
]
return available_models[0]

From quick testing, it doesn't seem like any of these work with the streaming tests, so those were marked with xfail

@pytest.mark.xfail(
reason="BertForSequenceClassification-caikit does not support streaming"
)
def test_generate_text_stream(model_name, connected_client):
results = connected_client.generate_text_stream(
model_name, "What is the meaning of life?"
)
assert results
@pytest.mark.xfail(
reason="BertForSequenceClassification-caikit does not support streaming"
)
def test_generate_text_stream_with_optional_args(model_name, connected_client):
results = connected_client.generate_text_stream(
model_name,
"What is the meaning of life?",
preserve_input_text=False,
max_new_tokens=20,
min_new_tokens=4,
)
assert results

We should find out whether it's related to caikit-np or if it is related to the way these models are created.

For reference:

tests: validate text generation results

We currently are only asserting that the generated text is not empty. We should be able to consistently reproduce the same outputs and validate those e.g.

def test_generate_text(model_name, connected_client):
generated_text = connected_client.generate_text(
model_name, "What does foobar mean?"
)
assert generated_text

One way of consistently returning the same results could be by settings the rng seeds in the requests

Set up test fixture using `caikit_nlp`

We should be able to set up a pytest fixture that sets up a caikit_nlp server instance and use that to test both grpc and http behaviour.

For example, to start a http and grpc server it is sufficient to run:

RUNTIME_LIBRARY=caikit_nlp python -m caikit.runtime

speed up tests/environment setup by installing torch-cpu

Installing caikit-nlp also requires torch which pulls down a lot of extra cuda dependencies which occupy a lot of space (and CI time). A full caikit-nlp install requires ~5GB of space. Installing the cpu version of torch, requires ~800MB

Specific versions can be installed by providing the index urls:

e.g.:

python -m venv .venv
source .venv/bin/activate
pip install --index-url=https://download.pytorch.org/whl/cpu torch
du -sh .venv # 813M

will install torch==2.1.0+cpu (not available on PyPi).

It could be worth it to explore whether we can avoid installing the full torch version in our nox sessions to speed up testing

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.