Human and AiConfig - Life is all about Composition
Tags: ai, llm, learning, promptengineering
Published: 2023-12-10 03:59:23

## Introduction
In this blog post, I will be discussing the topic of life is all about composition. You will be guided and taken into the world of AI based approach for your own understanding. We'll be making use of the AiConfig for this purpose. More details will be discussed shortly.

Understanding of "Composition" is really crucial in life. I cannot stress out on the significance of it in our life. Be it an artwork, programming or a construction or architectural work etc. everything that you see and work with involves the composition at the highest level. Let me walk you through with a real good example with a mixture of artificial intelligence (AI) generated composite artwork via DALL-E.

## Practicals
Let us get into the real-world problem to understand the compositions and the usage of the same with a realistic example. Here I am considering the DALL-E 3 Model for generating the water colored artwork.

![LittleGirlWithTheHorse](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/48vqph1vlxmftdbbtwrl.png)

![LittleGirlWithTheHorse1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cnr23scnbsnwfpujrley.png)

![LittleGirlWithTheHorse2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6qj2hf6oikx2sjuzblnz.png)

![LittleGirlWithTheHorse3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m81hl3nmbfvm3fwh8zqw.png)

![LittleGirlWithTheHorse4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9byev8zhfi111rg8s92s.png)

![LittleGirlWithTheHorseAndCat](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2tcbkx114ahe2hxv07wm.png)

Below are the features extracted from the DALL-3 prompt. Notice carefully each of the feature to understand the depth of the compositions. The more carefully you observe the artwork, the more compositions you see. You may call it as attributes/features or compositions, they all mean the same.

```
 "Features": [
            {
                "Feature": "Watercolor painting",
                "Description": "The artwork is created using watercolor painting technique, which involves using water-soluble pigments to create a translucent effect."
            },
            {
                "Feature": "Teenage girl",
                "Description": "The painting depicts a teenage girl, representing youth and energy. She is the central character in the artwork."
            },
            {
                "Feature": "Playful interaction",
                "Description": "The teenage girl is shown engaging in a playful interaction with the horse and the cat, indicating a joyful and lively atmosphere."
            },
            {
                "Feature": "Horse",
                "Description": "The horse is one of the animals in the painting. It should reflect affection and trust towards the girl, symbolizing a strong bond between them."
            },
            {
                "Feature": "Cat",
                "Description": "The cat is another animal in the painting. It should also reflect affection and trust towards the girl, emphasizing her love for animals."
            },
            {
                "Feature": "Lush outdoor setting",
                "Description": "The painting is set in a lush, outdoor environment, characterized by abundant vegetation and natural beauty."
            },
            {
                "Feature": "Enthusiasm and love for animals",
                "Description": "The teenage girl should be characterized by her enthusiasm and love for animals, which is evident in her interaction with the horse and the cat."
            },
            {
                "Feature": "Detailed artwork",
                "Description": "The artwork should exhibit a high level of detail, showcasing the artist's attention to intricacies and precision."
            },
            {
                "Feature": "Professional, artistically refined style",
                "Description": "The artwork should demonstrate a professional and refined style, indicating the artist's expertise and mastery of the watercolor technique."
            }
        ]
```

## Hands On
Now that you have understood the meaning and importance of "Composition", you will be guided with the mechanism to have a hands-on experience. For this purpose, we'll be making use of AiConig driven approach of [LastMileAI](https://lastmileai.dev/). If you are new to the LastMileAI or AiConfig, I request you to please read the following blogs

[Building with generative AI](https://dev.to/tanyarai/ditch-the-hassle-get-your-genai-code-productionized-now-3f2l)
[Prompt Chaining](https://dev.to/ranjancse/prompt-chaining-with-aiconfig-4afm)

Here's the AiConfig, copy and save it on your local.

```
{
  "name": "Text to Image",
  "schema_version": "latest",
  "metadata": {
    "models": {
      "gpt-4": {
        "model": "gpt-4",
        "top_p": 1,
        "temperature": 1,
        "system_prompt": "You are an expert DaLL-E prompt generator",
        "presence_penalty": 0,
        "frequency_penalty": 0
      }
    },
    "parameters": {}
  },
  "prompts": [
    {
      "name": "cell_1",
      "input": "Please provide a single Dall-E prompt template for generating the image. Make sure to include all the required attributes to make it more professional like an artist. \n\n{{content}}",
      "metadata": {
        "model": {
          "name": "gpt-4",
          "settings": {}
        },
        "parameters": {
          "content": "A little girl playing with the horse"
        },
        "remember_chat_context": true
      }
    },
    {
      "name": "art_generator",
      "input": "Generate a 600x600 {{cell_1.output}} make sure to do with water color painting",
      "metadata": {
        "model": {
          "name": "Dall-E 3",
          "settings": {}
        },
        "parameters": {
          
        },
        "remember_chat_context": true
      }
    }
  ]
}
```

1. Login to [LastMileAI](https://lastmileai.dev/)
2. Navigate to the Workbooks and then do the following to upload the aiconfig file.
3. Once the AiConfig is loaded, you can execute the cells and learn how to integrate with the AI models for generating the creative artwork, for example.

![AiConfigCreate](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjqxmep44hw9zop7tpt5.png) 

## Conclusion

We have learned the art and beauty of "Composition" and how to make use of it in our day-to-day tasks. The one who understands and drives with the composition will be a true winner. Either you use AiConfig or which ever approach you prefer, in the end the concept of composition remains the same.

Here's the most fascinating thing :) 

- This entire blog post was created with the composition mechanism.
- The AiConfig, if you closely deep dive into the cells, you will realize the composition