Created
April 8, 2024 22:38
-
-
Save fsndzomga/64770fab76e68dbcaea1e21bfdb48ac8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class logical_reasoner(dspy.Module): | |
def __init__(self): | |
super().__init__() | |
self.logical_reasoner = dspy.Predict("text -> premises, conclusions") | |
self.checker = dspy.ChainOfThought(check_logic) | |
def forward(self,text): | |
prediction = self.logical_reasoner(text=text) | |
result = self.checker(premises=prediction.premises, conclusions=prediction.conclusions) | |
return result | |
text="If it is raining, then the grass is wet. The grass is wet. Therefore, it is not raining." | |
lr = logical_reasoner() | |
print(lr(text=text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment