decodemai commited on
Commit
e522426
1 Parent(s): 89101ab

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -0
app.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import GPTJForCausalLM, AutoTokenizer
3
+
4
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
5
+
6
+ model = GPTJForCausalLM.from_pretrained("EleutherAI/gpt-j-6B", revision="float16", low_cpu_mem_usage=True)
7
+ model.to(device)
8
+ tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6B")
9
+
10
+ def get_topic(line):
11
+ prompt="""
12
+ Give 4 tech disruption ideas for a
13
+ Input: travel agency
14
+ Output:
15
+ Virtual Reality:Create virtual tours for customers to explore destinations before booking a trip, allowing them to experience the location in a more immersive way.
16
+ Artificial Intelligence-powered chatbot: Develop a chatbot that can handle customer inquiries, bookings, and provide personalized recommendations based on their preferences.
17
+ Blockchain-based loyalty program: Implement a blockchain-based loyalty program that rewards customers for booking with the agency and can be used at participating hotels, restaurants, and other travel-related businesses.
18
+ Social media integration: Utilize social media platforms such as Instagram and Facebook to showcase user-generated content, such as photos and reviews, in order to attract new customers and build trust with potential clients.
19
+ #####
20
+ Input:chatbot
21
+ Output:
22
+ Personalized shopping assistant: A chatbot that can assist customers in finding and purchasing products based on their preferences and previous purchase history. This chatbot could also recommend similar products and provide information about sales and promotions.
23
+ Virtual health coach: A chatbot that can assist users in tracking their fitness and health goals, providing personalized workout and nutrition plans, and answering any health-related questions they may have.
24
+ Smart home integration: A chatbot that can integrate with smart home devices, allowing users to control their lights, thermostat, and other devices through voice commands or text messages.
25
+ Educational tutor: A chatbot that can assist students in their studies by providing explanations of difficult concepts, practice quizzes, and personalized study plans. This chatbot could also assist students in scheduling and organizing their assignments and exams.
26
+ #####
27
+ Input:biscuit brand
28
+ Output:
29
+ Virtual reality cookie tasting experiences: Use virtual reality technology to create an immersive experience for customers where they can taste and interact with different biscuit flavors and varieties. This could be used in-store or online as a marketing tool to promote new products or limited edition flavors.
30
+ Smart packaging: Use smart packaging technology to create interactive packaging that provides nutritional information, recipes, and other information about the product. This could also include a QR code that customers can scan to access additional information or enter a contest.
31
+ AI-powered cookie customization: Use artificial intelligence technology to create a customization tool that allows customers to create their own unique biscuit flavor and design. This could include options such as choosing different flavors, shapes, and decorations.
32
+ Home delivery robots: Use autonomous delivery robots to deliver biscuits directly to customers' homes. This could be a convenient way for customers to receive their favorite biscuits without having to leave the house. The robots could also be used to deliver other household essentials.
33
+ #####
34
+ """
35
+ prompt += "Input:"+line + "\nOutput:"
36
+
37
+ input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)
38
+
39
+ generated_ids = model.generate(input_ids, do_sample=True, temperature=0.9, max_length=1000)
40
+ generated_text = tokenizer.decode(generated_ids[0])
41
+ #print(generated_text)
42
+ #print("************************")
43
+
44
+ result = generated_text.replace(prompt,'').strip()
45
+ result = result.replace("Output:","")
46
+ parts = result.split("###")
47
+ topic = parts[0].strip()
48
+ return topic
49
+
50
+ iface = gr.Interface(
51
+ fn=get_topic,
52
+ inputs='text',
53
+ outputs='text',
54
+ examples=[["cake shop","icecream parlor"]]
55
+ )
56
+
57
+ iface.launch()