Skip to main content

finetune latest open source llms in less than 10 line of code.

Project description

🌩️ Stream AI easily

train, finetune any open source model and deploy as api in less than 10 lines of python.

models:

  • llama-7b, 13b, 70b
  • mistral-7b
  • mixtral-8x7b
  • gemma-7b

run base model without creating api.

from streamai.app import endpointIO
from streamai.llms import AutoMistral
import json
modelinstance = AutoMistral(base_model="mistralai/Mistral-7B-v0.1")
modelinstance.loadmodel()
response = modelinstance.inferenceIO(prompt="what is python?")
print(response)

deploy your custom model with api.

from streamai.app import endpointIO
from streamai.llms import Autoalpacalora
def custom_model_IO(input:str):
    output = customodelinference(input) #depend on your inference function, just need to return string output from it.
    return f"this is output of {output}"

custom_model = endpointIO(custom_model_IO)
custom_model.run() #this will create a server api endpoint for your model, at http://0.0.0.0:8000 see terminal logs for more info about endpoints

deploy from available base model as api.

from streamai.app import endpointIO
from streamai.llms import Autoalpacalora
def testiofunc(inpt:str):
    output = modelinstance.inferenceIO(prompt=input)
modelinstance = Autoalpacalora("decapoda-research/llama-7b-hf")
modelinstance.loadmodel() #required for deployment of model as api, not required during finetuning.
alpaca_model = endpointIO(modelinstance.inferenceIO)
alpaca_model.run()

finetune any available model available in llms and then deploy it.

from streamai.app import endpointIO
from streamai.llms import AutoMistral
import json
modelinstance = AutoMistral(base_model="mistralai/Mistral-7B-v0.1")

# let's see what is the structure of dataset that is required for training
print(json.dumps(modelinstance.info['dataset'], indent = 1))

#let's provide the dataset url
modelinstance.train(dataset_url="https://firebasestorage.googleapis.com/v0/b/pdf-analysis-saas.appspot.com/o/Other%2Fdataset.json", model_name="mistral7btest")

serve your finetuned model as api.

from streamai.app import endpointIO
from streamai.llms import AutoMistral
import json
modelinstance = AutoMistral(base_model="mistralai/Mistral-7B-v0.1")

#load fine tuned model using directory in which finetuned model is stored.
modelinstance.loadmodel(finetuned_weights_dir="mistral7btest")
#provide lora weights if model is finetuned, it is directory that will be logged after traininig is done.

# now run the model as api endpoint.
finetunedmodel = endpointIO(modelinstance.inferenceIO)
finetunedmodel.run()

todo:

  • add input for num_train_epochs for finetuning.

  • add input for train test split.

  • add input for max_seq_length.

  • add both generation and training test cases for mistral.

  • add nginx reverse proxy.

  • add tests cases.

  • add endpoint for info about deployed model

  • sometime need to replace cudua lib in bitsandbytes with cuda lib 117 version(bnb bug).

cp venv/lib/python3.8/site-packages/bitsandbytes/libbitsandbytes_cuda117.so venv/lib/python3.8/site-packages/bitsandbytes/libbitsandbytes_cpu.so

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamai-0.1.2.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamai-0.1.2-py3-none-any.whl (34.5 kB view details)

Uploaded Python 3

File details

Details for the file streamai-0.1.2.tar.gz.

File metadata

  • Download URL: streamai-0.1.2.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for streamai-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bccd05b00d0e9aad9497be6497a686b6e544d4aaf76810f26d7762794c616a36
MD5 6710f85ba424e9ed790ef4da324da197
BLAKE2b-256 b1edabfc73e56db54d9d545f269ee0e4ff89b92248943e55a78e9cf98bff3a28

See more details on using hashes here.

File details

Details for the file streamai-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: streamai-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 34.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for streamai-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e329f24e1c8147ed4fbddd403faef7ce559f9faa5d716698ee215f86231d3fd9
MD5 32d90f426e9ebdd206e48b91156c35ba
BLAKE2b-256 994f00eb4007d9b74d8163866a5b7295c8a9b718917f0684655bded3d46c187a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page