How to Use DeepSeek's R1 Model in Java & Spring | Local & API Implementation

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.พ. 2025
  • 🔥 Learn how to integrate DeepSeek's powerful R1 reasoning model into your Java and Spring applications! This comprehensive tutorial covers both REST API implementation and local model setup, perfect for developers looking to build advanced AI applications.
    In this tutorial, you'll discover how to implement DeepSeek R1 in two different ways: through their REST API (similar to OpenAI's API) and by running the model locally on your machine. We'll explore Spring AI's powerful features and see how it simplifies working with multiple AI providers in your applications.
    What You'll Learn:
    Setting up a Java application with DeepSeek's REST API
    Building a Spring Boot application with Spring AI integration
    Running DeepSeek R1 locally and connecting it to your Spring app
    Implementing both blocking and streaming responses
    Using Spring AI's unified API for multiple AI providers
    ⌨️ Code and Resources:
    Java Example Code: github.com/dan...
    Spring Example Code: github.com/dan...
    DeepSeek Introduction Video: • Run ChatGPT-Level AI f...
    Spring AI Documentation: docs.spring.io...
    📚 Chapters:
    0:00 - Introduction
    2:15 - Java REST API Implementation
    8:30 - Spring AI Setup
    12:45 - Local Model Integration
    18:20 - Performance Comparison
    22:30 - Final Thoughts
    👋🏻Connect with me:
    Website: www.danvega.dev
    Twitter: / therealdanvega
    Github: github.com/dan...
    LinkedIn: / danvega
    Newsletter: www.danvega.de...
    💡 Want to see more Java and Spring tutorials? Subscribe and hit the notification bell to stay updated with the latest content!

