{"id":53712,"date":"2025-02-16T10:42:52","date_gmt":"2025-02-16T02:42:52","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53712\/"},"modified":"2025-02-16T10:42:52","modified_gmt":"2025-02-16T02:42:52","slug":"deepseek-r1%e6%96%b0%e9%97%bb%e6%8e%a8%e7%90%86","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53712\/","title":{"rendered":"DeepSeek-R1\u65b0\u95fb\u63a8\u7406"},"content":{"rendered":"<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4e86\u89e3\u4f7f\u7528 DeepSeek \u5bf9\u65b0\u95fb\u6587\u7ae0\u8fdb\u884c\u63a8\u7406\u7684\u65b9\u5f0f\u3002\u4e00\u5207\u90fd\u4f7f\u7528 Ollama \u5728\u672c\u5730\u8bbe\u7f6e\u3002<\/p>\n<p>\u5982\u679c\u4f60\u662f\u80a1\u7968\u6216\u5e76\u8d2d\u5206\u6790\u5e08\u5e76\u5e0c\u671b\u4e86\u89e3\u63a8\u7406\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4e00\u4e0b\u3002\u6211\u4eec\u4ecb\u7ecd\u4e86\u4e24\u79cd\u573a\u666f<\/p>\n<ul>\n<li>\u5bf9\u7b80\u5355\u65b0\u95fb\u8fdb\u884c\u63a8\u7406<\/li>\n<li>\u4f7f\u7528 Azure Bing API \u670d\u52a1\u4e3a\u65b0\u95fb\u63d0\u4f9b\u66f4\u591a\u80cc\u666f\u4fe1\u606f<\/li>\n<\/ul>\n<p>\u4ee3\u7801\u5728\u516c\u5f00\u63d0\u4f9b\u3002\u4f60\u9700\u8981\u77e5\u9053\u5982\u4f55\u8bbe\u7f6e Visual Studio Code Dev Container\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<h2>1\u3001\u573a\u666f1\uff1a\u7b80\u5355\u65b0\u95fb\u6587\u7ae0<\/h2>\n<p>\u8fd9\u91cc\u6211\u4eec\u5bf9\u7b80\u5355\u65b0\u95fb\u8fdb\u884c\u63a8\u7406\uff1a<\/p>\n<pre><code>import ollama\nfrom pprint import pprint\nimport re\n\n\ndef only_return_main_answer(response_content_from_llm):\n    \"\"\" This function removes the reasoning part of the response and only returns the main answer \"\"\"\n    tmp_answer = re.sub(r\"&lt;think&gt;.*?&lt;\/think&gt;\", \"\", response_content_from_llm, flags=re.DOTALL).strip()\n    return(tmp_answer)\n\n\nINSTRUCTION_PROMPT = \"You are expert on M&amp;A. Can you provide with a very brief summary of the following news article?\"\n\ndef get_all_responses(news_article):\n    response = ollama.chat(\n        model=\"deepseek-r1:1.5b\",\n        messages=[\n            {\"role\": \"system\", \"content\": INSTRUCTION_PROMPT},\n            {\"role\": \"user\", \"content\": news_article},\n        ],\n    )\n    response_content_from_llm = response[\"message\"][\"content\"]\n    only_answer_no_reasoning = only_return_main_answer(response_content_from_llm)\n    return(response_content_from_llm, only_answer_no_reasoning)\n\nnews_article = \"Nissan Motor Co. is prepared to reject an acquisition offer that would make it a subsidiary of Honda Motor Co., according to a person familiar with the matter, a move that could jeopardize talks between the two carmakers to join forces.\"\nresponse_content_from_llm, only_answer_no_reasoning = get_all_responses(news_article)\n\nprint(response_content_from_llm)<\/code><\/pre>\n<p>\u6211\u4eec\u5728\u8fd9\u91cc\u8981\u6c42\u8fdb\u884c\u7b80\u5355\u7684\u603b\u7ed3\u5e76\u67e5\u770b\u6240\u6709\u63a8\u7406\uff0c\u54cd\u5e94\u5982\u4e0b\uff1a<\/p>\n<pre><code>&lt;think&gt;\nOkay, so I need to provide a brief summary of the given news article about Nissan and Honda merging. Let me start by reading through the article carefully.\n\nThe article mentions that Nissan is considering an acquisition offer from Honda that would make it a subsidiary of Honda. This move could potentially delay or jeopardize talks between the two companies to merge. I remember seeing something like this before, so I think I can summarize it.\n\nI should note that the person involved in this information is familiar with the matter, which shows they're experienced and have some background knowledge. That might make the summary more credible.\n\nThe key points are: Nissan's decision to reject the merger offer, making it a subsidiary of Honda instead, and how this could affect their talks. It's important to mention that this move is crucial for their potential merger plan.\n\nI need to keep it brief, so I'll only include the main ideas without getting too detailed. Maybe something like: Nissan rejects the acquisition offer, considering it might delay or destabilize talks with Honda over a potential merger.\n&lt;\/think&gt;\n\nNissan has decided to reject an acquisition offer that would make it a subsidiary of Honda Motor Co., potentially delaying or destabilizing discussions about a potential merger between the two companies.<\/code><\/pre>\n<h2>2\u3001\u573a\u666f 2\uff1a\u4e3a\u65b0\u95fb\u63d0\u4f9b\u66f4\u591a\u80cc\u666f<\/h2>\n<p>\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528 \u63d0\u4f9b\u66f4\u591a\u4e0a\u4e0b\u6587\uff1a<\/p>\n<pre><code>\nimport ollama\nfrom pprint import pprint\nimport re, os \nfrom dotenv import load_dotenv\nload_dotenv()\n\n\nfrom news_search_client import NewsSearchClient\nfrom azure.core.credentials import AzureKeyCredential\nSUBSCRIPTION_KEY = os.getenv(\"BING_SEARCH_SUBSCRIPTION_KEY\")\nENDPOINT = \"https:\/\/api.bing.microsoft.com\" + \"\/v7.0\/\"\n\ndef news_search(param_query):\n    \"\"\"NewsSearch using BING API, latest 4 news description for the given query.\n    \"\"\"\n    client = NewsSearchClient(\n        endpoint=ENDPOINT, credential=AzureKeyCredential(SUBSCRIPTION_KEY)\n    )\n\n    try:\n        news_result = client.news.search(\n            query=param_query, market=\"en-us\", count=4, freshness=\"Week\",\n        )\n        if news_result.value:\n            return [{\"role\": \"assistant\", \"content\": n.description}  for n in news_result.value]\n\n    except Exception as err:\n        return []\n\n\nprint(news_search(\"Nissan Motor Co. merger\"))\n\n\"\"\"\n[{'role': 'assistant',\n  'content': 'Even if the merger is off, Nissan remains keen on working with Honda in areas such as electric vehicles and software defined vehicles.'},\n {'role': 'assistant',\n  'content': 'Two of Japan\u2019s largest automakers have been in talks to combine their operations to form one of the world\u2019s biggest car groups.'},\n {'role': 'assistant',\n  'content': 'The Wall Street Journal reported that Nissan was likely to walk away from a merger proposed in December that would create the world\u2019s third-largest auto maker. It was a'},\n {'role': 'assistant',\n  'content': 'Shares of Nissan Motor Co. and Honda Motor Co. rose following reports that the automakers\u2019 proposed merger may be scrapped.'}]\n\"\"\"\n\ndef only_return_main_answer(response_content_from_llm):\n    \"\"\" This function removes the reasoning part of the response and only returns the main answer \"\"\"\n    tmp_answer = re.sub(r\"&lt;think&gt;.*?&lt;\/think&gt;\", \"\", response_content_from_llm, flags=re.DOTALL).strip()\n    return(tmp_answer)\n\n\nINSTRUCTION_PROMPT = \"You are expert on M&amp;A. Can you provide with a very brief summary of the following news article?\"\n\ndef get_all_responses(news_article, news_topic):\n\n    tmp_content = news_search(news_article)\n    tmp_array = []\n    tmp_array.append({\"role\": \"system\", \"content\": INSTRUCTION_PROMPT})\n    for item in tmp_content:\n        tmp_array.append(item)\n    tmp_array.append({\"role\": \"user\", \"content\": news_article})\n\n    response = ollama.chat(\n        model=\"deepseek-r1:1.5b\",\n        messages=tmp_array\n    )\n    response_content_from_llm = response[\"message\"][\"content\"]\n    only_answer_no_reasoning = only_return_main_answer(response_content_from_llm)\n    return(response_content_from_llm, only_answer_no_reasoning)\n\nnews_article = \"Nissan Motor Co. is prepared to reject an acquisition offer that would make it a subsidiary of Honda Motor Co., according to a person familiar with the matter, a move that could jeopardize talks between the two carmakers to join forces.\"\nnews_topic= \"Nissan Motor Co. merger\"\nresponse_content_from_llm, only_answer_no_reasoning = get_all_responses(news_article,news_topic)\nprint(response_content_from_llm)\n<\/code><\/pre>\n<p>\u54cd\u5e94\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre><code>&lt;think&gt;\nAlright, so I'm trying to figure out how to approach this task. The user has given me some history about my previous interaction with them and now they've provided another query. Let's see what it says.\n\nIn their last message, they sent a complete summary of a news article about Nissan Motor Co. declining an acquisition offer that would make it a subsidiary of Honda Motor Co., potentially jeopardizing their talks to join forces. Now, the new query is identical: \"Nissan Motor Co. is prepared to reject an acquisition offer that would make it a subsidiary of Honda Motor Co., according to a person familiar with the matter, a move that could jeopardize talks between the two carmakers to join forces.\"\n\nHmm, I notice some repetition here. The user wrote this twice, once as a summary and then again as their current query. That's probably because they wanted me to provide a very brief summary of the news article in the previous message.\n\nLooking back, my initial response was a complete summary that included all the key points: Nissan is preparing to reject an acquisition offer, which could jeopardize their alliance with Honda. I should make sure to capture both parts accurately without including extra information.\n\nI also need to pay attention to the specific names and market capitalizations mentioned\u2014Nissan is valued at $250 billion, and Honda around $430 billion\u2014and ensure these details are included in my summary for clarity and completeness.\n\nAdditionally, I should check if there's any underlying context or reasoning behind the news. The user might be looking to understand why this merger-related decision is happening, possibly as a potential strategic move by one company over the other.\n\nI need to structure my response clearly, starting with the headline of the article, followed by the key details about the acquisition offer, the impact on the companies' relationship, and the mention of market valuations. That way, it's concise yet informative.\n\nWait, but in my previous interaction, I included both parts: the summary of the news and then repeated the same information. Maybe I should avoid redundancy this time and focus solely on the key points as requested by the user.\n\nSo, in my response, I'll make sure to separate these details into distinct paragraphs for clarity. That way, when the user asks again, they can easily extract the necessary information without getting bogged down by extra content.\n\nI also need to ensure that all numerical values are correctly noted\u2014Nissan at $250 billion and Honda at $430 billion. Missing this could lead to inaccuracies in the summary.\n\nLastly, I should confirm that my response is free from any external links or references unless they're part of the article's content, which they aren't in this case. Keeping it all within the user's instructions means being precise and concise.\n&lt;\/think&gt;\n\nNissan Motor Co. is preparing to reject an acquisition offer that would make it a subsidiary of Honda Motor Co., potentially jeopardizing talks between the two carmakers to join forces. According to a person familiar with the matter, this move could hamper the potential alliance between the companies.\n<\/code><\/pre>\n<h2>3\u3001\u7ed3\u675f\u8bed<\/h2>\n<p>\u867d\u7136\u8fd9\u662f\u4e3b\u89c2\u7684\uff0c\u4f46\u4e3a\u65b0\u95fb\u62a5\u9053\u63d0\u4f9b\u66f4\u591a\u80cc\u666f\u4f3c\u4e4e\u53ef\u4ee5\u4e3a\u6211\u4ea7\u751f\u66f4\u597d\u7684\u7b54\u6848\u3002<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5b9e\u9a8c\uff0c\u4f46\u4f60\u53ef\u4ee5\u901a\u8fc7\u6539\u53d8\u4e00\u4e9b\u4e8b\u60c5\u5e76\u5206\u6790\u7ed3\u679c\u6765\u8d85\u8d8a\u3002<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4e86\u89e3\u4f7f\u7528 DeepSeek \u5bf9\u65b0\u95fb\u6587\u7ae0\u8fdb\u884c\u63a8\u7406\u7684\u65b9\u5f0f\u3002\u4e00\u5207\u90fd\u4f7f\u7528 Ollama \u5728\u672c\u5730\u8bbe\u7f6e\u3002 \u5982\u679c\u4f60\u662f\u80a1\u7968\u6216\u5e76\u8d2d\u5206\u6790\u5e08\u5e76\u5e0c\u671b\u4e86\u89e3\u63a8\u7406\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4e00\u4e0b\u3002\u6211\u4eec\u4ecb\u7ecd\u4e86\u4e24\u79cd\u573a\u666f \u5bf9\u7b80\u5355\u65b0\u95fb\u8fdb\u884c\u63a8\u7406 \u4f7f\u7528 Azure Bing API \u670d\u52a1\u4e3a\u65b0\u95fb\u63d0\u4f9b\u66f4\u591a\u80cc\u666f\u4fe1\u606f \u4ee3\u7801\u5728\u516c\u5f00\u63d0\u4f9b\u3002\u4f60\u9700\u8981\u77e5\u9053\u5982\u4f55\u8bbe\u7f6e Visual Studio Code Dev Container\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u4e86\u3002 1\u3001\u573a\u666f1\uff1a\u7b80\u5355\u65b0\u95fb\u6587\u7ae0 \u8fd9\u91cc\u6211\u4eec\u5bf9\u7b80\u5355\u65b0\u95fb\u8fdb\u884c\u63a8\u7406\uff1a import ollama from pprint import pprint import re def only_return_main_answer(response_content_from_llm): &#8220;&#8221;&#8221; This function removes the reasoning part of the response and only returns the main answer &#8220;&#8221;&#8221; tmp_answer = re.sub(r&#8221;&lt;think&gt;.*?&lt;\/think&gt;&#8221;, &#8220;&#8221;, response_content_from_llm, flags=re.DOTALL).strip() return(tmp_answer) INSTRUCTION_PROMPT [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-53712","post","type-post","status-publish","format-standard","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=53712"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53712\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}