By using AWS re:Post, you agree to the AWS re:Post Terms of Use

Generate charts with natural language using AWS Bedrock Sonnet 3.5 LLM?

0

Hi!

I've been working a lot with langchain4j and also AWS Bedrock, I was wondering how can I generate charts from the data I already have stored in my vector DB using natural language. I though about using tools to tell the LLM which JS library structure should generate in JSON so then my frontend can draw the chart base on that JSON. Is this a good approach? Or should I load in my vector DB for example some documentation about how every chart of the library I want to use is being drawn so the LLM can know which JSON structure to generate for that?

Thanks!

2 Answers
1

Your approach to generating charts using natural language with AWS Bedrock and a vector database is on the right track, but there are some considerations and potential improvements to consider.

First, it's important to note that AWS Bedrock now supports Anthropic's Claude 3.5 Sonnet model, which has advanced capabilities for complex reasoning and quick outputs. This model could be particularly useful for your chart generation task.

Your idea of using tools to instruct the LLM to generate JSON structures for chart libraries is a good one. This approach allows for a separation of concerns, where the LLM focuses on understanding the natural language request and generating the appropriate data structure, while the frontend handles the actual rendering of the chart.

However, instead of relying solely on the vector database to store documentation about chart structures, you might want to consider using Amazon Bedrock's Knowledge Bases feature. This would allow you to securely connect the foundation model (in this case, Claude 3.5 Sonnet) to your internal data sources, including information about chart structures and your actual data.

Here's an improved approach you could consider:

  1. Use Amazon Bedrock Knowledge Bases to store both your data and information about chart structures. This allows for Retrieval Augmented Generation (RAG), which can provide more relevant and accurate responses.

  2. When a user makes a natural language request for a chart, use the Retrieve and Generate API provided by Amazon Bedrock. This API will query the knowledge base and use the LLM to generate responses based on the retrieved results.

  3. In your prompt engineering, include instructions for the LLM to generate the appropriate JSON structure for the requested chart type.

  4. On the frontend, use the generated JSON to render the chart using your preferred JavaScript library.

This approach leverages the strengths of the Bedrock ecosystem, particularly the Knowledge Bases feature and the Claude 3.5 Sonnet model's capabilities. It allows for a more integrated and potentially more accurate chart generation process, as the LLM has access to both your data and the chart structure information in a unified knowledge base.

Remember to configure your Knowledge Base with the appropriate vector embeddings model and vector store for optimal performance. You can use various vector store options with Amazon Bedrock Knowledge Bases, including Amazon OpenSearch Serverless, Amazon Aurora, MongoDB Atlas, Pinecone, or Redis Enterprise Cloud, depending on your specific needs and existing infrastructure.

By using this approach, you're not only generating charts based on natural language, but you're also creating a system that can potentially handle more complex queries and provide more insightful visualizations of your data.
Sources
Knowledge Bases for Amazon Bedrock supports Anthropic’s Claude 3.5 Sonnet - AWS
Create an Amazon Bedrock knowledge base - Amazon Bedrock
Dive deep into vector data stores using Amazon Bedrock Knowledge Bases | AWS Machine Learning Blog

profile picture
answered a month ago
profile picture
EXPERT
reviewed a month ago
0
Accepted Answer

Hi,

Yes, it's possible. Watch this video for a full example: https://www.youtube.com/watch?v=dhxrHvgXpSM

Best,

Didier

profile pictureAWS
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions