avatarRené Junge

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

7654

Abstract

-string">"product"</span>], template=<span class="hljs-string">"What is a good name for a company that makes {product}?"</span>,

<span class="hljs-built_in">print</span>(prompt.<span class="hljs-built_in">format</span>(product=<span class="hljs-string">"typing machines"</span>))

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

llm = OpenAI(temperature=<span class="hljs-number">0</span>) conversation = ConversationChain( llm=llm, verbose=<span class="hljs-literal">True</span>, memory=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>

The 10 Commandments for a Successful Writing Day

Anyone who earns money by writing has to keep a few basic things in mind every day to be successful. Some are obvious, others hardly anyone has on the list. Here come my ten commandments for a successful writing day.

Photo by Mark Duffel on Unsplash

Be organized

Creative chaos is only suitable for others. That doesn’t apply to you. When you sit down to complete your daily workload, you should have everything you need until your next break.

A glass of water and a bottle to refill, a hot cup of coffee or tea, pens and paper for notes — everything you need to work.

It’s also essential to organize your file storage cleanly. Nothing is more annoying than finding out that you have been working on an outdated version of your manuscript for two hours.

Your manuscript should also be well organized. Write with authoring software that allows you to create character databases, a story timeline, and archive research results.

The character database is vital to be able to check how old a character is, what she looks like, and what her preferences are. If you write with a standard text editing program, you will have a separate document containing all the properties of your characters.

If it is not possible to create a timeline for your story with your software, note the chronological progress of your story elsewhere. Ultimately, it doesn’t matter how you manage this information — the main thing is that you do it at all. You don’t want to scroll through a three-hundred-page manuscript to find out when your heroine left the house.

Separate writing from plotting

A writer’s block always has a chance to slow you down if you don’t know what’s going to happen next in your story. To avoid that, you must already have a plan for the following few scenes you want to write today.

It is not necessary to plan every detail in advance. But you should know what to do about the next few pages before you start writing the text.

Writing is a creative process that needs flow. You always interrupt this flow when you have to stop writing to think up the next pages of your story.

Planning and writing are two completely different processes that you should cleanly separate.

Separate writing and plotting from research

What is right for plotting is even more true for research.

Finding out what recoil a particular handgun causes is utterly different than constructing a suspense arc or writing a scene that you immerse yourself in with all your heart.

Plotting always comes first. The order of the other two steps is a matter of taste. You can start writing immediately after plotting, and use wildcards anywhere in the text where facts need to be researched. After writing, you can return to these places, do the necessary research, and fill the spaces.

Of course, after the plotting, you can also research all the facts you need before going on to write the scene. I prefer this order because I don’t like working with omissions in the text. But as I said, that’s a matter of taste.

Separate writing from editing

Corrections of spelling and grammar are always made at the end of the writing process.

Learn not to interrupt while writing to correct the mistakes you have made. When you do this, you force your brain to jump back and forth between two completely different work modes.

Writing is creative and controlled by the right hemisphere of the brain, whereas proofreading is analytical and is related to the left region of the brain.

The easiest and most effective way to stop you from correcting while writing is to turn off the spelling checker in your writing software.

In this way, you avoid your brain being alerted continuously by the software’s messages, and you don’t have to continually fight against the urge to look at the errors that your software reports to you with colored markers or any tones.

Have a goal for the day

Whenever you sit down to write, you should have a concrete goal for the day in mind. Only in this way can you judge at the end of the day whether or not you were successful by your standards.

You can formulate your daily goal in different ways. Most authors set a certain number of words as their goal. It is also possible to define a complete chapter or three or four scenes as a goal.

How you set your goals is up to you. But if you do without it entirely, I guarantee that you will never achieve what you could have achieved and that at the end of the day, you don’t know whether you can be satisfied or not.

The more precisely and unequivocally you define your daily goal, the more motivated you will be actually to achieve it. So I prefer a certain number of words. Two thousand words are two thousand words. But if you define only one chapter as your goal, you run the risk of cheating yourself. You might be tempted to make the section much shorter than it should be, just to reach your daily goal.

Besides, you should also define your daily goal in terms of time. If you only intend to write two thousand words, you can finish it in the early afternoon or late evening.

By the way, with no time limit, the late evening is much more likely than the early afternoon. Your brain will always want to convince you that in between, you can watch an episode of your favorite series or do something else that you find more pleasant than writing. The evening is far away.

Take breaks

People need breaks. Today, energy management is considered more important for personal success than time management.

Where in the past, people tried to squeeze as many activities as possible into one day, i.e., work as hard as possible, today the focus is on working as smart as possible.

Being able to assess one’s energy reserves is smart. It’s not intelligent to work against that. Some people manage an unbelievable amount every day without seeming to be at least stressed.

Others, on the other hand, suffer from burnout without ever having completed even the basics of their tasks.

Why is that? Some listen to their bodies, and others fight against them.

Regular pauses allow your body and brain to regenerate. When your cell phone battery is empty, you charge it. Why should you do it differently with your own power?

Those who give up their lunch break because they have so much to do will have done less by the end of the day than those who take a break and go back to work afterward.

If you work from home, you should even think about half an hour of nap time. Nothing recharges your batteries faster than a little sleep.

If you’re making money writing, you can’t work over your limit for a week and then get sick and can’t work for two weeks. If you don’t work as an author, you don’t earn money.

To do without breaks will harm not only your health but also your wallet in the long run.

But a warning: Don’t take your breaks spontaneously. Plan them into your daily routine at fixed times. And that with beginning time and end time. The danger that a quarter of an hour will turn into sixty minutes is otherwise far too high.

Stay focused

If I write above that, you should separate the writing process from the research, plotting, and editing, that also applies to everything else that is not writing.

If you write, you better not do anything else on the side.

You should put your mobile phone far away, and you should be logged out from all social networks and the email program.

If you need to get up in between because your legs are hurting, you should just stretch a bit instead of suddenly starting to clean your apartment or call people.

As long as you are working on your daily goal, anything that has nothing to do with writing is harmful. Only your breaks are exceptions. You have planned these in advance, and they belong to your to-do list.

Anything that is not on this list is better ignored until you are done the writing.

Note your results

If you have written your last word for the day, lean back, and enjoy the feeling of having earned something.

But don’t forget to document your progress. Make a note of the word count you have reached so that you have it black on white. Our memory is worse than we generally assume. If you don’t write down today that you have written two thousand words today, you won’t be able to say that with certainty in a week.

Complete documentation of what you have achieved every day can help you to overcome a motivation hole on bad days. When you see that you have reached your daily goal each time for the last fortnight, you will suddenly be very motivated not to let that chain break today.

Other results that you should note down concern your story. Update your timeline and scene plan. Write down plot twists that you have added to your story unscheduled.

So make sure you remember tomorrow what you sifted today. A summary of what you wrote today will anchor the current state of your story even more firmly in your head.

Backup

Now you can finally close all your documents. But the writing day is not over yet.

You still have to back up your data. If you ever had to read the lamentations of a colleague on Facebook in a group of authors, who lost weeks of work due to a hard disk crash, you know one thing: This should never happen to you.

So take your time and at least secure your current manuscript in a cloud. No matter if you use Dropbox, the Microsoft Cloud, or your webmail account — everything is better than having your work exclusively on your computer at home.

Plan the next day

Now comes the last step. If you are already too tired for this, you can also start the next day with this step.

Then the bid changes to “Plan the next session.”

But whether in the evening or the morning — now comes the time of plotting. In this step, you determine what you will write the next day (or after this step).

As I wrote above, you should always separate plotting, research, and writing. If you’ve been wondering when to plot so far, you now have the answer.

Read also:

do you want more of this?

Receive weekly email and don’t miss any of my articles.

suscribe here http://bit.ly/ReneJunge

Writing
Writing Tips
Writers On Writing
Focus
Success
Recommended from ReadMedium