TA Session 19 July: ROE Survival : Part 2#

TA Session 19 July: ROE Survival : Part 2

Duration: 2h 19m

Here’s an FAQ summary of the TDS live tutorial:

Q1: What are the arrangements for the ROE zip file, and how do I access it?

A1: The zip file will be made available via email and possibly a drive link ahead of the ROE start time. It’s password-protected and contains several files/datasets. You won’t be able to open it until ROE officially begins (8 PM Indian Standard Time tomorrow). The password will be delivered to you via the portal during the exam. Once you have the password, you’ll need to unzip the file to access the data.

Q2: Which software should I use to unzip the ROE files, especially if I’m not on Windows?

A2: I recommend using 7zip software if you’re on a Windows platform. For Mac OS, p7zip has been personally tested and works, though you might need a package manager like Homebrew to install it. For Linux, p7zip or any comfortable compression software will work. I won’t provide explicit instructions for installing these tools, but you should practice using them with password-protected archives yourself before the ROE.

Q3: Why do you recommend specific unzipping software? Can I use WinRAR or other tools?

A3: I recommend the specified software (7zip, p7zip) because they have been tested and are known to work. You can use any software you’re comfortable with, like WinRAR, but I highly recommend testing it first. Find or create a password-protected 7zip archive, then try to open it with your preferred software to ensure it works without issues.

Q4: Will a practice or “model” ROE be conducted, or will a practice zip file be provided?

A4: No, there won’t be a model ROE because each term’s exam is completely different. I also won’t be sending a practice zip file to avoid confusion. It’s a straightforward process: download the recommended unzipping software, create your own password-protected zip file with some text files, and then practice unzipping it. This is your practice.

Q5: What are the best practices for preparing my workspace before ROE?

A5:

  1. Separate Folder: Put the downloaded ROE zip file in a separate folder by itself. This makes it easier to manage the extracted files.
  2. Software Choice: Use an offline Integrated Development Environment (IDE) like VS Code or Jupyter Notebooks. I do not recommend Google Colab because it can sometimes disconnect or cause data loss during an ongoing ROE, which would be detrimental.
  3. Familiarize Yourself: Practice using your chosen IDE (VS Code or Jupyter Notebooks) and learn how to install necessary packages/extensions. These work similarly to Google Colab, but you’ll need to handle package management yourself. This was covered in detail in a previous video lecture.
  4. Speed is Key: The main challenge in ROE is speed, not knowledge. Minimize any potential disruptions by ensuring you’re comfortable with your tools before the exam starts.

Q6: How do I access the ROE exam portal?

A6: The ROE portal will be accessible the same way as your graded assignments. You’ll log into your TDS course portal, and there will be a specific ROE section.

Q7: What about the API key required for LLMs in ROE? Is it the same as the one for GA5?

A7: Yes, it will be the same API key that was sent out for Week 5’s graded assignment. Your token allowance for this key will be reset tomorrow, so you’ll have a fresh set of tokens to use for ROE API requests. I strongly recommend creating a variable for your API key in your chosen IDE (like VS Code) and testing it with a simple API call before ROE starts to ensure it works.

Q8: Why do you recommend VS Code/Jupyter Notebooks over Google Colab for ROE?

A8: Using an offline IDE like VS Code or Jupyter Notebooks avoids several issues:

  1. Time-Saving: You don’t waste time uploading potentially large data files to a cloud-based platform. Every minute saved is more time for solving questions.
  2. Reliability: It prevents potential connectivity issues or server problems that could lead to losing your work in the middle of ROE, which can happen with Google Colab.
  3. Control: You have full control over your environment, avoiding difficulties encountered by some users when uploading many files to Colab.

Q9: What is the basic structure for making an API call to an LLM for ROE?

A9:

  1. Requests Package: You’ll need Python’s requests package to make API calls. Install it using pip install requests.
  2. API Key: Store your API key (same as GA5) in a variable. Test it.
  3. URL (Endpoint): Use the specific URL for your requests. For ROE, the most important endpoints will likely be /completions (for general text generation/sentiment analysis) and /embeddings (for generating numerical representations of text).
  4. Request Parts: An API request typically has three parts:
    • URL: The specific endpoint you’re hitting.
    • Headers: Includes Content-Type and Authorization (where your API key goes). Keep this pre-prepared.
    • JSON Data (Body): This is the payload you’re sending. For a basic text generation request, it will contain model (e.g., gpt-3.5-turbo) and messages (a list of dictionaries, each with a role and content). The “system” role provides instructions, and the “user” role provides the data to act upon.
  5. Hit API Minimally: Store your request in a separate cell and run it only once to get the response. Avoid repeatedly hitting the API while debugging to save tokens.
  6. JSON Library: Import Python’s json library to work with the JSON responses.

