HafijulHoquenabid2 commited on
Commit
7286bf1
·
verified ·
1 Parent(s): a991fcf

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +95 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
+
3
+ # Load model directly
4
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
5
+
6
+ tokenizer = AutoTokenizer.from_pretrained("HafijulHoquenabid2/T5_flanlarge_phase_1")
7
+ model = AutoModelForSeq2SeqLM.from_pretrained("HafijulHoquenabid2/T5_flanlarge_phase_1")
8
+ # Domain-specific example questions and contexts
9
+ data = [
10
+ {
11
+ "question": "How can I enable two-factor authentication during the setup process for the smart door lock?",
12
+ "context": """
13
+ Setting Up Your Smart Door Lock: Comprehensive Instructions
14
+
15
+ A smart door lock allows you to lock and unlock your doors remotely through mobile apps or voice assistants, adding convenience and security to your home. Below are the step-by-step instructions for setting up your smart door lock properly, ensuring optimal functionality and security.
16
+
17
+ Step 1: Unboxing and Preparing the Components
18
+ 1. Unbox your smart door lock package. Ensure it contains:
19
+ - The smart lock device.
20
+ - Deadbolt assembly (if applicable).
21
+ - Mounting plate.
22
+ - Battery pack.
23
+ - Screws, bolts, and brackets.
24
+ - User manual.
25
+ 2. Identify the components and verify against the manual's checklist. If any item is missing, contact the manufacturer immediately.
26
+
27
+ Step 2: Removing the Existing Lock
28
+ 1. Use a screwdriver to remove your existing deadbolt or lock.
29
+ 2. Carefully detach the strike plate from the door frame.
30
+ 3. Ensure the door is free of debris or old hardware.
31
+
32
+ Step 3: Installing the Smart Lock
33
+ 1. Align the deadbolt assembly with the hole in your door.
34
+ 2. Secure the assembly with the provided screws.
35
+ 3. Attach the mounting plate to the door's interior side, ensuring proper alignment with the deadbolt assembly.
36
+ 4. Connect the smart lock device to the mounting plate using the screws and brackets provided.
37
+
38
+ Step 4: Configuring the Smart Lock
39
+ 1. Insert the battery pack into the smart lock device and power it on.
40
+ 2. Download the manufacturer's mobile app on your smartphone.
41
+ 3. Open the app and create an account if you don’t already have one.
42
+ 4. Follow the on-screen instructions to connect the smart lock to your Wi-Fi network. Ensure your network is secured with a strong password.
43
+
44
+ Step 5: Enabling Security Features
45
+ 1. Navigate to the app's settings menu and select “Security Settings.”
46
+ 2. Enable two-factor authentication by linking your phone number or email.
47
+ 3. Configure a backup PIN code to unlock the door in case of app failure.
48
+ 4. Set permissions for other users if required.
49
+
50
+ Step 6: Testing the Smart Lock
51
+ 1. Lock and unlock the door using the app to verify functionality.
52
+ 2. Test the manual override feature with the provided physical key.
53
+ 3. Check the responsiveness of any connected voice assistants (e.g., Alexa, Google Assistant).
54
+
55
+ Step 7: Finalizing the Setup
56
+ 1. Review the app's activity log to ensure no unauthorized access attempts.
57
+ 2. Enable auto-lock and geofencing features for additional convenience.
58
+ 3. Familiarize yourself with the customer support options for troubleshooting.
59
+
60
+ Additional Tips:
61
+ - Regularly update the smart lock’s firmware to ensure compatibility and security.
62
+ - Replace the batteries periodically or when low-battery alerts appear.
63
+ - Avoid sharing your PIN or app credentials with untrusted individuals.
64
+ """
65
+ }
66
+ ]
67
+
68
+ # Generate responses using attention mask
69
+ for item in data:
70
+ # Combine question and context
71
+ input_text = f"question: {item['question']} context: {item['context']}"
72
+
73
+ # Tokenize the input with attention mask
74
+ inputs = tokenizer(
75
+ input_text,
76
+ max_length=512,
77
+ padding="max_length",
78
+ truncation=True,
79
+ return_tensors="pt"
80
+ )
81
+
82
+ # Generate response
83
+ outputs = model.generate(
84
+ input_ids=inputs["input_ids"],
85
+ attention_mask=inputs["attention_mask"],
86
+ max_length=150,
87
+ num_beams=4,
88
+ early_stopping=True
89
+ )
90
+
91
+ # Decode and print the response
92
+ answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
93
+ print(f"Question: {item['question']}")
94
+ print(f"Generated Answer: {answer}")
95
+ print("-" * 80)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ torch
3
+ gradio