Skip to content

Commit 3efc3ba

Browse files
ChuckHendSilasMarvin
authored andcommitted
Stratified sampling (#1336)
I verified tests locally, because I wasn't able to figure out how to get them running via github actions...
1 parent 347168a commit 3efc3ba

File tree

39 files changed

+978
-130
lines changed

39 files changed

+978
-130
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ jobs:
4747
if: steps.pgml_extension_changed.outputs.PGML_EXTENSION_CHANGED_FILES != '0'
4848
run: |
4949
git submodule update --init --recursive
50+
- name: Get current version
51+
id: current-version
52+
run: echo "CI_BRANCH=$(git name-rev --name-only HEAD)" >> $GITHUB_OUTPUT
5053
- name: Run tests
54+
env:
55+
CI_BRANCH: ${{ steps.current-version.outputs.CI_BRANCH }}
5156
if: steps.pgml_extension_changed.outputs.PGML_EXTENSION_CHANGED_FILES != '0'
5257
run: |
5358
curl https://sh.rustup.rs -sSf | sh -s -- -y
@@ -58,8 +63,13 @@ jobs:
5863
cargo pgrx init
5964
fi
6065
66+
git checkout master
67+
echo "\q" | cargo pgrx run
68+
psql -p 28816 -h localhost -d pgml -P pager -c "CREATE EXTENSION pgml;"
69+
git checkout $CI_BRANCH
70+
echo "\q" | cargo pgrx run
71+
psql -p 28816 -h localhost -d pgml -P pager -c "ALTER EXTENSION pgml UPDATE;"
6172
cargo pgrx test
62-
6373
# cargo pgrx start
6474
# psql -p 28815 -h 127.0.0.1 -d pgml -P pager -f tests/test.sql
6575
# cargo pgrx stop

pgml-cms/docs/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ description: The key concepts that make up PostgresML.
44

55
# Overview
66

7-
PostgresML is a complete MLOps platform built on PostgreSQL.
7+
PostgresML is a complete MLOps platform built on PostgreSQL. 
88

99
> _Move the models to the database_, _rather than continuously moving the data to the models._
1010
11-
The data for ML & AI systems is inherently larger and more dynamic than the models. It's more efficient, manageable and reliable to move the models to the database, rather than continuously moving the data to the models\_.\_ PostgresML allows you to take advantage of the fundamental relationship between data and models, by extending the database with the following capabilities and goals:
11+
The data for ML & AI systems is inherently larger and more dynamic than the models. It's more efficient, manageable and reliable to move the models to the database, rather than continuously moving the data to the models. PostgresML allows you to take advantage of the fundamental relationship between data and models, by extending the database with the following capabilities and goals:
1212

1313
* **Model Serving** - _**GPU accelerated**_ inference engine for interactive applications, with no additional networking latency or reliability costs.
1414
* **Model Store** - Download _**open-source**_ models including state of the art LLMs from HuggingFace, and track changes in performance between versions.
1515
* **Model Training** - Train models with _**your application data**_ using more than 50 algorithms for regression, classification or clustering tasks. Fine tune pre-trained models like LLaMA and BERT to improve performance.
16-
* **Feature Store** - _**Scalable**_ access to model inputs, including vector, text, categorical, and numeric data. Vector database, text search, knowledge graph and application data all in one _**low-latency**_ system.
16+
* **Feature Store** - _**Scalable**_ access to model inputs, including vector, text, categorical, and numeric data. Vector database, text search, knowledge graph and application data all in one _**low-latency**_ system. 
1717

1818
<figure><img src=".gitbook/assets/ml_system.svg" alt="Machine Learning Infrastructure (2.0) by a16z"><figcaption><p>PostgresML handles all of the functions typically performed by a cacophony of services, <a href="https://a16z.com/emerging-architectures-for-modern-data-infrastructure/">described by a16z</a></p></figcaption></figure>
1919

20-
These capabilities are primarily provided by two open-source software projects, that may be used independently, but are designed to be used with the rest of the Postgres ecosystem, including trusted extensions like pgvector and pg\_partman.
20+
These capabilities are primarily provided by two open-source software projects, that may be used independently, but are designed to be used with the rest of the Postgres ecosystem, including trusted extensions like pgvector and pg\_partman.&#x20;
2121

2222
* **pgml** is an open source extension for PostgreSQL. It adds support for GPUs and the latest ML & AI algorithms _**inside**_ the database with a SQL API and no additional infrastructure, networking latency, or reliability costs.
2323
* **PgCat** is an open source proxy pooler for PostgreSQL. It abstracts the scalability and reliability concerns of managing a distributed cluster of Postgres databases. Client applications connect only to the proxy, which handles load balancing and failover, _**outside**_ of any single database.
2424

2525
<figure><img src=".gitbook/assets/architecture.png" alt="PostgresML architectural diagram" width="275"><figcaption><p>A PostgresML deployment at scale</p></figcaption></figure>
2626

27-
In addition, PostgresML provides [native language SDKs](https://github.com/postgresml/postgresml/tree/master/pgml-sdks/pgml) to implement best practices for common ML & AI applications. The JavaScript and Python SDKs are generated from the core Rust SDK, to provide the same API, correctness and efficiency across all application runtimes.
27+
In addition, PostgresML provides [native language SDKs](https://github.com/postgresml/postgresml/tree/master/pgml-sdks/pgml) to implement best practices for common ML & AI applications. The JavaScript and Python SDKs are generated from the core Rust SDK, to provide the same API, correctness and efficiency across all application runtimes.&#x20;
2828

2929
SDK clients can perform advanced machine learning tasks in a single SQL request, without having to transfer additional data, models, hardware or dependencies to the client application. For example:
3030

@@ -36,6 +36,6 @@ SDK clients can perform advanced machine learning tasks in a single SQL request,
3636
* Forecasting timeseries data for key metrics with complex metadata
3737
* Fraud and anomaly detection with application data
3838

39-
Our goal is to provide access to Open Source AI for everyone. PostgresML is under continuous development to keep up with the rapidly evolving use cases for ML & AI, and we release non breaking changes with minor version updates in accordance with SemVer. We welcome contributions to our [open source code and documentation](https://github.com/postgresml).
39+
Our goal is to provide access to Open Source AI for everyone. PostgresML is under continuous development to keep up with the rapidly evolving use cases for ML & AI, and we release non breaking changes with minor version updates in accordance with SemVer. We welcome contributions to our [open source code and documentation](https://github.com/postgresml).&#x20;
4040

4141
We can host your AI database in our cloud, or you can run our Docker image locally with PostgreSQL, pgml, pgvector and NVIDIA drivers included.

pgml-cms/docs/SUMMARY.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@
3838
* [Overview](introduction/apis/client-sdks/getting-started.md)
3939
* [Collections](introduction/apis/client-sdks/collections.md)
4040
* [Pipelines](introduction/apis/client-sdks/pipelines.md)
41-
* [Vector Search](introduction/apis/client-sdks/search.md)
42-
* [Document Search](introduction/apis/client-sdks/document-search.md)
41+
* [Search](introduction/apis/client-sdks/search.md)
4342
* [Tutorials](introduction/apis/client-sdks/tutorials/README.md)
4443
* [Semantic Search](introduction/apis/client-sdks/tutorials/semantic-search.md)
45-
* [Semantic Search Using Instructor Model](introduction/apis/client-sdks/tutorials/semantic-search-1.md)
44+
* [Semantic Search using Instructor model](introduction/apis/client-sdks/tutorials/semantic-search-using-instructor-model.md)
45+
* [Extractive Question Answering](introduction/apis/client-sdks/tutorials/extractive-question-answering.md)
46+
* [Summarizing Question Answering](introduction/apis/client-sdks/tutorials/summarizing-question-answering.md)
4647

4748
## Product
4849

pgml-cms/docs/introduction/apis/sql-extensions/pgml.deploy.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
description: >-
3+
Release trained models when ML quality metrics computed during training improve. Track model deployments over time and rollback if needed.
4+
---
5+
16
# pgml.deploy()
27

38
## Deployments
@@ -27,7 +32,7 @@ pgml.deploy(
2732
There are 3 different deployment strategies available:
2833

2934
| Strategy | Description |
30-
| ------------- | ------------------------------------------------------------------------------------------------ |
35+
| ------------- |--------------------------------------------------------------------------------------------------|
3136
| `most_recent` | The most recently trained model for this project is immediately deployed, regardless of metrics. |
3237
| `best_score` | The model that achieved the best key metric score is immediately deployed. |
3338
| `rollback` | The model that was deployed before to the current one is deployed. |
@@ -79,6 +84,8 @@ SELECT * FROM pgml.deploy(
7984
(1 row)
8085
```
8186

87+
88+
8289
### Rolling Back
8390

8491
In case the new model isn't performing well in production, it's easy to rollback to the previous version. A rollback creates a new deployment for the old model. Multiple rollbacks in a row will oscillate between the two most recently deployed models, making rollbacks a safe and reversible operation.
@@ -123,7 +130,7 @@ SELECT * FROM pgml.deploy(
123130

124131
### Specific Model IDs
125132

126-
In the case you need to deploy an exact model that is not the `most_recent` or `best_score`, you may deploy a model by id. Model id's can be found in the `pgml.models` table.
133+
In the case you need to deploy an exact model that is not the `most_recent` or `best_score`, you may deploy a model by id. Model id's can be found in the `pgml.models` table.
127134

128135
#### SQL
129136

pgml-cms/docs/introduction/apis/sql-extensions/pgml.embed.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
description: >-
3+
Generate high quality embeddings with faster end-to-end vector operations without an additional vector database.
4+
---
5+
16
# pgml.embed()
27

38
Embeddings are a numeric representation of text. They are used to represent words and sentences as vectors, an array of numbers. Embeddings can be used to find similar pieces of text, by comparing the similarity of the numeric vectors using a distance measure, or they can be used as input features for other machine learning models, since most algorithms can't use text directly.

pgml-cms/docs/introduction/apis/sql-extensions/pgml.predict/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
description: >-
3+
Batch predict from data in a table. Online predict with parameters passed in a query. Automatically reuse pre-processing steps from training.
4+
---
5+
16
# pgml.predict()
27

38
## API
@@ -51,7 +56,7 @@ LIMIT 25;
5156

5257
### Classification Example
5358

54-
If you've already been through the [pgml.train](../pgml.train "mention") examples, you can see the predictive results of those models:
59+
If you've already been through the [pgml.train](../pgml.train/ "mention") examples, you can see the predictive results of those models:
5560

5661
```sql
5762
SELECT

pgml-cms/docs/introduction/apis/sql-extensions/pgml.train/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
22
description: >-
3-
The training function is at the heart of PostgresML. It's a powerful single
4-
mechanism that can handle many different training tasks which are configurable
5-
with the function parameters.
3+
Pre-process and pull data to train a model using any of 50 different ML algorithms.
64
---
75

86
# pgml.train()
@@ -35,7 +33,7 @@ pgml.train(
3533
| Parameter | Example | Description |
3634
| --------------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
3735
| `project_name` | `'Search Results Ranker'` | An easily recognizable identifier to organize your work. |
38-
| `task` | `'regression'` | The objective of the experiment: `regression`, `classification` or `cluster` |
36+
| `task` | `'regression'` | The objective of the experiment: `regression`, `classification` or `cluster` |
3937
| `relation_name` | `'public.search_logs'` | The Postgres table or view where the training data is stored or defined. |
4038
| `y_column_name` | `'clicked'` | The name of the label (aka "target" or "unknown") column in the training table. |
4139
| `algorithm` | `'xgboost'` | <p>The algorithm to train on the dataset, see the task specific pages for available algorithms:<br><a data-mention href="regression.md">regression.md</a></p><p><a data-mention href="classification.md">classification.md</a><br><a data-mention href="clustering.md">clustering.md</a></p> |

pgml-cms/docs/introduction/apis/sql-extensions/pgml.transform/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
2+
description: >-
3+
Perform dozens of state-of-the-art natural language processing (NLP) tasks with thousands of models. Serve with the same Postgres infrastructure.
24
layout:
35
title:
46
visible: true

pgml-cms/docs/introduction/apis/sql-extensions/pgml.tune.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
---
2+
description: >-
3+
Fine tune open-source models on your own data.
4+
---
5+
16
# pgml.tune()
27

38
## Fine Tuning
49

5-
Pre-trained models allow you to get up and running quickly, but you can likely improve performance on your dataset by fine tuning them. Normally, you'll bring your own data to the party, but for these examples we'll use datasets published on Hugging Face.
10+
Pre-trained models allow you to get up and running quickly, but you can likely improve performance on your dataset by fine tuning them. Normally, you'll bring your own data to the party, but for these examples we'll use datasets published on Hugging Face.&#x20;
611

712
### Translation Example
813

pgml-cms/docs/resources/benchmarks/ggml-quantized-llm-support-for-huggingface-transformers.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
---
2+
description: >-
3+
Quantization allows PostgresML to fit larger models in less RAM.
4+
---
15
# GGML Quantized LLM support for Huggingface Transformers
26

7+
8+
39
Quantization allows PostgresML to fit larger models in less RAM. These algorithms perform inference significantly faster on NVIDIA, Apple and Intel hardware. Half-precision floating point and quantized optimizations are now available for your favorite LLMs downloaded from Huggingface.
410

511
## Introduction
@@ -54,7 +60,8 @@ SELECT pgml.transform(
5460

5561
## Quantization
5662

57-
_Discrete quantization is not a new idea. It's been used by both algorithms and artists for more than a hundred years._\\
63+
_Discrete quantization is not a new idea. It's been used by both algorithms and artists for more than a hundred years._\
64+
5865

5966
Going beyond 16-bit down to 8 or 4 bits is possible, but not with hardware accelerated floating point operations. If we want hardware acceleration for smaller types, we'll need to use small integers w/ vectorized instruction sets. This is the process of _quantization_. Quantization can be applied to existing models trained with 32-bit floats, by converting the weights to smaller integer primitives that will still benefit from hardware accelerated instruction sets like Intel's [AVX](https://en.wikipedia.org/wiki/Advanced\_Vector\_Extensions). A simple way to quantize a model can be done by first finding the maximum and minimum values of the weights, then dividing the range of values into the number of buckets available in your integer type, 256 for 8-bit, 16 for 4-bit. This is called _post-training quantization_, and it's the simplest way to quantize a model.
6067

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy