You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Step 3: Connect to PostgresDB with PostgresML enabled using a SQL IDE or [`psql`](https://www.postgresql.org/docs/current/app-psql.html)
144
+
Step 3: Connect to PostgresDB with PostgresML enabled using a SQL IDE or <ahref="https://www.postgresql.org/docs/current/app-psql.html"target="_blank">psql</a>
PostgresML integrates 🤗 Hugging Face Transformers to bring state-of-the-art NLP models into the data layer. There are tens of thousands of pre-trained models with pipelines to turn raw text in your database into useful results. Many state of the art deep learning architectures have been published and made available from Hugging Face <ahref= "https://huggingface.co/models"target="_blank">model hub</a>.
177
+
178
+
You can call different NLP tasks and customize using them using the following SQL query.
inputs =>TEXT[] ORBYTEA[], -- inputs for inference
184
+
args => JSONB -- (optional) arguments to the pipeline.
185
+
)
186
+
```
187
+
### Text Classification
188
+
189
+
Text classification involves assigning a label or category to a given text. Common use cases include sentiment analysis, natural language inference, and the assessment of grammatical correctness.
A fine-tune checkpoint of DistilBERT-base-uncased that is tuned on Stanford Sentiment Treebank(sst2) is used as a default <ahref="https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english"target="_blank">model</a> for text classification.
213
+
214
+
*SQL query using specific model*
215
+
216
+
To use one of the over 19,000 models available on Hugging Face, include the name of the desired model and its associated task as a JSONB object in the SQL query. For example, if you want to use a RoBERTa <ahref="https://huggingface.co/models?pipeline_tag=text-classification"target="_blank">model</a> trained on around 40,000 English tweets and that has POS (positive), NEG (negative), and NEU (neutral) labels for its classes, include this information in the JSONB object when making your query.
By selecting a model that has been specifically designed for a particular industry, you can achieve more accurate and relevant text classification. An example of such a model is <ahref="https://huggingface.co/ProsusAI/finbert"target="_blank">FinBERT</a>, a pre-trained NLP model that has been optimized for analyzing sentiment in financial text. FinBERT was created by training the BERT language model on a large financial corpus, and fine-tuning it to specifically classify financial sentiment. When using FinBERT, the model will provide softmax outputs for three different labels: positive, negative, or neutral.
242
+
243
+
```sql
244
+
SELECTpgml.transform(
245
+
inputs => ARRAY[
246
+
'Stocks rallied and the British pound gained.',
247
+
'Stocks making the biggest moves midday: Nvidia, Palantir and more'
0 commit comments