Once Upon a Time in the Realm of Generative AI

Once Upon a Time in the Realm of Generative AI

Unleashing the Magic of Generative AI and Long-Context Large Language Models (like Google Gemini 1.5 Pro and Anthropic Claude 3) to Create Concept Correlation Diagrams.

In the worldwide realm of artificial intelligence, long-context large language models have surfaced as revolutionary instruments, claiming an exceptional capacity to understand and handle extensive data across various languages. With their broad comprehension and parsing abilities, models such as Google Gemini 1.5 Pro and Anthropic Claude 3 are reshaping how we engage with and interpret textual data.

The Immense Capacity of Long-Context Models

To truly understand the potential of these models, let’s explore their impressive context lengths. Google Gemini claims an impressive 2 million tokens, equivalent to approximately 5,600 pages of text. Similarly, Anthropic Claude 3 can handle a remarkable 200,000 tokens, corresponding to around 560 pages. These remarkable statistics highlight the models’ exceptional ability to understand and analyze complex narratives and diverse subjects across multiple languages.

Generating a Tale for Schematic Representation

In this article, we will embark on a captivating journey, harnessing the power of generative AI to craft a mesmerizing story. But our adventure doesn’t stop there! We will then employ the long-context language models to analyze the story and generate a visually stunning sequence diagram, illustrating the intricate relationships between the entities within the narrative.

Use Claude3 via Google Cloud Platform Vertex AI

The prompts showcased throughout this article can be executed via code or explored interactively in public playgrounds like https://claude.ai/.

from anthropic import AnthropicVertex

project_id = "MY_PROJECT_ID"
region = "MY_REGION"

client = AnthropicVertex(project_id=project_id, region=region)

message = client.messages.create(
    model="claude-3-sonnet@20240229",
    max_tokens=100,
    messages=[
        {
            "role": "user",
            "content": "Hey Claude!", # <-- The prompt
        }
    ],
)
print(message)        

Generating a Sample Story

Here, we will provide a prompt to generate a sample story using a large language model. The prompt will be designed to elicit an engaging and coherent narrative, rich with diverse characters and plot twists: WOW!

Prompt: 
Make up a 9-paragraph fable. Engaging and coherent narrative, rich with diverse characters and plot twists. Set in timeless medieval times, it must include a knight, a dragon, a village and an epic battle!        

???? ????????

Output:
In the heart of a quaint medieval village nestled between rolling hills and lush forests, there lived a valiant knight named Sir Aldric. Renowned for his bravery and unwavering loyalty, Sir Aldric was beloved by all who dwelled within the humble hamlet. Yet, lurking amidst the tranquility, a fearsome dragon named Grendor cast a shadow of dread over the land.

For generations, Grendor had terrorized the village, pillaging crops and demanding tribute. The villagers, weary of living in fear, turned to Sir Aldric for aid. With his sword gleaming in the sunlight, Sir Aldric vowed to rid the land of the dragon once and for all.

Armed with his courage and determination, Sir Aldric set forth on his quest. Through dense forests and treacherous mountains, he journeyed until he reached the lair of Grendor. The dragon, sensing the knight’s approach, roared with fury, its fiery breath scorching the earth.

Undeterred, Sir Aldric charged forward, his sword clashing against Grendor’s scales. The battle raged on, each blow exchanged echoing through the valley. With every strike, Sir Aldric’s resolve hardened, fueled by the cries of the villagers and the promise of peace.

As the sun dipped below the horizon, casting an amber glow upon the battlefield, Sir Aldric and Grendor fought with unmatched ferocity. Yet, in the heat of the fray, tragedy struck. With a mighty roar, Grendor unleashed a torrent of flames, engulfing Sir Aldric in searing heat.

The villagers watched in horror as their champion fell, his body consumed by the dragon’s inferno. With a triumphant roar, Grendor spread its wings and took flight, leaving the village in ruins.

Though Sir Aldric had perished in battle, his sacrifice would not be forgotten. In the aftermath of his passing, the villagers united, vowing to rebuild their home and honor the memory of their fallen hero. And though Grendor may have triumphed that day, the spirit of Sir Aldric lived on, a beacon of hope in the face of darkness.        

?? We feel sad for Sir Aldric but his sacrifice will not be in vain!

The story will serve as the foundation for our subsequent analysis and diagramming.

Analyzing the Story and Generating a Sequence Diagram

