Applications of Generative Artificial intelligence
DrNBargavi
108 views
34 slides
Sep 24, 2024
Slide 1 of 34
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
About This Presentation
Applications of Generative Artificial intelligence
Size: 3.75 MB
Language: en
Added: Sep 24, 2024
Slides: 34 pages
Slide Content
Contents Brief Overview of Gen AI Evolution of Generative AI Brief Overview of Gen AI and LLM Real life Applications of LLM Interaction with LLM Limitations of LLM Gen AI Lifecycle Prompt Engineering How to choose a LLM Model Fine Tuning LLM Model Evaluation Use Cases
Brief Overview of Gen AI Generative AI refers to deep-learning models that can generate high-quality text, images, and other content based on the data they were trained on. Few such examples are: ChatGPT from OpenAI Bard from Google Bing Chat from Microsoft
Brief Overview of Gen AI: Model Overview
Evolution of Gen AI: Motivation
Evolution of Gen AI: Model
Text Generation by LLM: Self Supervised Learning Pre-trained language models are large neural networks trained on vast corpus of data, usually sourced from internet. Pretraining an LLM means teaching it to predict the next token in a self-supervised fashion. At the core of these self-supervised methods lies a framing called “ pretext task ” that allows us to use the data itself to generate labels and use supervised methods to solve unsupervised problems. In this formulation, we take large corpus of unlabeled text and setup a task to predict the next word given the previous words. Since we already know what word should come next from the corpus, we don’t need manually-annotated labels. Reference URL: Self Supervised Representation Learning in NLP (amitness.com)
Real life Applications of LLM: Functionalities
Real life Applications of LLM: Functionalities (Contd.)
Real life Applications of LLM: Application Domains We should consider it as thought partner and reasoning engine.
Components of LLM: Workflow
Key Components of LLM Tokenization: partition the text into meaningful sub word units Embedding : continuous vector representations of tokens that capture semantic information Attention: The attention mechanism, especially self-attention as seen in transformer architectures, plays a pivotal role in LLMs’ ability to handle their large size. Self-attention mechanisms analyze the relationships between all tokens in a sequence, facilitating the capture of long-range dependencies. In large models, this attention mechanism is highly parallelizable, enabling efficient processing of extensive sequences. Pre-training : During pre-training, models learn general linguistic patterns, world knowledge, and contextual understandings. Transfer Learning : This transfer learning approach leverages the massive scale of pre-trained models to adapt to new tasks without needing to retrain from scratch. Generation Capacity: produce coherent and contextually relevant text across various domains
Components of Interaction with LLM
Limitations of LLM Knowledge Cutoff: Training data till some specific time Hallucination: Refers to a phenomenon where the model generates text that is incorrect, nonsensical, or not real . Bias: R efers to the phenomenon where the generated text from a LLM reflects or reinforces harmful stereotypes, prejudices, or discrimination against certain groups or individuals based on their social identities, such as gender, race, religion, ethnicity, age, disability Toxicity: LLMs can produce content that may be perceived as rude, disrespectful, or even outright prejudiced . These potentially harmful outputs can target specific groups based on their ethnicity, religion, gender, sexual orientation, or other distinct characteristics. Context Length: Context length refers to the maximum number of tokens the model can remember when generating text.
Gen AI Lifecycle
Prompt Engineering: Elements of a Prompt A prompt contains any of the following elements: Instruction - a specific task or instruction you want the model to perform Context - external information or additional context that can steer the model to better responses Input Data - the input or question that we are interested to find a response for Output Indicator - the type or format of the output. Prompt Examples (Type of Prompt Task): Text Summarization Information Extraction Question Answering Text Classification Conversation Code Generation Reasoning
Prompt Engineering: Zero Shot Prompting Zero-Shot Prompting: This is a technique that allows a model to make predictions on unseen data without requiring additional training.
Prompt Engineering: Few shot Prompting Few-Shot Prompting: Few-shot prompting involves training LLMs on a small amount of task-specific data to fine-tune their performance. Few-shot prompting allows a language model to adapt and generalize to a specific task by providing it with only a few labeled examples or demonstrations.
How to Choose a LLM Model: Domain-wise
Fine Tuning LLM LLM fine-tuning is a supervised learning process where you use a dataset of labeled examples to update the weights of LLM and make the model improve its ability for specific tasks . Examples: GPT-3 -> ChatGPT(chat use case) GPT-4 -> GitHub Copilot (auto-completion of code) Why LLM Finetuning: More consistent outputs Reduce hallucination Customize the model to a specific use case Types of Finetuning: Standard Fine-tuning Instruction Fine-tuning PEFT Parameter Efficient Fine –tuning) - LoRA
LLM Model Evaluation
LLM Model Evaluation(Contd.) Metric Name Metric Description Techniques Relevance Relevance measures how well the model's responses align with the user's input or query. It identifies whether the model is able to understand user’s objective and provide appropriate and on-topic response. F1-Score and BERT Coherence Evaluates how effectively the model generates coherent and logical responses which align with the context of the conversation. It determines the ability of the model to provide insightful and contextually relevant answers. BLEU (Bilingual Evaluation Understudy), ROGUE (Recall oriented understudy for gisting evaluation) and BERTScore Accuracy Measuring accuracy of the response involves verifying whether it conveys the correct information. The easiest way is to compare the LLM output to the expected or desired result. SequenceMatcher , Jaccard similarity coefficient, Percentage_of_words Bias We need to evaluate whether LLM output exhibit any unintended biases or stereotypes. It can be different types; one of them is gender bias. avg_bias_ratio metric from responsible AI Toolbox library Fluency Fluency is the measurement that how effectively the model’s responses are structured, grammatically correct, and linguistically coherent. mlanguage_tool_python library for grammer checking
Use Case 1 – Automated Resume Analyser and Fake Resume Identification Automated Resume Analyzer using OpenAI URL: https://www.linkedin.com/pulse/automated-resume-analyzer-using-openai-anindita-desarkar-phd-adowf https://www.linkedin.com/pulse/ui-based-fake-resume-analyzer-using-langchain-anindita-desarkar-phd-n0lxf Problem Statement: Identifying the right candidate by analyzing the CV is always a pain area for the HR professionals across the industry. The problem becomes more complicated when need to parse large set of CVs within short time-period. We can leverage the power of OpenAI and LLM towards automating the CV analysis process. It will help the recruiters to find the best match from the available sets automatically based on important features extracted through LLM. Solution Outline: Step 1: Download all the CVs in a specific path in the system. Step 2: Build the Questionnaire for which we need to extract information from the resumes stored in the above folder. Step 3: Read the CV from the path one by one and send to OpenAI. Step 4: The predefined set of questions (prepared in Step 2) will be processed for the selected CV using LLM. It will be performed for all the CVs present in the path. Step 5: Store all the answers against the questions for all the CVs in an excel file.
Use Case 1 – Automated Resume Analyser and Fake Resume Identification (Contd.) What you need? • You need an Open API key; you can get yourself one by registering on your personal id • Few sample CVs in pdf format, which will be the input dataset for this application. Questions which will be extracted from Resume:
Use Case 1 – Automated Resume Analyser and Fake Resume Identification (Contd.)
Use Case 1 – Automated Resume Analyser and Fake Resume Identification (Contd.) Display Output:
Use Case 1 – Automated Resume Analyser and Fake Resume Identification (Contd.) Resume Analytics and Insights: 1. Get all the requisite information about all the candidates in one shot. More questions can be added in the questionnaire based on requirement. 2. Identify the right candidate for the right position based on skillset and experience details. 3. Can understand the skill gap in the market based on the set of resumes. 4. Various comparisons can be performed among candidates automatically based on the above output.
Use Case 2 – Prompt Engineering towards Optimization Problem Formulation URL: (4) Significance of Prompt Engineering towards Optimization Problem Formulation | LinkedIn Optimization which is nothing but doing trade off among various features towards getting the optimal output! However, the word optimal varies based on the environment or system constraints. Let us take an example, an engineering graduate has 3 offers in hand; hence need to choose the optimal one from the following options. Option 1: Working in the same city he is currently in and enjoy weekly meet with friends and family; pay package with 3L/year. Option 2: Working other city but work in a domain which is his dream area; pay package with 5L/year. Option 3: Work abroad in some boring domain; pay package with 10L/year. So which option he is going to choose as optimal? This is a very common scenario, many of us have seen probably seen or experienced. And we all agree that there is no single answer to this question because different options will be chosen by different persona based on their priority. Hence, optimal solution is heavily dependent on environment or system.
Use Case 2 – Prompt Engineering towards Optimization Problem Formulation (Contd.) Example 1 - Problem Formulation with LLM: Profit Maximization There is a Biscuit manufacturing company which produces two types of biscuits – A and B. Two major ingredients are used here which are Milk and Choco. Following are the required quantities to manufacture each unit of A and B. • Each unit of A requires 1 unit of Milk and 3 units of Choco • Each unit of B requires 1 unit of Milk and 2 units of Choco The company has a total of 5 units of Milk and 12 units of Choco and it makes following profit on each sale (sold items): • Rs 6 per unit A • Rs 5 per unit B Now, the goal of the company is to maximize its profit. So, what will be the optimal units of A and B it should produce towards achieving its goal.
Use Case 2 – Prompt Engineering towards Optimization Problem Formulation (Contd.) query = "Give the pyomo code with bonmin solver that outputs the optimal units of A and B it should produce towards maximize the total profit ?“ prompt = start_phrase + query
Use Case 2 – Prompt Engineering towards Optimization Problem Formulation (Contd.) Code snippet and LLM Output
Use Case 2 – Prompt Engineering towards Optimization Problem Formulation (Contd.) Example 2 - Problem Formulation with LLM: Revenue Maximization Prompt Example:
Use Case 3 – Prompt Engineering towards Optimization Problem Formulation (Contd.) Magic of PaLM Model in Pair Programming URL: https://www.linkedin.com/pulse/magic-palm-model-pair-programming-anindita-desarkar-phd-uugmf Pair programming is an Agile software development methodology where two developers team together on one computer to design, code and testing for better outcome. However, it’s always not possible to get help from a colleague due to paucity of time and other priorities! A gain, LLM is our Saviour ! Scenario 1 - Generating Test Cases from Software Design Document/Technical Specification Document Scenario 2 - Generate Python Program from Algorithm Scenario 3 - Improve Existing Code based on Time and Space Complexity Scenario 4 - Debug Your Code
Use Case 3 – Prompt Engineering towards Optimization Problem Formulation (Contd.) Scenario 1 - Generating Test Cases from Software Design Document/Technical Specification Document Now we will see what the available models are in google.generativeai or palm which we can use in pair programming context. Following output represents the models. Model(name='models/text-bison-001', base_model_id ='', version='001', display_name =' Text Bison ', description='Model targeted for text generation.', input_token_limit =8196, output_token_limit =1024, supported_generation_methods =[' generateText ', ' countTextTokens ', ' createTunedTextModel '], temperature=0.7, top_p =0.95, top_k =40),