avatarLambert Kung

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>

日文學習過來人狂推的文法書!人手都該有一本的文法書《適時適所》的五大特色

相信你在學習日文的過程中也有遇到類似的情形吧?

日文許多相似的文法是許多日文學習者會經歷的難題,想當初在學日文的過程中,日文的授受動詞、使役受身動詞、不同類型的動詞變化等相似的文法都困擾了我許久,尤其一般的日文學習者主要是依照 N5~N1 的級別這樣一級一級爬上去學習的,每一個級別有應該學習的文法種類,但是一般的日文教科書不會幫你統整相似的文法或句型,更遑論跨級別的文法整理。

而這時候就是《適時適所日本語表現句型》上場的時候了!除了一般的依照級別分類之日文檢定用書外,另外也推薦這一本日文文法整理的專門用書,不用再自己整理相似的文法了,讓日文教科書的老手出版社大新書局直接幫你整理完!

本篇文章有幾個特色:
1. 內容很詳細地介紹了《適時適所日本語表現句型 200》這套日文自學教材的特色,可以依自己的需求看自己是不適合這套用書
2. 舉出自己的日文學習歷程中遇到的瓶頸,以及《適時適所日本語表現句型 200》能幫上忙的地方

《適時適所日本語表現句型》簡介

【書名】

  • 《適時適所日本語表現句型 200 初.中級》
  • 《適時適所日本語表現句型 500 中.上級》

【價格(博客來九折連結)】

【內容簡介】

  • 共分為兩級,200 為初、中級,適合 N4~N5 程度之日文學習者;500 為中、上級,適合 N3~N1 程度之日文學習者
  • 依照日語之使用情境分章節,譬如說我手上的 500 第一課為<行為的對象>、第二課為<目的、手段、媒介>等
  • 每課的一開始會有簡單的小測驗,主要測驗讀者對於之後將要介紹的內容的了解程度,除了讓讀者明白自己的問題外,也有助於增加讀者的學習動機
  • 每一課會將用途相似或者日文學習者經常搞混之文法並列,並且區分每個文法的使用時機,讓讀者得以釐清日文文法,讓日文程度更上一階
  • 書中內容以日文為主,輔以簡單的中文
自己正在學習的《適時適所日本語表現句型 500》翻拍。圖片來源:筆者自行攝影。

《適時適所日本語表現句型》的五大特色

1、分成兩種級別,適合不同學習程度的人

有別於一般日文教科書以 JLPT 的五個級別作角材級別的區分,《適時適所日本語表現句型》的系列用書只有兩個級別,200 為初、中級,適合 N4~N5 程度之日文學習者;500 為中、上級,適合 N3~N1 程度之日文學習者,可以依照自己的程度選擇對應程度的文法用書。

2、相似文法的整理,並依照文法主題區分

由別於一般的日文學習書籍以 JLPT 的 N5~N1 作為區分,《適時適所日本語表現句型》將 N5 與 N4 的文法整合,N3 到 N1 的文法整合,依照使用情境區分,將相似的文法放在一起,並且說明不同文法的用途,讓日文學習者可以清楚地釐清每個文法的用法並且不再搞混。

3、培養日文閱讀能力

書中內容以日文為主,附註少數的中文,培養日文閱讀的沉浸環境。雖然是以日文為主,但是不用擔心看不懂作者的日文解說,除了因為我們是中文母語者,大多數的日文漢字對於我們來說不會過於困難,另一方面是作者的日文解釋都淺顯易懂,尤其是《適時適所日本語表現句型 200》,除了可以看純日文解說外,另外也可以搭配台灣版本的中譯解說,培養中日翻譯的基礎。

4、及時練習,點出盲點

每章節的一開頭有一頁篇幅的小試身手題目,首先測驗讀者對於之後的教學內容的理解程度,也讓讀者可以自己了解自己哪一部份的文法還會搞混甚至是誤用;而章節結束後,也會有課後的練習題,並附有解答,可以讓讀者知道在教材之後有沒有把原本不會的地方搞懂了!

5、大新書局出版,品質保證

相信學過日文的人都知道大新書局一系列的日文學習用書--《大家的日本語》吧,而這本《適時適所日本語表現句型》也是由大新書局出版的,內容品質有保障,不用擔心買到一些拐瓜劣棗的教科書!

推薦閱讀

給日語初學者「最完整」的日語自學用書推薦. 靠著《日本語 GOGOGO》系列用書,初學者也可以自學打好日文基礎!順便通過… | by 龔宇彥 YuYen, Kung | Kung’s Daily Life | Medium

半年的時間,從 N3 往 N2 前進的路. 靠著三本參考書,在半年的時間內,從 N3 往 N2 邁進,並且順利通過… | by 龔宇彥 YuYen, Kung | Kung’s Daily Life | Medium

謝謝看到最後的你

如果你覺得這篇文章不錯,請不吝給我 1~10 個掌聲(Claps); 如果你喜歡這篇文章,也歡迎分享到社群媒體給更多的朋友與持續關注我的最新文章。

Japanese
Books
Recommendations
Language Learning
Grammar
Recommended from ReadMedium