You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 04_Explore_OpenAI_models/README.md
+58-8Lines changed: 58 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,34 +9,84 @@ Azure OpenAI is powered by a diverse set of models with different capabilities.
9
9
| GPT-4 | A set of models that improve on GPT-3.5 and can understand and generate natural language and code. |
10
10
| GPT-3.5 | A set of models that improve on GPT-3 and can understand and generate natural language and code. |
11
11
| Embeddings | A set of models that can convert text into numerical vector form to facilitate text similarity. |
12
-
| DALL-E | A series of models in preview that can generate original images from natural language. |
13
-
| Whisper | A series of models in preview that can transcribe and translate speech to text. |
12
+
| DALL-E | A series of models that can generate original images from natural language. |
13
+
| Whisper | A series of models that can transcribe and translate speech to text. |
14
14
15
15
### GPT-4 and GPT-3.5 Models
16
16
17
17
GPT-4 can solve difficult problems with greater accuracy than any of OpenAI's previous models. Like GPT-3.5 Turbo, GPT-4 is optimized for chat and works well for traditional completions tasks.
18
18
19
19
The GPT-35-Turbo and GPT-4 models are language models that are optimized for conversational interfaces. The models behave differently than the older GPT-3 models. Previous models were text-in and text-out, meaning they accepted a prompt string and returned a completion to append to the prompt. However, the GPT-35-Turbo and GPT-4 models are conversation-in and message-out. The models expect input formatted in a specific chat-like transcript format, and return a completion that represents a model-written message in the chat. While this format was designed specifically for multi-turn conversations, you'll find it can also work well for non-chat scenarios too.
20
20
21
+
### Embeddings
22
+
23
+
Embeddings, such as the `text-embedding-ada-002` model, measure the relatedness of text strings.
24
+
25
+
Embeddings are commonly used for the following:
26
+
27
+
-**Search** - results are ranked by relevance to a query string
28
+
-**Clustering** - text strings are grouped by similarity
29
+
-**Recommendations** - items with related text strings are recommended
30
+
-**Anomaly detection** - outliers with little relatedness are identified
31
+
-**Diversity measurement** - similarity distributions are analyzed
32
+
-**Classification** - text strings are classified by their most similar label
33
+
21
34
### DALL-E
22
35
23
-
The DALL-E model, enables the use of a text prompt provided by a user as the input that the model then uses to generate an image response.
36
+
DALL-E is a model that can generate an original images from a natural language text description given as input.
37
+
38
+
### Whisper
39
+
40
+
Whisper is a speech recognition model, designed for general-purpose applications. Trained on an extensive dataset encompassing diverse audio inputs, and operates as a multi-tasking model capable of executing tasks like multilingual speech recognition, speech translation, and language identification.
24
41
25
42
## Selecting an LLM
26
43
27
-
Before a Large Language Model (LLM) can be implemented into a solution, an LLM model must be chosen.
44
+
Before a Large Language Model (LLM) can be implemented into a solution, an LLM model must be chosen. For this the business use case and other aspects to the overall goal of the AI solution will need to be defined.
45
+
46
+
Once the business goals of the solution are known, there are a few key considerations to think about:
28
47
48
+
-**Business Use Case** - What are the specific tasks the business needs the AI solution to perform? Each LLM is designed for different goals, such as text generation, language translation, image generation, answering questions, code generation, etc.
49
+
-**Pricing** - For cases where there may be multiple LLMs to choose from, the [pricing](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/) of the LLM could be a factor to consider. For example, when choosing between GPT-3.5 or GPT-4, it may be worth to consider that the overall cost of GPT-4 may be higher than GPT-3.5 for the solution since GPT-4 requires more compute power behind the scenes than GPT-3.5
50
+
-**Accuracy** - For cases where there may be multiple LLMs to choose from, the comparison of accuracy between them may be a factor to consider. For example, GPT-4 offers improvements over GPT-3.5 and depending on the use case, GPT-4 may provide increased accuracy.
51
+
-**Quotas and limits** - The Azure OpenAI service does have [quotas and limits](https://learn.microsoft.com/azure/ai-services/openai/quotas-limits) on using the service. This may affect the performance and pricing of the AI solution. Additionally, some of quotas and limits may vary depending on the Azure Region that is used to host the Azure OpenAI service. The potential impact of these on the pricing and performance of the solution will want to be considered in the design phase of the solution.
29
52
53
+
## Do I use an out-of-the-box model or a fine-tuned model?
30
54
55
+
A base model is a model that hasn't been customized or fine-tuned for a specific use case. Fine-tuned models are customized versions of base models where a model's
56
+
weights are trained on a unique set of prompts. Fine-tuned models let you achieve
57
+
better results on a wider number of tasks without needing to provide detailed examples for in-context learning as part of your completion prompt.
31
58
59
+
The [fine-tuning guide](https://learn.microsoft.com/azure/ai-services/openai/how-to/fine-tuning) can be referenced for more information.
32
60
33
61
## Explore and use models from code
34
62
35
-
- Completions
36
-
- Chat completions
37
63
64
+
### OpenAI Client Library
38
65
66
+
When integrating Azure OpenAI service in a solution written in Python, the OpenAI Python client library is used. This library is maintained by OpenAI, and is compatible with the Azure OpenAI service.
39
67
40
-
## Do I use an out-of-the-box model or a fine-tuned model?
68
+
Install the latest `openai` client library:
69
+
```bash
70
+
pip install openai
71
+
```
72
+
73
+
When using the OpenAI client library, the `key` and `endpoint` for the Azure OpenAI service will be needed. This will enable the application to make API calls against the Azure OpenAI service.
74
+
75
+
The Azure OpenAI service `key` and `endpoint` can be located on **Azure OpenAI** blade in the Azure Portal on the **Keys and Endpoint** pane.
76
+
77
+

78
+
79
+
It is helpful to set these as environment variables, then reference those environment variables from code. Here's an example of this using the recommended environment variable names:
0 commit comments