---
# System prepended metadata

title: 'Prompt engeneering phase [WIP]'

---

[TOC]



#  Prompt engeneering phase [WIP]
A improvement in the text generation. Enhancing the text's cohesion and getting ready for the fine-tuning phase. The user-collected context must be added to the gpt3 queries in order to enhance the outcomes.

## Regarding services
- Wizard
- Site Generator
- profile_fast_HTTP_API
- GPT3 backend(merge?)

## Problems
with the current version
- Poor connectivity of texts
- No global user state(!)
- Server side rendering(codex stopper)
- Lack of two-way communication with users
- The complexity of adding new queries to gpt
- Incorrect stack

## Benefits
after improvements
- More pertinent texts are produced
- Ability to generate texts, taking into account the information received from the user
- The capacity to work with query structures and complex queries
- Cheaper/faster way to create a sitnetic dataset for fine-tuning
- Possibility of extending the logic behind picture generation, as well as website structure and style generation, using only English.
- Ability to extend wizzard with content editing/regeneration plugin
- Obtaining a customized website in HTML

## Losses
- Increased gpt-3 query costs
- Change server side to client side pages generation


## Tasks overview
- Using context, improve the quality of generated texts
- Extraction of commercial properties
- Generation of synthetic characteristics
- Categorization experiments
- Prompt engineering
- Evaluation processes for testing text creation results (Anna)
- Increase server flexibility so logic and requests to GPT3 can be added rapidly
- Design awesome UI (somebody)

# Frontend wizard

## User data retreiving algo
Given that every user has a different set of preferences, we offer full-text cues as a way for them to quickly and easily verify the applicability of the services offered, explained, and reviewed. Most significantly, though, we gather information to construct user context. Except for the first point, all other points may be skipped or generated automatically.

1. We learn the area's precise location and the business speciality
2. Produce a list of 10 services and let the user select or update them.
3. Append summarized services list to user context
4. Create a list of the top 10 reasons your clients love you and let the user select or update them
5. Append summarized reasons list to user context
6. Provide the user with three names to select any or modify
7. Append selected name to user context
8. Provide 3 slogan options to select any or modify
9. Append selected slogan to user context
10. From the data that is received, we build a context that we pass to make content building GPT-3 requests

> We use the context we previously gathered to generate hints for each of new items.

## Need help
1. Scheme, UX, design
2. Front?

# GPT3 proxy
Render engine? with ability to make requests to gpt3

> Data logic:
> Client <-> State -> GPT3 prompts -> HTML templates

> State machine:
> Category && Location -> Services -> Loves -> Business Name -> Slogan -> Context
> Context -> Services descriptions
> Context -> About me
> Context -> Reviews
> Context -> Domain names list
> Context -> Ads
> Context -> Any(Images|Texts)
> Full context -> HTML
> HTML <-> HTML

## Things
 - Ability to easely add prompts using templates
 - Ability to make templates execution controlled by state machine
 - Global state to share results and knowledge between executions and requests
 - Maintain an intermediate state to construct custom requests
 - State machine
 - HTML Templates?
 - Codex tempalates?
 - Logic update?
 - Node? Amplify, lambda, step functions?
 - Cache?

## Routes
The following pseudo-routes skip some logic but provide a concept of how client, server, and gpt3 communicate. There are also examples of Minnesotan barbers, but you can list any specialty(although the more specific the better) and location(you can write more precisely).
> The screenshots show the data we send into gpt3 in white and the data we receive in response in green.

