Views
No views yet
1from transformers import AutoTokenizer
2from model import EnhancedRRN_QA_Model
3
4# Load tokenizer and model
5tokenizer = AutoTokenizer.from_pretrained("will4381/rrn-qa")
6model = EnhancedRRN_QA_Model("will4381/rrn-qa")
7
8# Load custom components
9import torch
10import os
11
12model.qa_head.load_state_dict(torch.load(os.path.join("will4381/rrn-qa", "qa_head.pth")))
13model.retroactive_update_layer.load_state_dict(torch.load(os.path.join("will4381/rrn-qa", "retroactive_layer.pth")))
14model.gating_mechanism.load_state_dict(torch.load(os.path.join("will4381/rrn-qa]", "gating_mechanism.pth")))
15
16# If using learned dynamic steps
17if os.path.exists(os.path.join("will4381/rrn-qa", "step_controller.pth")) and hasattr(model, "step_controller"):
18 model.step_controller.load_state_dict(torch.load(os.path.join("will4381/rrn-qa", "step_controller.pth")))
19
20# Example usage
21inputs = tokenizer("What is the capital of France?", "Paris is the capital of France.", return_tensors="pt")
22outputs = model(**inputs)code directory of this repository.python code/train.pypython code/test_model.py