Abstract
Our research explores the application of Large Language Models for enhancing legal advice through AI-driven conversational agents, focusing on the analysis and interpretation of user-generated content from a prominent online legal community. By leveraging BERTopic for topic modeling and GPT-3.5 for labeling of user intents, we constructed a dataset that served as the foundation for fine-tuning the Mistral 7B language model. This process involved Supervised Fine Tuning and Direct Preference Optimization, culminating in the creation of a Domain Specific Language Model for legal expertise. This model was then employed to guide GPT-3.5 responses, ensuring domain-specific relevance and contextual appropriateness. The evaluation of these responses was conducted using GPT-4, supplemented by human assessment, to gauge the quality of the models' outputs. We leverage an innovative end-to-end pipeline, building upon the framework proposed by Wang et al. (Empower large language model to perform better on industrial domain-specific question answering, 2023. arXiv:2305.11541), specifically adapted for the legal domain. This pipeline provides a foundational framework for developing sophisticated and scalable user-facing chatbots, presenting an alternative to the more common retrieval augmented generation techniques. Our contributions include providing datasets for further research on Legal Question Answering systems and advancements in human alignment of responses from chatbots. This research advances the technical frontier in AI-driven legal assistance and opens new avenues for enhancing the accessibility and quality of legal support through conversational AI technologies.