Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a4db3a

Browse files
Silas Marvingitbook-bot
Silas Marvin
authored andcommitted
GITBOOK-130: Added pgml.chunk documentation
1 parent47a96a6 commit9a4db3a

File tree

7 files changed

+61
-7
lines changed

7 files changed

+61
-7
lines changed

‎pgml-cms/docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*[SQL Extension](api/sql-extension/README.md)
1717
*[pgml.deploy()](api/sql-extension/pgml.deploy.md)
1818
*[pgml.embed()](api/sql-extension/pgml.embed.md)
19+
*[pgml.chunk()](api/sql-extension/pgml.chunk.md)
1920
*[pgml.generate()](api/sql-extension/pgml.generate.md)
2021
*[pgml.predict()](api/sql-extension/pgml.predict/README.md)
2122
*[Batch Predictions](api/sql-extension/pgml.predict/batch-predictions.md)

‎pgml-cms/docs/api/apis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ We also provide Client SDKs that implement the best practices on top of the SQL
1111
##SQL Extension
1212

1313
PostgreSQL is designed to be_**extensible**_. This has created a rich open-source ecosystem of additional functionality built around the core project. Some[extensions](https://www.postgresql.org/docs/current/contrib.html) are include in the base Postgres distribution, but others are also available via the[PostgreSQL Extension Network](https://pgxn.org/).\
14-
14+
\
1515
There are 2 foundational extensions included in a PostgresML deployment that provide functionality inside the database through SQL APIs.
1616

1717
***pgml** - provides Machine Learning and Artificial Intelligence APIs with access to more than 50 ML algorithms to train classification, clustering and regression models on your own data, or you can perform dozens of tasks with thousands of models downloaded from HuggingFace.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
description:Split some text into chunks using the specified splitter.
3+
---
4+
5+
#pgml.chunk()
6+
7+
Chunks are pieces of documents split using some specified splitter. This is typically done before embedding.
8+
9+
##API
10+
11+
```sql
12+
pgml.chunk(
13+
splitterTEXT,-- splitter name
14+
textTEXT,-- text to embed
15+
kwargs JSON-- optional arguments (see below)
16+
)
17+
```
18+
19+
##Example
20+
21+
```sql
22+
SELECTpgml.chunk('recursive_character','test');
23+
```
24+
25+
```sql
26+
SELECTpgml.chunk('recursive_character','test','{"chunk_size": 1000, "chunk_overlap": 40}'::jsonb);
27+
```
28+
29+
```sql
30+
SELECTpgml.chunk('markdown','# Some test');
31+
```
32+
33+
Note that the input text for those splitters is so small it isn't splitting it at all, a real world example would look more like:
34+
35+
```sql
36+
SELECTpgml.chunk('recursive_character', content)FROM documents;
37+
```
38+
39+
Where`documents` is some table that has a`text` column called`content`
40+
41+
##Supported Splitters
42+
43+
We support the following splitters:
44+
45+
*`recursive_character`
46+
*`latex`
47+
*`markdown`
48+
*`ntlk`
49+
*`python`
50+
*`spacy`
51+
52+
For more information on splitters see[ LangChain's docs](https://python.langchain.com/docs/modules/data\_connection/document\_transformers/)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ SELECT pgml.transform(
5858

5959
##Quantization
6060

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

6363
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.
6464

‎pgml-cms/docs/resources/benchmarks/making-postgres-30-percent-faster-in-production.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This is not only a performance benefit, but also a usability improvement for cli
2020

2121
##Benchmark
2222

23-
23+
\\
2424

2525
<figure><imgsrc="../../.gitbook/assets/pgcat_prepared_throughput.svg"alt=""><figcaption></figcaption></figure>
2626

‎pgml-cms/docs/resources/benchmarks/mindsdb-vs-postgresml.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Both Projects integrate several dozen machine learning algorithms, including the
3535
| Full Text Search| -||
3636
| Geospatial Search| -||
3737

38+
\
3839
Both MindsDB and PostgresML support many classical machine learning algorithms to do classification and regression. They are both able to load~~the latest LLMs~~ some models from Hugging Face, supported by underlying implementations in libtorch. I had to cross that out after exploring all the caveats in the MindsDB implementations. PostgresML supports the models released immediately as long as underlying dependencies are met. MindsDB has to release an update to support any new models, and their current model support is extremely limited. New algorithms, tasks, and models are constantly released, so it's worth checking the documentation for the latest list.
3940

4041
Another difference is that PostgresML also supports embedding models, and closely integrates them with vector search inside the database, which is well beyond the scope of MindsDB, since it's not a database at all. PostgresML has direct access to all the functionality provided by other Postgres extensions, like vector indexes from[pgvector](https://github.com/pgvector/pgvector) to perform efficient KNN & ANN vector recall, or[PostGIS](http://postgis.net/) for geospatial information as well as built in full text search. Multiple algorithms and extensions can be combined in compound queries to build state-of-the-art systems, like search and recommendations or fraud detection that generate an end to end result with a single query, something that might take a dozen different machine learning models and microservices in a more traditional architecture.
@@ -43,7 +44,7 @@ Another difference is that PostgresML also supports embedding models, and closel
4344

4445
The architectural implementations for these projects is significantly different. PostgresML takes a data centric approach with Postgres as the provider for both storage_and_ compute. To provide horizontal scalability for inference, the PostgresML team has also created[PgCat](https://github.com/postgresml/pgcat) to distribute workloads across many Postgres databases. On the other hand, MindsDB takes a service oriented approach that connects to various databases over the network.
4546

46-
47+
\\
4748

4849
<figure><imgsrc="../../.gitbook/assets/mindsdb-pgml-architecture.png"alt=""><figcaption></figcaption></figure>
4950

@@ -58,7 +59,7 @@ The architectural implementations for these projects is significantly different.
5859
| On Premise|||
5960
| Web UI|||
6061

61-
62+
\\
6263

6364
The difference in architecture leads to different tradeoffs and challenges. There are already hundreds of ways to get data into and out of a Postgres database, from just about every other service, language and platform that makes PostgresML highly compatible with other application workflows. On the other hand, the MindsDB Python service accepts connections from specifically supported clients like`psql` and provides a pseudo-SQL interface to the functionality. The service will parse incoming MindsDB commands that look similar to SQL (but are not), for tasks like configuring database connections, or doing actual machine learning. These commands typically have what looks like a sub-select, that will actually fetch data over the wire from configured databases for Machine Learning training and inference.
6465

@@ -286,7 +287,7 @@ PostgresML is the clear winner in terms of performance. It seems to me that it c
286287
| translation\_en\_to\_es| t5-base| 1573| 1148| 294|
287288
| summarization| sshleifer/distilbart-cnn-12-6| 4289| 3450| 479|
288289

289-
290+
\\
290291

291292
There is a general trend, the larger and slower the model is, the more work is spent inside libtorch, the less the performance of the rest matters, but for interactive models and use cases there is a significant difference. We've tried to cover the most generous use case we could between these two. If we were to compare XGBoost or other classical algorithms, that can have sub millisecond prediction times in PostgresML, the 20ms Python service overhead of MindsDB just to parse the incoming query would be hundreds of times slower.
292293

‎pgml-cms/docs/use-cases/embeddings/generating-llm-embeddings-with-open-source-models-in-postgresml.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ For comparison, it would cost about $299 to use OpenAI's cheapest embedding mode
198198
| GPU| 17ms| $72| 6 hours|
199199
| OpenAI| 300ms| $299| millennia|
200200

201-
201+
\\
202202

203203
You can also find embedding models that outperform OpenAI's`text-embedding-ada-002` model across many different tests on the[leaderboard](https://huggingface.co/spaces/mteb/leaderboard). It's always best to do your own benchmarking with your data, models, and hardware to find the best fit for your use case.
204204

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp