Skip to content

Commit 5f75215

Browse files
committed
-
0 parents  commit 5f75215

22 files changed

+5233
-0
lines changed

1.code.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# From NLP to Large Language Models
2+
3+
4+
## What is Natural Language Processing?
5+
6+
7+
## Language models
8+
9+
10+
## Statistical models (n-grams)
11+
12+
13+
## Knowledge-based models
14+
15+
16+
## Contextual language models
17+
18+
19+
## Neural network-based models
20+
21+
22+
### Feedforward neural networks
23+
24+
25+
### Recurrent neural networks (RNNs)
26+
27+
28+
### Long short-term memory (LSTM)
29+
30+
31+
### Gated recurrent units (GRUs)
32+
33+
34+
## Transformer models
35+
36+
37+
### Bidirectional encoder representations from transformers (BERT)
38+
39+
40+
### Generative pre-trained transformer (GPT)
41+
42+
43+
## What's next?

10.code.md

+192
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# Transfer Learning
2+
3+
4+
## What is transfer learning?
5+
6+
7+
## Inductive transfer
8+
9+
10+
## Transductive transfer
11+
12+
13+
## Inductive vs. transductive transfer
14+
15+
16+
## Transfer learning, fine-tuning, and prompt engineering
17+
18+
19+
## Fine-tuning with a prompt dataset: a practical example
20+
21+
22+
```text
23+
Q. What is SkillUp Academy?
24+
A. SkillUp Academy is an online learning platform offering a variety of courses across multiple disciplines, enabling learners to gain knowledge and skills at their own pace from anywhere in the world.
25+
26+
Q. How do I sign up?
27+
A. Just click on the "Sign Up" button on our homepage, provide your details, and get started!
28+
29+
Q. How can I pay for a course?
30+
A. We accept payments through PayPal, and Stripe.
31+
32+
Q. I am not satisfied with the course. Can I get a refund?
33+
A. Yes, we offer a 30-day money-back guarantee. If you're not satisfied within this period, you can request a refund. Please see our refund policy for details.
34+
35+
Q. Where can I find the terms of service for the website?
36+
A. Our terms of service can be found at the footer of our website or by clicking here.
37+
38+
Q. Is my personal information secure?
39+
A. Absolutely. We prioritize your privacy and have stringent measures in place to protect your data. Read more in our privacy policy here.
40+
41+
Q. Can I learn at my own pace?
42+
A. Yes, our courses are designed to allow you to learn at your convenience. Once you enroll, you'll have access to the course materials for a specific period, during which you can learn at your own pace.
43+
44+
Q. I have questions about the course content. How can I get them answered?
45+
A. Most courses have a discussion forum where you can ask questions, engage with fellow learners, and sometimes get responses from the course instructors.
46+
47+
Q. Can I access the courses on mobile?
48+
A. Yes, our platform is mobile-friendly, and we also have a dedicated app available for both Android and iOS.
49+
50+
Q. I'm an instructor. How can I offer a course on your platform?
51+
A. We're always looking for knowledgeable instructors. Just head to our 'Become an Instructor' page for details on how to collaborate with us.
52+
53+
Q. Do you offer certificates upon course completion?
54+
A. Yes, once you successfully complete a course and pass any required assessments, you will receive a certificate of completion.
55+
56+
Q. What should I do if I face technical issues?
57+
A. Please reach out to our support team via the 'Contact Us' page, and they'll be happy to assist you.
58+
```
59+
60+
61+
```json
62+
{"prompt": "lorem ipsum dolor sit amet.END_PROMPT", "completion": " consectetur adipiscing elit.\n"}
63+
{"prompt": "Vivamus vel lacus quis diam vestibulum scelerisque.END_PROMPT", "completion": " Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n"}
64+
...etc
65+
```
66+
67+
68+
```json
69+
{"prompt": "What is SkillUp Academy->", "completion": " SkillUp Academy is an online learning platform offering a variety of courses across multiple disciplines, enabling learners to gain knowledge and skills at their own pace from anywhere in the world.\n"}
70+
{"prompt": "How do I sign up->", "completion": " Just click on the \"Sign Up\" button on our homepage, provide your details, and get started!\n"}
71+
{"prompt": "How can I pay for a course->", "completion": " We accept payments through PayPal, and Stripe.\n"}
72+
{"prompt": "I am not satisfied with the course. Can I get a refund->", "completion": " Yes, we offer a 30-day money-back guarantee. If you're not satisfied within this period, you can request a refund. Please see our refund policy for details.\n"}
73+
{"prompt": "Where can I find the terms of service for the website->", "completion": " Our terms of service can be found at the footer of our website or by clicking here.\n"}
74+
{"prompt": "Is my personal information secure->", "completion": " Absolutely. We prioritize your privacy and have stringent measures in place to protect your data. Read more in our privacy policy here.\n"}
75+
{"prompt": "Can I learn at my own pace->", "completion": " Yes, our courses are designed to allow you to learn at your convenience. Once you enroll, you'll have access to the course materials for a specific period, during which you can learn at your own pace.\n"}
76+
{"prompt": "I have questions about the course content. How can I get them answered->", "completion": " Most courses have a discussion forum where you can ask questions, engage with fellow learners, and sometimes get responses from the course instructors.\n"}
77+
{"prompt": "Can I access the courses on mobile->", "completion": " Yes, our platform is mobile-friendly, and we also have a dedicated app available for both Android and iOS.\n"}
78+
{"prompt": "I'm an instructor. How can I offer a course on your platform->", "completion": " We're always looking for knowledgeable instructors. Just head to our 'Become an Instructor' page for details on how to collaborate with us.\n"}
79+
{"prompt": "Do you offer certificates upon course completion->", "completion": " Yes, once you successfully complete a course and pass any required assessments, you will receive a certificate of completion.\n"}
80+
{"prompt": "What should I do if I face technical issues->", "completion": " Please reach out to our support team via the 'Contact Us' page, and they'll be happy to assist you.\n"}
81+
```
82+
83+
84+
```bash
85+
pip install openai[datalib]
86+
```
87+
88+
89+
```bash
90+
export OPENAI_API_KEY=<your-api-key>
91+
```
92+
93+
94+
```bash
95+
openai tools fine_tunes.prepare_data -f data.jsonl
96+
```
97+
98+
99+
```bash
100+
Analyzing...
101+
102+
- Your file contains 12 prompt-completion pairs. In general, we recommend having at least a few hundred examples. We've found that performance tends to linearly increase for every doubling of the number of examples
103+
- All prompts end with suffix `->`
104+
- All completions end with suffix `\n`
105+
106+
No remediations found.
107+
108+
You can use your file for fine-tuning:
109+
> openai api fine_tunes.create -t "data.jsonl"
110+
111+
After you’ve fine-tuned a model, remember that your prompt has to end with the indicator string `->` for the model to start generating completions, rather than continuing with the prompt. Make sure to include `stop=["\n"]` so that the generated texts ends at the expected place.
112+
Once your model starts training, it'll approximately take 2.61 minutes to train a `curie` model, and less for `ada` and `babbage`. Queue will approximately take half an hour per job ahead of you.
113+
```
114+
115+
116+
```bash
117+
openai api fine_tunes.create -t "data.jsonl" -m curie --suffix "SkillUpAcademy"
118+
```
119+
120+
121+
```bash
122+
Upload progress: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.47k/2.47k [00:00<00:00, 8.63Mit/s]
123+
Uploaded file from data.jsonl: file-RdACszHknKQC49hdZdGxpoEA
124+
Created fine-tune: ft-WEYpsygNbeHy8YvxLCaiyB4i
125+
Streaming events until fine-tuning is complete...
126+
127+
(Ctrl-C will interrupt the stream, but not cancel the fine-tune)
128+
[..] Created fine-tune: ft-WEYpsygNbeHy8YvxLCaiyB4i
129+
[..] Fine-tune costs $0.01
130+
[..] Fine-tune enqueued. Queue number: 0
131+
132+
...etc
133+
```
134+
135+
136+
```bash
137+
openai api fine_tunes.follow -i ft-WEYpsygNbeHy8YvxLCaiyB4i
138+
```
139+
140+
141+
```bash
142+
[..] Created fine-tune: ft-WEYpsygNbeHy8YvxLCaiyB4i
143+
[..] Fine-tune costs $0.01
144+
[..] Fine-tune enqueued. Queue number: 0
145+
[..] Fine-tune started
146+
[..] Completed epoch 1/4
147+
[..] Completed epoch 2/4
148+
[..] Completed epoch 3/4
149+
[..] Completed epoch 4/4
150+
[..] Uploaded model: curie:ft-org:skillupacademy-2023-08-18-14-32-18
151+
[..] Uploaded result file: file-3fxL6gfapDyHqG7cjXDzFFOf
152+
[..] Fine-tune succeeded
153+
154+
Job complete! Status: succeeded 🎉
155+
Try out your fine-tuned model:
156+
157+
openai api completions.create -m curie:ft-faun:skillupacademy-2023-08-18-14-32-18 -p <YOUR_PROMPT>
158+
```
159+
160+
161+
```python
162+
import openai
163+
import os
164+
165+
openai.api_key = os.getenv("OPENAI_API_KEY")
166+
167+
model = "curie:ft-faun:skillupacademy-2023-08-18-14-32-18"
168+
prompt = input("Ask a question: ")
169+
instruction = f"""
170+
You are a helpful and smart customer service representative for SkillUp Academy.
171+
Answer the following questions based on the training data provided.
172+
If you don't know the answer, just say 'Sorry, I don't know the answer.'
173+
174+
AI: Hi there. I am Felix, the chatbot. How can I help you today?
175+
User: {prompt}
176+
"""
177+
178+
full_prompt = instruction + " " + prompt + "->"
179+
180+
response = openai.Completion.create(
181+
model=model,
182+
prompt=full_prompt,
183+
max_tokens=100, # adjust based on your need
184+
stop=["\n"],
185+
temperature=0 # strikes a balance between deterministic and random
186+
)
187+
188+
print(response.choices[0].text.strip())
189+
```
190+
191+
192+
## Why is prompt engineering vital for transfer learning and fine-tuning?

0 commit comments

Comments
 (0)