ความคิดเห็น • 43

  • @hernanbiondini
    @hernanbiondini วันที่ผ่านมา

    It was a pleasant surprise to find audio tracks in different languages ​​(in my case Spanish). On the other hand, excellent content.

  • @CodeJava
    @CodeJava วันที่ผ่านมา

    this is really fast update. Thank you!

  • @SaadatRizvi-i7k
    @SaadatRizvi-i7k 8 วันที่ผ่านมา +4

    Thanks for sharing, waiting eagerly for your Spring AI course that you told us about in the Spring Office Hours episode 😊

  • @sohaibmalik6846
    @sohaibmalik6846 8 วันที่ผ่านมา +1

    This actually will be soooo good for my new system. I wanted to implement notification system where there are three types of notifications (alerts, insights/suggestions, other), being pushed to my mobile app made using Kotlin.
    I was initially going for predefined messages using machine learning. But DeepSeek would be amazing, as now notifications would feel like some expert is giving suggestions.

  • @StigBSivertsen
    @StigBSivertsen 6 วันที่ผ่านมา +1

    Thanks for the video, Dan! I need to figure out how to train deepseek using my own data.

    • @DanVega
      @DanVega  5 วันที่ผ่านมา +1

      What type of data are you trying to bring to the conversation? RAG is certainly a possibility.

    • @StigBSivertsen
      @StigBSivertsen 5 วันที่ผ่านมา

      ​I work in the cyber security space and are managing security requirements. It would be awesome to be able to run deepseek locally in the company and train it on internal data like e.g. internal security requirements. I will look into RAG, thank you!

  • @arundhwajiiith
    @arundhwajiiith 5 วันที่ผ่านมา

    Great Tutorial

  • @mejiad7
    @mejiad7 8 วันที่ผ่านมา +2

    Thank you, very interesting!.

    • @DanVega
      @DanVega  5 วันที่ผ่านมา

      Thank you!

  • @AwkwardFX
    @AwkwardFX 8 วันที่ผ่านมา

    Greta video, looking forward to more.

  • @Talaria.School
    @Talaria.School 8 วันที่ผ่านมา +2

    thanks for your content.

    • @DanVega
      @DanVega  5 วันที่ผ่านมา +1

      Thank you for watching!

  • @vamsidhartiruveedhula496
    @vamsidhartiruveedhula496 8 วันที่ผ่านมา +3

    Great video Dan :), Can you please do a video on how to handle 10 million records with spring batch process

    • @DanVega
      @DanVega  5 วันที่ผ่านมา

      I don't have 10 million records, or any experience with this but I will look into it.

    • @vamsidhartiruveedhula496
      @vamsidhartiruveedhula496 5 วันที่ผ่านมา

      @DanVega may be can you take 1000 records, divide those into chunks and run in parallel processing ? 😅

  • @munkh3940
    @munkh3940 8 วันที่ผ่านมา +3

    Great greate video. im just wondering you will do a video for deepseek + RAG similiar to chatgpt-rag.

    • @DanVega
      @DanVega  7 วันที่ผ่านมา +1

      I have done some videos on RAG, nothing really changes just because. the model changes. If you go check out those videos you should be able to do the same for DeepSeek

  • @AzharAli-n5c
    @AzharAli-n5c 8 วันที่ผ่านมา +1

    Great

  • @hamiltonmbrito
    @hamiltonmbrito 3 วันที่ผ่านมา

    Could you keep AI translation for non -English countries? I don't know if it's activated by default, but it helps people from non -English language countries.

  • @StigBSivertsen
    @StigBSivertsen 6 วันที่ผ่านมา

    I'm sure you've heard Microsoft CEO talk about AI Agents as the future "replacement" backend/middle tier. Have you looked into how to train an AI model to run an SQL query to a database instead of, or in addition to a Spring repository layer?

    • @DanVega
      @DanVega  5 วันที่ผ่านมา +1

      2025 is indeed the year of the agent. I haven't tried this myself yet but there are some example out there of this. Basically what you want to do is convert human query to sql query. "Give me the first name, last name and email of the last 50 customers to signup for our service" = select top 50 fname,lname,email from customers order by signupDate desc

  • @rossbot22
    @rossbot22 7 วันที่ผ่านมา +1

    I think the deepseek-r1 model doesn't support tooling , so if you use functions in your Spring AI chat builder , it won't work

  • @faranak-cs
    @faranak-cs 6 วันที่ผ่านมา +1

    Hi Dan, Can you please make a video on Few Shot Prompt Template in Spring AI? Thanks
    I tried to implement using Assistant Message type, but the output from LLM is not what's expected.

    • @DanVega
      @DanVega  5 วันที่ผ่านมา

      I will put a blog post & video together on this to clarify but the short is you don't need the Assistant Message type you can just use the system message.
      var system = new SystemMessage("Classify the review as Positive or Negative. Sentiment: ");
      // enable in-context learning with examples
      var reviewOne = new SystemMessage("Review: I absolutely loved this movie. // Sentiment: Positive");
      var reviewTwo = new SystemMessage("Review: This film was boring and unintersting. // Sentiment: Negative");
      var newReview = new UserMessage("I enjoyed the visual effects but overall the plot was predictable and left me unimpressed.");
      String response = client.prompt(new Prompt(List.of(system,reviewOne,reviewTwo,newReview)))
      .call()
      .content();
      System.out.println(response);
      };
      }

    • @faranak-cs
      @faranak-cs 5 วันที่ผ่านมา

      @@DanVega Thanks a lot. That is great help for sure.

  • @sofiaolaya2619
    @sofiaolaya2619 7 วันที่ผ่านมา +1

    Deepseek platform is not opening in my country even with VPN

  • @kicosger5909
    @kicosger5909 7 วันที่ผ่านมา

    Why do I always have problems with the pom.xml generated by the Spring Initializr? They are mostly related to the Maven plugin.

    • @DanVega
      @DanVega  5 วันที่ผ่านมา

      What problems are you having?

  • @wangfred
    @wangfred 8 วันที่ผ่านมา

    Hi Dan, is deepseek safe?

    • @GnDNights
      @GnDNights 8 วันที่ผ่านมา +3

      Using it locally is indeed safe. However, using the web version or the API version is NOT safe. There are many principal privacy rules that are unclear or even unspecified. Additionally, Chinese law requires tech companies located in China to share collected data with the government.

    • @standout-engineer
      @standout-engineer 7 วันที่ผ่านมา +1

      @@GnDNights 作为中国人,我来回复你的问题,其实我们不应该泛化安全的概念,我们作为软件工程师,应该在技术上耕耘,我在国内也没用Baidu AI,没用Ali AI等,假若我是美国人,同样不会用OpenAI的API AI服务,这种安全或风险不随国家不同而改变,甚至说,在很早以前的大数据技术启蒙时,就已经存在,比如大数据杀熟,不管是哪个国家的老百姓,都是资本的牺牲品,第二点,开源,我想到了可能今后会被不法分子有非法用途(即便是本地部署),如电信诈骗,或恐怖主义,这不是在开玩笑,中国有阴阳学说,每件事物必有对立统一的属性,有利必有弊,我们除了需防范诈骗等,更应该想想如何结合业务,开发出合理的应用,用以辅助我们的生活,用善良的观念,来导正科技的发展。

    • @DanVega
      @DanVega  5 วันที่ผ่านมา +1

      Really great and insightful answer!

    • @GnDNights
      @GnDNights 3 วันที่ผ่านมา

      ​@@DanVega Thank you very much! I really appreciate that!

  • @alcar32sharif
    @alcar32sharif 8 วันที่ผ่านมา

    If you not using the 671B model its not really the DeepSeek R1 model.

    • @DanVega
      @DanVega  5 วันที่ผ่านมา

      It is the R1 model, just distilled and I still find I get decent results with it

  • @William91G
    @William91G 8 วันที่ผ่านมา +1

    INSTANT subscribe! :)

    • @DanVega
      @DanVega  5 วันที่ผ่านมา

      Thank you!

  • @attoumak
    @attoumak 7 วันที่ผ่านมา +1

    Could you stop enabling AI translation for non English countries? I don’t know if it’s enabled by default but it’s really frustrating

    • @DanVega
      @DanVega  5 วันที่ผ่านมา

      I don't know if I have control over this. I will have to look into this.

  • @torukobyte
    @torukobyte 8 วันที่ผ่านมา +6

    Please use dark theme instead of light 🥹

    • @DanVega
      @DanVega  5 วันที่ผ่านมา +1

      Dark Theme for coding... Light theme for presenting

    • @torukobyte
      @torukobyte 5 วันที่ผ่านมา +2

      @DanVega i have an eye condition that temporarily causes vision loss if I look at light themes for too long. If possible, I would really appreciate it if you could use darker themes in your videos. Also, thank you for the valuable information you provide!