With the story in hand, we will construct a prompt that instructs the language model to analyze the narrative, identify the key entities, and uncover the correlations between them. Based on this analysis, the model will generate a Mermaid “Sequence Diagram,” visually representing the interactions and relationships within the story in a language-agnostic manner.

Prompt: 
Analyze the following text and generate an Sequence diagram using Mermaid syntax. Analyze the provided text in depth. Relate the concepts, Identify the key entities and illustrate their relationships based on the context provided. Before produce the diagram verify the correctness of relations. Produce a valid Sequence diagram, no other comments.        

??????

Output: 
```mermaid
sequenceDiagram
?participant Sir_Aldric
?participant Dragon_Grendor
?participant Villagers
?Note over Sir_Aldric: Renowned knight, protector of the village
?Note over Dragon_Grendor: Fearsome dragon, terrorizing the village
?Note over Villagers: Living in fear of Grendor's reign
?Villagers->>Sir_Aldric: Seek help to defeat Grendor
?Sir_Aldric->>Villagers: Vows to rid the land of Grendor
?Sir_Aldric->>Sir_Aldric: Embarks on a quest
?Sir_Aldric->>Dragon_Grendor: Reaches Grendor's lair
?Dragon_Grendor->>Sir_Aldric: Roars with fury
?Sir_Aldric->>Dragon_Grendor: Charges into battle
?Sir_Aldric->>Dragon_Grendor: Sword clashes against Grendor's scales
?Note over Sir_Aldric,Dragon_Grendor: Fierce battle rages on
?Dragon_Grendor->>Sir_Aldric: Unleashes torrent of flames
?Note over Sir_Aldric: Succumbs to Grendor's fiery breath
?Villagers->>Sir_Aldric: Witness Sir Aldric's fall
?Dragon_Grendor->>Villagers: Leaves the village in ruins
?Villagers->>Villagers: Unite to rebuild and honor Sir Aldric
```        

Rendering the Diagram

With the generated “Sequence Diagram” in hand, we can run Python code to render the chart, transforming the textual representation into a visually captivating diagram (not covered here, but is very simple). For those eager to explore further, we recommend utilizing platforms like https://mermaid.live, which allow for the direct display and manipulation of Mermaid diagrams.

The sequence diagram

Expanding the Horizons: To fully harness the potential of long-context language models, i encourage readers to experiment with increasing the length of the model’s output. By allowing the models to generate more extensive and detailed responses, we can uncover deeper insights and create even more comprehensive diagrams.

Acknowledging Limitations and Embracing Possibilities: While the context length of these language models is indeed impressive, it’s important to acknowledge that it may still pose limitations for certain use cases. However, the aforementioned context lengths of Google Gemini and Anthropic Claude 3 provide ample room for capturing and analyzing a wide range of text and documents.

Conclusion

As we conclude our exploration of the remarkable capabilities of Generative AI and large language models, two key points emerge:

  1. Generative AI has unlocked a world of possibilities, enabling us to effortlessly tackle complex and challenging use cases across various domains. Whether you’re analyzing contracts, books, research papers, or any other form of textual data, these powerful tools allow you to extract valuable insights and uncover hidden connections with unprecedented ease and efficiency.
  2. We are standing at the forefront of a transformative era in artificial intelligence, where Generative AI is redefining the way we interact with and derive meaning from vast amounts of information. The models we have discussed today are just the beginning, offering a look into the immense potential that lies ahead. As these models continue to evolve and advance, we can anticipate even more sophisticated processing capabilities and deeper reasoning capacities, revolutionizing the landscape of natural language understanding and generation across industries.

Generative AI, powered by long-context language models, is revolutionizing the way we interact with and extract insights from complex textual data. From legal professionals to researchers, from business analysts to curious individuals, these tools empower us to make sense of the vast amounts of unstructured data that surround us.

Embrace the magic of Generative AI and witness firsthand its extraordinary potential to transform the way you analyze and understand complex documents. The future belongs to those who can effectively harness the power of artificial intelligence to drive understanding, innovation, and growth. So, embark on this exciting journey, and let Generative AI become your invaluable ally in navigating the complexities of the information age.

I hope this article has provided valuable insights. If you have any questions or experiences to share, please don’t hesitate to leave a comment below. Let’s continue the conversation and explore how we can revolutionize Generative AI together.

Davide Consonni

Cloud Solution Architect | Head of Cloud Native at Capgemini Italy

9 个月

Linkedin si era mangiato un pezzo di storia ??

回复

要查看或添加评论,请登录

Davide Consonni的更多文章

社区洞察

其他会员也浏览了