1"use strict";(self.webpackChunkspring_ai_alibaba_website=self.webpackChunkspring_ai_alibaba_website||[]).push([[5367],{28453:(e,n,d)=>{d.d(n,{R:()=>a,x:()=>r});var l=d(96540);const i={},s=l.createContext(i);function a(e){const n=l.useContext(s);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),l.createElement(s.Provider,{value:n},e.children)}},83135:(e,n,d)=>{d.r(n),d.d(n,{assets:()=>t,contentTitle:()=>r,default:()=>h,frontMatter:()=>a,metadata:()=>l,toc:()=>o});const l=JSON.parse('{"id":"rag/embeddings/ollama-embeddings","title":"Ollama Embeddings","description":"\u4f7f\u7528 https//ollama.com/search?c=embedding[AI Models] \u5e76\u4ece\u5b83\u4eec\u751f\u6210 embeddings\u3002","source":"@site/integration/rag/embeddings/ollama-embeddings.md","sourceDirName":"rag/embeddings","slug":"/rag/embeddings/ollama-embeddings","permalink":"/integration/rag/embeddings/ollama-embeddings","draft":false,"unlisted":false,"editUrl":"https://github.com/spring-ai-alibaba/website/tree/main/integration/rag/embeddings/ollama-embeddings.md","tags":[],"version":"current","lastUpdatedBy":"Ken Liu","lastUpdatedAt":1768271906000,"frontMatter":{},"sidebar":"integrationSidebar","previous":{"title":"Google GenAI Text Embeddings","permalink":"/integration/rag/embeddings/google-genai-embeddings-text"},"next":{"title":"OpenAI Embeddings","permalink":"/integration/rag/embeddings/openai-embeddings"}}');var i=d(74848),s=d(28453);const a={},r="Ollama Embeddings",t={},o=[{value:"\u5148\u51b3\u6761\u4ef6",id:"\u5148\u51b3\u6761\u4ef6",level:2},{value:"\u81ea\u52a8\u914d\u7f6e",id:"\u81ea\u52a8\u914d\u7f6e",level:2},{value:"\u57fa\u672c\u5c5e\u6027",id:"\u57fa\u672c\u5c5e\u6027",level:3},{value:"Embedding \u5c5e\u6027",id:"embedding-\u5c5e\u6027",level:3},{value:"\u8fd0\u884c\u65f6\u9009\u9879",id:"\u8fd0\u884c\u65f6\u9009\u9879",level:2},{value:"Auto-pulling Models",id:"auto-pulling-models",level:2},{value:"HuggingFace Models",id:"huggingface-models",level:2},{value:"\u793a\u4f8b Controller",id:"\u793a\u4f8b-controller",level:2},{value:"\u624b\u52a8\u914d\u7f6e",id:"\u624b\u52a8\u914d\u7f6e",level:2}];function c(e){const n={a:"a",code:"code",div:"div",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"ollama-embeddings",children:"Ollama Embeddings"})}),"\n",(0,i.jsxs)(n.p,{children:["\u4f7f\u7528 ",(0,i.jsx)(n.a,{href:"https://ollama.ai/%5BOllama",children:"https://ollama.ai/[Ollama"}),"] \u60a8\u53ef\u4ee5\u5728\u672c\u5730\u8fd0\u884c\u5404\u79cd ",(0,i.jsx)(n.a,{href:"https://ollama.com/search?c=embedding%5BAI",children:"https://ollama.com/search?c=embedding[AI"})," Models] \u5e76\u4ece\u5b83\u4eec\u751f\u6210 embeddings\u3002\nembedding \u662f\u6d6e\u70b9\u6570\uff08\u5217\u8868\uff09\u7684\u5411\u91cf\u3002\n\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u7684\u8ddd\u79bb\u8861\u91cf\u5b83\u4eec\u7684\u76f8\u5173\u6027\u3002\n\u5c0f\u8ddd\u79bb\u8868\u793a\u9ad8\u76f8\u5173\u6027\uff0c\u5927\u8ddd\u79bb\u8868\u793a\u4f4e\u76f8\u5173\u6027\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"OllamaEmbeddingModel"})," \u5b9e\u73b0\u5229\u7528 Ollama ",(0,i.jsx)(n.a,{href:"https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embeddings%5BEmbeddings",children:"https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embeddings[Embeddings"})," API] \u7aef\u70b9\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"\u5148\u51b3\u6761\u4ef6",children:"\u5148\u51b3\u6761\u4ef6"}),"\n",(0,i.jsx)(n.p,{children:"\u60a8\u9996\u5148\u9700\u8981\u8bbf\u95ee Ollama \u5b9e\u4f8b\u3002\u6709\u51e0\u79cd\u9009\u9879\uff0c\u5305\u62ec\u4ee5\u4e0b\uff1a"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["link:",(0,i.jsx)(n.a,{href:"https://ollama.com/download%5B%E4%B8%8B%E8%BD%BD%E5%B9%B6%E5%AE%89%E8%A3%85",children:"https://ollama.com/download[\u4e0b\u8f7d\u5e76\u5b89\u88c5"})," Ollama] \u5230\u60a8\u7684\u672c\u5730\u673a\u5668\u3002"]}),"\n",(0,i.jsxs)(n.li,{children:["\u914d\u7f6e\u5e76 xref",":api","/testcontainers.adoc[\u901a\u8fc7 Testcontainers \u8fd0\u884c Ollama]\u3002"]}),"\n",(0,i.jsxs)(n.li,{children:["\u901a\u8fc7 xref",":api","/cloud-bindings.adoc[Kubernetes Service Bindings] \u7ed1\u5b9a\u5230 Ollama \u5b9e\u4f8b\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u60a8\u53ef\u4ee5\u4ece ",(0,i.jsx)(n.a,{href:"https://ollama.com/search?c=embedding%5BOllama",children:"https://ollama.com/search?c=embedding[Ollama"})," \u6a21\u578b\u5e93] \u62c9\u53d6\u8981\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u7684\u6a21\u578b\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-shellscript",children:"ollama pull <model-name>\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u60a8\u8fd8\u53ef\u4ee5\u62c9\u53d6\u6570\u5343\u4e2a\u514d\u8d39\u7684 link:",(0,i.jsx)(n.a,{href:"https://huggingface.co/models?library=gguf&sort=trending%5BGGUF",children:"https://huggingface.co/models?library=gguf&sort=trending[GGUF"})," Hugging Face Models] \u4e2d\u7684\u4efb\u4f55\u4e00\u4e2a\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-shellscript",children:"ollama pull hf.co/<username>/<model-repository>\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u6216\u8005\uff0c\u60a8\u53ef\u4ee5\u542f\u7528\u81ea\u52a8\u4e0b\u8f7d\u4efb\u4f55\u6240\u9700\u6a21\u578b\u7684\u9009\u9879\uff1axref",(0,i.jsx)(n.div,{children:"Auto-pulling Models"}),"\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"\u81ea\u52a8\u914d\u7f6e",children:"\u81ea\u52a8\u914d\u7f6e"}),"\n",(0,i.jsx)(n.h1,{id:"\u6ce8\u610f",children:"[\u6ce8\u610f]"}),"\n",(0,i.jsxs)(n.h1,{id:"spring-ai-\u81ea\u52a8\u914d\u7f6estarter-\u6a21\u5757\u7684\u5de5\u4ef6\u540d\u79f0\u53d1\u751f\u4e86\u91cd\u5927\u53d8\u5316\u8bf7\u53c2\u9605-httpsdocsspringiospring-aireferenceupgrade-noteshtml\u5347\u7ea7\u8bf4\u660e-\u4e86\u89e3\u66f4\u591a\u4fe1\u606f",children:["Spring AI \u81ea\u52a8\u914d\u7f6e\u3001starter \u6a21\u5757\u7684\u5de5\u4ef6\u540d\u79f0\u53d1\u751f\u4e86\u91cd\u5927\u53d8\u5316\u3002\n\u8bf7\u53c2\u9605 ",(0,i.jsx)(n.a,{href:"https://docs.spring.io/spring-ai/reference/upgrade-notes.html%5B%E5%8D%87%E7%BA%A7%E8%AF%B4%E6%98%8E",children:"https://docs.spring.io/spring-ai/reference/upgrade-notes.html[\u5347\u7ea7\u8bf4\u660e"}),"] \u4e86\u89e3\u66f4\u591a\u4fe1\u606f\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["Spring AI \u4e3a Azure Ollama Embedding Model \u63d0\u4f9b Spring Boot \u81ea\u52a8\u914d\u7f6e\u3002\n\u8981\u542f\u7528\u5b83\uff0c\u8bf7\u5c06\u4ee5\u4e0b\u4f9d\u8d56\u9879\u6dfb\u52a0\u5230\u60a8\u7684 Maven ",(0,i.jsx)(n.code,{children:"pom.xml"})," \u6216 Gradle ",(0,i.jsx)(n.code,{children:"build.gradle"})," \u6784\u5efa\u6587\u4ef6\u4e2d\uff1a"]}),"\n",(0,i.jsx)(n.h1,{id:"tabs",children:"[tabs]"}),"\n",(0,i.jsx)(n.p,{children:"Maven::\n+"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-xml",children:"<dependency>\n <groupId>org.springframework.ai</groupId>\n <artifactId>spring-ai-starter-model-ollama</artifactId>\n</dependency>\n"})}),"\n",(0,i.jsx)(n.p,{children:"Gradle::\n+"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-groovy",children:"dependencies {\n implementation 'org.springframework.ai:spring-ai-starter-model-ollama'\n}\n"})}),"\n",(0,i.jsx)(n.p,{children:"======"}),"\n",(0,i.jsxs)(n.p,{children:["\u63d0\u793a\uff1a\u8bf7\u53c2\u9605 ",(0,i.jsx)(n.a,{href:"https://docs.spring.io/spring-ai/reference/getting-started.html#dependency-management",children:"Dependency Management"})," \u90e8\u5206\uff0c\u5c06 Spring AI BOM \u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u6587\u4ef6\u3002\nSpring AI \u5de5\u4ef6\u53d1\u5e03\u5728 Maven Central \u548c Spring Snapshot \u4ed3\u5e93\u4e2d\u3002\n\u8bf7\u53c2\u9605 Repositories \u90e8\u5206\uff0c\u5c06\u8fd9\u4e9b\u4ed3\u5e93\u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u7cfb\u7edf\u3002"]}),"\n",(0,i.jsx)(n.h3,{id:"\u57fa\u672c\u5c5e\u6027",children:"\u57fa\u672c\u5c5e\u6027"}),"\n",(0,i.jsxs)(n.p,{children:["\u524d\u7f00 ",(0,i.jsx)(n.code,{children:"spring.ai.ollama"}
1)," \u662f\u914d\u7f6e\u4e0e Ollama \u8fde\u63a5\u7684\u5c5e\u6027\u524d\u7f00"]}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"Property"}),(0,i.jsx)(n.th,{children:"Description"}),(0,i.jsx)(n.th,{children:"Default"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.base-url"}),(0,i.jsx)(n.td,{children:"Ollama API \u670d\u52a1\u5668\u8fd0\u884c\u7684\u57fa\u7840 URL\u3002"}),(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"+http://localhost:11434+"})})]})})]}),"\n",(0,i.jsxs)(n.p,{children:["\u4ee5\u4e0b\u662f\u7528\u4e8e\u521d\u59cb\u5316 Ollama \u96c6\u6210\u548c xref",(0,i.jsx)(n.div,{children:"auto-pulling models"})," \u7684\u5c5e\u6027\u3002"]}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"Property"}),(0,i.jsx)(n.th,{children:"Description"}),(0,i.jsx)(n.th,{children:"Default"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.init.pull-model-strategy"}),(0,i.jsx)(n.td,{children:"\u662f\u5426\u5728\u542f\u52a8\u65f6\u62c9\u53d6\u6a21\u578b\u4ee5\u53ca\u5982\u4f55\u62c9\u53d6\u3002"}),(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"never"})})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.init.timeout"}),(0,i.jsx)(n.td,{children:"\u7b49\u5f85\u6a21\u578b\u88ab\u62c9\u53d6\u7684\u65f6\u95f4\u3002"}),(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"5m"})})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.init.max-retries"}),(0,i.jsx)(n.td,{children:"\u6a21\u578b\u62c9\u53d6\u64cd\u4f5c\u7684\u6700\u5927\u91cd\u8bd5\u6b21\u6570\u3002"}),(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"0"})})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.init.embedding.include"}),(0,i.jsx)(n.td,{children:"\u5728\u521d\u59cb\u5316\u4efb\u52a1\u4e2d\u5305\u542b\u6b64\u7c7b\u578b\u7684\u6a21\u578b\u3002"}),(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"true"})})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.init.embedding.additional-models"}),(0,i.jsx)(n.td,{children:"\u9664\u4e86\u901a\u8fc7\u9ed8\u8ba4\u5c5e\u6027\u914d\u7f6e\u7684\u6a21\u578b\u4e4b\u5916\uff0c\u8fd8\u8981\u521d\u59cb\u5316\u7684\u5176\u4ed6\u6a21\u578b\u3002"}),(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"[]"})})]})]})]}),"\n",(0,i.jsx)(n.h3,{id:"embedding-\u5c5e\u6027",children:"Embedding \u5c5e\u6027"}),"\n",(0,i.jsx)(n.h1,{id:"\u6ce8\u610f-1",children:"[\u6ce8\u610f]"}),"\n",(0,i.jsxs)(n.p,{children:["\u73b0\u5728\u901a\u8fc7\u524d\u7f00\u4e3a ",(0,i.jsx)(n.code,{children:"spring.ai.model.embedding"})," \u7684\u9876\u7ea7\u5c5e\u6027\u6765\u914d\u7f6e embedding \u81ea\u52a8\u914d\u7f6e\u7684\u542f\u7528\u548c\u7981\u7528\u3002"]}),"\n",(0,i.jsx)(n.p,{children:"\u8981\u542f\u7528\uff0cspring.ai.model.embedding=ollama\uff08\u9ed8\u8ba4\u542f\u7528\uff09"}),"\n",(0,i.jsx)(n.p,{children:"\u8981\u7981\u7528\uff0cspring.ai.model.embedding=none\uff08\u6216\u4efb\u4f55\u4e0d\u5339\u914d ollama \u7684\u503c\uff09"}),"\n",(0,i.jsx)(n.h1,{id:"\u8fdb\u884c\u6b64\u66f4\u6539\u662f\u4e3a\u4e86\u5141\u8bb8\u914d\u7f6e\u591a\u4e2a\u6a21\u578b",children:"\u8fdb\u884c\u6b64\u66f4\u6539\u662f\u4e3a\u4e86\u5141\u8bb8\u914d\u7f6e\u591a\u4e2a\u6a21\u578b\u3002"}),"\n",(0,i.jsxs)(n.p,{children:["\u524d\u7f00 ",(0,i.jsx)(n.code,{children:"spring.ai.ollama.embedding.options"})," \u662f\u914d\u7f6e Ollama embedding \u6a21\u578b\u7684\u5c5e\u6027\u524d\u7f00\u3002\n\u5b83\u5305\u62ec Ollama \u8bf7\u6c42\uff08\u9ad8\u7ea7\uff09\u53c2\u6570\uff0c\u5982 ",(0,i.jsx)(n.code,{children:"model"}),"\u3001",(0,i.jsx)(n.code,{children:"keep-alive"})," \u548c ",(0,i.jsx)(n.code,{children:"truncate"}),"\uff0c\u4ee5\u53ca Ollama \u6a21\u578b ",(0,i.jsx)(n.code,{children:"options"})," \u5c5e\u6027\u3002"]}),"\n",(0,i.jsx)(n.p,{children:"\u4ee5\u4e0b\u662f Ollama embedding \u6a21\u578b\u7684\u9ad8\u7ea7\u8bf7\u6c42\u53c2\u6570\uff1a"}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"Property"}),(0,i.jsx)(n.th,{children:"Description"}),(0,i.jsx)(n.th,{children:"Default"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.enabled (\u5df2\u79fb\u9664\u4e14\u4e0d\u518d\u6709\u6548)"}),(0,i.jsx)(n.td,{children:"\u542f\u7528 Ollama embedding \u6a21\u578b\u81ea\u52a8\u914d\u7f6e\u3002"}),(0,i.jsx)(n.td,{children:"true"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.model.embedding"}),(0,i.jsx)(n.td,{children:"\u542f\u7528 Ollama embedding \u6a21\u578b\u81ea\u52a8\u914d\u7f6e\u3002"}),(0,i.jsx)(n.td,{children:"ollama"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.model"}),(0,i.jsxs)(n.td,{children:["\u8981\u4f7f\u7528\u7684 ",(0,i.jsx)(n.a,{href:"https://github.com/ollama/ollama?tab=readme-ov-file#model-library%5B%E6%94%AF%E6%8C%81%E7%9A%84%E6%A8%A1%E5%9E%8B",children:"https://github.com/ollama/ollama?tab=readme-ov-file#model-library[\u652f\u6301\u7684\u6a21\u578b"}),"] \u7684\u540d\u79f0\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4e13\u7528\u7684 ",(0,i.jsx)(n.a,{href:"https://ollama.com/search?c=embedding%5BEmbedding",children:"https://ollama.com/search?c=embedding[Embedding"})," Model] \u7c7b\u578b"]}),(0,i.jsx)(n.td,{children:"mxbai-embed-large"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.keep_alive"}),(0,i.jsx)(n.td,{children:"\u63a7\u5236\u6a21\u578b\u5728\u8bf7\u6c42\u540e\u4fdd\u6301\u5728\u5185\u5b58\u4e2d\u7684\u65f6\u95f4"}),(0,i.jsx)(n.td,{children:"5m"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.truncate"}),(0,i.jsx)(n.td,{children:"\u622a\u65ad\u6bcf\u4e2a\u8f93\u5165\u7684\u672b\u5c3e\u4ee5\u9002\u5408\u4e0a\u4e0b\u6587\u957f\u5ea6\u3002\u5982\u679c\u4e3a false \u4e14\u4e0a\u4e0b\u6587\u957f\u5ea6\u8d85\u51fa\uff0c\u5219\u8fd4\u56de\u9519\u8bef\u3002"}),(0,i.jsx)(n.td,{children:"true"})]})]})]}),"\n",(0,i.jsxs)(n.p,{children:["\u5176\u4f59\u7684 ",(0,i.jsx)(n.code,{children:"options"})," \u5c5e\u6027\u57fa\u4e8e link:",(0,i.jsx)(n.a,{href:"https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values%5BOllama",children:"https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values[Ollama"})," Valid Parameters and Values] \u548c link:",(0,i.jsx)(n.a,{href:"https://github.com/ollama/ollama/blob/main/api/types.go%5BOllama",children:"https://github.com/ollama/ollama/blob/main/api/types.go[Ollama"})," Types]\u3002\u9ed8\u8ba4\u503c\u57fa\u4e8e\uff1alink:",(0,i.jsx)(n.a,{href:"https://github.com/ollama/ollama/blob/b538dc3858014f94b099730a592751a5454cab0a/api/types.go#L364%5BOllama",children:"https://github.com/ollama/ollama/blob/b538dc3858014f94b099730a592751a5454cab0a/api/types.go#L364[Ollama"})," type defaults]\u3002"]}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"Property"}),(0,i.jsx)(n.th,{children:"Description"}),(0,i.jsx)(n.th,{children:"Default"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.numa"}),(0,i.jsx)(n.td,{children:"\u662f\u5426\u4f7f\u7528 NUMA\u3002"}),(0,i.jsx)(n.td,{children:"false"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.num-ctx"}),(0,i.jsx)(n.td,{children:"\u8bbe\u7f6e\u7528\u4e8e\u751f\u6210\u4e0b\u4e00\u4e2a token \u7684\u4e0a\u4e0b\u6587\u7a97\u53e3\u5927\u5c0f\u3002"}),(0,i.jsx)(n.td,{children:"2048"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.num-batch"}),(0,i.jsx)(n.td,{children:"\u63d0\u793a\u5904\u7406\u6700\u5927\u6279\u6b21\u5927\u5c0f\u3002"}),(0,i.jsx)(n.td,{children:"512"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.num-gpu"}),(0,i.jsx)(n.td,{children:"\u8981\u53d1\u9001\u5230 GPU(s) \u7684\u5c42\u6570\u3002\u5728 macOS \u4e0a\uff0c\u9ed8\u8ba4\u503c\u4e3a 1 \u4ee5\u542f\u7528 metal \u652f\u6301\uff0c0 \u4ee5\u7981\u7528\u3002\u8fd9\u91cc\u7684 1 \u8868\u793a NumGPU \u5e94\u8be5\u52a8\u6001\u8bbe\u7f6e"}),(0,i.jsx)(n.td,{children:"-1"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.main-gpu"}),(0,i.jsx)(n.td,{children:"\u4f7f\u7528\u591a\u4e2a GPU \u65f6\uff0c\u6b64\u9
1009\u9879\u63a7\u5236\u54ea\u4e2a GPU \u7528\u4e8e\u5c0f\u5f20\u91cf\uff0c\u5bf9\u4e8e\u8fd9\u4e9b\u5f20\u91cf\uff0c\u5728\u6240\u6709 GPU \u4e4b\u95f4\u62c6\u5206\u8ba1\u7b97\u7684\u5f00\u9500\u4e0d\u503c\u5f97\u3002\u76f8\u5173\u7684 GPU \u5c06\u4f7f\u7528\u7a0d\u591a\u7684 VRAM \u6765\u5b58\u50a8\u4e34\u65f6\u7ed3\u679c\u7684\u6682\u5b58\u7f13\u51b2\u533a\u3002"}),(0,i.jsx)(n.td,{children:"0"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.low-vram"}),(0,i.jsx)(n.td,{children:"-"}),(0,i.jsx)(n.td,{children:"false"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.f16-kv"}),(0,i.jsx)(n.td,{children:"-"}),(0,i.jsx)(n.td,{children:"true"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.logits-all"}),(0,i.jsx)(n.td,{children:"\u8fd4\u56de\u6240\u6709 token \u7684 logits\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u6700\u540e\u4e00\u4e2a\u3002\u8981\u542f\u7528 completions \u8fd4\u56de logprobs\uff0c\u8fd9\u5fc5\u987b\u4e3a true\u3002"}),(0,i.jsx)(n.td,{children:"-"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.vocab-only"}),(0,i.jsx)(n.td,{children:"\u4ec5\u52a0\u8f7d\u8bcd\u6c47\u8868\uff0c\u4e0d\u52a0\u8f7d\u6743\u91cd\u3002"}),(0,i.jsx)(n.td,{children:"-"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.use-mmap"}),(0,i.jsx)(n.td,{children:"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6a21\u578b\u88ab\u6620\u5c04\u5230\u5185\u5b58\u4e2d\uff0c\u8fd9\u5141\u8bb8\u7cfb\u7edf\u6839\u636e\u9700\u8981\u4ec5\u52a0\u8f7d\u6a21\u578b\u7684\u5fc5\u8981\u90e8\u5206\u3002\u4f46\u662f\uff0c\u5982\u679c\u6a21\u578b\u5927\u4e8e\u60a8\u7684\u603b RAM \u91cf\uff0c\u6216\u8005\u5982\u679c\u60a8\u7684\u7cfb\u7edf\u53ef\u7528\u5185\u5b58\u4e0d\u8db3\uff0c\u4f7f\u7528 mmap \u53ef\u80fd\u4f1a\u589e\u52a0\u9875\u9762\u8c03\u51fa\u7684\u98ce\u9669\uff0c\u4ece\u800c\u5bf9\u6027\u80fd\u4ea7\u751f\u8d1f\u9762\u5f71\u54cd\u3002\u7981\u7528 mmap \u4f1a\u5bfc\u81f4\u52a0\u8f7d\u65f6\u95f4\u53d8\u6162\uff0c\u4f46\u5982\u679c\u60a8\u4e0d\u4f7f\u7528 mlock\uff0c\u53ef\u80fd\u4f1a\u51cf\u5c11\u9875\u9762\u8c03\u51fa\u3002\u8bf7\u6ce8\u610f\uff0c\u5982\u679c\u6a21\u578b\u5927\u4e8e\u603b RAM \u91cf\uff0c\u5173\u95ed mmap \u5c06\u963b\u6b62\u6a21\u578b\u52a0\u8f7d\u3002"}),(0,i.jsx)(n.td,{children:"null"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.use-mlock"}),(0,i.jsx)(n.td,{children:"\u5c06\u6a21\u578b\u9501\u5b9a\u5728\u5185\u5b58\u4e2d\uff0c\u9632\u6b62\u5728\u5185\u5b58\u6620\u5c04\u65f6\u88ab\u4ea4\u6362\u51fa\u53bb\u3002\u8fd9\u53ef\u4ee5\u63d0\u9ad8\u6027\u80fd\uff0c\u4f46\u901a\u8fc7\u9700\u8981\u66f4\u591a RAM \u6765\u8fd0\u884c\u5e76\u53ef\u80fd\u51cf\u6162\u52a0\u8f7d\u65f6\u95f4\uff08\u56e0\u4e3a\u6a21\u578b\u52a0\u8f7d\u5230 RAM \u4e2d\uff09\u6765\u6362\u53d6\u5185\u5b58\u6620\u5c04\u7684\u4e00\u4e9b\u4f18\u52bf\u3002"}),(0,i.jsx)(n.td,{children:"false"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.num-thread"}),(0,i.jsx)(n.td,{children:"\u8bbe\u7f6e\u8ba1\u7b97\u671f\u95f4\u8981\u4f7f\u7528\u7684\u7ebf\u7a0b\u6570\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cOllama \u4f1a\u68c0\u6d4b\u6b64\u503c\u4ee5\u83b7\u5f97\u6700\u4f73\u6027\u80fd\u3002\u5efa\u8bae\u5c06\u6b64\u503c\u8bbe\u7f6e\u4e3a\u7cfb\u7edf\u5177\u6709\u7684\u7269\u7406 CPU \u6838\u5fc3\u6570\uff08\u800c\u4e0d\u662f\u903b\u8f91\u6838\u5fc3\u6570\uff09\u30020 = \u8ba9\u8fd0\u884c\u65f6\u51b3\u5b9a"}),(0,i.jsx)(n.td,{children:"0"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.num-keep"}),(0,i.jsx)(n.td,{children:"-"}),(0,i.jsx)(n.td,{children:"4"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.seed"}),(0,i.jsx)(n.td,{children:"\u8bbe\u7f6e\u7528\u4e8e\u751f\u6210\u7684\u968f\u673a\u6570\u79cd\u5b50\u3002\u5c06\u6b64\u8bbe\u7f6e\u4e3a\u7279\u5b9a\u6570\u5b57\u5c06\u4f7f\u6a21\u578b\u4e3a\u76f8\u540c\u7684\u63d0\u793a\u751f\u6210\u76f8\u540c\u7684\u6587\u672c\u3002"}),(0,i.jsx)(n.td,{children:"-1"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.num-predict"}),(0,i.jsx)(n.td,{children:"\u751f\u6210\u6587\u672c\u65f6\u9884\u6d4b\u7684\u6700\u5927 token \u6570\u3002(-1 = \u65e0\u9650\u751f\u6210\uff0c-2 = \u586b\u5145\u4e0a\u4e0b\u6587)"}),(0,i.jsx)(n.td,{children:"-1"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.top-k"}),(0,i.jsx)(n.td,{children:"\u51cf\u5c11\u751f\u6210\u65e0\u610f\u4e49\u7684\u6982\u7387\u3002\u8f83\u9ad8\u7684\u503c\uff08\u4f8b\u5982\uff0c100\uff09\u5c06\u7ed9\u51fa\u66f4\u591a\u6837\u5316\u7684\u7b54\u6848\uff0c\u800c\u8f83\u4f4e\u7684\u503c\uff08\u4f8b\u5982\uff0c10\uff09\u5c06\u66f4\u52a0\u4fdd\u5b88\u3002"}),(0,i.jsx)(n.td,{children:"40"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.top-p"}),(0,i.jsx)(n.td,{children:"\u4e0e top-k \u4e00\u8d77\u5de5\u4f5c\u3002\u8f83\u9ad8\u7684\u503c\uff08\u4f8b\u5982\uff0c0.95\uff09\u5c06\u5bfc\u81f4\u66f4\u591a\u6837\u5316\u7684\u6587\u672c\uff0c\u800c\u8f83\u4f4e\u7684\u503c\uff08\u4f8b\u5982\uff0c0.5\uff09\u5c06\u751f\u6210\u66f4\u4e13\u6ce8\u548c\u4fdd\u5b88\u7684\u6587\u672c\u3002"}),(0,i.jsx)(n.td,{children:"0.9"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.min-p"}),(0,i.jsx)(n.td,{children:"top_p \u7684\u66ff\u4ee3\u65b9\u6848\uff0c\u65e8\u5
1728\u786e\u4fdd\u8d28\u91cf\u548c\u591a\u6837\u6027\u7684\u5e73\u8861\u3002\u53c2\u6570 p \u8868\u793a token \u88ab\u8003\u8651\u7684\u6700\u5c0f\u6982\u7387\uff0c\u76f8\u5bf9\u4e8e\u6700\u53ef\u80fd\u7684 token \u7684\u6982\u7387\u3002\u4f8b\u5982\uff0cp=0.05 \u4e14\u6700\u53ef\u80fd\u7684 token \u6982\u7387\u4e3a 0.9\uff0c\u5219\u503c\u5c0f\u4e8e 0.045 \u7684 logits \u88ab\u8fc7\u6ee4\u6389\u3002"}),(0,i.jsx)(n.td,{children:"0.0"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.tfs-z"}),(0,i.jsx)(n.td,{children:"\u4f7f\u7528\u5c3e\u90e8\u81ea\u7531\u91c7\u6837\u6765\u51cf\u5c11\u8f93\u51fa\u4e2d\u4e0d\u592a\u53ef\u80fd\u7684 token \u7684\u5f71\u54cd\u3002\u8f83\u9ad8\u7684\u503c\uff08\u4f8b\u5982\uff0c2.0\uff09\u5c06\u51cf\u5c11\u66f4\u591a\u5f71\u54cd\uff0c\u800c\u503c\u4e3a 1.0 \u5219\u7981\u7528\u6b64\u8bbe\u7f6e\u3002"}),(0,i.jsx)(n.td,{children:"1.0"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.typical-p"}),(0,i.jsx)(n.td,{children:"-"}),(0,i.jsx)(n.td,{children:"1.0"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.repeat-last-n"}),(0,i.jsx)(n.td,{children:"\u8bbe\u7f6e\u6a21\u578b\u56de\u770b\u591a\u8fdc\u4ee5\u9632\u6b62\u91cd\u590d\u3002\uff08\u9ed8\u8ba4\u503c\uff1a64\uff0c0 = \u7981\u7528\uff0c-1 = num_ctx\uff09"}),(0,i.jsx)(n.td,{children:"64"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.temperature"}),(0,i.jsx)(n.td,{children:"\u6a21\u578b\u7684\u6e29\u5ea6\u3002\u589e\u52a0\u6e29\u5ea6\u5c06\u4f7f\u6a21\u578b\u56de\u7b54\u66f4\u5177\u521b\u9020\u6027\u3002"}),(0,i.jsx)(n.td,{children:"0.8"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.repeat-penalty"}),(0,i.jsx)(n.td,{children:"\u8bbe\u7f6e\u5bf9\u91cd\u590d\u7684\u60e9\u7f5a\u5f3a\u5ea6\u3002\u8f83\u9ad8\u7684\u503c\uff08\u4f8b\u5982\uff0c1.5\uff09\u5c06\u66f4\u5f3a\u70c8\u5730\u60e9\u7f5a\u91cd\u590d\uff0c\u800c\u8f83\u4f4e\u7684\u503c\uff08\u4f8b\u5982\uff0c0.9\uff09\u5c06\u66f4\u52a0\u5bbd\u677e\u3002"}),(0,i.jsx)(n.td,{children:"1.1"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.presence-penalty"}),(0,i.jsx)(n.td,{children:"-"}),(0,i.jsx)(n.td,{children:"0.0"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.frequency-penalty"}),(0,i.jsx)(n.td,{children:"-"}),(0,i.jsx)(n.td,{children:"0.0"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.mirostat"}),(0,i.jsx)(n.td,{children:"\u542f\u7528 Mirostat \u91c7\u6837\u4ee5\u63a7\u5236\u56f0\u60d1\u5ea6\u3002\uff08\u9ed8\u8ba4\u503c\uff1a0\uff0c0 = \u7981\u7528\uff0c1 = Mirostat\uff0c2 = Mirostat 2.0\uff09"}),(0,i.jsx)(n.td,{children:"0"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.mirostat-tau"}),(0,i.jsx)(n.td,{children:"\u63a7\u5236\u8f93\u51fa\u7684\u4e00\u81f4\u6027\u548c\u591a\u6837\u6027\u4e4b\u95f4\u7684\u5e73\u8861\u3002\u8f83\u4f4e\u7684\u503c\u5c06\u5bfc\u81f4\u66f4\u4e13\u6ce8\u548c\u4e00\u81f4\u7684\u6587\u672c\u3002"}),(0,i.jsx)(n.td,{children:"5.0"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.mirostat-eta"}),(0,i.jsx)(n.td,{children:"\u5f71\u54cd\u7b97\u6cd5\u5bf9\u751f\u6210\u6587\u672c\u53cd\u9988\u7684\u54cd\u5e94\u901f\u5ea6\u3002\u8f83\u4f4e\u7684\u5b66\u4e60\u7387\u5c06\u5bfc\u81f4\u8c03\u6574\u8f83\u6162\uff0c\u800c\u8f83\u9ad8\u7684\u5b66\u4e60\u7387\u5c06\u4f7f\u7b97\u6cd5\u66f4\u5177\u54cd\u5e94\u6027\u3002"}),(0,i.jsx)(n.td,{children:"0.1"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.penalize-newline"}),(0,i.jsx)(n.td,{children:"-"}),(0,i.jsx)(n.td,{children:"true"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.stop"}),(0,i.jsx)(n.td,{children:"\u8bbe\u7f6e\u8981\u4f7f\u7528\u7684\u505c\u6b62\u5e8f\u5217\u3002\u9047\u5230\u6b64\u6a21\u5f0f\u65f6\uff0cLLM \u5c06\u505c\u6b62\u751f\u6210\u6587\u672c\u5e76\u8fd4\u56de\u3002\u53ef\u4ee5\u901a\u8fc7\u5728 modelfile \u4e2d\u6307\u5b9a\u591a\u4e2a\u5355\u72ec\u7684 stop \u53c2\u6570\u6765\u8bbe\u7f6e\u591a\u4e2a\u505c\u6b62\u6a21\u5f0f\u3002"}),(0,i.jsx)(n.td,{children:"-"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"spring.ai.ollama.embedding.options.functions"}),(0,i.jsx)(n.td,{children:"\u51fd\u6570\u5217\u8868\uff0c\u7531\u5176\u540d\u79f0\u6807\u8bc6\uff0c\u4ee5\u5728\u5355\u4e2a\u63d0\u793a\u8bf7\u6c42\u4e2d\u542f\u7528\u51fd\u6570\u8c03\u7528\u3002\u5177\u6709\u8fd9\u4e9b\u540d\u79f0\u7684\u51fd\u6570\u5fc5\u987b\u5b58\u5728\u4e8e functionCallbacks \u6ce8\u518c\u8868\u4e2d\u3002"}),(0,i.jsx)(n.td,{children:"-"})]})]})]}),"\n",(0,i.jsxs)(n.p,{children:["\u63d0\u793a\uff1a\u6240\u6709\u524d\u7f00\u4e3a ",(0,i.jsx)(n.code,{children:"spring.ai.ollama.embedding.options"})," \u7684\u5c5e\u6027\u90fd\u53ef\u4ee5\u901a\u8fc7\u5728 ",(0,i.jsx)(n.code,{children:"EmbeddingRequest"})," \u8c03\u7528\u4e2d\u6dfb\u52a0\u7279\u5b9a\u4e8e\u8bf7\u6c42\u7684 ",(0,i.jsx)(n.a,{href:"#embedding-options",children:"embedding-options"})," \u5728\u8fd0\u884c\u65f6\u8986\u76d6\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"\u8fd0\u884c\u65f6\u9009\u9879",children:"\u8fd0\u884c\u65f6\u9009\u9879"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.a,{href:"https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaEmbeddingOptions.java%5BOllamaEmbeddingOptions.java",children:"https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaEmbeddingOptions.java[OllamaEmbeddingOptions.java"}),"] \u63d0\u4f9b Ollama \u914d\u7f6e\uff0c\u4f8b\u5982\u8981\u4f7f\u7528\u7684\u6a21\u578b\u3001\u4f4e\u7ea7 GPU \u548c CPU \u8c03\u4f18\u7b49\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u91cd\u8981\u63d0\u793a\uff1a",(0,i.jsx)(n.code,{children:"OllamaOptions"})," \u7c7b\u5df2\u88ab\u5f03\u7528\u3002\u5bf9\u4e8e chat \u6a21\u578b\uff0c\u8bf7\u4f7f\u7528 ",(0,i.jsx)(n.code,{children:"OllamaChatOptions"}),"\uff0c\u5bf9\u4e8e embedding \u6a21\u578b\uff0c\u8bf7\u4f7f\u7528 ",(0,i.jsx)(n.code,{children:"OllamaEmbeddingOptions"}),"\u3002\u65b0\u7c7b\u63d0\u4f9b\u7c7b\u578b\u5b89\u5168\u3001\u7279\u5b9a\u4e8e\u6a21\u578b\u7684\u914d\u7f6e\u9009\u9879\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u4e5f\u53ef\u4ee5\u4f7f\u7528 ",(0,i.jsx)(n.code,{children:"spring.ai.ollama.embedding.options"})," \u5c5e\u6027\u914d\u7f6e\u9ed8\u8ba4\u9009\u9879\u3002"]}
1),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u542f\u52a8\u65f6\u4f7f\u7528 ",(0,i.jsx)(n.code,{children:"OllamaEmbeddingModel(OllamaApi ollamaApi, OllamaEmbeddingOptions defaultOptions)"})," \u6765\u914d\u7f6e\u7528\u4e8e\u6240\u6709 embedding \u8bf7\u6c42\u7684\u9ed8\u8ba4\u9009\u9879\u3002\n\u5728\u8fd0\u884c\u65f6\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 ",(0,i.jsx)(n.code,{children:"OllamaEmbeddingOptions"})," \u5b9e\u4f8b\u4f5c\u4e3a ",(0,i.jsx)(n.code,{children:"EmbeddingRequest"})," \u7684\u4e00\u90e8\u5206\u6765\u8986\u76d6\u9ed8\u8ba4\u9009\u9879\u3002"]}),"\n",(0,i.jsx)(n.p,{children:"\u4f8b\u5982\uff0c\u4e3a\u7279\u5b9a\u8bf7\u6c42\u8986\u76d6\u9ed8\u8ba4\u6a21\u578b\u540d\u79f0\uff1a"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-java",children:'EmbeddingResponse embeddingResponse = embeddingModel.call(\n new EmbeddingRequest(List.of("Hello World", "World is big and salvation is near"),\n OllamaEmbeddingOptions.builder()\n .model("Different-Embedding-Model-Deployment-Name"))\n .truncates(false)\n .build());\n'})}),"\n",(0,i.jsx)(n.h2,{id:"auto-pulling-models",children:"Auto-pulling Models"}),"\n",(0,i.jsx)(n.p,{children:"Spring AI Ollama \u53ef\u4ee5\u5728 Ollama \u5b9e\u4f8b\u4e2d\u4e0d\u53ef\u7528\u65f6\u81ea\u52a8\u62c9\u53d6\u6a21\u578b\u3002\n\u6b64\u529f\u80fd\u5bf9\u4e8e\u5f00\u53d1\u548c\u6d4b\u8bd5\u4ee5\u53ca\u5c06\u5e94\u7528\u7a0b\u5e8f\u90e8\u7f72\u5230\u65b0\u73af\u5883\u7279\u522b\u6709\u7528\u3002"}),"\n",(0,i.jsxs)(n.p,{children:["\u63d0\u793a\uff1a\u60a8\u8fd8\u53ef\u4ee5\u6309\u540d\u79f0\u62c9\u53d6\u6570\u5343\u4e2a\u514d\u8d39\u7684 link:",(0,i.jsx)(n.a,{href:"https://huggingface.co/models?library=gguf&sort=trending%5BGGUF",children:"https://huggingface.co/models?library=gguf&sort=trending[GGUF"})," Hugging Face Models] \u4e2d\u7684\u4efb\u4f55\u4e00\u4e2a\u3002"]}),"\n",(0,i.jsx)(n.p,{children:"\u6709\u4e09\u79cd\u62c9\u53d6\u6a21\u578b\u7684\u7b56\u7565\uff1a"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"always"}),"\uff08\u5728 ",(0,i.jsx)(n.code,{children:"PullModelStrategy.ALWAYS"})," \u4e2d\u5b9a\u4e49\uff09\uff1a\u59cb\u7ec8\u62c9\u53d6\u6a21\u578b\uff0c\u5373\u4f7f\u5b83\u5df2\u7ecf\u53ef\u7528\u3002\u6709\u52a9\u4e8e\u786e\u4fdd\u60a8\u4f7f\u7528\u7684\u662f\u6a21\u578b\u7684\u6700\u65b0\u7248\u672c\u3002"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"when_missing"}),"\uff08\u5728 ",(0,i.jsx)(n.code,{children:"PullModelStrategy.WHEN_MISSING"})," \u4e2d\u5b9a\u4e49\uff09\uff1a\u4ec5\u5728\u6a21\u578b\u5c1a\u4e0d\u53ef\u7528\u65f6\u62c9\u53d6\u3002\u8fd9\u53ef\u80fd\u5bfc\u81f4\u4f7f\u7528\u6a21\u578b\u7684\u65e7\u7248\u672c\u3002"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"never"}),"\uff08\u5728 ",(0,i.jsx)(n.code,{children:"PullModelStrategy.NEVER"})," \u4e2d\u5b9a\u4e49\uff09\uff1a\u4ece\u4e0d\u81ea\u52a8\u62c9\u53d6\u6a21\u578b\u3002"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u8b66\u544a\uff1a\u7531\u4e8e\u4e0b\u8f7d\u6a21\u578b\u65f6\u53ef\u80fd\u51fa\u73b0\u5ef6\u8fdf\uff0c\u4e0d\u5efa\u8bae\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u81ea\u52a8\u62c9\u53d6\u3002\u76f8\u53cd\uff0c\u8bf7\u8003\u8651\u63d0\u524d\u8bc4\u4f30\u548c\u9884\u4e0b\u8f7d\u5fc5\u8981\u7684\u6a21\u578b\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u6240\u6709\u901a\u8fc7\u914d\u7f6e\u5c5e\u6027\u548c\u9ed8\u8ba4\u9009\u9879\u5b9a\u4e49\u7684\u6a21\u578b\u90fd\u53ef\u4ee5\u5728\u542f\u52a8\u65f6\u81ea\u52a8\u62c9\u53d6\u3002\n\u60a8\u53ef\u4ee5\u4f7f\u7528\u914d\u7f6e\u5c5e\u6027\u914d\u7f6e\u62c9\u53d6\u7b56\u7565\u3001\u8d85\u65f6\u548c\u6700\u5927\u91cd\u8bd5\u6b21\u6570\uff1a"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-yaml",children:"spring:\n ai:\n ollama:\n init:\n pull-model-strategy: always\n timeout: 60s\n max-retries: 1\n"})}),"\n",(0,i.jsx)(n.p,{children:"\u8b66\u544a\uff1a\u5e94\u7528\u7a0b\u5e8f\u5728 Ollama \u4e2d\u6240\u6709\u6307\u5b9a\u7684\u6a21\u578b\u53ef\u7528\u4e4b\u524d\u4e0d\u4f1a\u5b8c\u6210\u521d\u59cb\u5316\u3002\u6839\u636e\u6a21\u578b\u5927\u5c0f\u548c\u4e92\u8054\u7f51\u8fde\u63a5\u901f\u5ea6\uff0c\u8fd9\u53ef\u80fd\u4f1a\u663e\u8457\u51cf\u6162\u5e94\u7528\u7a0b\u5e8f\u7684\u542f\u52a8\u
165f6\u95f4\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u60a8\u53ef\u4ee5\u5728\u542f\u52a8\u65f6\u521d\u59cb\u5316\u5176\u4ed6\u6a21\u578b\uff0c\u8fd9\u5bf9\u4e8e\u5728\u8fd0\u884c\u65f6\u52a8\u6001\u4f7f\u7528\u7684\u6a21\u578b\u5f88\u6709\u7528\uff1a"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-yaml",children:"spring:\n ai:\n ollama:\n init:\n pull-model-strategy: always\n embedding:\n additional-models:\n - mxbai-embed-large\n - nomic-embed-text\n"})}),"\n",(0,i.jsx)(n.p,{children:"\u5982\u679c\u60a8\u53ea\u60f3\u5c06\u62c9\u53d6\u7b56\u7565\u5e94\u7528\u4e8e\u7279\u5b9a\u7c7b\u578b\u7684\u6a21\u578b\uff0c\u53ef\u4ee5\u4ece\u521d\u59cb\u5316\u4efb\u52a1\u4e2d\u6392\u9664 embedding \u6a21\u578b\uff1a"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-yaml",children:"spring:\n ai:\n ollama:\n init:\n pull-model-strategy: always\n embedding:\n include: false\n"})}),"\n",(0,i.jsx)(n.p,{children:"\u6b64\u914d\u7f6e\u5c06\u62c9\u53d6\u7b56\u7565\u5e94\u7528\u4e8e\u9664 embedding \u6a21\u578b\u4e4b\u5916\u7684\u6240\u6709\u6a21\u578b\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"huggingface-models",children:"HuggingFace Models"}),"\n",(0,i.jsxs)(n.p,{children:["Ollama \u53ef\u4ee5\u5f00\u7bb1\u5373\u7528\u5730\u8bbf\u95ee\u6240\u6709 ",(0,i.jsx)(n.a,{href:"https://huggingface.co/models?library=gguf&sort=trending%5BGGUF",children:"https://huggingface.co/models?library=gguf&sort=trending[GGUF"})," Hugging Face] Embedding \u6a21\u578b\u3002\n\u60a8\u53ef\u4ee5\u901a\u8fc7\u540d\u79f0\u62c9\u53d6\u8fd9\u4e9b\u6a21\u578b\u4e2d\u7684\u4efb\u4f55\u4e00\u4e2a\uff1a",(0,i.jsx)(n.code,{children:"ollama pull hf.co/<username>/<model-repository>"})," \u6216\u914d\u7f6e\u81ea\u52a8\u62c9\u53d6\u7b56\u7565\uff1axref",(0,i.jsx)(n.div,{children:"Auto-pulling Models"}),"\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-properties",children:"spring.ai.ollama.embedding.options.model=hf.co/mixedbread-ai/mxbai-embed-large-v1\nspring.ai.ollama.init.pull-model-strategy=always\n"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"spring.ai.ollama.embedding.options.model"}),"\uff1a\u6307\u5b9a\u8981\u4f7f\u7528\u7684 ",(0,i.jsx)(n.a,{href:"https://huggingface.co/models?library=gguf&sort=trending%5BHugging",children:"https://huggingface.co/models?library=gguf&sort=trending[Hugging"})," Face GGUF model]\u3002"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"spring.ai.ollama.init.pull-model-strategy=always"}),"\uff1a\uff08\u53ef\u9009\uff09\u5728\u542f\u52a8\u65f6\u542f\u7528\u81ea\u52a8\u6a21\u578b\u62c9\u53d6\u3002\n\u5bf9\u4e8e\u751f\u4ea7\uff0c\u60a8\u5e94\u8be5\u9884\u4e0b\u8f7d\u6a21\u578b\u4ee5\u907f\u514d\u5ef6\u8fdf\uff1a",(0,i.jsx)(n.code,{children:"ollama pull hf.co/mixedbread-ai/mxbai-embed-large-v1"}),"\u3002"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u793a\u4f8b-controller",children:"\u793a\u4f8b Controller"}),"\n",(0,i.jsxs)(n.p,{children:["\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a ",(0,i.jsx)(n.code,{children:"EmbeddingModel"})," \u5b9e\u73b0\uff0c\u60a8\u53ef\u4ee5\u5c06\u5176\u6ce8\u5165\u5230\u60a8\u7684\u7c7b\u4e2d\u3002\n\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528 ",(0,i.jsx)(n.code,{children:"EmbeddingModel"})," \u5b9e\u73b0\u7684\u7b80\u5355 ",(0,i.jsx)(n.code,{children:"@Controller"})," \u7c7b\u793a\u4f8b\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-java",children:'@RestController\npublic class EmbeddingController {\n\n private final EmbeddingModel embeddingModel;\n\n @Autowired\n public EmbeddingController(EmbeddingModel embeddingModel) {\n this.embeddingModel = embeddingModel;\n }\n\n @GetMapping("/ai/embedding")\n public Map embed(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {\n EmbeddingResponse embeddingResponse = this.embeddingModel.embedForResponse(List.of(message));\n return Map.of("embedding", embeddingResponse);\n }\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u624b\u52a8\u914d\u7f6e",children:"\u624b\u52a8\u914d\u7f6e"}),"\n",(0,i.jsxs)(n.p,{children:["\u5982\u679c\u60a8\u4e0d\u4f7f\u7528 Spring Boot\uff0c\u53ef\u4ee5\u624b\u52a8\u914d\u7f6e ",(0,i.jsx)(n.code,{children:"OllamaEmbeddingModel"}
1),"\u3002\n\u4e3a\u6b64\uff0c\u8bf7\u5c06 spring-ai-ollama \u4f9d\u8d56\u9879\u6dfb\u52a0\u5230\u9879\u76ee\u7684 Maven pom.xml \u6216 Gradle ",(0,i.jsx)(n.code,{children:"build.gradle"})," \u6784\u5efa\u6587\u4ef6\u4e2d\uff1a"]}),"\n",(0,i.jsx)(n.h1,{id:"tabs-1",children:"[tabs]"}),"\n",(0,i.jsx)(n.p,{children:"Maven::\n+"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-xml",children:"<dependency>\n <groupId>org.springframework.ai</groupId>\n <artifactId>spring-ai-ollama</artifactId>\n</dependency>\n"})}),"\n",(0,i.jsx)(n.p,{children:"Gradle::\n+"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-groovy",children:"dependencies {\n implementation 'org.springframework.ai:spring-ai-ollama'\n}\n"})}),"\n",(0,i.jsx)(n.p,{children:"======"}),"\n",(0,i.jsxs)(n.p,{children:["\u63d0\u793a\uff1a\u8bf7\u53c2\u9605 ",(0,i.jsx)(n.a,{href:"https://docs.spring.io/spring-ai/reference/getting-started.html#dependency-management",children:"Dependency Management"})," \u90e8\u5206\uff0c\u5c06 Spring AI BOM \u6dfb\u52a0\u5230\u60a8\u7684\u6784\u5efa\u6587\u4ef6\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u6ce8\u610f\uff1a",(0,i.jsx)(n.code,{children:"spring-ai-ollama"})," \u4f9d\u8d56\u9879\u8fd8\u63d0\u4f9b\u5bf9 ",(0,i.jsx)(n.code,{children:"OllamaChatModel"})," \u7684\u8bbf\u95ee\u3002\n\u6709\u5173 ",(0,i.jsx)(n.code,{children:"OllamaChatModel"})," \u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 ",(0,i.jsx)(n.a,{href:"../../chatmodels/ollama-chat",children:"Ollama Chat Client"})," \u90e8\u5206\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\uff0c\u521b\u5efa\u4e00\u4e2a ",(0,i.jsx)(n.code,{children:"OllamaEmbeddingModel"})," \u5b9e\u4f8b\uff0c\u5e76\u4f7f\u7528\u4e13\u7528\u7684 ",(0,i.jsx)(n.code,{children:"chroma/all-minilm-l6-v2-f32"})," embedding \u6a21\u578b\u8ba1\u7b97\u4e24\u4e2a\u8f93\u5165\u6587\u672c\u7684 embeddings\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-java",children:'var ollamaApi = OllamaApi.builder().build();\n\nvar embeddingModel = new OllamaEmbeddingModel(this.ollamaApi,\n OllamaEmbeddingOptions.builder()\n\t\t\t.model(OllamaModel.MISTRAL.id())\n .build());\n\nEmbeddingResponse embeddingResponse = this.embeddingModel.call(\n new EmbeddingRequest(List.of("Hello World", "World is big and salvation is near"),\n OllamaEmbeddingOptions.builder()\n .model("chroma/all-minilm-l6-v2-f32"))\n .truncate(false)\n .build());\n'})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"OllamaEmbeddingOptions"})," \u63d0\u4f9b\u6240\u6709 embedding \u8bf7\u6c42\u7684\u914d\u7f6e\u4fe1\u606f\u3002"]})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(c,{...e})}):c(e)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.