You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a text(page sized texts) and list of labels(20 -30), I want to classify the text into any one of the label based on the content of text. I have more than 1000+ training examples and very challenging texts are expected in the test set. Which is the best suited way of approach for me? Will IReRa method give me good result? I have already tried COPRO method.
class Label(dspy.Signature):
"""Given a text and list of labels, select a label from the given list that matches the content of the text.
The label must be chosen from the given list of labels only. """
text = dspy.InputField(desc="Text data to be labelled")
labelPool = dspy.InputField(desc="List of label names from which a label has to be chosen")
label = dspy.OutputField(desc="Should be chose from the given list of labels.")
class PredictorModule(dspy.Module):
def init(self):
super().init()
self.signature = Label
self.predictor = dspy.ChainOfThought(self.signature)
def forward(self,text,labelPool):
result = self.predictor(text=text,labelPool=labelPool)
if result.label not in labelPool:
result.label="Other"
print(result)
return dspy.Prediction(
label=result.label,
rationale = result.rationale
)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Given a text(page sized texts) and list of labels(20 -30), I want to classify the text into any one of the label based on the content of text. I have more than 1000+ training examples and very challenging texts are expected in the test set. Which is the best suited way of approach for me? Will IReRa method give me good result? I have already tried COPRO method.
class Label(dspy.Signature):
"""Given a text and list of labels, select a label from the given list that matches the content of the text.
The label must be chosen from the given list of labels only. """
text = dspy.InputField(desc="Text data to be labelled")
labelPool = dspy.InputField(desc="List of label names from which a label has to be chosen")
label = dspy.OutputField(desc="Should be chose from the given list of labels.")
class PredictorModule(dspy.Module):
def init(self):
super().init()
self.signature = Label
self.predictor = dspy.ChainOfThought(self.signature)
def forward(self,text,labelPool):
result = self.predictor(text=text,labelPool=labelPool)
if result.label not in labelPool:
result.label="Other"
print(result)
return dspy.Prediction(
label=result.label,
rationale = result.rationale
)
Beta Was this translation helpful? Give feedback.
All reactions