{"id":53739,"date":"2025-02-16T17:13:20","date_gmt":"2025-02-16T09:13:20","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53739\/"},"modified":"2025-02-16T17:13:20","modified_gmt":"2025-02-16T09:13:20","slug":"%e7%94%a8dspy%e6%8f%90%e5%8f%96%e7%bd%91%e7%ab%99%e8%af%8d%e6%b1%87%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53739\/","title":{"rendered":"\u7528DSPy\u63d0\u53d6\u7f51\u7ad9\u8bcd\u6c47\u8868"},"content":{"rendered":"<blockquote><p>\n  \u201c\u5982\u679c\u4f60\u60f3\u77e5\u9053\u672a\u6765\u5728\u54ea\u91cc\u521b\u9020\uff0c\u90a3\u5c31\u53bb\u5bfb\u627e\u8bed\u8a00\u88ab\u53d1\u660e\u548c\u5f8b\u5e08\u805a\u96c6\u7684\u5730\u65b9\u3002\u201d\u2014\u2014\u65af\u56fe\u5c14\u7279\u00b7\u5e03\u5170\u5fb7\n<\/p><\/blockquote>\n<p>\u8fd9\u5bf9\u4e8e\u4eba\u5de5\u667a\u80fd\u6765\u8bf4\u5f53\u7136\u662f\u6b63\u786e\u7684\u3002\u8ba9\u6211\u4eec\u628a[\u5f8b\u5e08]\u653e\u5728\u4e00\u8fb9\uff0c\u4e13\u6ce8\u4e8e\u6587\u5b57\u3002\uff08\u867d\u7136\u6cd5\u5f8b\u548c\u6587\u5b57\u901a\u5e38\u65e0\u6cd5\u5206\u5f00\uff01\uff09<\/p>\n<p>\u4efb\u4f55\u4e3a\u5e7f\u5927\u8bfb\u8005\u64b0\u5199\u6709\u5173AI\u7684\u6587\u7ae0\u7684\u4eba\u90fd\u4f1a\u53d1\u73b0\u81ea\u5df1\u4e00\u904d\u53c8\u4e00\u904d\u5730\u89e3\u91ca\u76f8\u540c\u7684\u672f\u8bed\u3002\u4f60\u65e0\u6cd5\u77e5\u9053\u8bfb\u8005\u4f1a\u628a\u4ec0\u4e48\u5e26\u5230\u4e00\u7bc7\u6587\u7ae0\u4e2d\uff0c\u800c\u8be5\u9886\u57df\u7684\u53d1\u5c55\u901f\u5ea6\u8ba9\u4e13\u5bb6\u4eec\u611f\u5230\u56f0\u60d1\uff0c\u4ed6\u4eec\u5bf9\u5e38\u7528\u672f\u8bed\u7684\u542b\u4e49\u4e89\u8bba\u4e0d\u4f11\u3002<\/p>\n<p>\u8fd9\u79cd\u5b9a\u4e49\u7684\u91cd\u590d\u542f\u53d1\u4e86\u4e3a\u6211\u7684\u7f51\u7ad9\u521b\u5efaAI\u8bcd\u6c47\u8868\u3002\u8fd9\u662f\u4e00\u9879\u6b63\u5728\u8fdb\u884c\u7684\u5de5\u4f5c\uff0c\u6709\u5927\u91cf\u79ef\u538b\u5de5\u4f5c\uff0c\u4f46\u4eca\u5929\u6211\u60f3\u5206\u4eab\u5b83\u662f\u5982\u4f55\u5f00\u59cb\u7684\uff0c\u4f7f\u7528DSPy\u3001Claude 3.5 Haiku \u548c\u4e00\u4e9b Jekyll \u529f\u80fd\u3002<\/p>\n<p>\u6211\u7684\u7f51\u7ad9\u662f\u4e00\u4e2a Jekyll \u7f51\u7ad9\u3002Jekyll \u662f\u4e00\u4e2a\u7528 Ruby \u7f16\u5199\u7684\u9759\u6001\u535a\u5ba2\u5f15\u64ce\u3002\u6240\u8c13\u201c\u9759\u6001\u201d\uff0c\u662f\u6307\u6ca1\u6709\u670d\u52a1\u5668\uff0c\u53ea\u6709\u6587\u4ef6\u3002\u8fd9\u4e9b\u6587\u4ef6\u662f\u4f7f\u7528 Jekyll \u8f6f\u4ef6\u751f\u6210\u548c\u7ec4\u88c5\u7684\uff0c\u89e3\u6790\u6211\u6240\u6709\u7684 markdown \u6587\u4ef6\u548c HTML \u6a21\u677f\u4ee5\u6784\u5efa\u5b8c\u6574\u7684\u7ad9\u70b9\u3002<\/p>\n<p>\u6211\u4eec\u5c06\u521b\u5efa\u4e00\u4e2a\u5c0f\u578b Python \u811a\u672c\uff0c\u8be5\u811a\u672c\u5c06\u51c6\u5907\u5e76\u5c06\u6240\u6709\u8fd9\u4e9b markdown \u5e16\u5b50\u901a\u8fc7 LLM \u4f20\u8f93\uff0c\u4ee5\u4fbf\u8bc6\u522b\u6f5c\u5728\u7684\u8bcd\u6c47\u8868\u672f\u8bed\u548c\u5b9a\u4e49\u3002<\/p>\n<p>\u9996\u5148\uff0c\u8ba9\u6211\u4eec\u8bbe\u7f6e DSPy \u5e76\u5c06\u5176\u6307\u5411 Claude\uff1a<\/p>\n<pre><code>import dspy\n\n# Set up DSPy and the LM\nlm = dspy.LM('anthropic\/claude-3-5-haiku-latest', api_key='YOUR_API_KEY')\ndspy.configure(lm=lm)<\/code><\/pre>\n<p>\u4e0a\u6b21\u6211\u4eec\u4f7f\u7528 DSPy \u65f6\uff0c\u6211\u4eec\u63a2\u7d22\u4e86\u5b83\u7684\u5de5\u4f5c\u539f\u7406\u4ee5\u53ca\u5b83\u5982\u4f55\u5728\u7ed9\u5b9a\u4e00\u4e9b\u8f7b\u91cf\u7ea7\u7ed3\u6784\u548c\u5b9a\u4e49\u7684\u60c5\u51b5\u4e0b\u4e3a\u4f60\u751f\u6210\u548c\u4f18\u5316\u63d0\u793a\u3002\u8fd9\u6b21\uff0c\u6211\u4eec\u5e0c\u671b\u8fd4\u56de\u4e00\u4e2a\u66f4\u590d\u6742\u7684\u5bf9\u8c61\uff1b\u4e0d\u4ec5\u4ec5\u662f\u8bcd\u6c47\u8868\u672f\u8bed\uff0c\u8fd8\u6709\u5176\u5b9a\u4e49\u3001\u540c\u4e49\u8bcd\u3001\u7f29\u5199\uff08\u5982\u679c\u6709\u7684\u8bdd\uff09\u4ee5\u53ca\u5e16\u5b50\u4e2d\u7684\u8be6\u7ec6\u9610\u8ff0\u3002\u8ba9\u60c5\u51b5\u590d\u6742\u5316\u7684\u662f\uff0c\u6211\u4eec\u5e0c\u671b\u6bcf\u4e2a\u5e16\u5b50\u5305\u542b\u8bb8\u591a\u672f\u8bed &#8211; DSPy \u9700\u8981\u8fd4\u56de\u4e00\u4e2a\u5b8c\u5168\u5b9a\u4e49\u7684\u672f\u8bed\u6570\u7ec4\u3002<\/p>\n<p>\u503c\u5f97\u5e86\u5e78\u7684\u662f\uff0cDSPy \u53ef\u4ee5\u4e0e Pydantic \u5f88\u597d\u5730\u914d\u5408\u4f7f\u7528\uff0cPydantic \u662f\u4e00\u4e2a\u6570\u636e\u9a8c\u8bc1\u5e93\uff0c\u5b83\u5141\u8bb8\u6211\u4eec\u5b9a\u4e49\u6240\u9700\u7684\u672f\u8bed\u5bf9\u8c61\uff1a<\/p>\n<pre><code>from pydantic import BaseModel\n\n# Define the Term object we want returned\nclass Term(BaseModel):\n    term: str = dspy.OutputField(desc=\"A glossary term, like: a technical term specific to the subject matter, a concept crucial to understanding an article's main ideas, a term explicitly defined or explained in a post, or a word or phrase that are frequently used or emphasized in the post. Do not include the abbreviation in the 'term' field.\")\n    abbreviation: str = dspy.OutputField(desc=\"Populate the abbreviation field if the term is abbreviated in the article, ensure that it is not pluralized. If there is no abbreviation, populate the abbreviation field with an empty string.\")\n    definition: str = dspy.OutputField(desc=\"A definition of the term. Lightly edit the definition so it can stand alone outside the context of the post, but ensure that you do not add any information that is not present in the original text.\")\n    details: str = dspy.OutputField(desc=\"Text from the post that expounds a bit on the term, adding texture and details beyond the definition. The 'details' field can be empty if there is no additional context to provide and multiple paragraphs if there is more than one piece of context to provide.\")\n    synonyms: List[str] = dspy.OutputField(desc=\"Any synonyms, acronyms, or alternative terms that are used in the post\")<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u4e0d\u4ec5\u5b9a\u4e49\u4e86\u8981\u8fd4\u56de\u7684\u6bcf\u4e2a\u672f\u8bed\u7684\u5c5e\u6027\uff0c\u8fd8\u7b80\u8981\u63cf\u8ff0\u4e86\u6bcf\u4e2a\u5c5e\u6027\u3002DSPy \u4f1a\u6ce8\u610f\u5230\u8fd9\u4e9b\u7c7b\u578b\u548c\u63cf\u8ff0\uff0c\u5e76\u5728 LLM \u7684\u8bf4\u660e\u4e2d\u4f7f\u7528\u5b83\u4eec\u3002<\/p>\n<p>\u8d77\u521d\uff0c\u8fd9\u611f\u89c9\u5f88\u5197\u957f\u3002\u5982\u679c\u6211\u4eec\u8981\u8be6\u7ec6\u8bf4\u660e\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u76f4\u63a5\u56de\u5230\u6807\u51c6\u7684\u957f\u63d0\u793a\uff0c\u5e76\u9644\u4e0a\u793a\u4f8b\u683c\u5f0f\u5462\uff1f<\/p>\n<p>\u9996\u5148\uff0c\u6211\u771f\u7684\u5f88\u559c\u6b22\u5c06\u63d0\u793a\u5206\u89e3\u6210\u72ec\u7acb\u7ec4\u4ef6\u7684\u65b9\u5f0f\u3002\u6d4f\u89c8\u672f\u8bed\u63cf\u8ff0\u6bd4\u76ee\u6d4b\u4e00\u5835\u4e09\u91cd\u5f15\u53f7\u5b57\u7b26\u4e32\u66f4\u5bb9\u6613\u3002\u6dfb\u52a0\u6216\u5220\u9664\u672f\u8bed\u5b9a\u4e49\u7684\u5c5e\u6027\u5f88\u7b80\u5355\u3002<\/p>\n<p>\u6b64\u5916\uff0cDSPy \u7ba1\u7406\u7ed3\u6784\u5316\u6570\u636e\u7684\u63d0\u53d6\u4ece\u63d0\u793a\u4e2d\u3002\u901a\u8fc7\u50cf\u8fd9\u6837\u5b9a\u4e49\u6211\u7684\u7b7e\u540d\uff0c\u6211\u53ef\u4ee5\u8c03\u7528\u5b83\u5e76\u8fd4\u56de\u4e00\u4e2a\u586b\u5145\u7684 <code>Term<\/code> \u5bf9\u8c61\u5217\u8868\uff0c\u800c\u65e0\u9700\u5904\u7406\u539f\u59cb\u6587\u672c\u56de\u590d\uff1a<\/p>\n<pre><code># Find key terms for the post and terms where their definition might not be clear to the reader\nclass ExtractTerms(dspy.Signature):\n    \"\"\"\n    Find key terms for the post and terms where their definition might\n    not be clear to the reader, from a markdown blog post. Ignore all \n    text between markdown code blocks.\n    \"\"\"\n\n    post: str = dspy.InputField(desc=\"the markdown blog post\")\n    terms: List[Term] = dspy.OutputField(desc=\"Array of glossary terms.\")\n\nextractTerms = dspy.Predict(ExtractTerms)<\/code><\/pre>\n<p>\u8fd9\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8c03\u7528\uff1a<\/p>\n<pre><code>terms = extractTerms(post=MY_MARKDOWN_POST_STRING).terms<\/code><\/pre>\n<p>\u73b0\u5728\u6211\u4eec\u53ef\u4ee5\u6d4f\u89c8\u6bcf\u7bc7\u6587\u7ae0\uff0c\u83b7\u53d6\u8be5\u6587\u7ae0\u7684\u672f\u8bed\uff0c\u5e76\u8bb0\u4e0b\u8be5\u672f\u8bed\u51fa\u73b0\u5728\u54ea\u7bc7\u6587\u7ae0\u4e2d\uff1a<\/p>\n<pre><code># Get the terms from the posts\nposts_path = Path(\"..\/_posts\")\nglossary = []\nfor post_file in sorted(posts_path.glob('*.md')):\n    print(f\"Processing {post_file}\")\n    with open(post_file, 'r') as f:\n        post_content = f.read()\n        # Remove any YAML frontmatter if it exists\n        post_content = re.split(r'\\n---\\n', post_content, maxsplit=2)[-1]\n        try:\n            terms = extractTerms(post=post_content)\n        except Exception as e:\n            print(f\"Failed to process {post_file}: {e}\")\n            continue\n        for term in terms.terms:\n            # We convert our term object to a dict so we\n            # can save our post path\n            term_dict = term.dict()\n            if term_dict['term'] not in glossary:\n                if str(post_file).startswith('..\/'):\n                    term_dict['path'] = str(post_file)[3:]\n                else:\n                    term_dict['path'] = post_file\n                print(f\"Adding term {term_dict['term']}\")\n                glossary.append(term_dict)<\/code><\/pre>\n<p>\u5982\u679c\u5728\u591a\u7bc7\u5e16\u5b50\u4e2d\u8bc6\u522b\u51fa\u76f8\u540c\u7684\u672f\u8bed\uff08\u786e\u5b9e\u5982\u6b64\uff09\uff0c\u6211\u4eec\u7684\u8bcd\u6c47\u8868\u5217\u8868\u4e2d\u5c31\u4f1a\u51fa\u73b0\u91cd\u590d\u7684\u672f\u8bed\u3002\u6211\u4eec\u53ef\u4ee5\u5408\u5e76\u5b83\uff0c\u6355\u83b7\u5f15\u7528\u7ed9\u5b9a\u672f\u8bed\u7684\u6bcf\u7bc7\u5e16\u5b50\u5e76\u8fde\u63a5\u5b83\u4eec\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<p>\u6bd4\u8f83\u4e24\u4e2a\u672f\u8bed\u5b57\u5178\uff0c\u770b\u770b\u5b83\u4eec\u662f\u5426\u662f\u540c\u4e00\u4e2a\u672f\u8bed<\/p>\n<pre><code># Compare two term dicts to see if they are the same term\ndef compare_terms(term1, term2):\n    if term1['term'].lower() == term2['term'].lower():\n        return True\n    if any(syn.lower() in [s.lower() for s in term2['synonyms']] for syn in term1['synonyms']):\n        return True\n    if term1['term'].lower() in [s.lower() for s in term2['synonyms']]:\n        return True\n        \n    return False\n\n# Condense the glossary by finding identical terms and merging their definitions, details, and synonyns.\nmerged_glossary = {}\nfor term in glossary:\n    found = False\n    for key in merged_glossary:\n        if compare_terms(term, merged_glossary[key]):\n            found = True\n            merged_glossary[key]['details'] += \"\\n\\n\" + term['details']\n            merged_glossary[key]['synonyms'] += term['synonyms']\n            merged_glossary[key]['pages'].append(term['path'])\n            merged_glossary[key]['synonyms'] = list(set(merged_glossary[key]['synonyms']))\n            break\n    if not found:\n        page = term['path']\n        term['pages'] = [page]\n        merged_glossary[term['term']] = term<\/code><\/pre>\n<p>\u7136\u540e\u6211\u4eec\u5bf9\u5176\u8fdb\u884c\u6392\u5e8f\u5e76\u5c06\u5176\u4fdd\u5b58\u5230 _data \u76ee\u5f55\uff1a<\/p>\n<pre><code># Sort the merged_glossary by keys\nsorted_glossary = dict(sorted(merged_glossary.items()))\n\n# Create the _data directory if it doesn't exist\nPath(\"..\/_data\").mkdir(parents=True, exist_ok=True)\n\n# Write the sorted glossary values to a YAML file\nwith open('..\/_data\/glossary_gen.yaml', 'w') as yaml_file:\n    yaml.dump(list(sorted_glossary.values()), yaml_file, default_flow_style=False, sort_keys=False)<\/code><\/pre>\n<p>\u6211\u4eec\u5728\u8fd9\u91cc\u5c06\u5176\u79f0\u4e3a glossary_get.yaml\uff0c\u56e0\u4e3a\u6211\u4eec\u7684\u6700\u7ec8\u8bcd\u6c47\u8868\u5c06\u53ea\u662f glossary.yaml\u3002\u6211\u4eec\u5c06\u624b\u52a8\u68c0\u67e5\u548c\u7f16\u8f91\u751f\u6210\u7684\u8f93\u51fa\uff0c\u5e76\u5728\u5b8c\u6210\u540e\u5c06\u5176\u91cd\u547d\u540d\u4e3a\u66f4\u7b80\u5355\u7684\u540d\u79f0\u3002\u8fd9\u6837\uff0c\u4efb\u4f55\u672a\u6765\u7684\u751f\u6210\u90fd\u4e0d\u4f1a\u8986\u76d6\u6211\u4eec\u624b\u5de5\u6253\u78e8\u7684\u6587\u4ef6\u3002<\/p>\n<p>_data \u76ee\u5f55\u4e2d\u7684 YAML \u6587\u4ef6\u7531 Jekyll \u4e13\u95e8\u5904\u7406\u3002YAML\uff08\u6216 CSV \u6216 JSON\uff09\u4f5c\u4e3a\u5bf9\u8c61\u8bfb\u5165\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u6784\u5efa\u7f51\u7ad9\u671f\u95f4\u5f15\u7528\u5b83\u3002<\/p>\n<p>\u6211\u4eec\u7684\u8bcd\u6c47\u8868\u9875\u9762\u4f7f\u7528\u4e00\u4e9b\u8f7b\u91cf\u7ea7\u6a21\u677f\u6765\u5448\u73b0\u6bcf\u4e2a\u672f\u8bed\u3002<\/p>\n<p>\u4f46\u66f4\u597d\u7684\u662f\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 Jekyll \u7684\u5305\u542b\u529f\u80fd\u89e3\u51b3\u6211\u4eec\u6700\u521d\u7684\u95ee\u9898\uff0c\u5b83\u7c7b\u4f3c\u4e8e Rails \u7684\u5c40\u90e8\u51fd\u6570\u3002\u8ba9\u6211\u4eec\u50cf\u8fd9\u6837\u521b\u5efa _includes\/term.html\uff1a<\/p>\n<pre><code>&lt;div class=\"term\"&gt;\n{% for item in site.data.glossary %}\n    {% if item.term == include.term or item.abbreviation == include.term %}\n        {% if item.abbreviation == \"\" %}\n            &lt;h1&gt;{{ item.term }} &lt;\/h1&gt;\n        {% else %}\n            &lt;h1&gt;{{ item.term}} ({{ item.abbreviation}})&lt;\/h1&gt;\n        {% endif %}\n        {% if item.synonyms.size &gt; 0 %}\n            &lt;p class=\"aka\"&gt;&lt;span class=\"aka-header\"&gt;Also known as&lt;\/span&gt; {{ item.synonyms | join: \", \" }}&lt;\/p&gt;\n        {% endif %}\n            &lt;div class=\"definition\"&gt;\n                &lt;p&gt;{{ item.definition }}&lt;\/p&gt;\n            {% if include.show_details == \"true\" %}\n                &lt;p&gt;{{ item.details | markdownify }}&lt;\/p&gt;\n            {% endif %}\n            &lt;\/div&gt;\n    {% endif %}\n{% endfor %}\n&lt;\/div&gt;<\/code><\/pre>\n<p>\u6dfb\u52a0\u4e00\u4e9b CSS \u6837\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u6b64\u884c\u6dfb\u52a0\u5230\u4efb\u4f55\u672a\u6765\u7684\u5e16\u5b50\u4e2d\uff1a<\/p>\n<pre><code>{% include term.html term=\"RLHF\" %}<\/code><\/pre>\n<p>\u7ed3\u679c\uff1a<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u989d\u5916\u7684\u53c2\u6570\u6765\u8be6\u7ec6\u8bf4\u660e\u4e00\u4e0b\uff1a<\/p>\n<pre><code>{% include term.html term=\"RLHF\" show_details=\"true\" %}<\/code><\/pre>\n<p>\u8fd9\u8ba9\u6211\u4eec\u5f97\u5230\uff1a<\/p>\n<p>\u4f7f\u7528 LLM \u6765\u52a0\u5feb\u8bcd\u6c47\u8868\u7684\u6c47\u7f16\u6709\u5f88\u5927\u5e2e\u52a9\u3002\u6211\u4eec\u6700\u521d\u7684 YAML \u8f93\u51fa\u8d85\u8fc7 2,000 \u884c\u3002\u4fee\u526a\u79bb\u9898\u672f\u8bed\u548c\u8c03\u6574\u7ec6\u8282\u82b1\u4e86\u4e00\u4e2a\u5c0f\u65f6\u5de6\u53f3\u3002<\/p>\n<p>\u4f7f\u7528 DSPy \u7684\u521d\u59cb\u811a\u672c\u7f16\u5199\u53ea\u82b1\u4e86\u5341\u51e0\u5206\u949f\u5de6\u53f3\u3002 DSPy \u8ba9\u4f60\u83b7\u5f97\u6982\u5ff5\u9a8c\u8bc1\u7684\u901f\u5ea6\u4ee4\u4eba\u5370\u8c61\u6df1\u523b\uff0c\u5b83\u8ba9\u4f60\u65e0\u9700\u9762\u5bf9\u5197\u957f\u7684\u63d0\u793a\uff0c\u800c\u662f\u4e3a\u4f60\u63d0\u4f9b\u4e86\u672a\u6765\u8fed\u4ee3\u548c\u4f18\u5316\u7684\u811a\u624b\u67b6\u3002<\/p>\n<p>\u5982\u679c\u4f60\u60f3\u5728\u81ea\u5df1\u7684\u7f51\u7ad9\u4e0a\u5c1d\u8bd5\u4e00\u4e0b\uff0c\u53ef\u4ee5\u5728\u627e\u5230\u6211\u7684\u6240\u6709\u4ee3\u7801\u3002<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>\u201c\u5982\u679c\u4f60\u60f3\u77e5\u9053\u672a\u6765\u5728\u54ea\u91cc\u521b\u9020\uff0c\u90a3\u5c31\u53bb\u5bfb\u627e\u8bed\u8a00\u88ab\u53d1\u660e\u548c\u5f8b\u5e08\u805a\u96c6\u7684\u5730\u65b9\u3002\u201d\u2014\u2014\u65af\u56fe\u5c14\u7279\u00b7\u5e03\u5170\u5fb7 \u8fd9\u5bf9\u4e8e\u4eba\u5de5\u667a\u80fd\u6765\u8bf4\u5f53\u7136\u662f\u6b63\u786e\u7684\u3002\u8ba9\u6211\u4eec\u628a[\u5f8b\u5e08]\u653e\u5728\u4e00\u8fb9\uff0c\u4e13\u6ce8\u4e8e\u6587\u5b57\u3002\uff08\u867d\u7136\u6cd5\u5f8b\u548c\u6587\u5b57\u901a\u5e38\u65e0\u6cd5\u5206\u5f00\uff01\uff09 \u4efb\u4f55\u4e3a\u5e7f\u5927\u8bfb\u8005\u64b0\u5199\u6709\u5173AI\u7684\u6587\u7ae0\u7684\u4eba\u90fd\u4f1a\u53d1\u73b0\u81ea\u5df1\u4e00\u904d\u53c8\u4e00\u904d\u5730\u89e3\u91ca\u76f8\u540c\u7684\u672f\u8bed\u3002\u4f60\u65e0\u6cd5\u77e5\u9053\u8bfb\u8005\u4f1a\u628a\u4ec0\u4e48\u5e26\u5230\u4e00\u7bc7\u6587\u7ae0\u4e2d\uff0c\u800c\u8be5\u9886\u57df\u7684\u53d1\u5c55\u901f\u5ea6\u8ba9\u4e13\u5bb6\u4eec\u611f\u5230\u56f0\u60d1\uff0c\u4ed6\u4eec\u5bf9\u5e38\u7528\u672f\u8bed\u7684\u542b\u4e49\u4e89\u8bba\u4e0d\u4f11\u3002 \u8fd9\u79cd\u5b9a\u4e49\u7684\u91cd\u590d\u542f\u53d1\u4e86\u4e3a\u6211\u7684\u7f51\u7ad9\u521b\u5efaAI\u8bcd\u6c47\u8868\u3002\u8fd9\u662f\u4e00\u9879\u6b63\u5728\u8fdb\u884c\u7684\u5de5\u4f5c\uff0c\u6709\u5927\u91cf\u79ef\u538b\u5de5\u4f5c\uff0c\u4f46\u4eca\u5929\u6211\u60f3\u5206\u4eab\u5b83\u662f\u5982\u4f55\u5f00\u59cb\u7684\uff0c\u4f7f\u7528DSPy\u3001Claude 3.5 Haiku \u548c\u4e00\u4e9b Jekyll \u529f\u80fd\u3002 \u6211\u7684\u7f51\u7ad9\u662f\u4e00\u4e2a Jekyll \u7f51\u7ad9\u3002Jekyll \u662f\u4e00\u4e2a\u7528 Ruby \u7f16\u5199\u7684\u9759\u6001\u535a\u5ba2\u5f15\u64ce\u3002\u6240\u8c13\u201c\u9759\u6001\u201d\uff0c\u662f\u6307\u6ca1\u6709\u670d\u52a1\u5668\uff0c\u53ea\u6709\u6587\u4ef6\u3002\u8fd9\u4e9b\u6587\u4ef6\u662f\u4f7f\u7528 Jekyll \u8f6f\u4ef6\u751f\u6210\u548c\u7ec4\u88c5\u7684\uff0c\u89e3\u6790\u6211\u6240\u6709\u7684 markdown \u6587\u4ef6\u548c HTML \u6a21\u677f\u4ee5\u6784\u5efa\u5b8c\u6574\u7684\u7ad9\u70b9\u3002 \u6211\u4eec\u5c06\u521b\u5efa\u4e00\u4e2a\u5c0f\u578b Python \u811a\u672c\uff0c\u8be5\u811a\u672c\u5c06\u51c6\u5907\u5e76\u5c06\u6240\u6709\u8fd9\u4e9b markdown \u5e16\u5b50\u901a\u8fc7 LLM \u4f20\u8f93\uff0c\u4ee5\u4fbf\u8bc6\u522b\u6f5c\u5728\u7684\u8bcd\u6c47\u8868\u672f\u8bed\u548c\u5b9a\u4e49\u3002 \u9996\u5148\uff0c\u8ba9\u6211\u4eec\u8bbe\u7f6e DSPy \u5e76\u5c06\u5176\u6307\u5411 Claude\uff1a import dspy # Set up DSPy and the LM lm = dspy.LM(&#8216;anthropic\/claude-3-5-haiku-latest&#8217;, api_key=&#8217;YOUR_API_KEY&#8217;) dspy.configure(lm=lm) \u4e0a\u6b21\u6211\u4eec\u4f7f\u7528 DSPy \u65f6\uff0c\u6211\u4eec\u63a2\u7d22\u4e86\u5b83\u7684\u5de5\u4f5c\u539f\u7406\u4ee5\u53ca\u5b83\u5982\u4f55\u5728\u7ed9\u5b9a\u4e00\u4e9b\u8f7b\u91cf\u7ea7\u7ed3\u6784\u548c\u5b9a\u4e49\u7684\u60c5\u51b5\u4e0b\u4e3a\u4f60\u751f\u6210\u548c\u4f18\u5316\u63d0\u793a\u3002\u8fd9\u6b21\uff0c\u6211\u4eec\u5e0c\u671b\u8fd4\u56de\u4e00\u4e2a\u66f4\u590d\u6742\u7684\u5bf9\u8c61\uff1b\u4e0d\u4ec5\u4ec5\u662f\u8bcd\u6c47\u8868\u672f\u8bed\uff0c\u8fd8\u6709\u5176\u5b9a\u4e49\u3001\u540c\u4e49\u8bcd\u3001\u7f29\u5199\uff08\u5982\u679c\u6709\u7684\u8bdd\uff09\u4ee5\u53ca\u5e16\u5b50\u4e2d\u7684\u8be6\u7ec6\u9610\u8ff0\u3002\u8ba9\u60c5\u51b5\u590d\u6742\u5316\u7684\u662f\uff0c\u6211\u4eec\u5e0c\u671b\u6bcf\u4e2a\u5e16\u5b50\u5305\u542b\u8bb8\u591a\u672f\u8bed &#8211; DSPy \u9700\u8981\u8fd4\u56de\u4e00\u4e2a\u5b8c\u5168\u5b9a\u4e49\u7684\u672f\u8bed\u6570\u7ec4\u3002 \u503c\u5f97\u5e86\u5e78\u7684\u662f\uff0cDSPy \u53ef\u4ee5\u4e0e Pydantic [&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-53739","post","type-post","status-publish","format-standard","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53739","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=53739"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53739\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}