Q10: How do I get structured data (e.g., JSON) back from the LLM, not just free-form text?

A10: You need to tell the LLM explicitly that you want structured data using a JSON schema within your API request.

  1. JSON Schema: Define a JSON schema that describes the structure of the data you expect. This schema will specify the type of the overall output (usually “object” for a dictionary), and list properties (keys) with their respective types (e.g., “string”, “number”, “array”, “object”, “boolean”, “null”). Arrays will have an items property describing their content.
  2. response_format: In your API request’s JSON body, include {"response_format": {"type": "json_object"}}. This forces the AI to output JSON.
  3. Function Calling (Advanced): For more complex scenarios, you can use “function calling”. This involves defining a tools list in your JSON request, where each tool is a function with a name, description, and parameters (another JSON schema describing the function’s expected inputs). You also include a tool_choice parameter to hint which function the AI should call. This allows the AI to execute specific predefined actions based on its understanding of the user’s prompt.

Q11: Will I be creating custom functions for function calling in ROE? Where do I define what the function does?

A11: You won’t be explicitly defining functions within the ROE. The function calling feature is meant to interact with functions the AI already “knows.” Your task would be to call these pre-existing functions or trigger certain behaviors from the AI. The AI’s knowledge base and its ability to learn and remember function definitions are part of the LLM’s capabilities. You’ll specify how to call a function (its name, arguments via schema) but not its underlying implementation. For ROE, you’ll likely be calling functions that are already part of the AI’s system.

Q12: Why are embeddings useful, and how do I work with them in ROE?

A12: Embeddings are numerical representations of text that capture semantic meaning. They’re useful for tasks like similarity comparisons, correlations, or building regression models.

  1. Endpoint & Model: Embeddings use a different API endpoint (/embeddings) and a specific model (e.g., text-embedding-ada-002).
  2. JSON Body: The JSON body for an embedding request differs, typically including input (the text you want to embed), model, and encoding_format.
  3. Output Structure: The output from an embeddings API call will be a JSON object containing a list of numbers (an array), representing the embedding vector. This vector typically has 1536 features.
  4. Processing: Convert the embedding output into a NumPy array. Keep this code handy, as you won’t have time to figure out array manipulations during ROE.

Q13: How can I analyze the similarity or relationships between words using embeddings?

A13: Once you have embeddings as NumPy arrays, you can perform various analyses:

  1. Dot Product: Use numpy.dot() to calculate the dot product between two embedding vectors, which indicates similarity.
  2. Cosine Similarity: For a normalized similarity score, use cosine_similarity from sentence_transformers.util.
  3. Correlation/Regression: With multiple embedding vectors (e.g., for several words), you can use numpy.corrcoef for correlations or numpy.polyfit for linear regression (if you treat embeddings as coordinates).
  4. Dictionaries: Convert your NumPy arrays back into a Python dictionary with words as keys and their embedding vectors as values for easy access.

Q14: Will ROE include advanced topics like Retrieval Augmented Generation (RAG) or custom function definitions?

A14: RAG is a more advanced application of embeddings. While notebooks cover it, I personally believe it’s unlikely to appear in ROE in a complex form. ROE questions are typically simpler, focusing on foundational understanding and quick problem-solving, not highly involved implementations. My advice is to master the basics of API calls, embeddings, and common data manipulations first.

Q15: What common data manipulation functions should I be familiar with for ROE?

A15: Be comfortable with numpy and pandas for data handling:

  • NumPy: Learn how to use functions for min, max, average, median, unique items, array transpose, and basic array operations. The “NumPy for Absolute Beginners” guide is a good resource.
  • Pandas: Understand how to use DataFrames, inspect them, perform calculations, and use functions like text-to-columns (also available in Excel) and pivot tables (also in Excel/Google Sheets). pandas and numpy are closely related, so skills in one often transfer to the other.

Q16: Where can I find resources to learn more about specific topics like VS Code tips, profiling, or RAG?

A16:

  • VS Code Tips: I’ve linked a video demonstrating cool tricks and tips for fast VS Code usage.
  • Profiling: A Jupyter notebook on profiling is provided in the course materials.
  • RAG: The relevant course notebook (Week 5 context) covers Retrieval Augmented Generation. While advanced, reviewing it can provide insight.

Q17: Will ROE questions be focused on a specific week’s content or distributed across all weeks?

A17: ROE will cover content you’ve learned throughout the course. I cannot provide specific details on content distribution or weightage per week.

Q18: What about the API key for ROE? Is it the same as the one for GA5?

A18: Yes, it’s the same API key. Your token allowance will be reset before ROE, so you’ll have a fresh set. You should test it before ROE starts.

Q19: How many questions will be in the ROE, and will they all be MCQs?

