diff --git a/pgml-cms/docs/README.md b/pgml-cms/docs/README.md index 1d993a933..e12ddf095 100644 --- a/pgml-cms/docs/README.md +++ b/pgml-cms/docs/README.md @@ -4,12 +4,14 @@ description: The key concepts that make up PostgresML. # Overview -PostgresML is a complete MLOps platform built on PostgreSQL. Our operating principle is: +PostgresML is a complete [MLOps platform](## "A Machine Learning Operations platform is a set of practices that streamlines bringing machine learning models to production") built on PostgreSQL. Our operating principle is: > _Move models to the database, rather than constantly moving data to the models._ Data for ML & AI systems is inherently larger and more dynamic than the models. It's more efficient, manageable and reliable to move models to the database, rather than continuously moving data to the models. +We offer both [managed-cloud](/docs/product/cloud-database/) and [local](/docs/resources/developer-docs/installation) installations to provide solutions for wherever you keep your data. + ## AI engine PostgresML allows you to take advantage of the fundamental relationship between data and models, by extending the database with the following capabilities: @@ -48,8 +50,8 @@ Some of the use cases include: ## Our mission -PostgresML strives to provide access to open source AI for everyone. We are continuously developping PostgresML to keep up with the rapidly evolving use cases for ML & AI, but we remain committed to never breaking user facing APIs. We welcome contributions to our [open source code and documentation](https://github.com/postgresml) from the community. +PostgresML strives to provide access to open source AI for everyone. We are continuously developing PostgresML to keep up with the rapidly evolving use cases for ML & AI, but we remain committed to never breaking user-facing APIs. We welcome contributions to our [open source code and documentation](https://github.com/postgresml target="_blank") from the community. ## Managed cloud -While our extension and pooler are open source, we also offer a managed cloud database service for production deployments of PostgresML. You can [sign up](https://postgresml.org/signup) for an account and get a free Serverless database in seconds. +While our extension and pooler are open source, we also offer a managed cloud database service for production deployments of PostgresML. You can [sign up](https://postgresml.org/signup target="_blank") for an account and get a free Serverless database in seconds. diff --git a/pgml-cms/docs/api/apis.md b/pgml-cms/docs/api/apis.md index a4a465d4f..b23be60e6 100644 --- a/pgml-cms/docs/api/apis.md +++ b/pgml-cms/docs/api/apis.md @@ -4,15 +4,15 @@ description: Overview of the PostgresML SQL API and SDK. # API overview -PostgresML is a PostgreSQL extension which adds SQL functions to the database where it's installed. The functions work with modern machine learning algorithms and latest open source LLMs while maintaining a stable API signature. They can be used by any application that connects to the database. +PostgresML is a PostgreSQL extension which adds SQL functions to the database where it is installed. The functions work with modern machine learning algorithms and latest open source LLMs while maintaining a stable API signature. They can be used by any application that connects to the database. -In addition to the SQL API, we built and maintain a client SDK for JavaScript, Python and Rust. The SDK uses the same extension functionality to implement common ML & AI use cases, like retrieval-augmented generation (RAG), chatbots, and semantic & hybrid search engines. +In addition to the SQL API, we built and maintain a client SDK for JavaScript, Python, and Rust. The SDK uses the same extension functionality to implement common ML & AI use cases, like retrieval-augmented generation (RAG), chatbots, and semantic & hybrid search engines. Using the SDK is optional, and you can implement the same functionality with standard SQL queries. If you feel more comfortable using a programming language, the SDK can help you to get started quickly. ## [SQL extension](sql-extension/) -The PostgreSQL extension provides all of the ML & AI functionality, like training models and inference, via SQL functions. The functions are designed for ML practitioners to use dozens of ML algorithms to train models, and run real time inference, on live application data. Additionally, the extension provides access to the latest Hugging Face transformers for a wide range of NLP tasks. +The PostgreSQL extension provides all of the ML & AI functionality, like training models and inference, via SQL functions. The functions are designed for ML practitioners to use dozens of ML algorithms to train models and run real time inference on live application data. Additionally, the extension provides access to the latest Hugging Face transformers for a wide range of NLP tasks. ### Functions @@ -21,18 +21,18 @@ The following functions are implemented and maintained by the PostgresML extensi | Function | Description | |------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [pgml.embed()](sql-extension/pgml.embed) | Generate embeddings inside the database using open source embedding models from Hugging Face. | -| [pgml.transform()](sql-extension/pgml.transform/) | Download and run latest Hugging Face transformer models, like Llama, Mixtral, and many more to perform various NLP tasks like text generation, summarization, sentiment analysis and more. | +| [pgml.transform()](sql-extension/pgml.transform/) | Download and run the latest Hugging Face transformer models, like Llama, Mixtral, and many more to perform various NLP tasks like text generation, summarization, sentiment analysis, and more. | | pgml.transform_stream() | Streaming version of [pgml.transform()](sql-extension/pgml.transform/). Retrieve tokens as they are generated by the LLM, decreasing time to first token. | | [pgml.train()](sql-extension/pgml.train/) | Train a machine learning model on data from a Postgres table or view. Supports XGBoost, LightGBM, Catboost and all Scikit-learn algorithms. | | [pgml.deploy()](sql-extension/pgml.deploy) | Deploy a version of the model created with pgml.train(). | | [pgml.predict()](sql-extension/pgml.predict/) | Perform real time inference using a model trained with pgml.train() on live application data. | | [pgml.tune()](sql-extension/pgml.tune) | Run LoRA fine tuning on an open source model from Hugging Face using data from a Postgres table or view. | -Together with standard database functionality provided by PostgreSQL, these functions allow to create and manage the entire life cycle of a machine learning application. +Together with standard database functionality provided by PostgreSQL, these functions allow you to create and manage the entire life cycle of a machine-learning application. ## [Client SDK](client-sdk/) -The client SDK implements best practices and common use cases, using the PostgresML SQL functions and standard PostgreSQL features to do it. The SDK core is written in Rust, which manages creating and running queries, connection pooling, and error handling. +The client SDK implements best practices and common use cases using the PostgresML SQL functions and standard PostgreSQL features. The SDK core is written in Rust, which manages creating and running queries, connection pooling, and error handling. For each additional language we support (currently JavaScript and Python), we create and publish language-native bindings. This architecture ensures all programming languages we support have identical APIs and similar performance when interacting with PostgresML. diff --git a/pgml-cms/docs/api/sql-extension/pgml.deploy.md b/pgml-cms/docs/api/sql-extension/pgml.deploy.md index 3181f9d51..2fd0b9493 100644 --- a/pgml-cms/docs/api/sql-extension/pgml.deploy.md +++ b/pgml-cms/docs/api/sql-extension/pgml.deploy.md @@ -87,7 +87,7 @@ SELECT * FROM pgml.deploy( ### Rolling Back -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. +If the new model is not performing well in production, it is 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. #### Rollback @@ -101,7 +101,7 @@ SELECT * FROM pgml.deploy( #### Output ```sql - project | strategy | algorithm + project | strategy | algorithm ------------------------------------+----------+----------- Handwritten Digit Image Classifier | rollback | linear (1 row) @@ -129,7 +129,7 @@ SELECT * FROM pgml.deploy( ### Specific Model IDs -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. +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 ids can be found in the `pgml.models` table. #### SQL diff --git a/pgml-cms/docs/api/sql-extension/pgml.embed.md b/pgml-cms/docs/api/sql-extension/pgml.embed.md index b31c944b3..3aa74cbf2 100644 --- a/pgml-cms/docs/api/sql-extension/pgml.embed.md +++ b/pgml-cms/docs/api/sql-extension/pgml.embed.md @@ -6,7 +6,7 @@ description: >- # pgml.embed() -The `pgml.embed()` function generates [embeddings](/docs/use-cases/embeddings/) from text, using in-database models downloaded from Hugging Face. Thousands of [open-source models](https://huggingface.co/models?library=sentence-transformers) are available and new and better ones are being published regularly. +The `pgml.embed()` function generates [embeddings](/docs/use-cases/embeddings/) from text, using in-database models downloaded from Hugging Face. Thousands of [open-source models](https://huggingface.co/models?library=sentence-transformers) are available, with new and better models being published regularly. ## API @@ -69,7 +69,7 @@ VALUES {% endtab %} {% endtabs %} -In this example, we're using [generated columns](https://www.postgresql.org/docs/current/ddl-generated-columns.html) to automatically create an embedding of the `quote` column every time the column value is updated. +In this example, we are using [generated columns](https://www.postgresql.org/docs/current/ddl-generated-columns.html) to automatically create an embedding of the `quote` column every time the column value is updated. #### Using embeddings in queries diff --git a/pgml-cms/docs/api/sql-extension/pgml.train/README.md b/pgml-cms/docs/api/sql-extension/pgml.train/README.md index ec49916cc..ce304355d 100644 --- a/pgml-cms/docs/api/sql-extension/pgml.train/README.md +++ b/pgml-cms/docs/api/sql-extension/pgml.train/README.md @@ -37,7 +37,7 @@ pgml.train( | `task` | `'regression'` | The objective of the experiment: `regression`, `classification` or `cluster` | | `relation_name` | `'public.search_logs'` | The Postgres table or view where the training data is stored or defined. | | `y_column_name` | `'clicked'` | The name of the label (aka "target" or "unknown") column in the training table. | -| `algorithm` | `'xgboost'` |

