Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Latest commit

 

History

History
168 lines (136 loc) · 3.88 KB

quickstart.mdx

File metadata and controls

168 lines (136 loc) · 3.88 KB
Error in user YAML: (<unknown>): did not find expected key while parsing a block mapping at line 1 column 1
---
title: "Quickstart" description: "Start building your machine learning application"
icon: "rocket"
---

Install Wyvern

pip install wyvern-ai
poetry add wyvern-ai

This will also install the wyvern CLI

Create Wyvern Application

Once Wyvern is installed, run this command to initialize your Wyvern project:

wyvern init my-project
cd my-project

Now that the wyvern init has set up your initial repository, you should see the following file structure in the my-project repository:

├── pipelines
│   ├── __init__.py
│   ├── main.py
│   ├── product_ranking
│   │   ├── __init__.py
│   │   ├── models.py
│   │   ├── ranking_pipline.py
│   │   ├── realtime_features.py
│   │   ├── schemas.py
├── feature-store-python
│   ├── features
│   │   ├── feature_store.yaml
│   │   ├── features.py
│   │   ├── main.py
├── .env
└── .gitignore

The generated template code is an ML pipeline example for ranking products.

Run Wyvern Application

Pre-requisite

  1. Redis service

Wyvern uses redis as its index and online feature store. By default, Wyvern connects to the localhost:6379

Your can run this command to install and spin up local redis

wyvern redis

Run the wyvern service

wyvern run

Now your wyvern service runs on http://0.0.0.0:5001 and the default ranking API schema could be found at http://0.0.0.0:5001/redoc#operation/MyRankingPipeline_api_v1_ranking_post.

Test ranking request

Assuming you have 24 products and you would like to rank them. Here's a curl request:

curl --location 'http://0.0.0.0:5001/api/v1/ranking' \
--header 'Content-Type: application/json' \
--data '{
    "request_id": "test_request_id",
    "query": {"query": "candle"},
    "candidates": [
        {"product_id": "p1"},
        {"product_id": "p2"},
        {"product_id": "p3"},
        {"product_id": "p4"},
        {"product_id": "p5"},
        {"product_id": "p6"},
        {"product_id": "p7"},
        {"product_id": "p8"},
        {"product_id": "p9"},
        {"product_id": "p10"},
        {"product_id": "p11"},
        {"product_id": "p12"},
        {"product_id": "p13"},
        {"product_id": "p14"},
        {"product_id": "p15"},
        {"product_id": "p16"},
        {"product_id": "p17"},
        {"product_id": "p18"},
        {"product_id": "p19"},
        {"product_id": "p20"},
        {"product_id": "p21"},
        {"product_id": "p22"},
        {"product_id": "p23"},
        {"product_id": "p24"}
    ],
    "user_page_size": 8,
    "user_page": 0,
    "candidate_page_size": 24,
    "candidate_page": 0
}'

The request sends 24 products to Wyvern. Wyvern ranks these products and returns the 8 products (in descending order) to show on the first page ("user_page": 0).

You should see a response like the following with the products being ordered descendingly by their ranking score.

{
  "ranked_candidates": [
    {
      "candidate_id": "p9",
      "ranked_score": 43.13991415724884
    },
    {
      "candidate_id": "p18",
      "ranked_score": 42.314880208313376
    },
    {
      "candidate_id": "p17",
      "ranked_score": 41.62010469362527
    },
    {
      "candidate_id": "p3",
      "ranked_score": 40.48391586690772
    },
    {
      "candidate_id": "p19",
      "ranked_score": 39.82504624652922
    },
    {
      "candidate_id": "p24",
      "ranked_score": 39.10042317690844
    },
    {
      "candidate_id": "p11",
      "ranked_score": 38.670359237541945
    },
    {
      "candidate_id": "p21",
      "ranked_score": 37.27313489135458
    }
  ]
}

Congratulations on making your first Wyvern request!

More

Head over to the Wyvern Application to learn more about Wyvern