Question Answering on Data ft. Llama 3

Amal
ScrapeHero
Published in
6 min readMay 2, 2024

Meta recently released their new and powerful Llama 3 which is an instruction tuned generative model that comes in 8B and 70B sizes. (Release Date: April 18, 2024)

According to their benchmark, they already outperforms all open-source models available right now like Mistral, Gemma etc. Even outperformed bigger competitors like OpenAI’s GPT-3.5 Turbo, Anthropic’s Claude in several benchmark tests.

About Groq, we have covered it in our previous blog on how to do the inference with Groq API and how it is able to achieve hyper speed inference.

Groq uses something called as Language Processing Units (LPUs) that helps you to achieve faster inference and their hardware is more efficient than any AI processor.

GROQ API:

We will be utilizing Groq API to test Llama3. This model is also available in 2 variants (8B, 70B) here.

To create an API key: https://console.groq.com/keys

You can also check for the rate limit.

Available models: https://console.groq.com/docs/models

Data:

The Data used here is about location reviews and ratings of Starbucks stores in the USA region.

The data has been collected from ScrapeHero, one of the leading web-scraping companies in the world. Here’s the Data Source that we used for analysis!

Columns:

ID, Name, Address, Street, Zip_Code, State, City, Author, Review, Rating
Installation

Create a Virtual Environment on Python or Anaconda:

python -m venv myenv

Activate the Virtual Environment:

On Windows:

myenv\Scripts\activate

On macOS and Linux:

source myenv/bin/activate

Install dependency libraries:

pip install -q langchain langchain_core langchain-groq pandas

Question Answering with Groq ft Llama 3:

Now we can dive into the coding part on how we can achieve this using Langchain, they have a module for Groq which we can directly call with API and get the results.

Query: Mention some of the negative comments from New york city outlets

from langchain_core.prompts import ChatPromptTemplate
from langchain_groq import ChatGroq
import pandas as pd

df = pd.read_csv(“Starbucks_reviews.csv”)
reviews = list(df[df.city==”New York”].review)


chat = ChatGroq(temperature=0.3, groq_api_key=”YOUR_API_KEY”, model_name=”llama3–70b-8192")
human_prompt = “Mention some of the negative comments from New york city outlets: {review}”
system_prompt = “You are a helpful assistant and your task is to listen to the query carefully and provide analytical answer”
prompt = ChatPromptTemplate.from_messages([(“system”, system_prompt), (“human”, human_prompt)])
chain = prompt | chat
print(chain.invoke({“review”: reviews}))

Response:

Here are some of the negative comments from New York City outlets:\n\n

1. “A huge disappointment. It was like any other Starbucks but with higher prices, slower service, and almost no place to sit and relax.”\n

2. “It’s giving out. Also, it doesn’t help that the waiters disrespect you for not ordering something immediately. Take your money somewhere else.”\n

3. “Beautiful store fit out, but that\ ‘s where the positivity ends. $8.17 for a cortado is egregious in any realm, but when you factor in the dreadful standards of the baristas then it\’s compounded. The coffee was burnt with bubbling milk. Please, train your staff properly. Farcical experience.”\n

4. “Complete rip off! Double the price! The experience is not worth the price.”\n

5. “Not going there anymore, I lost my train twice last month waiting for my order. They need some major work if they want to keep this location.”\n

6. “Took a while to be able to order, the on-line thing wouldn\’t work for us so we had to go to the counter. After a reminder someone did come to take the order and it was very pleasant. The apple foam iced coffee was delicious. One toilet though? Big queues while we were there.”\n

7. “Just have to share this photo. All three team members were on their phones. As I waited in line behind 2 other customers, the cashier was on his phone invested in whatever he was doing as I took his photo right in front of him. The Barista had his phone on speaker as he told the girl he was speaking with how it wasn\’t busy at all. The third male was standing toward the back on his phone as well. Just think it’s funny how all three were not at all interested in the Customers in the cafe.”\n

8. “Got every pastry we ordered wrong. The tag had the correct item but didn’t have the correct pastry in the bag. Workers were visibly arguing across the room. When I went up to order the barista was definitely annoyed or part of the current drama because she made a side comment “get me out of here” and also openly cursed in front of me while I was ordering.”\n

9. “All coffee drinks are very strong in flavor which is good. They also have a variety of sweet and savory croissants as well as pizza slices and desserts. Unfortunately, everything is overpriced and employees do not look like they enjoy working here and the ordering system is inefficient.”\n

10. “Employees all seemed to have a really bad attitude like they are better than other Starbucks locations. Very disorganized and they don\’t let customers redeem star points. All the women on the left stand there and yell at each other while barely working. Starbucks Reserve seems to be a total scam and all not worth the hype!!! Stay away from very rude employees!!!

Here are the positive comments, just replace the human prompt with positive comments:

Here are some positive comments from New York City outlets:\n\n* “Excellent menu selection. Great merch. Staff were extremely helpful.”\n* “Delicious specialty coffee and drinks in an exquisite space at the base of the Empire State Building.”\n* “The staff was very nice and we had such a great time making conversation with them. Thomas gave us great suggestions for what to eat and was incredibly friendly.”\n*

“We had an amazing experience at this restaurant with Thomas and Jimmy as our waiters. Thomas was hilarious and left a lasting impact on my life and my goals of who I want to become (he was also a wonderful waiter).”\n* “Espresso martini the perfect.”\n* “Starbucks reserved in NYC has an industrial feel to the decor and general ambience of the place. It offers high-quality coffee and a wide range of exclusive drinks.”\n*

“The first floor is dedicated to selling merch and to-go orders. The basement has actual tables where you can sit down.”\n* “Great vibe and really good cocktails. Gonna be coming back for sure.”\n* “Drinks and food are always fresh and exactly as ordered. Facility is super clean and the staff is very friendly. Definitely recommend!!”\n*

“Beautiful store. Make sure you check out the experience lounge.”\n* “Always super packed but today, I absentmindedly left a bag and was six stops away got off the train and called them, and the manager secured my bag.”\n* “The staff are very friendly, but the food leaves a lot to be desired. Apart from not being good, it is very expensive.”\n\nThese comments highlight the positive aspects of the Starbucks Reserve Bar, including the excellent menu selection, friendly staff, and high-quality coffee and drinks.

Query: What specific menu items or drinks are frequently praised or criticized in Los Angeles region?

Based on the reviews, here are some specific menu items or drinks that are frequently praised or criticized:\n\n

**Praised:**\n\n* Hot chocolate\n* Sandwiches (specifically, breakfast sandwiches)\n* Matcha lattes\n* Iced Apple Crisp Oatmilk Macchiato\n* Banana bread\n* Pumpkin cake\n\n

**Critized:**\n\n* Drinks with too much sugar or not enough sugar\n* Whipped cream being added to drinks when not requested\n* Cold brew with curdled cream\n* Lemonade being bitter\n* Food items being frozen and reheated\n* Drinks being made incorrectly or with the wrong ingredients\n

**Common complaints:**\n\n* Slow service, long wait times\n* Rude or unfriendly staff\n* Incorrect or incomplete orders\n* Mobile orders being slow or incorrect\n* Lack of parking or inconvenient parking\n* Restrooms being dirty or unavailable\n\n

**Praised staff members:**\n\n* Michelle\n* Avery\n* Cori\n* Stephanie\n* Jae\n* Bianca\n* Gonzo\n* Paul

Conclusion:

In this blog, we’ve explored how we can do a simple question answering based system on Starbucks review data with the help of Groq’s accelerated LPU.

Hope you learned something new today, Happy Learning!

--

--