Open manisnesan opened 1 year ago
https://gist.github.com/joeddav/a11e5cc0850f0e540324177a53b547ae
Python wrapper around ChatGPT API
Instruction: Tell the model what you want
Extract the name of the author from the quotation below.
“Some humans theorize that intelligent species go extinct before they can expand into outer space. If they're correct, then the hush of the night sky is the silence of the graveyard.” ― Ted Chiang, Exhalation Output:
Ted Chiang
Completion: Induce the model to complete the beginning of what you want
“Some humans theorize that intelligent species go extinct before they can expand into outer space. If they're correct, then the hush of the night sky is the silence of the graveyard.” ― Ted Chiang, Exhalation
The author of this quote is Output:
Ted Chiang
Demonstration: Show the model what you want, with either: A few examples in the prompt Many hundreds or thousands of examples in a fine-tuning training dataset - Few Shot prompts
Quote: “When the reasoning mind is forced to confront the impossible again and again, it has no choice but to adapt.” ― N.K. Jemisin, The Fifth Season Author: N.K. Jemisin
Quote: “Some humans theorize that intelligent species go extinct before they can expand into outer space. If they're correct, then the hush of the night sky is the silence of the graveyard.” ― Ted Chiang, Exhalation Author: Output:
Ted Chiang
Source : Openai cookbook
Source: cohere.ai - prompt Engineering • Give clearer instructions – the more explicit you articulate the desired task, it's inputs, and outputs, the better the results will be.
• Ask the model to answer as if it was an expert.
• Supply better examples. If you're demonstrating examples in your prompt, make sure that your examples are diverse and high quality.
• Prompt the model to explain its reasoning using a prefix like "Let's think step by step". This is known as chain-of-thought reasoning
• Generate many outputs, and then use the model to pick the best one (an example of iterative refinement)
• If you're still having trouble, try splitting complex tasks into simpler subtasks
the two that immediately came to mind: https://lilianweng.github.io/posts/2023-03-15-prompt-engineering/ and https://www.oneusefulthing.org/p/a-guide-to-prompting-ai-for-what and this repo also gave me lots of ideas: https://github.com/f/awesome-chatgpt-prompts
Additional Resources for Prompt Engineering 1️⃣ Microsoft - Introduction to prompt engineering https://lnkd.in/dAfVftGG
2️⃣ Chip Huyen - Building LLM applications for production https://lnkd.in/dEiZqzpT
3️⃣ DAIR.AI - Prompt Engineering Guide https://lnkd.in/dXZdgM7e
4️⃣ PromptsLab - Awesome Prompt Engineering https://lnkd.in/dF9naw2a
5️⃣ Lilian Weng (OpenAI) - Prompt Engineering https://lnkd.in/dBTJRpZd
6️⃣ Microsoft - Prompt engineering techniques https://lnkd.in/dDzsJXhb
7️⃣ Cobus Greyling - Generative AI Prompt Pipelines https://lnkd.in/d5U5XkFd
8️⃣ Xavier (Xavi) Amatriain (LinkedIn) - Prompt Engineering 101 - Introduction and resources https://lnkd.in/drT8Z_Rq
9️⃣ Xavier (Xavi) Amatriain - Prompt Engineering: How to Talk to the AIs (course) https://lnkd.in/dGKqcWFj
Problem: ChatGPT - it doesn't know about YOUR data
Solution:
The main way of doing this is through a process commonly referred to as "Retrieval Augmented Generation".
In this process, rather than just passing a user question directly to a language model, the system "retrieves" any documents that could be relevant in answering the question, and then passes those documents (along with the original question) to the language model for a "generation" step.
The main way most people - including us at LangChain - have been doing retrieval is by using semantic search
Quoting Simon Willison analogy for language models
Think of language models like ChatGPT as a “calculator for words”
Idea
To enhance an existing Large Language Model with custom knowledge, there are 2 main methods:
Pros & Cons
Prompt Engineering and Retrieval Augmented Generation
instead of simply
Demonstrate-Search-Predict
Related to https://github.com/manisnesan/til/issues/33
Jeremy posed a Challenge if this can be written without langchain for comparison purpose in this tweet
"Help me build my intuition about ... "
A magic spell to learn anything
some examples, how to -get a fat ass -build a company -build an iOS app using the share sheet api -do advanced meditation techniques
Also add " with a memorable metaphor "
Use case 1: Can LLM answer the question (using APIChain) "Who was the CTO of Apple when it's share prices was at its lowest point in the last 10 years"
Use case 2: "Find me flights from Toronto to Bangalore flying out on June 27 & returning on Aug 12, without transiting via the U.S and without involving a self-transfer"
Lean Approach: User Query -> [sequence of external API/data store calls] -> LLM synthesizes the answer Holy Grail: User Query -> LLM decomposes query -> calls appropriate external services where needed -> combines responses in coherent answer in requested format
Task decomposition
Next
Resources
Why
Challenges
This is based on the idea from KnowledgeOps talk by Amir Feizpour
Generate Tasks to achieve Objective -> Prioritize -> Execute -> Reflect on Performance -> Ask for user feedback/input
Creating a lung cancer detection model using visual transformer using ChatGPT https://chat.openai.com/c/c990f5d0-39bc-4a74-b845-585a20bdf29f
Example
https://github.com/Significant-Gravitas/Auto-GPT/blob/master/autogpt/config/ai_config.py
Related: https://github.com/manisnesan/til/issues/26#issuecomment-1527493329 and https://github.com/Aggregate-Intellect/practical-llms/blob/main/README.md#llmops-expanding-the-capabilities-of-language-models-with-external-tools
Challenges
Solution
What
Peter Bull's (from DrivenData) notes from the Full Stack Deep Learning LLM Bootcamp:
"Our new baseline for all NLP tasks will be asking an LLM to do the task."
Harnessing LLMs: Part I
https://www.linkedin.com/pulse/harnessing-llms-part-i-peter-bull/
LLM Observability
Fine tuning red pajama OSS LLM
@johnrobinsn shows how to take a base model and instruction tune it using the Alpaca dataset, including the steps required to prepare the data - but we can adapt this easily to our own data.
John Berryman quote from Inside GitHub working with LLMS behind GitHub copilot
The secret is that we don’t just have to provide the model with the original file that the GitHub Copilot user is currently editing; instead we look for additional pieces of context inside the IDE that can hint the model towards better completions.”
He continues, “There have been several changes that helped get GitHub Copilot where it is today, but one of my favorite tricks was when we pulled similar texts in from the user’s neighboring editor tabs. That was a huge lift in our acceptance rate and characters retained.”
Generative vs Extractive https://haystack.deepset.ai/blog/generative-vs-extractive-models/
Wayde Gilliam tips on Retrieval LLM
Example: You many ONLY use the provided documents to provide your answer and you should always include a citation that is the document's Id where it is used in the answer.
From @nirantk
How can you always keep your answers fresh and automatically updated?
Tutorial Colab Notebook here w/ Detailed Diagrams: bit.ly/updatedQAColab
Built with (@CohereAI + @OpenAI + @qdrant_engine) using @llama_index
Production
All the Hard Stuff Nobody Talks About when Building Products with LLMs
Phillip Carter shares lessons learned building LLM features for Honeycomb - hard won knowledge from building a query assistant for turning human questions into Honeycomb query filters.
Building LLM Applications for Production - Chip Huyen
Discusses the MLOps Challenges such as the following in building LLM applications in production
Consistency | Hallucination | Privacy | Data Drift | Context Length | Model Updates & Compatibility | LM On the Edge
https://home.mlops.community/home/videos/building-llm-applications-for-production
Yet to review the other talks that I missed
Part 1 can found in this link (Apr 2023) https://home.mlops.community/home/collections/llms-in-production-conference-2023-04-13
Landing Section
https://github.com/Aggregate-Intellect/practical-llms/blob/main/README.md
Update: Twitter thread, Slides and Recording available as of Mar 14, 2023
LLM Interfaces Workshop and Hackathon
https://lu.ma/llm-interfaces - Apr 28, 2023
Excellent talks
Considerations
Source : Pratik Pakodas - Substack
Courses
Check them out: deeplearning.ai/short-courses/