### User Services
- getUserServices`(category: string, location: string|Location, previous?: string): ExecutionId, ServicesText`
> 
![](https://i.imgur.com/YGAjBSw.png)

```javascript
const { Configuration, OpenAIApi } = require("openai");

const configuration = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);

const response = await openai.createCompletion({
  model: "text-davinci-002",
  prompt: "I have a barber business in Minnesota. List the top 10 services that i can offer in brief form:\n1.",
  temperature: 1,
  max_tokens: 1024,
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0,
});
```
> Can generate 10, and then 10 more services, and then 10 more. When previous is specified, we add " Add more 10:\n{List next number}" to the gpt3 query.

 - setUserServices`(ExecutionId, ServicesText: string): ExecutionId`
Create shortest context from services
![](https://i.imgur.com/ehmduid.png)

```javascript
const response = await openai.createCompletion({
  model: "text-davinci-002",
  prompt: "I have a barber business in Minnesota. List the top 10 services that i can offer in brief form:\n1. Haircuts\n2. Beard Trims\n3. Hot Towel Shaves\n4. Facials\n5. Waxing\n6. Manicures\n7. Pedicures\n8. Shampooing\n9. Conditioning\n10. Styling\n\nWrite the dry properties from the text above, dry, comma separated and without numbers:",
  temperature: 1,
  max_tokens: 1024,
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0,
});
```
### Love Reasons
- getLoveReasons`(ExecutionId, previous?: string): ExecutionId, LoveReasons: string`
![](https://i.imgur.com/4Hf1HG1.png)

```javascript
const response = await openai.createCompletion({
  model: "text-davinci-002",
  prompt: "I have a barber business in Minnesota. I provide Haircuts, Beard Trims, Hot Towel Shaves, Facials, Waxing, Manicures, Pedicures, Shampooing, Conditioning, Styling.\n\nWrite 10 reasons why customers love me:\n1.",
  temperature: 1,
  max_tokens: 1024,
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0,
});
```
> When previous is specified, we add " Add more 10:\n{List next number}" to the gpt3 query.
 - setLoveReasons`(ExecutionId, LoveReasons: string): ExecutionId`
![](https://i.imgur.com/FKWpFAQ.png)
```javascript
const response = await openai.createCompletion({
  model: "text-davinci-002",
  prompt: "1. I provide an excellent haircutting experience.\n2. I am very personable and make my customers feel comfortable.\n3. I am excellent at beard trims.\n4. I give a great hot towel shave.\n5. I do an excellent job with facials.\n6. I am very experienced in waxing.\n7. I give great manicures and pedicures.\n8. I am excellent at shampooing and conditioning.\n9. I have a lot of experience in styling.\n10. I always go above and beyond for my customers.\n\nWrite the dry properties from the text above, dry, comma separated and without numbers:",
  temperature: 1,
  max_tokens: 1024,
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0,
});
```

### Business name
- getUserNames`(ExecutionId, previous?: string): ExecutionId, namesVariants: string`
![](https://i.imgur.com/ddoGwV6.png)
```javascript
const response = await openai.createCompletion({
  model: "text-davinci-002",
  prompt: "I have a barber business in Minnesota. \nMy services: Haircuts, Beard Trims, Hot Towel Shaves, Facials, Waxing, Manicures, Pedicures, Shampooing, Conditioning, Styling. \nCustomers love me because provide an excellent haircutting experience, personable, make customers feel comfortable, excellent beard trims, give great hot towel shave, excellent facials, experienced waxing, give great manicures and pedicures, excellent shampooing and conditioning, experienced styling, go above and beyond for customers.\n\nCome up with 3 awesome names for my business that don't look like each other:",
  temperature: 1,
  max_tokens: 256,
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0,
});
``` 
 - setUserName`(ExecutionId, Name: string): ExecutionId`

### Slogan
 - getUserSlogan`(ExecutionId, previous?: string): ExecutionId, slogansTexts`
![](https://i.imgur.com/V4zY8M8.png)
```javascript
const response = await openai.createCompletion({
  model: "text-davinci-002",
  prompt: "I have a barber business in Minnesota. \nMy business name Ace of Blades Barbershop.\nMy services: Haircuts, Beard Trims, Hot Towel Shaves, Facials, Waxing, Manicures, Pedicures, Shampooing, Conditioning, Styling. \nCustomers love me because provide an excellent haircutting experience, personable, make customers feel comfortable, excellent beard trims, give great hot towel shave, excellent facials, experienced waxing, give great manicures and pedicures, excellent shampooing and conditioning, experienced styling, go above and beyond for customers.\n\nCome up with 3 awesome slogans for my business that don't look like each other:",
  temperature: 1,
  max_tokens: 512,
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0,
});
```
 - setUserSlogan`(ExecutionId, SloganText: string): ExecutionId`
> Ready-to-use example context
 ```text
I have a barber business in Minnesota. 
My business name: Ace of Blades Barbershop.
My slogan: For the perfect cut, come to Ace of Blades! 
My services: Haircuts, Beard Trims, Hot Towel Shaves, Facials, Waxing, Manicures, Pedicures, Shampooing, Conditioning, Styling. 
Customers love me: provide an excellent haircutting experience, personable, make customers feel comfortable, excellent beard trims, give great hot towel shave, excellent facials, experienced waxing, give great manicures and pedicures, excellent shampooing and conditioning, experienced styling, go above and beyond for customers.
 ```

### About me
- getAboutMe`(ExecutionId): aboutMe: string`
![](https://i.imgur.com/kFDINXE.png)
```javascript
const response = await openai.createCompletion({
  model: "text-davinci-002",
  prompt: "I have a barber business in Minnesota. \nMy business name: Ace of Blades Barbershop.\nMy slogan: For the perfect cut, come to Ace of Blades! \nMy services: Haircuts, Beard Trims, Hot Towel Shaves, Facials, Waxing, Manicures, Pedicures, Shampooing, Conditioning, Styling. \nCustomers love me: provide an excellent haircutting experience, personable, make customers feel comfortable, excellent beard trims, give great hot towel shave, excellent facials, experienced waxing, give great manicures and pedicures, excellent shampooing and conditioning, experienced styling, go above and beyond for customers.\nText characteristics: About my business, long story, long text, from first person.\nText:",
  temperature: 1,
  max_tokens: 3074,
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0,
});
```
### Reviews
Generate 3 random names
![](https://i.imgur.com/CC1YNjz.png)
```javascript
const response = await openai.createCompletion({
  model: "text-davinci-002",
  prompt: "Write 3 names of people who live in Minnesota:\n1.",
  temperature: 0.7,
  max_tokens: 256,
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0,
});
```
Generate reviews with context
![](https://i.imgur.com/bqiMHCA.png)
```javascript=
const response = await openai.createCompletion({
  model: "text-davinci-002",
  prompt: "I have a barber business in Minnesota. \nMy business name: Ace of Blades Barbershop.\nMy slogan: For the perfect cut, come to Ace of Blades! \nMy services: Haircuts, Beard Trims, Hot Towel Shaves, Facials, Waxing, Manicures, Pedicures, Shampooing, Conditioning, Styling. \nCustomers love me: provide an excellent haircutting experience, personable, make customers feel comfortable, excellent beard trims, give great hot towel shave, excellent facials, experienced waxing, give great manicures and pedicures, excellent shampooing and conditioning, experienced styling, go above and beyond for customers.\nReviews characteristics:\n1. 3 reviews\n2. has a different text structure\n3. has a unique text style\n4. on behalf of different people\n5. in a different and unique style\n6. without specifying any services\n7. The beginning and ending of each of the reviews is very different\n8. without braces\nReviews:\n1.",
  temperature: 1,
  max_tokens: 3074,
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0,
});
```
### Domain generation
![](https://i.imgur.com/rTcfIaR.png)

![](https://i.imgur.com/XO2Nvj7.png)
```javascript=
const response = await openai.createCompletion({
  model: "text-davinci-002",
  prompt: "I have a barber business in Minnesota. \nMy business name: Ace of Blades Barbershop.\nMy slogan: For the perfect cut, come to Ace of Blades! \nMy services: Haircuts, Beard Trims, Hot Towel Shaves, Facials, Waxing, Manicures, Pedicures, Shampooing, Conditioning, Styling. \nCustomers love me: provide an excellent haircutting experience, personable, make customers feel comfortable, excellent beard trims, give great hot towel shave, excellent facials, experienced waxing, give great manicures and pedicures, excellent shampooing and conditioning, experienced styling, go above and beyond for customers.\nDomains conditions:\n1.  for my business\n2. 15 pieces\n3. domains don't look like each other\n4. in lower case\n5. without www\n6. com and us zone\n7. with my location\n8. close text\nDomains:\n1.",
  temperature: 0.7,
  max_tokens: 256,
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0,
});
```
> TODO specify more options to domain search logic
### Services description
TODO
Generate service descripion with `[insert]` gpt route
### Export/import
 - getWebsiteHTML`(ExecutionId): HTML`
 - setWebsiteHTML`(ExecutionId, HTML)`
> Save and host


# Fine-tuning phase
Enhancing text connectivity and refining model logic to precisely address our issues.
- Gathering and putting together a dataset
- Synthetic data?
- Parsing?
- Using connected metrics
- Versioning of data
- Experimentation procedures
- wandb.ai

# Image phase
Where are you, not waited for, not guessed at, invitations to the WALLE2?
- Logo generation
- Blocks realistic photos generation
- [ ] Invation accepted

# Code phase

- [x] Invation accepted