Friday, February 09, 2024

NLP pitstop using GPT-3.5 translate, summarize, sentiment analysis and Named Entity Extraction!!!


Introduction:

   Large Language Models (LLMs) represent a groundbreaking advancement in the field of artificial intelligence, particularly in natural language processing. These models are designed to understand, generate, and manipulate human-like text on a massive scale. One of the most notable examples of LLMs is OpenAI's GPT-3 (Generative Pre-trained Transformer 3), which is part of the Transformer architecture. What sets LLMs apart is their ability to learn from vast amounts of diverse data, enabling them to perform a wide range of language-related tasks, such as text completion, translation, summarization, and even creative writing. These models are pre-trained on extensive datasets and can then be fine-tuned for specific applications. The architecture of LLMs, particularly the Transformer model, utilizes attention mechanisms to capture relationships between words and phrases in a text. This allows the models to grasp context and generate coherent and contextually relevant responses. GPT-3, for instance, has a staggering number of parameters, reaching hundreds of billions, contributing to its ability to understand and generate complex language patterns. As researchers continue to explore and improve upon the capabilities of Large Language Models, the technology is expected to play a pivotal role in shaping the future of human-computer interaction, information retrieval, and content generation. However, it is crucial to approach the development and deployment of LLMs with a careful consideration of ethical implications and societal impact.


NLP pitstop powered by GenAI [gpt-3.5-turbo]:












    

Based on, Gadget framework [ A serverless Node.js environment for running your JavaScript code accompanied by Actions and HTTP routes that are used to execute and organize your backend code]. Above it has defined three data models: user, session and translation. Below is an example how it describes relation between variable. Ex: User has many translations. You may supply multiple languages separated by space or comma.











As user logs in after being authenticated into the application, it stores the records as below.









Below is the JS and is calling Open-AI API end point [openai.chat.completions]:















Access Gadget based NLP pitstop:
To access, you can use GMail to authenticate and login: translate and capture sentiment here

Hope you had fun using this simple translator with sentiment capture!!

Thursday, February 01, 2024

Pentaho (PDI) to translate human language (i.e. NLP task) using Open-AI!

LLMs (Large Language Models), example like [LLaMA, GPT-4, ChatGPT, Megatron-Turning NLG, Mistral 7B] continue to fascinate the way NLP tasks [Question/Answering, Translation of human languages, Sentiment analysis, Text Summarization] being able to solve! Here is a question for Open-AI .

Who was the first person to land on moon.. and the answer from the system is basically given the statistical distribution of words in public corpus, what words are likely to follow the sequence? Here Neil Armstrong!!


How about human language translation, which can increase productivity coming from different cultural background, LLMs can be trained to covert one language to few more languages !? Here is an example.



Wow, how Open-AI could easily translate into few languages for an English sentence!

How about using this in a data pipe using ETL/ELT tool like (Pentaho Data Integration-PDI) to call REST end point of  Open-AI Chat Completions. Below is a transformation (data pipeline) which takes input as above API endpoint, to supply a language, input data, which engine to use.



The input is a step 'Data grid', then prepare a JSON payload (using step 'Add constant'), using string replacement, replace the string for LANG, SENTENCE, GEN_AI_MODEL as per the input coming from Data grid step. Once the JSON body is prepared then pass onto the end point via calling 'REST client' step in Spoon.


















Once REST client invokes Open-AI end point and gets the result (with code 200 as success), then you can see the data coming out from "dummy" step as below.

Translated Output


Conclusion: This simple translator in a data pipe line, shows you how you can use Open-AI REST end-point, while solving a business scenario where you are dealing with customer feedbacks, VoC data sets, increase in efficiency so sales, strengthen partnerships, avoid misunderstandings/disputes etc. 

The challenge you may get into while using this model is performance, how long the Open-AI takes for a paragraph or even for a document to translate, another is cost: for large text size as these systems charge in number of tokens, so an Open source LLM, may be another option. 

Hope you enjoyed!