How to Structure Reddit Data for a Chatbot with Deep Learning, Python, TensorFlow, and SQLite, Part 2

208.7K views
•
November 25, 2017
by
sentdex
YouTube video player
How to Structure Reddit Data for a Chatbot with Deep Learning, Python, TensorFlow, and SQLite, Part 2

TL;DR

Store paired parent comments and their best replies in SQLite so large Reddit datasets can be processed without loading entire monthly files into RAM. Part 2 imports sqlite3 and JSON, selects the May 2015 data, removes unneeded JSON fields, and prepares batched SQL transactions for potentially millions or billions of comments. Read on for the database structure, field choices, and performance rationale.

Transcript

What's going on Everybody welcome to part two of our chat bot with Python and tensorflow tutorial series in this tutorial We're going to be doing is beginning to build our Database that's going to store our basically our parent comments - they're paired best reply comments So the reason why we really want to do something like this is because well f... Read More

Key Insights

  • 🤖 Handling large files in memory is not practical for building chat bots, so storing the data in a database is necessary.
  • 🛩️ SQLite is a suitable choice for a database management system, especially for smaller projects.
  • 💁 The structure of the Reddit data files can be simplified by storing only necessary information in the database.
  • ❓ The tutorial emphasizes the importance of efficient data handling and suggests using database transactions for improved performance.
  • 🤖 The choice of database and table naming conventions can depend on the specific requirements of the chat bot project.

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: How do you structure Reddit data for a chatbot with Python, TensorFlow, and SQLite?

Create a SQLite database that stores parent comments paired with their best reply comments. Read each Reddit JSON sample, retain only useful fields, and use the resulting records to prepare chatbot training data.

Q: Why store chatbot training comments in a database instead of reading the files into RAM?

Even individual monthly files can be too large to load into RAM before creating training files. A chatbot may eventually use many months and possibly billions of comments, making database storage more practical.

Q: Why does the tutorial use SQLite for the chatbot database?

SQLite keeps the database setup simple and avoids requiring MySQL or another large database server. The tutorial says SQLite can get the job done, although another database system can be used.

Q: How can a database reduce the size of the Reddit comment data?

The source samples are JSON objects containing many keys and values that the project does not need. Storing only selected values in named database columns removes repeated field names and unnecessary information.

Q: Which Reddit comment fields are useful for this chatbot project?

The tutorial considers fields such as score, ups, downs, gilding, creation time, and subreddit potentially useful, depending on the type of bot. Fields such as link ID, name, received time, and author flair may be omitted when they do not serve the project.

Q: What warning does the tutorial give about Reddit score data?

The presenter warns that the score data may be flawed and says downs appear to always be zero. He is unsure whether score equals ups or whether ups minus score reveals downs, so he recommends treating these values cautiously and testing them.

Q: Which Python modules are imported to begin building the database?

The code imports sqlite3 for the database, JSON for reading the Reddit data format, and datetime. Datetime is used for simple logging output so progress can be monitored while processing large files.

Q: Why use SQL transactions when inserting Reddit comments?

Inserting millions of rows one by one is described as inefficient. The tutorial builds a large transaction and executes the inserts together because that approach is much faster.

Summary & Key Takeaways

  • The tutorial focuses on building a database to store parent and reply comments, as handling large files is not feasible for creating chat bot training files.

  • The tutorial uses SQLite as the database management system.

  • The content provides an overview of the structure of the Reddit data files and explains the need for a database in handling large amounts of data.


Read in Other Languages (beta)

Share This Summary 📚

Explore More Summaries from sentdex 📚