$curl http://localhost:11434/api/embeddings -d '{"model": "nomic-embed-text:v1.5","prompt": "The sky is blue because of Rayleigh scattering"
}'
{"embedding":[-1.246808409690857,0.10344144701957703,0.6935597658157349,-0.6157534718513489,0.4244955778121948,-0.7677388191223145,1.4136837720870972,0.012530215084552765,0.007208258379250765,-0.858286440372467,1.02878999710083,0.6512939929962158,1.0005667209625244,1.4231345653533936,0.30222395062446594,-0.4343869090080261,-1.358498215675354,-1.0671193599700928,0.3035725951194763,-1.5876567363739014,-0.9811925888061523,-0.31766557693481445,-0.32180508971214294,0.5726669430732727,-1.4187577962875366,-0.23533311486244202,-0.3387795686721802,0.02435961365699768,-0.9517765641212463,0.4120883047580719,-0.4619484841823578,-0.6658303737640381,0.010240706615149975,0.7687620520591736,0.9147310853004456,-0.18446297943592072,1.6336615085601807,1.006791353225708,-0.7928107976913452,0.3333768844604492,-0.9133707880973816,-0.8000166416168213,-0.41302260756492615,0.32945334911346436,0.44106146693229675,-1.3581880331039429,-0.2830675542354584,-0.49363842606544495,0.20744864642620087,0.039297714829444885,-0.6562637686729431,-0.24374787509441376,-0.22294744849205017,-0.664574921131134,0.5489196181297302,1.0000559091567993,0.45487216114997864,0.5257866382598877,0.25838619470596313,0.8648120760917664,0.32076674699783325,1.79911208152771,-0.23030932247638702,0.27912014722824097,0.6304138898849487,-1.1762936115264893,0.2685599625110626,-0.6646256446838379,0.332780659198761,0.1742674708366394,-0.27117523550987244,-1.1485087871551514,0.07291799038648605,0.7712352275848389,...,]}
1.
2.
3.
4.
5.
注意:如果curl请求得到的应答是类似{"error":"error starting the external llama server: exec: "ollama_llama_server": executable file not found in $PATH "},可以尝试重启Ollama服务来解决:systemctl restart ollama。
$go run textembedding.go
[][]float32{[]float32{-1.2468084,0.10344145,0.69355977,-0.6157535,0.42449558,-0.7677388,1.4136838,0.012530215,0.0072082584,-0.85828644,1.02879,0.651294,1.0005667,1.4231346,0.30222395,-0.4343869,-1.3584982,-1.0671194,0.3035726,-1.5876567,-0.9811926,-0.31766558,-0.3218051,0.57266694,-1.4187578,-0.23533311,-0.33877957,0.024359614,-0.95177656,0.4120883,-0.46194848,-0.6658304,0.010240707,0.76876205,0.9147311,-0.18446298,1.6336615,1.0067914,-0.7928108,0.33337688,-0.9133708,-0.80001664,-0.4130226,0.32945335,0.44106147,-1.358188,-0.28306755,-0.49363843,0.20744865,0.039297715,-0.65626377,-0.24374788,-0.22294745,-0.6645749,0.5489196,1.0000559,0.45487216,0.52578664,0.2583862,0.8648121,0.32076675,1.7991121,-0.23030932,0.27912015,0.6304139,-1.1762936,0.26855996,-0.66462564,0.33278066,0.17426747,-0.27117524,-1.1485088,0.07291799,0.7712352,-1.2570909,-0.6230442,0.02963586,-0.4936177,-0.014295651,0.5730515,...,-0.5260737,-0.44808808,0.9352375}}
768