
{"id":4276,"date":"2025-01-14T20:13:48","date_gmt":"2025-01-14T12:13:48","guid":{"rendered":"https:\/\/infernews.com\/?p=4276"},"modified":"2025-01-14T20:26:51","modified_gmt":"2025-01-14T12:26:51","slug":"ollama-%e7%b5%90%e6%a7%8b%e5%8c%96%e7%9a%84%e8%bc%b8%e5%87%ba%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"https:\/\/infernews.com\/blog\/ollama-%e7%b5%90%e6%a7%8b%e5%8c%96%e7%9a%84%e8%bc%b8%e5%87%ba%e6%96%b9%e6%a1%88\/","title":{"rendered":"Ollama \u7d50\u69cb\u5316\u7684\u8f38\u51fa\u65b9\u6848"},"content":{"rendered":"\n<p>\u300cstructured-outputs\u300d\uff0c\u4e3b\u8981\u5c55\u793a\u5982\u4f55\u5229\u7528 OpenAI \u548c Ollama \u9019\u5169\u500b\u5927\u578b\u8a9e\u8a00\u6a21\u578b\u5e73\u53f0\uff0c\u4ee5\u7d50\u69cb\u5316\u7684\u8f38\u51fa\u65b9\u5f0f\u9a57\u8b49\u6578\u7368\u904a\u6232\u7684\u6709\u6548\u6027\u3002\u7a0b\u5f0f\u78bc\u5305\u542b\u4e00\u500b\u6e2c\u8a66\u67b6\u69cb\uff0c\u793a\u7bc4\u5982\u4f55\u4f7f\u7528\u4e0d\u540c\u7684\u6a21\u578b\uff08\u4f8b\u5982 OpenAI \u7684 gpt-4o-mini \u548c Ollama \u7684 phi4\uff09\u4ee5\u53ca\u76f8\u61c9\u7684\u57f7\u884c\u6307\u4ee4\u3002\u5c08\u6848\u76ee\u524d\u53ea\u6709 Python \u7a0b\u5f0f\u78bc\uff0c\u4e26\u6709\u7c21\u6f54\u7684 README \u6a94\u8aaa\u660e\u4f7f\u7528\u65b9\u6cd5\uff0c\u4f46\u7f3a\u4e4f\u66f4\u8a73\u7d30\u7684\u5c08\u6848\u63cf\u8ff0\u548c\u8cc7\u6e90\u9023\u7d50\uff0c\u661f\u661f\u6578\u548c\u95dc\u6ce8\u5ea6\u4e5f\u90fd\u5f88\u4f4e\u3002&nbsp;<strong>\u6838\u5fc3\u76ee\u7684<\/strong>\u5728\u65bc\u5c55\u793a\u7d50\u69cb\u5316\u8f38\u51fa\u7684\u61c9\u7528\uff0c\u4e26\u63d0\u4f9b OpenAI \u548c Ollama \u7684\u5be6\u4f5c\u7bc4\u4f8b\u3002<\/p>\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"lyte-wrapper\" title=\"Ollama Structured Outputs with Phi4 is KILLER - Get Started NOW!!\" style=\"width:853px;max-width:100%;margin:5px auto;\"><div class=\"lyMe\" id=\"WYL_b4SzU62nSKQ\" itemprop=\"video\" itemscope itemtype=\"https:\/\/schema.org\/VideoObject\"><div><meta itemprop=\"thumbnailUrl\" content=\"https:\/\/infernews.com\/blog\/wp-content\/plugins\/wp-youtube-lyte\/lyteCache.php?origThumbUrl=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fb4SzU62nSKQ%2Fhqdefault.jpg\" \/><meta itemprop=\"embedURL\" content=\"https:\/\/www.youtube.com\/embed\/b4SzU62nSKQ\" \/><meta itemprop=\"duration\" content=\"PT26M11S\" \/><meta itemprop=\"uploadDate\" content=\"2025-01-13T17:30:06Z\" \/><\/div><div id=\"lyte_b4SzU62nSKQ\" data-src=\"https:\/\/infernews.com\/blog\/wp-content\/plugins\/wp-youtube-lyte\/lyteCache.php?origThumbUrl=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fb4SzU62nSKQ%2Fhqdefault.jpg\" class=\"pL\"><div class=\"tC\"><div class=\"tT\" itemprop=\"name\">Ollama Structured Outputs with Phi4 is KILLER - Get Started NOW!!<\/div><\/div><div class=\"play\"><\/div><div class=\"ctrl\"><div class=\"Lctrl\"><\/div><div class=\"Rctrl\"><\/div><\/div><\/div><noscript><a href=\"https:\/\/youtu.be\/b4SzU62nSKQ\" rel=\"nofollow\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/infernews.com\/blog\/wp-content\/plugins\/wp-youtube-lyte\/lyteCache.php?origThumbUrl=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fb4SzU62nSKQ%2F0.jpg\" alt=\"Ollama Structured Outputs with Phi4 is KILLER - Get Started NOW!!\" width=\"853\" height=\"460\" \/><br \/>Watch this video on YouTube<\/a><\/noscript><meta itemprop=\"description\" content=\"Structured Outputs gives the ability to specify to the model to return it&#039;s outputs in a format that you specify. Now that Ollama supports structured outputs, you can do some pretty incredible things from building verifiers to agent. In this video chris explains how to get started with Structured Outputs and show how it&#039;s can be used to write verifiers or even self-reflecting sudoku puzzle verifiers. Github Repo: https:\/\/github.com\/chrishayuk\/structured-outputs Full Video on Phi4: https:\/\/youtu.be\/aYvt9czdgbU 00:00 - Introduction 01:45 - Verifiers demo 02:45 - Pydantic Objects 05:11 - Getting the schema and json 06:30 - Ollama and Phi4 10:00 - Calling Structured Outputs from Ollama and Phi4 14:54 - Using Llama3.1 15:13 - IBM Granite 15:23 - Verifiying Sudoku Puzzles 19:57 - Reflecting with Multiple Passes 24:52 - Conclusion\"><\/div><\/div><div class=\"lL\" style=\"max-width:100%;width:853px;margin:5px auto;\"><\/div><figcaption><\/figcaption><\/figure>\n\n<div class=\"vlp-link-container vlp-layout-spotlight-clone wp-block-visual-link-preview-link\"><a href=\"https:\/\/github.com\/chrishayuk\/structured-outputs\" class=\"vlp-link\" title=\"GitHub - chrishayuk\/structured-outputs\" rel=\"nofollow\" target=\"_blank\"><\/a><div class=\"vlp-layout-zone-main\"><span class=\"vlp-block-0 vlp-link-title\">GitHub &#8211; chrishayuk\/structured-outputs<\/span><div class=\"vlp-block-1 vlp-link-summary\">Contribute to chrishayuk\/structured-outputs development by creating an account on GitHub.<\/div><div class=\"vlp-block-2 vlp-link-image\"><img decoding=\"async\" src=\"https:\/\/opengraph.githubassets.com\/07e2d45ab0c021e0f2b845a30447614b27a73f0a66c11d278c390ab4799a5812\/chrishayuk\/structured-outputs\" style=\"max-width: 1024px; max-height: 1024px\" \/><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>\u300cstructured-outputs\u300d\uff0c\u4e3b\u8981\u5c55\u793a\u5982\u4f55\u5229\u7528 OpenAI \u548c Ollama \u9019\u5169\u500b\u5927\u578b\u8a9e\u8a00\u6a21\u578b\u5e73\u53f0\uff0c\u4ee5\u7d50\u69cb\u5316\u7684\u8f38\u51fa\u65b9\u5f0f\u9a57\u8b49\u6578\u7368\u904a\u6232\u7684\u6709\u6548\u6027\u3002\u7a0b\u5f0f\u78bc\u5305\u542b\u4e00\u500b\u6e2c\u8a66\u67b6\u69cb\uff0c\u793a\u7bc4\u5982\u4f55\u4f7f\u7528\u4e0d\u540c\u7684\u6a21\u578b\uff08\u4f8b\u5982 OpenAI \u7684 gpt-4o-mini \u548c Ollama \u7684 phi4\uff09\u4ee5\u53ca\u76f8\u61c9\u7684\u57f7\u884c\u6307\u4ee4\u3002\u5c08\u6848\u76ee\u524d\u53ea\u6709 Python \u7a0b\u5f0f\u78bc\uff0c\u4e26\u6709\u7c21\u6f54\u7684 README \u6a94\u8aaa\u660e\u4f7f\u7528\u65b9\u6cd5\uff0c\u4f46\u7f3a\u4e4f\u66f4\u8a73\u7d30\u7684\u5c08\u6848\u63cf\u8ff0\u548c\u8cc7\u6e90\u9023\u7d50\uff0c\u661f\u661f\u6578\u548c\u95dc\u6ce8\u5ea6\u4e5f\u90fd\u5f88\u4f4e\u3002&nbsp;\u6838\u5fc3\u76ee\u7684\u5728\u65bc\u5c55\u793a\u7d50\u69cb\u5316\u8f38\u51fa\u7684\u61c9\u7528\uff0c\u4e26\u63d0\u4f9b OpenAI \u548c Ollama \u7684\u5be6\u4f5c\u7bc4\u4f8b\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"googlesitekit_rrm_CAowvqSiDA:productID":"","footnotes":""},"categories":[38,122,27,133],"tags":[],"class_list":["post-4276","post","type-post","status-publish","format-standard","hentry","category-38","category-ollama","category-paper","category-133"],"_links":{"self":[{"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/posts\/4276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/comments?post=4276"}],"version-history":[{"count":0,"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/posts\/4276\/revisions"}],"wp:attachment":[{"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/media?parent=4276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/categories?post=4276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infernews.com\/blog\/wp-json\/wp\/v2\/tags?post=4276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}