A19: I cannot specify the exact number of questions. However, all questions will be Multiple Choice Questions (MCQs). This is a change from previous years to reduce issues with subjective grading. I’ve also shared strategies on how to approach MCQs, including answering all questions (even guessing blindly) to maximize potential points.

Q20: What general strategies should I use to maximize my score in ROE?

A20:

  1. Answer All MCQs: Always provide an answer for every MCQ, even if you have to guess blindly.
  2. Preparation & Speed: The primary challenge in ROE is speed. Ensure you are intimately familiar and comfortable with your chosen IDE and tools to minimize disruptions and save time.
  3. Organize Your Workspace: Create a well-structured workspace with code snippets for common tasks (API calls, data manipulations) so you can quickly adapt to ROE questions.
  4. Practice: Practice extracting information from various file types (HTML, XML, DB, CSV) using the tools you plan to use.
  5. Focus on Objective Tasks: While data cleaning may be needed, prioritize objective clean-up tasks (e.g., dropping nulls, duplicates, correcting obvious non-standard values like numbers in names) rather than subjective ones.

Q21: How will ROE address data cleaning challenges, especially for project data?

A21: For ROE, you won’t be expected to perform subjective data cleaning (making judgment calls on what’s “right”). Instead, focus on objective clean-up tasks where the correction is clear (e.g., dropping rows with null values, removing exact duplicates, fixing obvious data entry errors like numbers in name fields if specified). I won’t provide specific instructions for each data set, as the goal is to test your ability to apply general data cleaning principles.

Q22: Should I create and use my own “cheat sheet” or notebook with code snippets for ROE?

A22: Absolutely! I strongly recommend creating your own notebook with essential code snippets. This includes templates for API calls, data manipulation functions (NumPy, Pandas), and other operations you expect to use. This saves valuable time during the exam, allowing you to focus on solving the problem rather than remembering syntax.

Q23: How can I efficiently handle XML files in ROE?

A23: I recommend using Python’s BeautifulSoup library for handling XML files. It’s a robust tool that simplifies parsing and extracting data from XML. You can find example XML datasets on data.gov to practice with.

Q24: What tool should I use for extracting tables from PDF files?

A24: tabula-py (the Python wrapper for Tabula) is an excellent tool for extracting tables from PDFs. Alternatively, you can use online services like ilovepdf. For ROE, expect relatively simple PDF tables.

Q25: What is Nominatim, and how should I use it for geo-coding distances in Project 1 or ROE?

A25: Nominatim is a tool for geo-coding (converting addresses to coordinates) and reverse geo-coding (coordinates to addresses).

  1. Library: Use the geopy library in Python, specifically its geodesic function, to calculate distances between coordinates.
  2. Coordinates: Use the exact coordinates assigned to a constituency, not bounding box extremes.
  3. Data Source: You must use Nominatim as the sole source for geo-coding information. Do not use Google Maps or other external sources. If Nominatim returns a “null” location for a constituency, you should drop that constituency from your calculations for ROE.
  4. Mandatory: Using Nominatim is compulsory for the relevant project section.

Q26: What is the process for submitting answers in ROE, and is there a specific format?

A26: You should refer to the “Clarifications about Project” post on Discourse. It contains explicit instructions and examples for the submission format. You must follow the specified format and order exactly.

Q27: Where can I find recordings of previous TA sessions relevant to ROE?

A27: You can find recordings of all previous TA sessions on the TDS YouTube playlist. I recommend watching recent sessions, especially the one from last Sunday and potentially others covering specific topics like RA (Retrieval Augmented Generation), as they provide valuable insights and practical demonstrations.

Q28: Is the ROE a live-streamed or recorded session? Will my activity be monitored?

A28: The ROE itself is not live-streamed, and your activity (like screen sharing or switching tabs) is not monitored. It’s treated like a “timed mock test” where you’re expected to complete it within a set timeframe. It’s an open-book exam, so you can use any resources you want, including multiple browser windows.

Q29: Are there specific tips for using Pandas for text-to-columns functionality?

A29: Yes, Pandas has powerful text-to-columns functionality. When using Python, you can specify how many breaks (splits) you expect in your data, which is more flexible than some Excel versions. Pandas works very well for this.

Q30: How can Pivot Tables be useful in ROE?

A30: Pivot tables (available in Excel/Google Sheets, or programmatically in Pandas) are a very useful skill for ROE. They help you quickly summarize and extract specific information from your data, which can save a lot of time depending on the question asked.

Q31: What is the estimated time of upload for this session’s recording?

A31: The recording needs to be processed by Google (which takes a few hours). Then, the instructor uploads it to YouTube. The earliest you can expect it is tomorrow morning.

Q32: What is the most crucial advice for success in ROE?

A32: Don’t miss any question! Always provide an answer for every MCQ, even if it’s a guess. Good luck!