The algorithm to train on the dataset, see the task specific pages for available algorithms:
regression.md

classification.md
clustering.md

| +| `algorithm` | `'xgboost'` |

The algorithm to train on the dataset, see the task specific pages for available algorithms:
[regression.md](regression.md "mention")

[classification.md](classification.md "mention")
[clustering.md](clustering.md "mention")

| | `hyperparams` | `{ "n_estimators": 25 }` | The hyperparameters to pass to the algorithm for training, JSON formatted. | | `search` | `grid` | If set, PostgresML will perform a hyperparameter search to find the best hyperparameters for the algorithm. See [hyperparameter-search.md](hyperparameter-search.md "mention") for details. | | `search_params` | `{ "n_estimators": [5, 10, 25, 100] }` | Search parameters used in the hyperparameter search, using the scikit-learn notation, JSON formatted. | @@ -63,7 +63,7 @@ This will create a "My Classification Project", copy the `pgml.digits` table int When used for the first time in a project, `pgml.train()` function requires the `task` parameter, which can be either `regression` or `classification`. The task determines the relevant metrics and analysis performed on the data. All models trained within the project will refer to those metrics and analysis for benchmarking and deployment. -The first time it's called, the function will also require a `relation_name` and `y_column_name`. The two arguments will be used to create the first snapshot of training and test data. By default, 25% of the data (specified by the `test_size` parameter) will be randomly sampled to measure the performance of the model after the `algorithm` has been trained on the 75% of the data. +The first time it is called, the function will also require a `relation_name` and `y_column_name`. The two arguments will be used to create the first snapshot of training and test data. By default, 25% of the data (specified by the `test_size` parameter) will be randomly sampled to measure the performance of the model after the `algorithm` has been trained on the 75% of the data. !!! tip diff --git a/pgml-cms/docs/api/sql-extension/pgml.transform/text-classification.md b/pgml-cms/docs/api/sql-extension/pgml.transform/text-classification.md index eb670b267..bacb0e77b 100644 --- a/pgml-cms/docs/api/sql-extension/pgml.transform/text-classification.md +++ b/pgml-cms/docs/api/sql-extension/pgml.transform/text-classification.md @@ -8,7 +8,7 @@ Text classification is a task which includes sentiment analysis, natural languag ### Sentiment analysis -Sentiment analysis is a type of natural language processing technique which analyzes a piece of text to determine the sentiment or emotion expressed within. It can be used to classify a text as positive, negative, or neutral. +Sentiment analysis is a type of natural language processing (NLP) technique which analyzes a piece of text to determine the sentiment or emotion expressed within. It can be used to classify a text as positive, negative, or neutral. #### Example diff --git a/pgml-cms/docs/api/sql-extension/pgml.transform/text-generation.md b/pgml-cms/docs/api/sql-extension/pgml.transform/text-generation.md index 8d84ca762..36b31c6b9 100644 --- a/pgml-cms/docs/api/sql-extension/pgml.transform/text-generation.md +++ b/pgml-cms/docs/api/sql-extension/pgml.transform/text-generation.md @@ -27,7 +27,7 @@ _Result_ ### Model from hub -To use a specific model from :hugging: model hub, pass the model name along with task name in task. +To use a specific model from the Hugging Face model hub, pass the model name along with task name in task. ```sql SELECT pgml.transform( @@ -109,7 +109,7 @@ _Result_ ### Beam Search -Text generation typically utilizes a greedy search algorithm that selects the word with the highest probability as the next word in the sequence. However, an alternative method called beam search can be used, which aims to minimize the possibility of overlooking hidden high probability word combinations. Beam search achieves this by retaining the num\_beams most likely hypotheses at each step and ultimately selecting the hypothesis with the highest overall probability. We set `num_beams > 1` and `early_stopping=True` so that generation is finished when all beam hypotheses reached the EOS token. +Text generation typically utilizes a greedy search algorithm that selects the word with the highest probability as the next word in the sequence. However, an alternative method called beam search can be used, which aims to minimize the possibility of overlooking hidden high probability word combinations. Beam search achieves this by retaining the `num\_beams` most likely hypotheses at each step and ultimately selecting the hypothesis with the highest overall probability. We set `num_beams > 1` and `early_stopping=True` so that generation is finished when all beam hypotheses reached the EOS token. ```sql SELECT pgml.transform( @@ -135,14 +135,16 @@ _Result_ ]] ``` -Sampling methods involve selecting the next word or sequence of words at random from the set of possible candidates, weighted by their probabilities according to the language model. This can result in more diverse and creative text, as well as avoiding repetitive patterns. In its most basic form, sampling means randomly picking the next word $w\_t$ according to its conditional probability distribution: $$w_t \approx P(w_t|w_{1:t-1})$$ +Sampling methods involve selecting the next word or sequence of words at random from the set of possible candidates, weighted by their probabilities according to the language model. This can result in more diverse and creative text, as well as avoiding repetitive patterns. In its most basic form, sampling means randomly picking the next word `$w\_t$` according to its conditional probability distribution: `$$w_t \approx P(w_t|w_{1:t-1})$$`. -However, the randomness of the sampling method can also result in less coherent or inconsistent text, depending on the quality of the model and the chosen sampling parameters such as temperature, top-k, or top-p. Therefore, choosing an appropriate sampling method and parameters is crucial for achieving the desired balance between creativity and coherence in generated text. +However, the randomness of the sampling method can also result in less coherent or inconsistent text, depending on the quality of the model and the chosen sampling parameters such as `temperature`, `top-k`, or `top-p`. Therefore, choosing an appropriate sampling method and parameters is crucial for achieving the desired balance between creativity and coherence in generated text. You can pass `do_sample = True` in the arguments to use sampling methods. It is recommended to alter `temperature` or `top_p` but not both. ### _Temperature_ +The `temperature` parameter can fine tune the level of confidence, diversity, and randommness of a model. It uses a range from 0 (very conservative output) to infinity (very diverse output) to define how the model should select a certain output based on the output's certainty. Higher temperatures should be used when the certainty of the output is low, and lower temperatures should be used when the certainty is very high. A `temperature` of 1 is considered a medium setting. + ```sql SELECT pgml.transform( task => '{ @@ -167,6 +169,8 @@ _Result_ ### _Top p_ +Top_p is a technique used to improve the performance of generative models. It selects the tokens that are in the top percentage of probability distribution, allowing for more diverse responses. If you are experiencing repetitive responses, modifying this setting can improve the quality of the output. The value of `top_p` is a number between 0 and 1 that sets the probability distribution, so a setting of `.8` sets the probability distribution at 80 percent. This means that it selects tokens that have an 80% probability of being accurate or higher. + ```sql SELECT pgml.transform( task => '{ diff --git a/pgml-cms/docs/api/sql-extension/pgml.tune.md b/pgml-cms/docs/api/sql-extension/pgml.tune.md index 4c874893a..f62f40eae 100644 --- a/pgml-cms/docs/api/sql-extension/pgml.tune.md +++ b/pgml-cms/docs/api/sql-extension/pgml.tune.md @@ -45,7 +45,7 @@ translation \=== -This HuggingFace dataset stores the data as language key pairs in a JSON document. To use it with PostgresML, we'll need to provide a `VIEW` that structures the data into more primitively typed columns. +This Hugging Face dataset stores the data as language key pairs in a JSON document. To use it with PostgresML, we'll need to provide a `VIEW` that structures the data into more primitively typed columns. \=== "SQL" diff --git a/pgml-cms/docs/introduction/getting-started/README.md b/pgml-cms/docs/introduction/getting-started/README.md index 309e0ac64..bc89d7854 100644 --- a/pgml-cms/docs/introduction/getting-started/README.md +++ b/pgml-cms/docs/introduction/getting-started/README.md @@ -4,6 +4,16 @@ description: Getting starting with PostgresML, a GPU powered machine learning da # Getting started +This guide will walk you through the steps of getting started with PostgresML by following these easy steps: + +1. [Create a free cloud account with PostgresML](/docs/introduction/getting-started/create-your-database#sign-up-for-an-account). This also creates a PostgresML database and includes access to GPU-accelerated models and 5 GB of storage. +2. [Select a plan](create-your-database#select-a-plan). +3. [Connect your PostgreSQL client to your PostgresML database](connect-your-app). + +If you would prefer to run PostgresML locally, you can skip to our [Developer Docs](/docs/resources/developer-docs/quick-start-with-docker). + +## How PostgresML works + A PostgresML deployment consists of multiple components working in concert to provide a complete Machine Learning platform: * PostgreSQL database, with [_pgml_](/docs/api/sql-extension/), _pgvector_ and many other extensions that add features useful in day-to-day and machine learning use cases @@ -14,6 +24,4 @@ We provide a fully managed solution in [our cloud](create-your-database), and do
PostgresML architecture
-By building PostgresML on top of a mature database, we get reliable backups for model inputs and proven scalability without reinventing the wheel, so that we can focus on providing access to the latest developments in open source machine learning and artificial intelligence. - -This guide will help you get started with a generous [free account](create-your-database), which includes access to GPU accelerated models and 5 GB of storage, or you can skip to our [Developer Docs](/docs/resources/developer-docs/quick-start-with-docker) to see how to run PostgresML locally with our Docker image. +By building PostgresML on top of a mature database, we get reliable backups for model inputs and proven scalability without reinventing the wheel, so that we can focus on providing access to the latest developments in open source machine learning and artificial intelligence. \ No newline at end of file diff --git a/pgml-cms/docs/resources/developer-docs/installation.md b/pgml-cms/docs/resources/developer-docs/installation.md index 03ae95ece..8f589ec2e 100644 --- a/pgml-cms/docs/resources/developer-docs/installation.md +++ b/pgml-cms/docs/resources/developer-docs/installation.md @@ -33,7 +33,7 @@ brew bundle **Rust** -PostgresML is written in Rust, so you'll need to install the latest compiler from [rust-lang.org](https://rust-lang.org). Additionally, we use the Rust PostgreSQL extension framework `pgrx`, which requires some initialization steps: +PostgresML is written in Rust, so you'll need to install the latest compiler from [rust-lang.org](https://rust-lang.org target="_blank"). Additionally, we use the Rust PostgreSQL extension framework `pgrx`, which requires some initialization steps: ```bash cargo install cargo-pgrx --version 0.11.2 && \ @@ -238,7 +238,7 @@ make install ### Other Linuxes -PostgresML will compile and run on pretty much any modern Linux distribution. For a quick example, you can take a look at what we do to build the extension on [Ubuntu](https://github.com/postgresml/postgresml/blob/master/.github/workflows/ubuntu-packages-and-docker-image.yml), and modify those steps to work on your distribution. +PostgresML will compile and run on pretty much any modern Linux distribution. For a quick example, you can take a look at what we do to build the extension on [Ubuntu](https://github.com/postgresml/postgresml/blob/master/.github/workflows/ubuntu-packages-and-docker-image.yml target="_blank"), and modify those steps to work on your distribution. #### Get the source code @@ -279,7 +279,7 @@ lld **Rust** -PostgresML is written in Rust, so you'll need to install the latest compiler version from [rust-lang.org](https://rust-lang.org). +PostgresML is written in Rust, so you'll need to install the latest compiler version from [rust-lang.org](https://rust-lang.org target="_blank"). #### `pgrx` @@ -310,7 +310,7 @@ The dashboard is a web app that can be run against any Postgres database which h To get our source code, you can clone our GitHub repository (if you haven't already): ```bash -git clone clone https://github.com/postgresml/postgresml && \ +git clone https://github.com/postgresml/postgresml && \ cd pgml-dashboard ``` @@ -333,7 +333,7 @@ DATABASE_URL=postgres:///pgml_dashboard ### Get Rust -The dashboard is written in Rust and uses the SQLx crate to interact with Postgres. Make sure to install the latest Rust compiler from [rust-lang.org](https://rust-lang.org). +The dashboard is written in Rust and uses the SQLx crate to interact with Postgres. Make sure to install the latest Rust compiler from [rust-lang.org](https://rust-lang.org target="_blank"). ### Database setup @@ -346,7 +346,7 @@ cargo sqlx database setup ### Frontend dependencies -The dashboard frontend is using Sass which requires Node & the Sass compiler. You can install Node from Brew, your package repository, or by using [Node Version Manager](https://github.com/nvm-sh/nvm). +The dashboard frontend is using Sass which requires Node & the Sass compiler. You can install Node from Brew, your package repository, or by using [Node Version Manager](https://github.com/nvm-sh/nvm target="_blank"). If using nvm, you can install the latest stable Node version with: diff --git a/pgml-cms/docs/use-cases/chatbots.md b/pgml-cms/docs/use-cases/chatbots.md index 17668b0e0..ba682ae5f 100644 --- a/pgml-cms/docs/use-cases/chatbots.md +++ b/pgml-cms/docs/use-cases/chatbots.md @@ -4,9 +4,9 @@ description: CLI tool to build and deploy chatbots # Example Application -Introduction +## Introduction -A command line tool to build and deploy a _**knowledge based**_ chatbot using PostgresML and OpenAI API. +This tutorial will walk you through the process of creating a command line tool to build and deploy a _**knowledge based**_ chatbot using PostgresML and OpenAI API. There are two stages in building a knowledge based chatbot: @@ -20,7 +20,7 @@ This tool automates the above two stages and provides a command line interface t Before you begin, make sure you have the following: * PostgresML Database: Sign up for a free [GPU-powered database](https://postgresml.org/signup) -* Python version >=3.8 +* Python version of 3.8 or newer * OpenAI API key ## Getting started @@ -40,7 +40,7 @@ wget https://raw.githubusercontent.com/postgresml/postgresml/master/pgml-apps/pg ``` 3. Copy the template file to `.env` -4. Update environment variables with your OpenAI API key and PostgresML database credentials. +4. Update environment variables with your OpenAI API key and PostgresML database credentials, replacing the sample `OPENAI_API_KEY` and `DATABASE_URL` data with your data in the following command: ```bash OPENAI_API_KEY= @@ -79,7 +79,7 @@ optional arguments: ### Ingest -In this step, we ingest documents, chunk documents, generate embeddings and index these embeddings for fast query. +In this step, you ingest documents, chunk documents, generate embeddings and index these embeddings for fast query. ```bash LOG_LEVEL=DEBUG pgml-chat --root_dir --collection_name --stage ingest @@ -93,7 +93,7 @@ You can interact with the bot using the command line interface or Slack. #### Command Line Interface -In this step, we start chatting with the chatbot at the command line. You can increase the log level to ERROR to suppress the logs. CLI is the default chat interface. +In this step, you can start chatting with the chatbot at the command line. You can increase the log level to ERROR to suppress the logs. CLI is the default chat interface. ```bash LOG_LEVEL=ERROR pgml-chat --collection_name --stage chat --chat_interface cli @@ -121,7 +121,7 @@ SLACK_BOT_TOKEN= SLACK_APP_TOKEN= ``` -In this step, we start chatting with the chatbot on Slack. You can increase the log level to ERROR to suppress the logs. +In this step, you can start chatting with the chatbot on Slack. You can increase the log level to ERROR to suppress the logs. ```bash LOG_LEVEL=ERROR pgml-chat --collection_name --stage chat --chat_interface slack @@ -145,7 +145,7 @@ Once the slack app is running, you can interact with the chatbot on Slack as sho DISCORD_BOT_TOKEN= ``` -In this step, we start chatting with the chatbot on Discord. You can increase the log level to ERROR to suppress the logs. +In this step, you can start chatting with the chatbot on Discord. You can increase the log level to ERROR to suppress the logs. ```bash pgml-chat --collection_name --stage chat --chat_interface discord diff --git a/pgml-cms/docs/use-cases/chatbots/README.md b/pgml-cms/docs/use-cases/chatbots/README.md index 333cbfa8f..95364c9e0 100644 --- a/pgml-cms/docs/use-cases/chatbots/README.md +++ b/pgml-cms/docs/use-cases/chatbots/README.md @@ -33,7 +33,7 @@ text -> tokens -> LLM -> probability distribution -> predicted token -> text

The flow of inputs through an LLM. In this case the inputs are "What is Baldur's Gate 3?" and the output token "14" maps to the word "I"

{% hint style="info" %} -We have simplified the tokenization process. Words do not always map directly to tokens. For instance, the word "Baldur's" may actually map to multiple tokens. For more information on tokenization checkout [HuggingFace's summary](https://huggingface.co/docs/transformers/tokenizer\_summary). +We have simplified the tokenization process. Words do not always map directly to tokens. For instance, the word "Baldur's" may actually map to multiple tokens. For more information on tokenization checkout [Hugging Face's summary](https://huggingface.co/docs/transformers/tokenizer\_summary). {% endhint %} To be very specific, modern LLM's are [function approximators](https://en.wikipedia.org/wiki/Function\_approximation) for the next most likely `token` given a list of `tokens`. They are not perfect and the level of accuracy is dependent on a number of factors like the model architecture, the training algorithms, and potentially most importantly the data it was trained on. @@ -356,7 +356,7 @@ By chaining these special tags we can build a conversation that Hermes has been This example highlights that modern LLM's are stateless function approximators. Notice we have included the first question we asked and the models response in our input. Every time we ask it a new question in our conversation, we will have to supply the entire conversation history if we want it to know what we already discussed. LLMs have no built in way to remember past questions and conversations. {% endhint %} -Doing this by hand seems very tedious, how do we actually accomplish this in the real world? We use [Jinja](https://jinja.palletsprojects.com/en/3.1.x/) templates. Conversational models on HuggingFace typical come with a Jinja template which can be found in the `tokenizer_config.json`. [Checkout `teknium/OpenHermes-2.5-Mistral-7B`'s Jinja template in the `tokenizer_config.json`](https://huggingface.co/teknium/OpenHermes-2.5-Mistral-7B/blob/main/tokenizer\_config.json). For more information on Jinja templating check out [HuggingFace's introduction](https://huggingface.co/docs/transformers/main/chat\_templating). +Doing this by hand seems very tedious, how do we actually accomplish this in the real world? We use [Jinja](https://jinja.palletsprojects.com/en/3.1.x/) templates. Conversational models on Hugging Face typical come with a Jinja template which can be found in the `tokenizer_config.json`. [Checkout `teknium/OpenHermes-2.5-Mistral-7B`'s Jinja template in the `tokenizer_config.json`](https://huggingface.co/teknium/OpenHermes-2.5-Mistral-7B/blob/main/tokenizer\_config.json). For more information on Jinja templating check out [Hugging Face's introduction](https://huggingface.co/docs/transformers/main/chat\_templating). Luckily for everyone reading this, our `pgml` library automatically handles templating and formatting inputs correctly so we can skip a bunch of boring code. We do want to change up our program a little bit to take advantage of this automatic templating: @@ -393,7 +393,7 @@ Hello! My name is Hermes. How can I help you today? You just asked me what my name is, and I am a friendly and helpful chatbot named Hermes. How can I assist you today? Feel free to ask me any questions or seek any assistance you need. ``` -Note that we have a list of dictionaries called `history` we use to store the chat history, and instead of feeding text into our model, we are inputting the `history` list. Our library automatically converts this list of dictionaries into the format expected by the model. Notice the `roles` in the dictionaries are the same as the `roles` of the messages in the previous example. This list of dictionaries with keys `role` and `content` as a storage system for messages is pretty standard and used by us as well as OpenAI and HuggingFace. +Note that we have a list of dictionaries called `history` we use to store the chat history, and instead of feeding text into our model, we are inputting the `history` list. Our library automatically converts this list of dictionaries into the format expected by the model. Notice the `roles` in the dictionaries are the same as the `roles` of the messages in the previous example. This list of dictionaries with keys `role` and `content` as a storage system for messages is pretty standard and used by us as well as OpenAI and Hugging Face. Let's ask it the dreaded question: diff --git a/pgml-cms/docs/use-cases/embeddings/personalize-embedding-results-with-application-data-in-your-database.md b/pgml-cms/docs/use-cases/embeddings/personalize-embedding-results-with-application-data-in-your-database.md index d6094233b..f16272951 100644 --- a/pgml-cms/docs/use-cases/embeddings/personalize-embedding-results-with-application-data-in-your-database.md +++ b/pgml-cms/docs/use-cases/embeddings/personalize-embedding-results-with-application-data-in-your-database.md @@ -1,12 +1,12 @@ # Personalize embedding results with application data in your database -PostgresML makes it easy to generate embeddings using open source models from Huggingface and perform complex queries with vector indexes and application data unlike any other database. The full expressive power of SQL as a query language is available to seamlessly combine semantic, geospatial, and full text search, along with filtering, boosting, aggregation, and ML reranking in low latency use cases. You can do all of this faster, simpler and with higher quality compared to applications built on disjoint APIs like OpenAI + Pinecone. Prove the results in this series to your own satisfaction, for free, by signing up for a GPU accelerated database. +PostgresML makes it easy to generate embeddings using open source models from Hugging Face and perform complex queries with vector indexes and application data unlike any other database. The full expressive power of SQL as a query language is available to seamlessly combine semantic, geospatial, and full text search, along with filtering, boosting, aggregation, and ML reranking in low latency use cases. You can do all of this faster, simpler and with higher quality compared to applications built on disjoint APIs like OpenAI + Pinecone. Prove the results in this series to your own satisfaction, for free, by signing up for a GPU accelerated database. ## Introduction This article is the third in a multipart series that will show you how to build a post-modern semantic search and recommendation engine, including personalization, using open source models. You may want to start with the previous articles in the series if you aren't familiar with PostgresML's capabilities. -1. Generating LLM Embeddings with HuggingFace models +1. Generating LLM Embeddings with Hugging Face models 2. Tuning vector recall with pgvector 3. Personalizing embedding results with application data 4. Optimizing semantic results with an XGBoost ranking model - coming soon! @@ -107,8 +107,6 @@ CREATE INDEX !!! -Now we can incorporate a customer embedding to personalize the results whenever they search. Normally, we'd have the `customers.id` in our application already because they'd be searching and browsing our site, but we don't have an actual application or customers for this article, so we'll have to find one for our example. Let's find a customer that loves the movie Empire Strikes Back. No Star Wars made our original list, so we have a good opportunity to improve our previous results with personalization. - ## Finding a customer to personalize results for Now that we have customer embeddings around movies they've reviewed, we can incorporate those to personalize the results whenever they search. Normally, we'd have the `customers.id` handy in our application because they'd be searching and browsing our app, but we don't have an actual application or customers for this article, so we'll have to find one for our example. Let's find a customer that loves the movie "Empire Strikes Back". No "Star Wars" made our original list of "Best 1980's scifi movie", so we have a good opportunity to improve our previous results with personalization. @@ -185,8 +183,6 @@ This is odd at first glance. The review doesn't mention anything thing about Sta If someone only ever bothered to write 1 review, and they are upset about the physical DVD, it's likely they are a big fan of the movie, and they are upset about the physical DVD because they wanted to keep it for a long time. This is a great example of how stacking and relating embeddings carefully can generate insights at a scale that is otherwise impossible, revealing the signal in the noise. -Now we can write our personalized SQL query. It's nearly the same as our query from the previous article, but we're going to include an additional CTE to fetch the customers embedding by id, and then tweak our `final_score`. Here comes personalized query results, using that customer 44366773's embedding. Instead of the generic popularity boost we've been using, we'll calculate the cosine similarity of the customer embedding to all the movies in the results, and use that as a boost. This will push movies that are similar to the customer's embedding to the top of the results. - ## Personalizing search results Now we can write our personalized SQL query. It's nearly the same as our query from the previous article, but we're going to include an additional CTE to fetch the customers embedding by id, and then tweak our `final_score`. Instead of the generic popularity boost we've been using, we'll calculate the cosine similarity of the customer embedding to all the movies in the results, and use that as a boost. This will push movies that are similar to the customer's embedding to the top of the results. Here comes personalized query results, using that customer 44366773's embedding: 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