llm = OpenAI(temperature=<span class="hljs-number">0.9</span>)
text = (prompt.<span class="hljs-built_in">format</span>(product=<span class="hljs-string">"typing machines"</span>))
<span class="hljs-built_in">print</span>(llm(text))</pre></div><p id="107e">⬇️ Notebook view:</p><figure id="8121"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*sNd-kSpCkaenSz159KjRuQ.png"><figcaption></figcaption></figure><p id="0e77">The following prototype is a good example of how LangChain can be used to automate prompt engineering, and leverage LLMs for conversational context:</p><div id="e533"><pre><span class="hljs-keyword">from</span> langchain.llms <span class="hljs-keyword">import</span> OpenAI
<span class="hljs-keyword">from</span> langchain.chains <span class="hljs-keyword">import</span> ConversationChain
<span class="hljs-keyword">from</span> langchain.chains.conversation.memory <span class="hljs-keyword">import</span> ConversationBufferMemory
conversation.predict(<span class="hljs-built_in">input</span>=<span class="hljs-string">"Hi there!"</span>)</pre></div><p id="e3e8">Response:</p><div id="f542"><pre>> Entering new ConversationChain chain...
Prompt after formatting:
The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.
Current conversation:
Human: Hi there!
AI:
> Finished chain.
Hi there! It's nice to meet you. My name is AI. What's your name?</pre></div><p id="31b3">Input:</p><div id="3efb"><pre>conversation.predict(<span class="hljs-built_in">input</span>=<span class="hljs-string">"My name is Cobus"</span>)</pre></div><p id="1b3e">Response:</p><div id="8fca"><pre>> Entering new ConversationChain chain...
Prompt after formatting:
The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.
Current conversation:
Human: Hi there!
AI: Hi there! It's nice to meet you. My name is AI. What's your name?
Human: My name is Cobus
AI:
> Finished chain.
Nice to meet you, Cobus! What can I do for you today?</pre></div><p id="bcbb">This approach is not optimal for longer conversations as the prompt size sent to the LLM will just grow too big.</p><p id="fdcf">In this final example, the user is prompted for input and this is used to generate the response, it also illustrates how two chains are combined.</p><div id="f1bf"><pre>title = <span class="hljs-built_in">input</span>(<span class="hljs-string">'What is your title? '</span>)
<span class="hljs-built_in">print</span> (<span class="hljs-string">'I have your title as '</span> + title)
era = <span class="hljs-built_in">input</span>(<span class="hljs-string">'Lasty, from what era should the text be? '</span>)
<span class="hljs-built_in">print</span> (<span class="hljs-string">'I have your era as '</span> + era)
<span class="hljs-comment"># This is an LLMChain to write a synopsis given a title of a play and the era it is set in.</span>
llm = OpenAI(temperature=<span class="hljs-number">.7</span>)
template = <span class="hljs-string">"""You are a playwright. Given the title of play and the era it is set in, it is your job to write a synopsis for that title.
Title: {title}
Era: {era}
Playwright: This is a synopsis for the above play:"""</span>
prompt_template = PromptTemplate(input_variables=[<span class="hljs-string">"title"</span>, <span class="hljs-string">'era'</span>], template=template)
synopsis_chain = LLMChain(llm=llm, prompt=prompt_template, output_key=<span class="hljs-string">"synopsis"</span>)
<span class="hljs-comment"># This is an LLMChain to write a review of a play given a synopsis.</span>
llm = OpenAI(temperature=<span class="hljs-number">.7</span>)
template = <span class="hljs-string">"""You are a play critic from the New York Times. Given the synopsis of play, it is your job to write a review for that play.
Play Synopsis:
{synopsis}
Review from a New York Times play critic of the above play:"""</span>
prompt_template = PromptTemplate(input_variables=[<span class="hljs-string">"synopsis"</span>], template=template)
review_chain = LLMChain(llm=llm, prompt=prompt_template, output_key=<span class="hljs-string">"review"</span>)
<span class="hljs-comment"># This is the overall chain where we run these two chains in sequence.</span>
<span class="hljs-keyword">from</span> langchain.chains <span class="hljs-keyword">import</span> SequentialChain
overall_chain = SequentialChain(
chains=[synopsis_chain, review_chain],
input_variables=[<span class="hljs-string">"era"</span>, <span class="hljs-string">"title"</span>],
<span class="hljs-comment"># Here we return multiple variables</span>
output_variables=[<span class="hljs-string">"synopsis"</span>, <span class="hljs-string">"review"</span>],
verbose=<span class="hljs-literal">True</span>)
review = overall_chain({<span class="hljs-string">"title"</span>:title, <span class="hljs-string">"era"</span>: era})
<span class="hljs-built_in">print</span> (review)</pre></div><p id="bc8d">And the output:</p><div id="b537"><pre>> Entering new SequentialChain chain...
> Finished chain.
{'title': 'Tragedy at sunset on the beach', 'era': 'Victorian ', 'synopsis': "\n\nTragedy at Sunset on the Beach is set in the Victorian era and tells the story of a young girl, Amelia, whose search for love and happiness leads her to a fateful encounter with a mysterious stranger on the beach at sunset. While walking along the shore, Amelia meets a man named William, who presents her with a rose as a symbol of his affection. Though she initially resists his advances, Amelia eventually finds herself drawn to William and the two quickly grow close. \n\nHowever, as the sun sets, a secret from William's past is revealed that changes everything. It turns out that William is a wanted criminal and is being pursued by the police. After a tense confrontation, William is arrested and taken away, leaving Amelia heartbroken and alone.\n\nIn the aftermath of their chance encounter, Amelia is forced to grapple with the tragedy of her unrequited love, and the harsh realities of life. Her journey serves as a reminder that love isn't always as simple and straightforward as it may seem.", 'review': '\n\nTragedy at Sunset on the Beach is a captivating tale of love, loss, and the power of the human spirit. The set in the Victorian era allows for a unique perspective on the themes of the story, and the performance by the cast is truly remarkable.\n\nThe story follows Amelia, a young girl whose search for love and happiness leads her to a fateful encounter with a mysterious stranger on the beach at sunset. We watch as Amelia’s relationship with the stranger, William, develops and evolves, only to be cut short when a secret from his past is revealed. This revelation forces Amelia to confront the harsh realities of life and the tragedy of her unrequited love.\n\nThe play is a thought-p
Options
rovoking exploration of love, sacrifice, and the power of human connection. It’s a story that is sure to resonate with audiences who are looking for a story of love, loss, and hope. Highly recommended.'}</pre></div><h1 id="e5a3">In Conclusion</h1><p id="2a02">In the recent past, I have written a number of times on the coming fragmentation and that a single contained Conversational AI framework will not suffice.</p><p id="43a6">Already we are seeing that LLMs are forcing traditional chatbot framework providers to look out ward to technologies they should make provision for.</p><p id="e321">LangChain is software that fills a critical voice which currently exists to make LLMs more conversational.</p><p id="b240"><b><i>⭐️ Please follow me on <a href="https://www.linkedin.com/in/cobusgreyling/">LinkedIn</a> for updates on Conversational AI ⭐️</i></b></p><figure id="10d2"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*lIm_TXh6TC9uGn63lOjZtQ.png"><figcaption></figcaption></figure><p id="42a0"><i>I’m currently the <a href="https://www.linkedin.com/in/cobusgreyling">Chief Evangelist</a> @ <a href="https://www.humanfirst.ai">HumanFirst</a>. I explore and write about all things at the intersection of AI and language; ranging from <a href="https://cobusgreyling.medium.com/the-large-language-model-landscape-9da7ee17710b">LLMs</a>, <a href="https://cobusgreyling.medium.com/the-five-categories-of-conversational-ai-f2410beeaf2f">Chatbots</a>, <a href="https://cobusgreyling.medium.com/three-key-voicebot-design-considerations-7bf25444dfec">Voicebots</a>, Development Frameworks, <a href="https://cobusgreyling.medium.com/testing-complex-utterances-with-the-co-here-humanfirst-integration-145ab4eedd84">Data-Centric latent spaces</a> and more.</i></p><div id="02f7" class="link-block">
<a href="https://www.humanfirst.ai">
<div>
<div>
<h2>NLU design tooling</h2>
<div><h3>“Conversation Designer, Retail, 10k+ employees The tool that turned conversation designers, into NLU designers” ★★★★★…</h3></div>
<div><p>www.humanfirst.ai</p></div>
</div>
<div>
<div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*lgMaRGTU1PRX4MB7)"></div>
</div>
</div>
</a>
</div><figure id="7278"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*qPfFI9uFl04n1ZUywxH38w.png"><figcaption></figcaption></figure><figure id="9789"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*mwQw4LOeZdWG1AD8RDheXw.jpeg"><figcaption><a href="https://www.linkedin.com/in/cobusgreyling">https://www.linkedin.com/in/cobusgreyling</a></figcaption></figure><figure id="bcbe"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*qPfFI9uFl04n1ZUywxH38w.png"><figcaption></figcaption></figure><div id="525b" class="link-block">
<a href="https://cobusgreyling.medium.com/subscribe">
<div>
<div>
<h2>Get an email whenever Cobus Greyling publishes.</h2>
<div><h3>Get an email whenever Cobus Greyling publishes. By signing up, you will create a Medium account if you don’t already…</h3></div>
<div><p>cobusgreyling.medium.com</p></div>
</div>
<div>
<div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*jN8P0LRxgRrefLMK)"></div>
</div>
</div>
</a>
</div><div id="b7d5" class="link-block">
<a href="https://eliza.community">
<div>
<div>
<h2>Eliza Language Technology Community — Language Technology: Conversational AI, NLP/NLP, CCAI…</h2>
<div><h3>ELIZA — Where language technology enthusiasts unite.</h3></div>
<div><p>eliza.community</p></div>
</div>
<div>
<div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*yM6mui4LoM4fDMPx)"></div>
</div>
</div>
</a>
</div><div id="63e6" class="link-block">
<a href="https://cobusgreyling.medium.com/the-cobus-quadrant-of-nlu-design-4b1654f21d70">
<div>
<div>
<h2>The Cobus Quadrant™ Of NLU Design</h2>
<div><h3>NLU design is vital to planning and continuously improving Conversational AI experiences.</h3></div>
<div><p>cobusgreyling.medium.com</p></div>
</div>
<div>
<div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*yLwyX_HKYjwqFY0IkmesCw.png)"></div>
</div>
</div>
</a>
</div><div id="e342" class="link-block">
<a href="https://cobusgreyling.medium.com/the-cobus-quadrant-of-conversation-design-capabilities-9a28c23409cd">
<div>
<div>
<h2>The Cobus Quadrant™ Of Conversation Design Capabilities</h2>
<div><h3>∗ This is part one of a two part series, please also take a look part two, the Cobus Quadrant of NLU Design.</h3></div>
<div><p>cobusgreyling.medium.com</p></div>
</div>
<div>
<div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*xdvS5qYcZsxll7FEUWRitA.png)"></div>
</div>
</div>
</a>
</div><div id="198e" class="link-block">
<a href="https://chat.langchain.dev/">
<div>
<div>
<h2>LangChain Chat</h2>
<div><h3>LangChain documentation chatbot</h3></div>
<div><p>chat.langchain.dev</p></div>
</div>
<div>
<div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/)"></div>
</div>
</div>
</a>
</div><figure id="a944"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*qPfFI9uFl04n1ZUywxH38w.png"><figcaption></figcaption></figure><div id="8473" class="link-block">
<a href="https://github.com/hwchase17/langchain">
<div>
<div>
<h2>GitHub - hwchase17/langchain: ⚡ Building applications with LLMs through composability ⚡</h2>
<div><h3>⚡ Building applications with LLMs through composability ⚡ pip install langchain Large language models (LLMs) are…</h3></div>
<div><p>github.com</p></div>
</div>
<div>
<div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*JB0ci66QVXXsDtm8)"></div>
</div>
</div>
</a>
</div><div id="1e65" class="link-block">
<a href="https://langchain.readthedocs.io/">
<div>
<div>
<h2>Welcome to LangChain</h2>
<div><h3>Large language models (LLMs) are emerging as a transformative technology, enabling developers to build applications…</h3></div>
<div><p>langchain.readthedocs.io</p></div>
</div>
<div>
<div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/)"></div>
</div>
</div>
</a>
</div><figure id="8d81"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*qPfFI9uFl04n1ZUywxH38w.png"><figcaption></figcaption></figure></article></body>
My Grandmother and Muhammad Ali
How Parkinson’s disease took one of our greatest champions and how it is slowly taking one of my champions too
Muhammad Ali passed away yesterday at age 74 after being treated for respiratory complications — complications that almost certainly were tied to his 32-year fight with Parkinson’s disease.
It was one of the few fights in his life Ali was never able to win.
In 2016 we rush to call everything the greatest. Steph Curry is the greatest shooter of all time. The Warriors are the greatest team in history. LeBron James is the greatest NBA postseason player ever. Mike Trout is the greatest young star in baseball. Lionel Messi is the greatest in soccer history.
In a world of lowercasegreatests, Muhammad Ali was the only The Greatest.
Muhammad Ali was The Greatest for what he did both in the ring and out. Having never watched a full boxing match, unless you count the choppy stream of that expensive sparring contest between Mayweather and Pacquiao a year ago, I don’t feel qualified to paint a picture of Ali’s greatness here. I missed Ali’s matches and I missed all of his political uppercuts too.
Ali’s story has been told countless times over, and it will be told again and again in the upcoming days. And like you, I can’t wait to take it all in. Here’s a good place to start:
I can’t tell you about experiencing Muhammad Ali’s greatness for myself because, at age 32, I am the age of Ali’s fight with Parkinson’s disease, the disease which ultimately took everything from him.
Parkinson’s disease is not fatal. But it’s not not fatal either.
The disease doesn’t kill you, but it slowly kills everything about you, and in the end, it probably lends a helping hand in your death too.
Parkinson’s is a degenerative disease of the nervous system. It’s the result of an imbalance of dopamine, a chemical our brains need to function normally every minute of every day. For some reason, some brains simply stop producing enough dopamine.
That lack of dopamine often exhibits itself in motor functions — which is why you’ve probably heard Parkinson’s called “The Shaking Palsy” before. If you were born in the ‘80s or after like me, one of your only real memories of Muhammad Ali is the stirring moment at the 1996 Atlanta Olympics when he lit the torch at the Opening Ceremonies. Go ahead, watch the 1-minute video:
Those images reflect all that most people know about Parkinson’s disease. Oh yeah, that’s that disease that makes people’s hands and arms shake, right? Like Muhammad Ali and Michael J. Fox?
Yes, that is Parkinson’s. Unfortunately, Parkinson’s is so much more.
And we owe it to Ali to learn more about the disease in his passing.
And to my Grandma Lou.
Float like a butterfly, sting like a bee…
Like Muhammad Ali, my Grandma Lou is The Greatest.
Grandma Lou worked for many decades at her Carlson Nursery in Jamestown, North Dakota, where she had greenhouses and greenhouses full of every plant and flower you could ever imagine. Like a bumblebee, Grandma would flit endlessly from plant to plant, flower to flower, bringing them water and giving them life. It was her passion. It was her life.
When she wasn’t caring for the many plants or recommending the right weedkiller or potting soil, Grandma Lou was probably hosting. She was always a bit of a social butterfly. Someone would drop by for ten minutes to pick up some petunias only to find themselves still inside an hour later sharing a piece of pie with Grandma, chatting it up. Grandma was always cooking as grandmothers are wont to do, always hosting, always greeting.
That was the grandma I remembered as a little boy, but that grandmother is long since gone. Parkinson’s has taken so much from her.
Parkinson’s does present itself first and most obviously in the tremors. It’s a shaking hand or a tapping foot or sometimes a twitching eye or trembling lip. At first, it’s barely noticeable but as the disease progresses, it’s uncontrollable. The shaking comes and doesn’t go. And it is exhausting. Try shaking one of your hands or feet just for the duration of this section.
After the tremors comes hypokinesia, or slowness of movement. Did you notice how slowly Ali moved to light the Olympic flame? That was not for dramatic effect. With Parkinson’s, everything becomes slow and deliberate. The disease attacks your muscles, all of them. They are constantly working, as the tremors begin to move inside of your body, and you slowly lose control.
With that loss of muscle control comes a stiffness and rigidity to movement and then a loss of balance and coordination. It is a series of chain reactions and, slowly but surely, the last of your motor capabilities are taken from you.
An estimated 10+ million people worldwide have been diagnosed with Parkinson’s disease, nearly a million in the United States alone. Its cause is unknown, and there is no cure.
There are treatments of course. You can take a pill every couple hours exactly on the hour to try to simulate the brain’s release of dopamine and balance your levels. But if the pill is not at exactly the right moment or if the levels aren’t balanced or if your body doesn’t agree, the symptoms return in a flash.
So why not pump more dopamine into the body? Too much dopamine leads to psychosis — basically schizophrenic symptoms, things like hallucinations and delusions. And as the dopamine imbalance continues and as the disease worsens, Parkinson’s often causes wild mood swings and loss of appetite and differing levels of apathy or anxiety or depression.
I don’t know if Muhammad Ali experienced all of these things, but I’ve seen every single one of them in my grandma.
First it was the shaking hands. It made playing cards a bit harder, then harder still, and eventually impossible. She just couldn’t hold the cards anymore.
Soon Grandma began to lose her balance. She stumbled as she walked, and she would fall sometimes. She’s so stubborn, like most grandmas I’m sure. She still to this day is determined that she will walk again someday, but she won’t, not on this side of heaven. She went from a walker to a wheelchair and has lived in a nursing home for the better part of two decades now. She can’t walk, can’t feed herself, can’t make it to the bathroom.
I’ve been away in Chicago for 15 years now, so I see Grandma Lou a few times a year. Every time I see her, Parkinson’s has taken another tiny piece of the grandmother I still know and love.
For many years, Grandma was totally mentally capable, a fully-functioning mind trapped inside a prison of a body that just wouldn’t listen anymore. Now the countless pills and worsened symptoms have mostly taken that too. Some visits are happy, on the rare good days. Others are full of tears or leave you feeling hurt and sad. I know it’s not her fault, and I know that’s not really my grandma on those days, but that’s what Parkinson’s has done.
Today a visit with Grandma is pretty great if she can open her eyes and see you and if her vocal cords can do just enough to have a conversation for a few minutes. She says she’s tired, but there are muscles in your eyelids too, working hard to keep them open and help you blink. I think Parkinson’s has just about defeated those now too.
Gratefully, Parkinson’s cannot take away my Grandma’s love. It cannot take away her ability to listen. And mercifully it has not taken her ability to return my hug or to give me a kiss.
Around 1 in 325 people worldwide are living with Parkinson’s disease. You almost certainly know someone somewhere quietly struggling with this disease.
There isn’t a cure — yet. But researchers are always finding new and improved ways to catch the disease early, to treat it properly, and to look for a cure.
As we mourn the loss of a great hero in Muhammad Ali, please consider supporting the Michael J. Fox Foundation for Parkinson’s Research using the link below. Your contribution could be the difference:
As for me, I will continue to mourn the slow loss of one of my own heroes. Parkinson’s can take away my grandma’s motor functions and it has taken away so much more from her, but it cannot take my Grandma Lou from me.
Note: I am not a physician or an expert on Parkinson’s disease, but I’ve done my best to represent what I’ve learned about it here. I apologize for any oversights.
If you like this article, please comment below and share it with your friends. Be sure to follow Brandon on Medium or @wheatonbrando for more sports, humor, pop culture, and life musings. Visit the rest of Brandon’s writing archives here.