RAG C1M4 Graded Lab Assignment Issue

Hi. I’m having an issue with the RAG C1M4 graded lab, Programming Assignment: Developing a RAG-based Chatbot, first part, 3.1 Deciding if a query is FAQ or Product related.

My label result appears to be returning the prompt instead of the label output (i.e. not FAQ or Product Related as expected), any guesses what I might be doing wrong? I thought I was correctly getting the ‘content’ from the response, but…

Thank you.

P.S. Is there an easy way of seeing the value of variables in the Jupyter lab notebook instead of printing out things?

Hey @rawiz happy to help - what I’d suggest is checking a few places in the code. First, make sure your ‘prompt’ variable is defined similar to the hints provided, using ‘Label: ’ correctly. Also, when defining the ‘label’ variable later on in the block, check out the commented line above - it has some good guidance on how to proceed. Let me know if that helps!

Thanks Lauren. Well I thought I had done the prompt OK, like the example(s) you had in the labs, e.g. starting with: prompt = f"“”… etc

And followed the advice on this comment hint you had:

# Get the label by accessing the 'content' key of the response dictionary

I had of course seen a similar code line in your ungraded lab:

result = response['content']

Hey @rawiz - that’s a great observation, the ungraded labs definitely help prepare you for the later assignments! And yes, formatting f-strings can be a bit finicky — sometimes it takes a little trial and error to get them right. Were you able to get it working and pass all the unit tests?

Unfortunately not so far. So pasting some code below that is literally taken direct from your ungraded and graded labs (a hint), i.e. I’m not giving away any answers or my own code per your code of conduct. I was basically modifying these, which seem pretty close to what would be needed, but I can’t figure out why I’m ending up appearing to be returning the prompt back as the label, sigh…


From ungraded lab

prompt = f"“”
Determine the category of the following query as either “nutritional” or “outfit” related.

  • Nutritional queries: These are related to nutrition products, such as whey protein, vitamins, supplements, dietary products, and health-related food and beverages.
    • Outfit queries: These pertain to clothing and fashion, including items like shirts, dresses, shoes, accessories, and jewelry.
      Examples:
  1. Query: “Where can I buy high-protein snacks?” Expected answer: Nutritional
  2. Query: “Best shirt styles for summer 2023” Expected answer: Outfit
  3. Query: “Are there any shoes designed for running?” Expected answer: Outfit
  4. Query: “What multivitamins should I take daily?” Expected answer: Nutritional
  5. Query: “Best weight loss products that are stylish” Expected answer: Nutritional
  6. Query: “Athletic wear that boosts performance” Expected answer: Outfit

Query: {query}

Instructions: Respond with “Nutritional” if the query pertains to nutritional products or “Outfit” if it pertains to clothing or fashion products.
Answer only one single word.
“”"
return prompt


From your graded lab hints:

Label the following instruction as an FAQ-related query or a product-related query.
Product-related answers are specific to product information or require using product details to answer. Products are clothes from a store. 
An FAQ question addresses common inquiries and provides answers to help users find the information they need.
Examples:
        Is there a refund for incorrectly bought clothes? Label: FAQ
        Tell me about the cheapest T-shirts that you have. Label: Product
        Do you have blue T-shirts under 100 dollars? Label: Product
        I bought a T-shirt and I didn't like it. How can I get a refund? Label: FAQ

Return only one of the two labels: FAQ or Product.
Instruction: {query}

Ok, let’s troubleshoot a bit more. I just went through the lab again on Coursera and confirmed the unittests are passing on my end. This might be an obvious one, and forgive me if you’ve already checked, but is your prompt wrapped in f-string formatting like f""" ... """ with clean triple quotes and proper indentation? Sometimes mismatched quotation marks (curly vs straight) or stray characters can throw things off.

Also, let’s make sure the prompt only contains the labeling instructions and examples similar to the hint — no trailing lines like return prompt, which might have accidentally get included in the f-string (based on the code you shared from the ungraded lab). The graded lab hint also shows the correct inclusion of {query}, which is slightly different from the ungraded lab format. Good to keep in mind as that {query} substitution is key to making sure the model knows what to classify.

Let me know if any of this is helpful!

I appear to have clean f-string, not getting any error messages. Maybe I need to look more carefully at the indents though.

return prompt is outside the string.

I think I’ve got the code on {query} in OK…

A tiny bit of my code, this is how I’m trying to get the label:

deleted bit about label getting content from response

Hey @rawiz sharing your code from the assignment is against the code of conduct, so if you could edit that from your post that would be great!

However, that is the correct approach, so maybe there is an issue with the other two variables - the comment lines above are very helpful for those, too.

This issue has been resolved, but if anyone visiting this thread is running into a similar problem, double-check your prompt definition. Make sure you’re formatting the prompt string correctly and passing it to the LLM through the pipeline, rather than returning the string itself. The goal is to return the model’s generated output, not the prompt that triggers it.

@LaurenRitter I am running into LLM call error as shown in the ss. I am running into a similar issue for /lab/tree/C1M4_Ungraded_Lab_1.ipynb which is already under discussion.

However, the issue for me is that my financial aid access to this course is expiring tomorrow (ss attached) and even though I am at the finishing line, due to these errors, I am unable to finish the course on time.

It would be of great help if I can be guided as soon as possible or if my access to the course can be extended for one more week so I can submit my lab once the issues are fixed. I had a similar issue in Module 3 lab as well which I was able to submit once they updated the files.

FYI:
This thread has been cold for 7 months, it’s unlikely to still be actively monitored.