<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by legaltextai on Medium]]></title>
        <description><![CDATA[Stories by legaltextai on Medium]]></description>
        <link>https://medium.com/@legaltextai?source=rss-c5b3b382389b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zlGpNgaI13kgkfbUdsY7pA.png</url>
            <title>Stories by legaltextai on Medium</title>
            <link>https://medium.com/@legaltextai?source=rss-c5b3b382389b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 23:13:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@legaltextai/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Crush 1L Year With AI-Powered Tools: Lesson 6.]]></title>
            <link>https://medium.com/@legaltextai/crush-1l-year-with-ai-powered-tools-lesson-6-95cc8a68045b?source=rss-c5b3b382389b------2</link>
            <guid isPermaLink="false">https://medium.com/p/95cc8a68045b</guid>
            <category><![CDATA[law-school-tips]]></category>
            <category><![CDATA[law-school]]></category>
            <category><![CDATA[legaltech]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[legal-ai]]></category>
            <dc:creator><![CDATA[legaltextai]]></dc:creator>
            <pubDate>Mon, 21 Aug 2023 18:47:37 GMT</pubDate>
            <atom:updated>2023-08-21T18:53:39.914Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Power of Automated Case Search and Summarization.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JKlUD-qdVB6lD-aTQGrU1w.png" /></figure><p>In the grand halls of legal academia, especially your first year in law school, you will be tasked with dissecting countless legal cases, each filled with intricate details and nuanced arguments. Your professors will expect you to master these cases, and it may seem an insurmountable task.</p><p>But fret not! For I shall guide you in creating a digital assistant that will help you search and summarize legal cases with ease. This assistant will not replace your intellect but rather enhance it, allowing you to delve deeper into the legal world.</p><h4>Step 1: Setting Up Your Workspace</h4><p>First, you must prepare your digital workspace. If you haven’t already for my previous lessons, install Anaconda and open Jupyter notebook, a platform where you can write and run Python code.</p><pre># Let&#39;s install and import the necessary tools<br>!pip install bs4 requests anthropic<br>import os<br>from bs4 import BeautifulSoup<br>import requests<br>import anthropic</pre><h4>Step 2: Acquiring the Keys to Knowledge</h4><p>You will need an <a href="https://docs.anthropic.com/claude/reference/getting-started-with-the-api">API key from Anthropic</a>.</p><blockquote>I highly recommend Anthropic, based on my personal experience using it to analyze legal data. If you haven’t received its API key yet, feel free to use OpenAI, applying the same logic.</blockquote><pre>anthropic = Anthropic(<br>    # defaults to os.environ.get(&quot;ANTHROPIC_API_KEY&quot;)<br>    api_key=&quot;your_key_here&quot;, <br>)</pre><h4>Step 3: Searching for a Legal Case</h4><p>Now, we craft a function to search for legal cases on Google Scholar. This function will accept your query and return the title, link, and citation of the top search result.</p><blockquote>Make sure your use of Google Scholar is for educational purposes only</blockquote><pre>def search_legal_cases(query, num_results=10):<br>    url = &quot;https://scholar.google.com/scholar&quot;<br>    headers = {<br>        &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.3&quot;<br>    }<br><br>    params = {<br>        &quot;q&quot;: query,<br>        &quot;hl&quot;: &quot;en&quot;,<br>        &quot;num&quot;: num_results,<br>        &quot;as_sdt&quot;: &quot;4&quot;,  # This parameter filters the search results to legal cases<br>    }<br><br>    response = requests.get(url, proxies=proxies, headers=headers, params=params)<br>    soup = BeautifulSoup(response.text, &quot;html.parser&quot;)<br><br>    results = []<br>    for result in soup.find_all(&quot;div&quot;, class_=&quot;gs_ri&quot;):<br>        title = result.find(&quot;h3&quot;, class_=&quot;gs_rt&quot;).text<br>        base_url = &quot;https://scholar.google.com&quot;<br>        link = base_url + result.find(&quot;a&quot;)[&quot;href&quot;]<br>        citation = result.find(&quot;div&quot;, class_=&quot;gs_a&quot;).text.replace(&quot; - Google Scholar&quot;, &quot;&quot;)<br>        results.append((title, link, citation))<br><br>    return results</pre><h4>Step 4. Extracting the Text of the Decision</h4><p>Next, we write a function to extract the text of the decision from the web link of the top search result mentioned above.</p><pre>def extract_text_from_link(url):<br>    headers = {<br>        &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.3&quot;<br>    }<br>    <br>    response = requests.get(url, headers=headers, proxies=proxies)<br>    soup = BeautifulSoup(response.content, &quot;html.parser&quot;)<br>    <br>    text = soup.get_text(separator=&quot;\n&quot;)<br>    return text</pre><h4>Step 5. Summarizing the Text of the Decision Using IRAC Framework.</h4><p>Finally, we create a function that takes the full text of the case and generates its summary using <a href="https://www.csun.edu/~kkd61657/brief.pdf">the IRAC framework</a>.</p><pre>def get_summary(text):<br>    prompt = f&#39;&#39;&#39;{HUMAN_PROMPT}  <br>    You are a law professor specialized in legal writing and legal research. <br>    Summarize the case in {text} according to the following requirements:  <br>    Facts (name of the case and its parties, what happened factually).<br>    Procedural history (what happened in the past procedurally, what were prior judgements). <br>    Issues (what is in dispute).<br>    Holding (the applied rule of law). <br>    Rationale (reasons for the holding).<br>    Decision (what did the court decide, e.g. affirmed, overruled).<br>    Other opinions (if there are any dissenting or concurring opinions, summarize majority opinion, dissenting opinion and concurring opinion).<br>    {AI_PROMPT}&#39;&#39;&#39;<br>    completion = anthropic.completions.create(<br>    model=&quot;claude-2&quot;,<br>    max_tokens_to_sample=300,<br>    prompt=prompt,<br>)<br>    response = completion.completion<br>    return response</pre><p>Now, let’s test all of these functions through a single query. Feel free to replace <em>‘brown v board, supreme’</em> with another broadly defined search query, e.g., <em>‘google v oracle , appeal’</em>, or <em>‘470 U.S. 298’, </em>or any other case that you are studying for any of your classes.</p><pre>search_query = &quot;brown v board, supreme&quot; <br>results = search_legal_cases(search_query)<br>summary = get_summary(text)<br>print(summary) </pre><pre>&quot;Here is a summary of the key points in Brown v. Board of Education:<br><br>Facts: This consolidated case involves black students in Kansas, South Carolina, Virginia, and Delaware who were denied admission to public schools attended by white students under laws permitting or requiring racial segregation. <br><br>Procedural History: The plaintiffs sued in federal district courts seeking admittance to the white schools. The district courts relied on the &quot;separate but equal&quot; doctrine from Plessy v. Ferguson and denied relief, finding the schools were substantially equal. The Supreme Court granted direct review.<br><br>Issue: Does the racial segregation of public schools deprive black students of the equal protection of the laws under the Fourteenth Amendment?<br><br>Holding: Yes. Separate educational facilities are inherently unequal. Racial segregation in public education violates the Equal Protection Clause.<br><br>Rationale: Segregating black students solely due to their race generates a feeling of inferiority that affects their motivation to learn. Public education is extremely important, so unequal access violates equal protection.<br><br>Decision: Reversed and remanded. Racial segregation in public schools is unconstitutional nationwide. Courts should craft decrees to admit students to public schools on a racially nondiscriminatory basis.<br><br>Concurring Opinions: None. All justices joined the unanimous opinion.<br><br>Dissenting Opinions: None.&quot;</pre><p>If you want to see this code in action, check out its <a href="https://legaltext.streamlit.app/">working prototype</a> on the Streamlit platform.</p><p>I hope that this code serves you well and aids you in your noble pursuit of legal wisdom. Farewell for now, my dear friend, and may your endeavors be fruitful and your intellect ever sharp.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95cc8a68045b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crush 1L Year With AI-Powered Tools: Lesson 5.]]></title>
            <link>https://medium.com/@legaltextai/crush-1l-year-with-ai-powered-tools-lesson-5-23782af8ef0f?source=rss-c5b3b382389b------2</link>
            <guid isPermaLink="false">https://medium.com/p/23782af8ef0f</guid>
            <category><![CDATA[anthropics]]></category>
            <category><![CDATA[legaltech]]></category>
            <category><![CDATA[law-school]]></category>
            <category><![CDATA[1l]]></category>
            <category><![CDATA[legal-ai]]></category>
            <dc:creator><![CDATA[legaltextai]]></dc:creator>
            <pubDate>Wed, 12 Jul 2023 17:40:27 GMT</pubDate>
            <atom:updated>2023-07-12T17:40:27.308Z</atom:updated>
            <content:encoded><![CDATA[<h3>ChatGPT and Claude: Your AI Note-Taking Sidekicks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RRxDZWZ4tNdtd7ji8nHLPQ.png" /></figure><p>As students, we all know the importance of <a href="https://www.law.georgetown.edu/wp-content/uploads/2018/11/Updated-Tips-and-Techniques-for-Notes.pdf">taking great notes during lectures</a>. You’ll rely on those quality notes later for writing briefs, essays, and exam prep. Manually capturing every detail and retrieving those later is not always easy, but chat models ChatGPT by OpenAI and Claude by Anthropic can definitely help!</p><p>Let’s teach these models to be your personal note-taking assistants. Simply start a chat and give the instruction:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YPJDgsZT4-aBfbqIgTVYuQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JyqB2MOofitfUzzFJgaYwA.png" /><figcaption>We start a chat by giving specific instructions for the model to follow</figcaption></figure><p>As your professor covers key points, summarize them in the chat using line breaks to separate ideas (SHIFT + ENTER to remain in the same text window, or ENTER — to start a new one).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X4nNL6AGX4Jgsn_wB4iCOA.png" /><figcaption>Here are some notes taken during the first lecture in <a href="https://www.studocu.com/en-us/document/university-of-michigan/intro-to-constitutional-law/full-constitutional-law-outline-mortenson-2lecture-notes/2244555">Con Law class</a>.</figcaption></figure><p>The model will store these notes and can later respond to questions like “Summarize the first lecture”, “What were the key points about Heller?” or “What is the founding intent?”.</p><p><a href="https://www.anthropic.com/index/claude-2">Claude has just introduced</a> the added bonus of allowing you to upload documents, like the full Heller opinion, that you can also use for reference during your chat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nCZUKYV-WV2ZkP3jCKAKTw.png" /><figcaption>Here, we uploaded the full Heller opinion. Claude “read” and summarized it. You may ask questions like “What were Breyer’s arguments in Heller?”</figcaption></figure><p>The only catch is there is a limit on the amount of documents one may upload in the same chat instance.</p><p>Another good use of these models is to have them fix your disorganized or messy notes. For example, you could provide the AI with your raw notes and the template like this:</p><p>Your notes:</p><p><em>talked about negligence — reasonable person standard</em></p><p><em>3 elements — duty breach causation</em></p><p><em>palsgraf case — no duty to unforeseeable plaintiff</em></p><p><em>proximate cause — scope of risk matters</em></p><p>The template:</p><p><em>[Date] [Course] [Professor] [Lecture Title]</em></p><p><em>Key Points:</em></p><p><em>Cases Discussed:</em></p><p><em>Concepts Covered:</em></p><p><em>Additional Notes:</em></p><p><em>Follow Up:</em></p><p>Both ChatGPT and Claude will reformat your notes according to the provided template. This takes the jumbled information and organizes it neatly into labeled sections, making it much easier to review, study from, and add to later. Having an AI assistant instantly structure and formalize your rough notes can save you tons of time.</p><p>While both have pros and cons, ChatGPT and Claude bring us closer to effortless, foolproof note-taking and subsequent retrieval.</p><p>Going forward, even more effective would be AIs that can listen to lectures and automatically create outlines, which we ‘ll discuss how to do in the next lecture. But for now, ChatGPT and Claude are great tools to keep your notes organized as you progress through the semester. Give it a try for one of your next lectures!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23782af8ef0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crush 1L Year With AI-Powered Tools: Lesson 4.]]></title>
            <link>https://medium.com/@legaltextai/crush-1l-year-with-ai-powered-tools-lesson-4-195ab8cdc422?source=rss-c5b3b382389b------2</link>
            <guid isPermaLink="false">https://medium.com/p/195ab8cdc422</guid>
            <category><![CDATA[1l]]></category>
            <category><![CDATA[law-school]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[legaltech]]></category>
            <dc:creator><![CDATA[legaltextai]]></dc:creator>
            <pubDate>Fri, 07 Jul 2023 15:21:01 GMT</pubDate>
            <atom:updated>2023-07-07T15:21:01.515Z</atom:updated>
            <content:encoded><![CDATA[<h3>Selecting the Right Legal Source: Using Langchain’s RouterChain for Dynamic Sourcing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0IkMNJ4arQRoOTEQM6oyQw.png" /></figure><p>When building an AI system for the legal domain, it is useful to enable it select between multiple data sources dynamically based on the input. For example, you may have texts of several cases and textbooks. Uploading them all into one folder, and searching with the same query through all of them might take longer and cost more.</p><p>To address that, Langchain’s RouterChain paradigm offers an elegant solution for creating chains that can dynamically choose which sub-chain to use for a given input.</p><p>Below is an example of a simple way to implement RouterChain.</p><p>First, let’s import all the libraries and packages we will need and add OpenAI API key:</p><pre>from langchain.chains.router import MultiRetrievalQAChain  <br>from langchain.llms import OpenAI   <br>from langchain.embeddings import OpenAIEmbeddings  <br>from langchain.document_loaders import TextLoader   <br>from langchain.document_loaders import PyPDFLoader   <br>from langchain.vectorstores import FAISS<br><br>os.environ[&quot;OPENAI_API_KEY&quot;] = &quot;YOUR_OPENAI_API_KEY&quot;</pre><p>Next, we’ll load and create retrievers for two legal cases: <a href="https://scholar.google.com/scholar_case?case=15197092051369647665&amp;q=oracle+google+appeal+&amp;hl=en&amp;as_sdt=800006">Oracle v Google</a>, and <a href="http://danfingerman.com/law/cases/Hawkins.html?i=1">Hawkins</a>, and one for an excerpt from “<a href="https://www.amazon.com/Learning-Legal-Reasoning-Briefing-Analysis/dp/0960851445">Learning Legal Reasoning</a>” textbook by Prof John Delaney.</p><pre>howtobrief = TextLoader(&#39;delaney.txt&#39;).load_and_split()  <br>howtobrief_retriever = FAISS.from_documents(howtobrief, OpenAIEmbeddings()).as_retriever()   <br><br>oracle = PyPDFLoader(&#39;oracle.pdf&#39;).load_and_split()  <br>oracle_retriever = FAISS.from_documents(oracle, OpenAIEmbeddings()).as_retriever()   <br><br>hawkins = PyPDFLoader(&#39;hawkins.pdf&#39;).load_and_split()  <br>hawkins_retriever = FAISS.from_documents(hawkins, OpenAIEmbeddings()).as_retriever()</pre><p>Now, we’ll describe what each retriever should be used for and initiate the MultiRetrievalQAChain:</p><pre>retriever_infos = [<br>    {<br>        &quot;name&quot;: &quot;howtobrief&quot;, <br>        &quot;description&quot;: &quot;Delaney guidelines on how to exctract facts from a legal case&quot;, <br>        &quot;retriever&quot;: howtobrief_retriever<br>    },<br>    {<br>        &quot;name&quot;: &quot;oracle&quot;, <br>        &quot;description&quot;: &quot;Good for understanding Oracle v Google case&quot;, <br>        &quot;retriever&quot;: oracle_retriever<br>    },<br>    {<br>        &quot;name&quot;: &quot;hawkins&quot;, <br>        &quot;description&quot;: &quot;Good for understanding Hawkins case&quot;, <br>        &quot;retriever&quot;: hawkins_retriever<br>    }<br>]<br><br>chain = MultiRetrievalQAChain.from_retrievers(OpenAI(), retriever_infos, verbose=True)</pre><p>Let’s test it:</p><pre>print(chain.run(&quot;what are the Delaney guidelines on finding facts?&quot;)) </pre><p>From the response you may see some thinking process where the agent chose the Delaney textbook as the most appropriate to consult with:</p><pre>&gt; Entering new  chain...<br>howtobrief: {&#39;query&#39;: &#39;What are the Delaney Guidelines on finding facts?&#39;}<br>&gt; Finished chain.<br> The Delaney Guidelines on finding facts are as follows: 1) Identify parties and their roles; 2) Identify plaintiff&#39;s cause of action at trial; 3) Identify trial court&#39;s disposition of cause-of-action; 4) Identify which party appealed to which court and the relief requested; and 5) Identify any prior action taken by an intermediate appellate court.</pre><p>Let’s now query specific cases:</p><pre>print(chain.run(&quot;what was oracle v google about?&quot;))</pre><pre>&gt; Entering new  chain...<br>oracle: {&#39;query&#39;: &#39;What was the Oracle v Google case about?&#39;}<br>&gt; Finished chain.<br> The Oracle v Google case was about Google&#39;s use of 37 API packages from Oracle&#39;s Java software platform in its Android operating system.</pre><pre>print(chain.run(&quot;what did the court decide in hawkins case?&quot;))</pre><pre>&gt; Entering new  chain...<br>hawkins: {&#39;query&#39;: &#39;what did the court decide in the Hawkins case?&#39;}<br>&gt; Finished chain.<br> The court decided that the jury was allowed to consider two elements of damage: (1) Pain and suffering due to the operation; and (2) positive ill effects of the operation upon the plaintiff&#39;s hand. The court also decided that the true measure of the plaintiff&#39;s damage was the difference between the value to him of a perfect hand or a good hand, such as the jury found the defendant promised him, and the value of his hand in its present condition, including any incidental consequences fairly within the contemplation of the parties when they made their contract. The court also decided that it was erroneous and misleading to submit to the jury as a separate element of damage any change for the worse in the condition of the plaintiff&#39;s hand resulting from the operation. Finally, the court decided that the defendant&#39;s requests for instructions were loosely drawn and were properly denied.</pre><p>Langchain’s RouterChain approach allows you to dynamically create complex AI systems that analyze the legal input and determine which data sources and modules are most appropriate to leverage for a given example.</p><p>This flexibility and intelligence allows for more robust and broadly capable legal AI systems that can help grasp complex legal concepts faster when preparing for classes or exams.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=195ab8cdc422" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crush 1L Year With AI-Powered Tools: Lesson 3.]]></title>
            <link>https://medium.com/@legaltextai/crush-1l-year-with-ai-powered-tools-lesson-3-b296b66e5e53?source=rss-c5b3b382389b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b296b66e5e53</guid>
            <category><![CDATA[law-school]]></category>
            <category><![CDATA[1l]]></category>
            <category><![CDATA[legaltech]]></category>
            <category><![CDATA[legal-ai]]></category>
            <dc:creator><![CDATA[legaltextai]]></dc:creator>
            <pubDate>Fri, 16 Jun 2023 15:04:58 GMT</pubDate>
            <atom:updated>2023-06-16T15:04:58.592Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why Proper Prompting Makes a Big Difference in Legal AI</h4><p>Welcome back! This post continues our series on leveraging AI to elevate your 1L studies. In Lessons 1 and 2, we examined how to construct a database of case files and query them in natural language using large language models (LLMs).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-58LU-zsK_tHVHmI19vs2w.png" /></figure><p>In this lesson, we will explore why proper prompting is essential — that is, how the phrasing of your question impacts the LLM’s response.</p><p>Broad, open-ended prompts like “What was this case about?” or “Brief this case using IRAC framework” may seem straightforward, but they leave too much open to interpretation by the AI model. Without clear guidance on what information is most relevant or important, the AI’s response may miss the mark.</p><p>Let’s run an experiment and compare two prompts that are aimed to extract the same information from a case. We will use the database that we built in <a href="https://medium.com/@legaltextai/crush-1l-year-with-ai-powered-tools-lesson-2-44979a03f3a1">Lesson 2</a>.</p><pre>from langchain import OpenAI<br>from langchain.embeddings.openai import OpenAIEmbeddings<br>from langchain.document_loaders import PyPDFDirectoryLoader<br>from langchain.indexes import VectorstoreIndexCreator</pre><pre>os.environ[&quot;OPENAI_API_KEY&quot;] = &quot;your_api_key&quot;</pre><pre>loader = PyPDFDirectoryLoader(&#39;supreme_court/&#39;)<br>index = VectorstoreIndexCreator().from_loaders([loader])</pre><p>One of the cases that we uploaded into a ‘supreme_court’ folder was <a href="https://tile.loc.gov/storage-services/service/ll/usrep/usrep005/usrep005137/usrep005137.pdf">Marbury v. Madison (1803)</a>. Let’s run two queries:</p><p>Prompt 1:</p><pre>query = &quot;Brief Marbury v. Madison case using the IRAC model. Present in a bullet point format&quot;<br>result = index.query_with_sources(query)<br>print(result[&#39;answer&#39;])</pre><p><em>“IRAC” is a commonly used framework for analyzing and briefing legal cases. It stands for:</em></p><ul><li><em>Issue: Identify the key question or legal issue addressed in the case. This guides the entire analysis.</em></li><li><em>Rule: Explain the legal rule, standard, or test used by the court to resolve the issue. Discuss the source of law the rule is derived from (e.g. statute, precedent).</em></li><li><em>Application: Apply the rule to the facts of the case. Explain how the rule leads to the court’s decision. You may weigh evidence for multiple sides here before concluding.</em></li><li><em>Conclusion: State the court’s finding or holding. Explain the outcome and any subsequent impact or implications.</em></li></ul><p><em>Using the IRAC framework helps to systematically unpack the reasoning in a case by isolating each element of the analysis. For law students, IRAC is a useful structure for both studying and discussing cases to gain a full understanding of how the law was applied to reach the ultimate conclusion.</em></p><p>In Prompt 2, we will articulate for the LLM, with greater specificity, what we aim to convey:</p><pre>query = &#39;&#39;&#39;<br><br>Summarize Marbury v. Madison according to the following requirements:<br><br>Facts: Name of the case and its parties, what happened factually and <br>procedurally, and the judgment. <br><br>Issues: What were the main issues at stake. <br><br>Procedural history: What happened procedurally. <br><br>Holding: The applied rule of law. <br><br>Rationale: Reasons for the holding. <br><br>Decision: What did the court decide, e.g. affirmed, overruled.  <br><br>Policy implications: What are the wider policy and social consequences of this decision.<br><br>Present in a bullet point format. <br><br>&#39;&#39;&#39;<br><br>result = index.query_with_sources(query)<br>print(result[&#39;answer&#39;])</pre><p>Let’s compare the results from these two prompts:</p><p>The answer from Prompt 1:</p><p><em>“Marbury v. Madison was a case in which William Marbury sued James Madison, the Secretary of State of the United States, for failing to deliver Marbury’s commission as a justice of the peace.</em></p><p><em>The Supreme Court held that Marbury had a right to the commission, but that the Court could not issue a writ of mandamus to enforce it because the Judiciary Act of 1789, which authorized the Court to issue such writs, was unconstitutional.”</em></p><p>The answer from Prompt 2:</p><p><em>“Marbury v. Madison:</em></p><ul><li><em>Facts: Case between William Marbury and James Madison, Marbury was appointed as a justice of the peace but his commission was not delivered to him.</em></li><li><em>Issues: Whether Marbury had a right to the commission and if so, whether the Supreme Court had the power to issue a writ of mandamus to Madison.</em></li><li><em>Procedural History: Marbury filed a petition for a writ of mandamus in the Supreme Court.</em></li><li><em>Holding: The Supreme Court held that Marbury had a right to the commission, but the Court did not have the power to issue a writ of mandamus to Madison.</em></li><li><em>Rationale: The Court reasoned that the Judiciary Act of 1789, which gave the Supreme Court the power to issue writs of mandamus, was unconstitutional because it exceeded the scope of the Supreme Court’s authority as defined in Article III of the Constitution.</em></li><li><em>Decision: The Court overruled Marbury’s petition.</em></li><li><em>Policy Implications: The decision established the principle of judicial review, which is the power of the Supreme Court to declare laws unconstitutional.”</em></li></ul><p>In contrast, with a broad prompt to simply “brief the case using IRAC,” the AI is left to determine what belongs in each section of the IRAC model. It may fail to identify legally meaningful facts, confuse issues and holdings, or lack a complete rationale. The AI is still learning, so we must provide the clearest criteria possible to yield the output we need.</p><p>In summary, carefully crafted prompting is key to enabling AI to develop sophisticated legal analytical skills. Providing clear guidelines on the relevant elements to cover in a case summary or brief helps the AI model illuminate the legally significant details and arguments — rather than generating a superficial response lacking reasoned analysis. With practice at structured prompting, AI comprehension and reasoning in law will continue to improve over time. But for now, thoughtful prompting remains foundational.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b296b66e5e53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crush 1L Year With AI-Powered Tools: Lesson 2.]]></title>
            <link>https://medium.com/@legaltextai/crush-1l-year-with-ai-powered-tools-lesson-2-44979a03f3a1?source=rss-c5b3b382389b------2</link>
            <guid isPermaLink="false">https://medium.com/p/44979a03f3a1</guid>
            <category><![CDATA[legaltech]]></category>
            <category><![CDATA[law-school]]></category>
            <category><![CDATA[law-school-tips]]></category>
            <category><![CDATA[legal-ai]]></category>
            <category><![CDATA[1l]]></category>
            <dc:creator><![CDATA[legaltextai]]></dc:creator>
            <pubDate>Tue, 13 Jun 2023 16:04:52 GMT</pubDate>
            <atom:updated>2023-06-13T16:04:52.916Z</atom:updated>
            <content:encoded><![CDATA[<p>In <a href="https://medium.com/@legaltextai/crush-1l-year-with-ai-powered-tools-lesson-1-b4b75f324d66">Lesson 1</a>, we learned how to add a PDF file of a legal case and query it using the Langchain framework. In this lesson, we will add several cases to our database and learn how to query them all at once.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1MgfzHwhW1b54vOB6CoVcA.png" /></figure><p>First, let’s make sure we have all the necessary packages and libraries installed:</p><pre>from langchain import OpenAI<br>from langchain.embeddings.openai import OpenAIEmbeddings<br>from langchain.document_loaders import PyPDFDirectoryLoader<br>from langchain.indexes import VectorstoreIndexCreator</pre><p>We’ll explore these packages in more depth later. At a high level, they are needed to:</p><ol><li>Load the files.</li><li>Create an index.</li><li>Retrieve the relevant texts.</li></ol><p>For now, our goal is to demonstrate the abilities of large language models without going into too much detail.</p><p>Next, we set our OpenAI API key. You can obtain it at platform.openai.com:</p><pre>os.environ[&quot;OPENAI_API_KEY&quot;] = &quot;your_api_key&quot;</pre><p>Let’s upload several PDF files into a directory called ‘supreme_court’:</p><p><a href="https://tile.loc.gov/storage-services/service/ll/usrep/usrep005/usrep005137/usrep005137.pdf">Marbury v. Madison (1803)</a></p><p><a href="https://tile.loc.gov/storage-services/service/ll/usrep/usrep347/usrep347483/usrep347483.pdf">Brown v. Board of Education (1954)</a></p><p><a href="https://tile.loc.gov/storage-services/service/ll/usrep/usrep372/usrep372335/usrep372335.pdf">Gideon v. Wainwright (1963)</a></p><p><a href="https://tile.loc.gov/storage-services/service/ll/usrep/usrep384/usrep384436/usrep384436.pdf">Miranda v. Arizona (1966)</a></p><p><a href="https://tile.loc.gov/storage-services/service/ll/usrep/usrep410/usrep410113/usrep410113.pdf">Roe v. Wade (1973)</a></p><p>Next, we will ingest the uploaded documents using Langchain’s PDF directory loader and generate an index. For question answering across multiple documents, building an index over the data enables us to intelligently access the most pertinent documents for a given question, without the need to pass all the documents to the language model (which saves us time and money).</p><pre>loader = PyPDFDirectoryLoader(&#39;supreme_court/&#39;)<br>index = VectorstoreIndexCreator().from_loaders([loader])</pre><p>Don’t forget, use of the OpenAI API is not free (even though OpenAI offers some credits for new subscribers). Please monitor your usage and budget accordingly.</p><p>We are now ready to query our cases, all at once:</p><pre>query = &quot;What was the issue in Miranda?&quot;<br>result = index.query_with_sources(query)<br>print(result)<br><br>{&#39;question&#39;: &#39;What was the issue in Miranda?&#39;, <br>&#39;answer&#39;: &#39; The issue in Miranda was the admissibility of a confession <br>obtained by police without informing the defendant of their rights.\n&#39;, <br>&#39;sources&#39;: &#39;supreme_court/service-ll-usrep-usrep384-usrep384436-usrep384436.pdf&#39;}</pre><p>Note that “query_with_sources” allows you to see the name of the document where the answer was found.</p><p>You can now experiment with various questions by changing the input in the “query” variable. For example:</p><pre>query = &quot;which case talks about segregation in public schools?&quot;<br>result = qa.run(query)<br>print(result)<br><br>{&#39;question&#39;: &#39;which case talks about segregation in public schools?&#39;, <br>&#39;answer&#39;: &#39; The case of Brown v. Board of Education talks about segregation in public schools.\n&#39;, <br>&#39;sources&#39;: &#39;supreme_court/service-ll-usrep-usrep347-usrep347483-usrep347483.pdf&#39;}</pre><p>That concludes our lesson for today. We have learned how to construct a database containing multiple cases and execute natural language searches over that database. As your legal studies advance, your database will expand exponentially, and the ability to rapidly locate answers across precedents will prove invaluable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44979a03f3a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crush 1L Year With AI-Powered Tools: Lesson 1.]]></title>
            <link>https://medium.com/@legaltextai/crush-1l-year-with-ai-powered-tools-lesson-1-b4b75f324d66?source=rss-c5b3b382389b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4b75f324d66</guid>
            <category><![CDATA[law-school]]></category>
            <category><![CDATA[legal-ai]]></category>
            <category><![CDATA[legal-research]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[1l]]></category>
            <dc:creator><![CDATA[legaltextai]]></dc:creator>
            <pubDate>Wed, 07 Jun 2023 12:52:54 GMT</pubDate>
            <atom:updated>2023-06-07T12:52:54.106Z</atom:updated>
            <content:encoded><![CDATA[<p>My dear friend, I hear you have taken on the monumental task of studying law! It is a perilous profession, not meant for the faint of heart. Your professors will inundate you with piles of archaic texts, filled with a tangled web of precedents you must unravel to satisfy their high demands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wIm87xYcJOcP7aGOd_sW2A.png" /></figure><p>Fear not, for I will guide you in training your AI replica to such an extent that it can think and write as well as the finest legal minds in history! Under my tutelage, this skill will amplify your abilities, not replace them.</p><p>Our goal here is not to cheat on assignments — rather, it is to mold you into a more capable lawyer by providing you the most powerful tool yet available to the legal profession.</p><p>The objective of these short lessons is to prepare you for the first year of law school by establishing a framework that will become your “second brain” — a teaching aid to assist you through the challenging initial year of legal study.</p><p>We will explore how to apply large language models and examine the principal approaches to legal reasoning and logic.</p><p>By building this foundation before you embark on law school, you will have the tools in place to handle the demanding coursework from the very first day. This “second brain” will help you learn, retain, and analyze legal concepts throughout your first year and beyond.</p><p>Again, the goal here is not to teach you every legal subject you will encounter in your 1L year. Rather, it is to show you how to use AI tools to aid you in your learning and make the first year slightly less difficult.</p><p><strong>Lesson 1. Querying a legal case.</strong></p><p>In your first year of law school, you will have to analyze a staggering number of court cases and legal decisions. Professors expect students to thoroughly brief and answer questions about dozens of cases for each class session.</p><p>Our goal here is to make that work more productive by helping you build a systematic approach to legal analysis. With consistent practice, you will be briefing cases thoroughly and effectively, developing an ever-growing legal “database” in both your memory and your “second brain” to draw from in the future. Let’s start!</p><ol><li>Install <a href="https://www.anaconda.com/download">Anaconda</a>.</li><li>You will need an <a href="https://platform.openai.com/account/api-keys">OpenAI API key</a> and, ideally, API keys for <a href="https://dashboard.cohere.ai/welcome/register">Cohere</a> and <a href="https://www.anthropic.com/earlyaccess">Anthropic</a> as well. Do not worry if you do not have all the keys yet; OpenAI will suffice to get started. (Cohere and Anthropic currently offer generous free trial access. At this point, Anthropic is my favorite by far.)</li><li>Open Jupyter, create a new notebook, and follow along:</li></ol><pre>#We &#39;ll need to install and import some packages and libraries first <br>pip install langchain </pre><pre>import os<br>from langchain.document_loaders import PyPDFLoader <br>from langchain.indexes import VectorstoreIndexCreator<br>os.environ[&quot;OPENAI_API_KEY&quot;] = &quot;add your OpenAI API key here&quot;</pre><p>4. Download a copy of the famous case of <a href="https://madisonian.net/downloads/contracts/hawkins.pdf">Hawkins v McGee</a> and save the pdf to your working folder (name it “hawkins.pdf”).</p><p>5. Now, we “read” the file and prepare it for search queries.</p><pre>loader = PyPDFLoader(&quot;hawkins.pdf&quot;)<br>pages = loader.load_and_split()  <br>index = VectorstoreIndexCreator().from_loaders([loader])</pre><p>6. Let’s run some queries over the case now.</p><pre>query = &quot;What were the facts of the case?&quot;<br>response = index.query(query)<br>print(response) </pre><p>Replace the query with: “Who was the judge?”, “When was it decided?”, “What were the defendant’s arguments?”, etc.</p><p>That’s it for today. We’ve learned something new:</p><ul><li>Large language models can help analyze legal cases.</li><li>Analyzing cases through questions and answers can complement the traditional method that involves reading, highlighting, summarizing, and memorizing.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4b75f324d66" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>