Legal FLAN-T5 Question Answering

Description

This Question Answering model has been fine-tuned on FLANT5 using legal data. FLAN-T5 is a state-of-the-art language model developed by Google AI that utilizes the T5 architecture for text generation tasks. This model provides a powerful and efficient solution for accurately answering legal questions and delivering insightful information in the legal domain.

Predicted Entities

Copy S3 URI

How to use

document_assembler = nlp.MultiDocumentAssembler()\
    .setInputCols("question", "context")\
    .setOutputCols("document_question", "document_context")

leg_qa = legal.QuestionAnswering.pretrained("legqa_flant5_finetuned","en","legal/models")\
    .setInputCols(["document_question", "document_context"])\
    .setCustomPrompt("question: {QUESTION} context: {CONTEXT}")\
    .setMaxNewTokens(50)\
    .setOutputCol("answer")

pipeline = nlp.Pipeline(stages=[document_assembler, leg_qa])

question = 'How often will the incentive rate be reviewed?'
context = '''

The incentive rate shall remain in effect for a period of one year from the effective date. After the one year period, the incentive rate may be adjusted, or new incentive rates may be put in place, as determined by the governing body of Lincoln Parish, Louisiana. 
The incentive rate shall be reviewed annually by the governing body and any changes or adjustments shall be made in accordance with the terms and conditions of this agreement. Furthermore, the incentive rate shall be adjusted to reflect any changes in the cost of production of the oil or the market price of the oil, as determined by the governing body.
If an adjustment is necessary, the governing body shall notify the parties of such adjustment in writing.'''

data = spark.createDataFrame([[question, context]]).toDF("question", "context")

result = pipeline.fit(data).transform(data)

Results

+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|result                                                                                                                                                                  |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|[The incentive rate shall be reviewed annually by the governing body.                                                                                                  ]|
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Model Information

Model Name: legqa_flant5_finetuned
Compatibility: Legal NLP 1.0.0+
License: Licensed
Edition: Official
Language: en
Size: 920.9 MB
Case sensitive: true

References

In house annotated dataset