Week2 Llms
Week2 Llms
Week2 Llms
ETMI5: Explain to Me in 5
In this section, we delve into the limitations of general AI models in specialized
domains, underscoring the significance of domain-adapted LLMs. We explore
the advantages of these models, including depth, precision, improved user
experiences, and addressing privacy concerns.
Introduction
Prompting
Prompt Engineering
Prompt engineering, a rapidly growing field, revolves around refining
prompts to unleash the full potential of Language Models in various
applications.
Why Prompting?
Large language models are trained through a process called unsupervised
learning on vast amounts of diverse text data. During training, the model learns
to predict the next word in a sentence based on the context provided by the
preceding words. This process allows the model to capture grammar, facts,
reasoning abilities, and even some aspects of common sense.
2. Training Data Patterns: During training, the model learns from a wide
range of text, capturing the linguistic nuances and patterns present in the
data. Effective prompts leverage this training by incorporating similar
language and structures that the model has encountered in its training data.
This enables the model to generate responses that are consistent with its
learned patterns.
5. Mitigating Bias: The model may inherit biases present in its training data.
Thoughtful prompts can help mitigate bias by providing additional context or
framing questions in a way that encourages unbiased responses. This is
crucial for aligning model outputs with ethical standards.
1. Instruction: Clearly specify the task or action you want the model to
perform. This sets the context for the model's response and guides its
behavior.
3. Input Data: Include the input or question for which you seek a response.
This is the information on which you want the model to act or provide
insights.
4. Output Indicator: Define the type or format of the desired output. This
guides the model in presenting the information in a way that aligns with your
expectations.
Prompt:
In this example:
Note that this example doesn't explicitly use context, but context can also be
incorporated into the prompt to provide additional information that aids the
model in understanding the task better.
It's important to highlight that not all four elements are always necessary for a
prompt, and the format can vary based on the specific task. The key is to
1. Use the Latest Model: For optimal results, it is recommended to use the
latest and most capable models.
7. Provide Positive Guidance: Instead of stating what not to do, clearly state
what actions should be taken in a given situation, offering positive guidance.
Zero-shot involves adding the prompt "Let's think step by step" to the original
question to guide the LLM through a systematic reasoning process. Few-shot
prompting provides the model with a few examples of similar problems to
enhance reasoning abilities. These CoT methods prompt significantly improves
the model's performance by explicitly instructing it to think through the problem
step by step. In contrast, without the special prompt, the model fails to provide
the correct answer.
Key Characteristics:
This work arises from the fact that human thought processes often follow non-
linear patterns, deviating from simple sequential chains. In response, the
authors propose Graph-of-Thought (GoT) reasoning, a novel approach that
models thoughts not just as chains but as graphs, capturing the intricacies of
non-sequential thinking.
3. Self Consistency
4. ReACT
The ReAct framework combines reasoning and action in LLMs to enhance their
capabilities in dynamic tasks. The framework involves generating both verbal
reasoning traces and task-specific actions in an interleaved manner. ReAct aims
to address the limitations of models, like chain-of-thought , that lack access to
the external world and can encounter issues such as fact hallucination and error
propagation. Inspired by the synergy between "acting" and "reasoning" in
human learning and decision-making, ReAct prompts LLMs to create, maintain,
and adjust plans for acting dynamically. The model can interact with external
1. Dynamic Querying:
The process begins by querying the LLM with or without a few CoT
examples for a set of training questions.
2. Uncertainty Metric:
3. Selective Annotation:
4. Adaptive Learning:
The newly annotated exemplars are incorporated into the training data,
enriching the model's understanding and adaptability for those specific
questions.
The model learns from the newly annotated examples, adjusting its
responses based on the task-specific guidance provided.
3. Chain-of-Knowledge (CoK)
Risks
Prompting comes with various risks, and prompt hacking is a notable concern
that exploits vulnerabilities in LLMs. The risks associated with prompting
include:
1. Prompt Injection:
2. Prompt Leaking:
3. Jailbreaking:
5. Security Concerns:
Popular Tools
Here is a collection of well-known tools for prompt engineering. While some
function as end-to-end app development frameworks, others are tailored for
prompt generation and maintenance or evaluation purposes. The listed tools are
predominantly open source or free to use and have demonstrated good
adaptability. It's important to note that there are additional tools available,
although they might be less widely recognized or require payment.
1. PromptAppGPT:
2. PromptBench:
3. Prompt Engine:
4. Prompts AI:
5. OpenPrompt:
6. Promptify:
Features: Test suite for LLM prompts, perform NLP tasks in a few lines
of code, handle out-of-bounds predictions, output provided as Python
objects for easy parsing, support for custom examples and samples, run
inference on models from the Huggingface Hub.
Objective: Aims to facilitate prompt testing for LLMs, simplify NLP tasks,
and optimize prompts to reduce OpenAI token costs.
3. https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-
developers/
4. https://learnprompting.org/courses
2. https://arxiv.org/abs/2309.11495
3. https://arxiv.org/abs/2310.08123
4. https://arxiv.org/abs/2305.13626