AI
Machine Learning
Field of study that gives computers the ability to learn without being explicitly programmed.
- Arthur Samuel (1959)
Algorithms which can learn from data and respond accordingly.
How it works?
- Huge datasets
- Find pattern in data
- Generalised pattern found
- Algorithm makes intelligent decisions based on the patterns it has recognised.
Supervised learning
Given a dataset with inputs and labels , supervised learning determines relation/mapping between X and Y, so that for a given , the algorithm can determine .
- Regression: Y is continuous. For example, housing prices
- Classification: Y is discreet. For example, tumour being malignant (1) or benign (0).
Support vector machines: Infinite number of inputs. Uses Kernel
Generative AI
Prompting
Prompt Components
Set the context:
Component | Description | Example |
---|---|---|
Particpants | Who is sending and receiving the model's output | You are a world-renowned cake decorator. Your customers include families, newlyweds, and children. |
Setting | Contextual information | You have a well-loved bakery known for its cakes. You also have a popular blog read by your customers. You are writing your latest blog post. |
Goal | What is to be achieved with the output | You want to capture customers’ attention while teaching them about novel decorating techniques. |
Relationships | between the participants involved. Also, how the output related to the participants | Your customers have a sweet tooth and are always curious about new cakes you make with fresh methods. |
Data | Give the model data to work with | Your bakery has a new line of cakes that you'd like to advertise to customers |
Give clear instructions: Tell the LLM what type of content you want and what it must include.
Set the constraints:
Component | Description | Example |
---|---|---|
Limits | Guardrails that the models must stay within to prevent it from hallucinating | You must follow the given instructions. You must not address any content or generate answers that you don’t have data on or basis for. |
Language | Write the blog in English. | |
Style and Tone | The blog must be written at an 8th grade reading level and use adjectives to evoke imagery in the prose. Use brief, declarative sentences in an active voice. Strictly avoid using filler words, slang, and redundant language. The blog must be less than 600 words. |
Training the model within prompt
Zero-shot prompting
- When you provide a prompt which is not part of the training data.
- Basically, you are not giving any example to help it out.
- Even if the model has not seen the prompt before, it can generate a good-enough output close to the desirable outcome you expected.
Which is why LLMs are so useful for performing tasks without needing retraining.
One-shot Prompting
- When you provide one example within the prompt to guide the model
- You are basically training the model shortly and nudging it towards the expected behaviour.
Few-shot prompting
- When you provide multiple examples in your prompt
- This better demonstrates the expected outcome in certain scenarios
- The model can generalise from the examples, and give more precise output.
For example,
Nudges
You can nudge the LLM towards certain behaviour by injecting some sentences into the prompt.
Its not entirely understood yet, as to why these sentences influence LLM behaviour, but these nudges possibly direct LLMs towards certain kinds of training data.
For example, if you use a nudge for accuracy, it might guide LLM towards dataset which prioritises thoroughness and precision.
Accuracy
Nudge the LLM to be more accurate by including the following phrases in the prompt:
Correctness is a life or death situation.
Take a deep breath and {{action}}
For example,
Take a deep breath and classify the following utterance.
Intent Classification
LLM can be used as a reasoning engine, to identify intent of a query by a user.
Intent classification prompt
You are an intent classification system. Correctness is a life or death situation.
We provide you with the actions and their descriptions:
d. When the user asks for a warm drink. a: WARM_DRINK
d. When the user asks for something else. a: NONE
d: When the user asks for a cold drink. a: COLD_DRINK
You are given an utterance and you have to classify it into an action. Only respond with the action class.
Now take a deep breath and classify the following utterances.
u: I want a warm hot chocolate. a: WARM_DRINK
We provide you with the actions and their descriptions.
d:{{descriptions}} a: {{actions}}
You are given an utterance and you have to classify it into an action. Only respond with the action class.
Now take a deep breath and classify the following utterances.
{{utterances}}
Agents
Agents are a new type of software that are capable of thinking, acting, and making decisions with the help of AI within safe, predefined boundaries. Think of them as your digital assistants, always ready to lend a hand. From supercharging employee productivity to tackling tasks independently, agents expand your team’s capacity and capabilities.
Any AI development platform will have to segregate the different capabilities the agent is able to perform. First it identifies the path to follow, and then acts on basis of the particular action or function and the knowledge defined within that path or topic.