{"id":19493116,"url":"https://github.com/pehrs/spring-ai-vespa-embedding-sample","last_synced_at":"2025-10-05T12:33:06.684Z","repository":{"id":220289920,"uuid":"751247338","full_name":"pehrs/spring-ai-vespa-embedding-sample","owner":"pehrs","description":"Simple local RAG sample using Spring-AI, Ollama LLMs and Vespa-AI","archived":false,"fork":false,"pushed_at":"2024-02-04T11:36:31.000Z","size":93,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T15:06:32.039Z","etag":null,"topics":["llm","ollama","rag","spring-ai","spring-boot","spring-boot-3","vespa-engine"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pehrs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-01T08:20:07.000Z","updated_at":"2025-02-18T00:36:56.000Z","dependencies_parsed_at":"2024-02-04T11:49:04.325Z","dependency_job_id":null,"html_url":"https://github.com/pehrs/spring-ai-vespa-embedding-sample","commit_stats":null,"previous_names":["pehrs/spring-ai-vespa-embedding-sample"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pehrs/spring-ai-vespa-embedding-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pehrs%2Fspring-ai-vespa-embedding-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pehrs%2Fspring-ai-vespa-embedding-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pehrs%2Fspring-ai-vespa-embedding-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pehrs%2Fspring-ai-vespa-embedding-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pehrs","download_url":"https://codeload.github.com/pehrs/spring-ai-vespa-embedding-sample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pehrs%2Fspring-ai-vespa-embedding-sample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278457259,"owners_count":25989952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["llm","ollama","rag","spring-ai","spring-boot","spring-boot-3","vespa-engine"],"created_at":"2024-11-10T21:24:26.005Z","updated_at":"2025-10-05T12:33:06.667Z","avatar_url":"https://github.com/pehrs.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spring-ai-vespa-embedding-sample\n\nThis repo is the result of me experimenting with running LLM models \n[spring-ai](https://docs.spring.io/spring-ai/reference/), \n[ollama](https://ollama.ai/) and [vespa](https://vespa.ai/). \nI wanted to run everything locally and not rely on any online services. \n\nThis is a simple RAG Spring AI service running everything locally \nthat uses Vespa as the VectorStore and an ollama model \nfor building embeddings and prompting.\n\nThe repo has two (spring-boot) applications:\n\n- [PopulateVespaVectorStore](src/main/java/com/pehrs/spring/ai/etl/PopulateVespaVectorStore.java) - \nBatch job that will get a number of news articles via RSS feeds and insert them into Vespa for \nthe RAG calling the ollama to generate the embedding vector.\n- [RagSampleService](src/main/java/com/pehrs/spring/ai/service/RagSampleService.java) - Service that will use Vespa to do a similarity search \nto provide set of documents for the PromptTemplate. The service uses this [template](src/main/resources/rag-prompt-template.st).\n\n\n![Overview](spring-ai-vespa-embedding-sample.svg)\n\nThis code is built on-top of these samples:\n- https://github.com/habuma/spring-ai-rag-example\n- https://github.com/chenkunyun/spring-boot-assembly/tree/master\n- https://docs.vespa.ai/en/tutorials/news-1-getting-started.html\n\n\nRemember that spring-ai is still in development. \nPlease check out these for updates:\n\n- https://docs.spring.io/spring-ai/reference/\n- https://github.com/spring-projects/spring-ai\n- https://repo.spring.io/ui/native/snapshot/org/springframework/ai/spring-ai/\n\n## Build\n\n```shell\n# if you use asdf then set jdk version to 17+\nasdf local java corretto-17.0.6.10.1\n\n# Results go into target/spring-ai-vespa-embedding-sample-0.0.1-SNAPSHOT-assembly/\nmvn clean package\n```\n\n## Runtime Requirements\n\n### Ollama model running locally\n\nInstall [ollama](https://ollama.ai/download) \n\nThe [default configuration](src/main/resources/vespa.yaml) is using the [mistral llm](https://ollama.ai/library/mistral):\n```shell\nollama pull mistral:latest\n```\n\nTo list your local ollama models:\n```shell\nollama list\n\n# For more details on the models do:\ncurl -s localhost:11434/api/tags | jq .\n```\n\n### Vespa\n\n#### Start Vespa cluster\n\nYou need to start a Vespa version 8 cluster:\n\n```shell\ndocker run --detach \\\n  --name vespa \\\n  --hostname vespa-tutorial \\\n  --publish 8080:8080 \\\n  --publish 19071:19071 \\\n  --publish 19092:19092 \\\n  --publish 19050:19050 \\\n  vespaengine/vespa:8\n```\n\nNote: the 19050 port is not absolutely necessary, but has a nice \n[status page](http://localhost:19050/clustercontroller-status/v1/llm) for the Vespa cluster once you have your Vespa doc-types in place.\n\n#### Deploy application\nInstall the vespa-cli if needed:\n```shell\nbrew install vespa-cli\n```\n\nRun from the root of this repo:\n```shell\nvespa deploy --wait 300 vespa\n```\nIf you used the above docker command to expose the 19050 \nport then you can monitor the Cluster status on this page:\nhttp://127.0.0.1:19050/clustercontroller-status/v1/llm\n\n\n#### Stopping Vespa \n\nTo kill (and delete all data from) the Vespa cluster just:\n```shell\ndocker rm -f vespa\n```\n\n\n## Usage\n\nThe examples below are using bash scripts to start the \napplications as the \"normal\" way of building a spring-boot application, \nwith the `spring-boot-maven-plugin` plugin, does not allow you \nto have multiple applications. \nSo I'm using the `maven-assembly-plugin` to build a distribution with start scripts.\n\nNOTE: The scripts have only been tested on Linux (Ubuntu 22.04) so your mileage might vary. \nYou can always start the applications in Intellij, if you use that.\n\n### Populate Vespa with your favorite news\n\n```shell\n./target/spring-ai-vespa-embedding-sample-0.0.1-SNAPSHOT-assembly/bin/populate-vespa-cluster.sh \\\n   http://www.svt.se/nyheter/rss.xml\n```\n\n### Start the RAG-Service\n\n```shell\n./target/spring-ai-vespa-embedding-sample-0.0.1-SNAPSHOT-assembly/bin/rag-service.sh\n```\n\nOnce the service is up and running then you can ask a question:\n\n```shell\ncurl localhost:8082/ask \\\n  -H \"Content-type: application/json\" \\\n  -d '{\"question\": \"What are the top 5 news?\"}'\n```\n\n## Configuration\n\n### Vespa \n\nIf you need to change the vespa config please make sure that your \n[vespa.yaml](src/main/resources/vespa.yaml) config aligns \nwith the [vespa schema](vespa/schemas/embeddings.sd) deployed\n\n### Ollama\n\nIf you need to change the ollama config please make sure \nyour [application.properties](src/main/resources/application.properties) \nalign with your downloaded model (`ollama list`)\n\n## Misc\n\nThe image above is created using [PlantUML](https://plantuml.com/command-line) \nfrom the [spring-ai-vespa-embedding-sample.puml](spring-ai-vespa-embedding-sample.puml) file. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpehrs%2Fspring-ai-vespa-embedding-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpehrs%2Fspring-ai-vespa-embedding-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpehrs%2Fspring-ai-vespa-embedding-sample/lists"}