WordEmbeddings SDK
Python sdk to interface with the Word Embeddings API
Example Usage
# import the library
from word_embeddings_sdk import WordEmbeddingsSession
# instantiate a session with your credentials
session = WordEmbeddingsSession(customer_id="...", api_key="...")
# list all your models, should be empty at this point
session.get_models()
# create a new model
model_info = session.create_model(model_name="testing model")
# now when you list your models you will see the one you just created
session.get_models()
# get model info and store it for later use
model_info = session.get_models()['models'][0]
# kick off your first finetuning job, in this example we are finetuning an embeddings model geared towards foods
finetune_info = session.finetune(
model_id=model_info.get("id"),
datasets=[{
"loss": "TripletLoss",
"loss_params": {
"distance": "cosine",
"margin": 0.5
},
"examples": [
{"texts": ["Cheeseburger", "Hamburger", "Pizza"]},
{"texts": ["Sushi", "Maki Roll", "Ice Cream"]},
{"texts": ["Pancakes", "Waffles", "Salad"]},
{"texts": ["Steak", "Ribeye", "Hot Dog"]},
{"texts": ["Chicken Wings", "Buffalo Wings", "French Fries"]},
{"texts": ["Tacos", "Burritos", "Nachos"]},
{"texts": ["Spaghetti", "Lasagna", "Garlic Bread"]},
{"texts": ["Sashimi", "Nigiri", "Tempura"]},
{"texts": ["Donuts", "Cupcakes", "Muffins"]},
{"texts": ["Pho", "Ramen", "Spring Rolls"]},
{"texts": ["Fish and Chips", "Clam Chowder", "Onion Rings"]},
{"texts": ["Fried Chicken", "Chicken Nuggets", "Mashed Potatoes"]},
{"texts": ["Sushi Rolls", "California Roll", "Edamame"]},
{"texts": ["Pasta Carbonara", "Fettuccine Alfredo", "Caesar Salad"]},
{"texts": ["Gyoza", "Dumplings", "Fried Rice"]},
{"texts": ["Cheesecake", "Brownies", "Creme Brulee"]},
{"texts": ["Pad Thai", "Tom Yum Soup", "Thai Curry"]},
{"texts": ["Fish Tacos", "Shrimp Tacos", "Guacamole"]},
{"texts": ["Chicken Parmesan", "Meatball Subs", "Garlic Knots"]},
{"texts": ["Burger and Fries", "Fish Sandwiches", "Onion Rings"]},
{"texts": ["Tiramisu", "Cannoli", "Gelato"]},
{"texts": ["Chicken Caesar Wrap", "Greek Salad", "Hummus"]},
{"texts": ["Beef Stir Fry", "Sweet and Sour Chicken", "Egg Rolls"]},
{"texts": ["Peking Duck", "Mongolian Beef", "Fried Rice"]},
{"texts": ["Shrimp Scampi", "Lobster Bisque", "Crab Cakes"]},
{"texts": ["Chicken Tikka Masala", "Naan Bread", "Samosas"]},
{"texts": ["potato salad", "mashed potatoes", "sushi rolls"]},
{"texts": ["cheeseburger", "hamburger", "ice cream"]},
{"texts": ["steak", "ribeye steak", "salmon"]},
{"texts": ["fried chicken", "grilled chicken", "lobster"]},
{"texts": ["cheese", "mozzarella cheese", "chocolate"]},
{"texts": ["sushi", "sashimi", "tempura"]},
{"texts": ["fried rice", "steamed rice", "fried noodles"]}
]
}]
)
# check on the finetuning job status
session.monitor_finetuning(finetune_info.get("finetune_id"))
# get all model versions
model_versions = session.get_model_versions()
# model is done training, lets get some embeddings
embeddings = session.inference(model_id=model_info.get("id"), model_version_id=finetune_info.get("model_version_id"),
input_texts=["oatmeal cookie", "bagel", "fried chicken"])
# if you want to keep the resource that is hosting your model hot, you can use this function
session.keep_alive(model_id=model_info.get("id"), model_version_id=finetune_info.get("model_version_id"))
# your inferences will now have a shorter delay between the call and response since you don't have to wait for the underlying resources to spin up
embeddings = session.inference(model_id=model_info.get("id"), model_version_id=finetune_info.get("model_version_id"),
input_texts=["shrimp poboy", "candy cane"])
# and then when you are finished running your inferences make sure to tear down your resources
if input("tear down stack? [Y/n] ") == "Y":
session.tear_down(model_id=model_info.get("id"), model_version_id=finetune_info.get("model_version_id"))
# if you want to delete a model version
if input("delete model version? [Y/n] ") == "Y":
session.delete_model_version(model_id=model_info.get("id"), model_version_id=finetune_info.get("model_version_id"))
# and if you want to delete a model
if input("delete model? [Y/n] ") == "Y":
session.delete_model(model_id=model_info.get("id"))
Metadata
Release files for word-embeddings-sdk 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| word_embeddings_sdk-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for word_embeddings_sdk-0.1.5-py3-none-any.whl |
Release files / word_embeddings_sdk-0.1.5-py3-none-any.whl
| Download URL | word_embeddings_sdk-0.1.5-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
571f926d91a8918dae49b06419740d819f76393d8057ec279648638acbd840c0
|
|
BLAKE2b-256 checksum How to use checksums |
4ed27896da0b2f9b99706684ed46a330501193f5aa703e86b6e54fe874f59d55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for word-embeddings-sdk 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.