Spaces:
Sleeping
Sleeping
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM | |
# Load model directly | |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM | |
tokenizer = AutoTokenizer.from_pretrained("HafijulHoquenabid2/T5_flanlarge_phase_1") | |
model = AutoModelForSeq2SeqLM.from_pretrained("HafijulHoquenabid2/T5_flanlarge_phase_1") | |
# Domain-specific example questions and contexts | |
data = [ | |
{ | |
"question": "How can I enable two-factor authentication during the setup process for the smart door lock?", | |
"context": """ | |
Setting Up Your Smart Door Lock: Comprehensive Instructions | |
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. | |
Step 1: Unboxing and Preparing the Components | |
1. Unbox your smart door lock package. Ensure it contains: | |
- The smart lock device. | |
- Deadbolt assembly (if applicable). | |
- Mounting plate. | |
- Battery pack. | |
- Screws, bolts, and brackets. | |
- User manual. | |
2. Identify the components and verify against the manual's checklist. If any item is missing, contact the manufacturer immediately. | |
Step 2: Removing the Existing Lock | |
1. Use a screwdriver to remove your existing deadbolt or lock. | |
2. Carefully detach the strike plate from the door frame. | |
3. Ensure the door is free of debris or old hardware. | |
Step 3: Installing the Smart Lock | |
1. Align the deadbolt assembly with the hole in your door. | |
2. Secure the assembly with the provided screws. | |
3. Attach the mounting plate to the door's interior side, ensuring proper alignment with the deadbolt assembly. | |
4. Connect the smart lock device to the mounting plate using the screws and brackets provided. | |
Step 4: Configuring the Smart Lock | |
1. Insert the battery pack into the smart lock device and power it on. | |
2. Download the manufacturer's mobile app on your smartphone. | |
3. Open the app and create an account if you don’t already have one. | |
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. | |
Step 5: Enabling Security Features | |
1. Navigate to the app's settings menu and select “Security Settings.” | |
2. Enable two-factor authentication by linking your phone number or email. | |
3. Configure a backup PIN code to unlock the door in case of app failure. | |
4. Set permissions for other users if required. | |
Step 6: Testing the Smart Lock | |
1. Lock and unlock the door using the app to verify functionality. | |
2. Test the manual override feature with the provided physical key. | |
3. Check the responsiveness of any connected voice assistants (e.g., Alexa, Google Assistant). | |
Step 7: Finalizing the Setup | |
1. Review the app's activity log to ensure no unauthorized access attempts. | |
2. Enable auto-lock and geofencing features for additional convenience. | |
3. Familiarize yourself with the customer support options for troubleshooting. | |
Additional Tips: | |
- Regularly update the smart lock’s firmware to ensure compatibility and security. | |
- Replace the batteries periodically or when low-battery alerts appear. | |
- Avoid sharing your PIN or app credentials with untrusted individuals. | |
""" | |
} | |
] | |
# Generate responses using attention mask | |
for item in data: | |
# Combine question and context | |
input_text = f"question: {item['question']} context: {item['context']}" | |
# Tokenize the input with attention mask | |
inputs = tokenizer( | |
input_text, | |
max_length=512, | |
padding="max_length", | |
truncation=True, | |
return_tensors="pt" | |
) | |
# Generate response | |
outputs = model.generate( | |
input_ids=inputs["input_ids"], | |
attention_mask=inputs["attention_mask"], | |
max_length=150, | |
num_beams=4, | |
early_stopping=True | |
) | |
# Decode and print the response | |
answer = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
print(f"Question: {item['question']}") | |
print(f"Generated Answer: {answer}") | |
print("-" * 80) | |