Lab2_Text_models_Questions (2)
Lab2_Text_models_Questions (2)
Ex 1: Text Summarisation
Problem Statement: Summarise the minutes of the meeting given below in 4 bullet points:
Car Manufacturing Company
Agenda:
1. Call to Order
2. Approval of Previous Meeting Minutes
3. CEO's Report
4. Financial Report
Meeting Minutes:
1. Call to Order:
- The meeting was called to order by Bharath Thippireddy.
3. CEO's Report:
- Bharath Thippireddy presented an overview of the company's performance, highlighting key
achievements and challenges. Key points discussed include:
- Sales figures for the last quarter.
- Progress on cost reduction initiatives.
- Highlights from recent industry events.
- The CEO answered questions from board members.
4. Financial Report:
- The Chief Financial Officer ([CFO's Name]) presented the financial report. Key financial metrics
discussed include:
- Revenue and profit margins.
- Budget vs. actual expenditure.
- Cash flow analysis.
- The board discussed financial performance and the impact on shareholder value.
Page 1 of 8
Program :
instruction = """ Summarise the minutes of the meeting given below in 4 bullet points:
Car Manufacturing Company
Agenda:
1. Call to Order
2. Approval of Previous Meeting Minutes
3. CEO's Report
4. Financial Report
Meeting Minutes:
1. Call to Order:
- The meeting was called to order by Bharath Thippireddy.
3. CEO's Report:
- Bharath Thippireddy presented an overview of the company's performance, highlighting key
achievements and challenges. Key points discussed include:
- Sales figures for the last quarter.
- Progress on cost reduction initiatives.
- Highlights from recent industry events.
- The CEO answered questions from board members.
4. Financial Report:
- The Chief Financial Officer ([CFO's Name]) presented the financial report. Key financial metrics
discussed include:
- Revenue and profit margins.
- Budget vs. actual expenditure.
- Cash flow analysis.
- The board discussed financial performance and the impact on shareholder value.
"""
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "user",
Page 2 of 8
"content": [
{
"type": "text",
"text": instruction
}
]
},
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
#print(response)
print(response.choices[0].message.content)
--------------------------------------------------------------------------------------------------------------------------------------
EX2: TEXT CLASSIFICATION
PROGRAM:
--------------------------------------------------------------------------------------------------------------------------------------
EX3: SENTIMENT ANALYSIS
PROBLEM: Given a set of Social Media Posts below, analyse the sentiment of each and classify it as
either positive, negative, or neutral. Provide a brief explanation for your classification
1. Just got my hands on the new XPhone - absolutely loving the camera and battery life! 📸🔋
#TechLove
2. Disappointed with the XPhone. Its pricey and not much different from the last model. Expected
more. 😕 #TechTalk
3. XPhones latest update is a game-changer for mobile gaming. The graphics are just incredible! 🎮💯
4. Cant believe I waited this long for the XPhone... its underwhelming and overpriced. Back to my old
phone, I guess. 😒
Page 3 of 8
5. The XPhone has exceeded my expectations. Fast, sleek, and the new AI features are a standout! 🚀
#Innovation
PROGRAM:
PROGRAM:
_------------------------------------------------------------------------------------------------------------------------------------
Page 4 of 8
if number % i == 0:
primeFlag = False
break
if primeFlag == True:
print(number, " is prime.")
else:
print(number, " is not prime.")
PROGRAM:
--------------------------------------------------------------------------------------------------------------------------------------
EX6: ERROR HANDLING
PROGRAM:
Page 5 of 8
EX7: CHATBOT APPLICATION
PROGRAM
PROGRAM:
#temperature indicates the randomness in the response. Between 0 to 1. Its 0 when the
#response is determininstic and 1 when the response is more creative
#default openAI model is text-danvinci-003
print(llm(prompt))
responses = llm.generate([prompt]*5)
Page 6 of 8
PROBLEM: CREATE A PROMPT WITH ONE INPUT VARIABLE. GENERATE A SUITABLE NAME FOR A
COMPANY THAT MAKES A PARTICULAR PRODUCT (USE ANY PRODUCT NAME). INPUT IS THE
NAME OF THE PRODUCT.
PROGRAM:
prompt = PromptTemplate.from_template(template=prompt_template)
# make a prediction
prediction = llm.predict(prompt_formatted_str)
PROBLEM: GENERATE A SUITABLE NAME FOR A COMPANY THAT MAKES A PARTICULAR PRODUCT
(USE ANY PRODUCT NAME) IN A SPECIFIC LANGUAGE. INPUTS ARE THE PRODUCT AND THE
LANGUAGE.
PROGRAM:
prompt = PromptTemplate(
template = """/You are a naming consultant, give responses to the following/
question: {question}. Do not use technical words, give easy/
to understand responses. Give your response in {language}""",
Page 7 of 8
input_variables = ["question", "language"]
)
# make a prediction
prediction = llm.predict(prompt_formatted_str)
Page 8 of 8