Objectives:
• Learn how to use Large language models (LLM), such as OpenAI, to analyze Twitter data.
Data:
• The demo Twitter data from previous labs.
• The Python code at https://github.com/xbwei/machine_lear...
Steps:
1. Log in to MongoDB Atlas https://www.mongodb.com with the account you created in the previous section and find the Tweet collection.
2. In the Connect/Drivers window, find the connection string for Python.
3. log in to AWS Academy, start the leaner lab, and start the Notebook instance on Sagemaker.
4. Modify the config.ini file and add the following two items:
[mymongo]
connection = your mongodb connection string from Step2
[myopenai]
openai_api = the openai API key
You need to type the MongoDB password in the connection string manually.
5. Download the Python code and upload it to your Notebook instance.
6. Execute the Python codes cell by cell. Ensure the database and collection names match the names in the Python code.
7. Query your Twitter data from MongoDB and extract the data to analyze with OpenAI. You can use MongoDB Compass to write the queries. Make sure you only extract less than 100 Tweets.
8. Use Open AI to analyze the extracted Tweets for the following analysis:
8.1. Sentiment analysis
8.2. Language Translation
8.3. Emotion identification
8.4. Entities extraction.
8.5. Summarization
The results will be saved in the MogoDB database.
Please note: if the progress bar freezes, please click the Interept button to let it continue.
9. Stop the notebook instance and end the leaner lab when the analysis is complete.
10. In MongoDB Charts, open the lab11 dashboard and add the following charts. You may need to filter the tweets when necessary.
10.1. Twitter sentiment and emotion
10.2. Extracted person and organization
10.3. Tweet summary.
You need to choose a different data source for this table.
11. Publish your dashboard
11.1. Make the dashboard public.
11.2. Make the data source public with unauthenticated access.
11.3. Test the dashboard URL in the private mode of your browser.