|
19 | 19 | </h2>
|
20 | 20 |
|
21 | 21 | <palign="center">
|
22 |
| -Generative AI andSimple ML with |
| 22 | +Generative AI andTraditional ML with |
23 | 23 | <a href="https://www.postgresql.org/" target="_blank">PostgreSQL</a>
|
24 | 24 | </p>
|
25 | 25 |
|
@@ -86,6 +86,7 @@ SELECT pgml.transform(
|
86 | 86 |
|
87 | 87 |
|
88 | 88 | **Sentiment Analysis**
|
| 89 | + |
89 | 90 | *SQL query*
|
90 | 91 |
|
91 | 92 | ```sql
|
@@ -754,15 +755,21 @@ Similar to other tasks, we can specify a model for text-to-text generation.
|
754 | 755 | SELECTpgml.transform(
|
755 | 756 | task=>'{
|
756 | 757 | "task" : "text2text-generation",
|
757 |
| - "model" : "bigscience/T0" |
| 758 | + "model" : "t5-small" |
758 | 759 | }'::JSONB,
|
759 | 760 | inputs=> ARRAY[
|
760 |
| -'Is the word''table'' used in the same meaning in the two previous sentences? Sentence A: you can leave the books on the table over there. Sentence B: the tables in this book areveryhard to read.' |
| 761 | +'translate from English to French: I''mveryhappy' |
761 | 762 |
|
762 | 763 | ]
|
763 | 764 | )AS answer;
|
764 |
| - |
765 | 765 | ```
|
| 766 | +*Result* |
| 767 | +```json |
| 768 | +[ |
| 769 | + {"generated_text":"Je suis très heureux"} |
| 770 | +] |
| 771 | +``` |
| 772 | + |
766 | 773 | ##Fill-Mask
|
767 | 774 | Fill-mask refers to a task where certain words in a sentence are hidden or "masked", and the objective is to predict what words should fill in those masked positions. Such models are valuable when we want to gain statistical insights about the language used to train the model.
|
768 | 775 | 
|
@@ -838,8 +845,14 @@ The index is being created on the embedding column in the tweet_embeddings table
|
838 | 845 | By creating an index on the embedding column, the database can quickly search for and retrieve records that are similar to a given query vector. This can be useful for a variety of machine learning applications, such as similarity search or recommendation systems.
|
839 | 846 |
|
840 | 847 | ```sql
|
841 |
| -CREATEINDEXON tweet_embeddings USING ivfflat (embedding vector_cosine_ops); |
| 848 | +CREATE EXTENSION vector;-- installing pgvector |
| 849 | + |
| 850 | +CREATETABLEitems (texttext, embedding vector(768)); |
| 851 | +insert into itemsselecttext, embeddingfrom tweet_embeddings; |
| 852 | + |
| 853 | +CREATEINDEXON items USING ivfflat (embedding vector_cosine_ops); |
842 | 854 | ```
|
| 855 | + |
843 | 856 | ##Step 3: Querying the index using embeddings for your queries
|
844 | 857 | Once your embeddings have been indexed, you can use them to perform queries against your database. To do this, you'll need to provide a query embedding that represents the query you want to perform. The index will then return the closest matching embeddings from your database, based on the similarity between the query embedding and the stored embeddings.
|
845 | 858 |
|
|