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
-[Set Up Your Azure Environment](#set-up-your-azure-environment)
21
-
-[Set Up a Database for Context Storage](#set-up-a-database-for-context-storage)
22
-
-[Implement Contextual Memory in the Application](#implement-contextual-memory-in-the-application)
23
-
-[Example](#example)
24
-
-[Other considerations:](#other-considerations)
25
-
-[Wiki](#wiki)
26
-
27
-
<!-- /TOC -->
28
13
29
-
Find below strategies to enhance process efficiency:
14
+
<details>
15
+
<summary><b>Table of Contents</b> (Click to expand)</summary>
16
+
17
+
-[General Overview](#general-overview)
18
+
-[Set Up Your Azure Environment](#set-up-your-azure-environment)
19
+
-[Set Up a Database for Context Storage](#set-up-a-database-for-context-storage)
20
+
-[Implement Contextual Memory in the Application](#implement-contextual-memory-in-the-application)
21
+
-[Example](#example)
22
+
-[Other considerations:](#other-considerations)
23
+
-[Wiki](#wiki)
24
+
25
+
</details>
26
+
27
+
28
+
> Find below strategies to enhance process efficiency, these approaches can significantly reduce computational demands and enhance model efficiency in chatbot applications.
30
29
31
30
-[Contextual Memory](#implement-contextual-memory-in-the-application): Implement a server-side system that retains conversation context. This allows for sending only new user requests to the model, with the server adding necessary context before the API call.
32
31
-**Prompt Compression**: Apply techniques to shorten the prompt by removing non-essential words, simplifying sentences, and concentrating on key context and instructions.
33
32
-**Batch Processing**: For multiple queries, group them into a single API call to decrease request numbers and boost efficiency.
34
33
-**Parameterization**: Use a parameterized format for prompts to allow dynamic input substitution, reducing prompt size while keeping it flexible.
35
34
-**Preprocessing**: Clean and preprocess input data to eliminate unnecessary whitespace, punctuation, and formatting issues, optimizing prompt processing efficiency.
36
35
37
-
These approaches can significantly reduce computational demands and enhance model efficiency in chatbot applications.
38
-
39
36
## General Overview
40
37
### Set Up Your Azure Environment
41
38
@@ -45,7 +42,9 @@ These approaches can significantly reduce computational demands and enhance mode
45
42
|**Deploy a Model**| 1. **Navigate to Azure OpenAI Studio**: <br> - Go to Azure OpenAI Studio. <br> - Sign in with your Azure credentials. <br> 2. **Create a Deployment**: <br> - Select your Azure OpenAI resource. <br> - Click on `Deployments` and then `Create new deployment`. <br> - Choose the model you want to deploy (e.g., GPT-4). <br> - Configure the deployment settings and click `Create`. |
46
43
47
44
### Set Up a Database for Context Storage
48
-
Using Azure SQL Database:
45
+
46
+
> Using Azure SQL Database:
47
+
49
48
1. Create an Azure SQL Database:
50
49
- In the Azure Portal, click on `Create a resource`.
51
50
- Search for `SQL Database` and select it.
@@ -54,17 +53,17 @@ Using Azure SQL Database:
54
53
2. Configure the Database:
55
54
- Set up the firewall rules to allow your application to connect to the database.
56
55
- Create a table to store conversation context.
57
-
58
-
```sql
59
-
CREATETABLEcontext (
60
-
user_id NVARCHAR(50) PRIMARY KEY,
61
-
conversation NVARCHAR(MAX)
62
-
);
63
-
```
56
+
57
+
```sql
58
+
CREATETABLEcontext (
59
+
user_id NVARCHAR(50) PRIMARY KEY,
60
+
conversation NVARCHAR(MAX)
61
+
);
62
+
```
64
63
65
64
## Implement Contextual Memory in the Application
66
65
67
-
To implement contextual memory, you'll need to store and manage the conversation context on the server. This way, you only have to send the user's most recent request with each request. Here's a step-by-step guide to getting started:
66
+
>To implement contextual memory, you'll need to store and manage the conversation context on the server. This way, you only have to send the user's most recent request with each request. Here's a step-by-step guide to getting started:
68
67
69
68
- Set Up a Server: To store the conversation context. This can be done using a web server with a database.
70
69
- Store Conversation Context: When a user sends a message, store the conversation context in a database. This context can include the user’s previous messages, the bot’s responses, and any other relevant information.
@@ -73,7 +72,7 @@ To implement contextual memory, you'll need to store and manage the conversation
73
72
74
73
### Example
75
74
76
-
Here’s a simplified example using Python and a database like Azure SQL. For more information on how to connect to the SQL database click [here](https://learn.microsoft.com/en-us/azure/azure-sql/database/azure-sql-python-quickstart?view=azuresql&tabs=windows%2Csql-auth#add-code-to-connect-to-azure-sql-database). For more about Azure OpenAI On Your Data API click [here](https://learn.microsoft.com/en-us/azure/ai-services/openai/references/on-your-data?tabs=python)
75
+
> Here’s a simplified example using Python and a database like Azure SQL. For more information on how to connect to the SQL database click [here](https://learn.microsoft.com/en-us/azure/azure-sql/database/azure-sql-python-quickstart?view=azuresql&tabs=windows%2Csql-auth#add-code-to-connect-to-azure-sql-database). For more about Azure OpenAI On Your Data API click [here](https://learn.microsoft.com/en-us/azure/ai-services/openai/references/on-your-data?tabs=python)
Use the Azure OpenAI API to send the prompt and receive the response. Click [here](https://learn.microsoft.com/en-us/azure/ai-services/openai/quickstart?tabs=command-line%2Cpython-new&pivots=programming-language-python) if want to see more.
146
+
> [!TIP]
147
+
> Use the Azure OpenAI API to send the prompt and receive the response. Click [here](https://learn.microsoft.com/en-us/azure/ai-services/openai/quickstart?tabs=command-line%2Cpython-new&pivots=programming-language-python) if want to see more.
- To enhance context management, consider truncating older parts of the conversation, summarizing previous discussions, and using tokens effectively to manage prompt size.
191
192
- For security and privacy, ensure the stored context is secure and adheres to privacy laws by encrypting sensitive data, implementing access controls, and ensuring compliance with data protection regulations like GDPR and CCPA.
0 commit comments