DEV Community

Việt Anh Trần Hữu
Việt Anh Trần Hữu

Posted on

How to Use DeepSeek R1 for Free in Visual Studio Code with Cline or Roo Code

Xin chào mọi người lại là Slao đây
Dạo gần đây DeepSeek đang khuấy đẩo thị trường AI, làm cho các ông lớn phải đau đầu
Chúng ta sẽ đi qua một chút về DeepSeek và cách sử dụng nó nhé

Nếu bạn đang tìm kiếm một AI vượt trội trong lý luận và cũng như miễn phí thì DeepSeek R1 là lựa chọn tuyệt vời vì nó là mã nguồn mở cạnh tranh vượt trội với GPT-4, o1-mini, Claude 3.5 ....

Bài viết này sẽ hướng dẫn bạn tích hợp DeepSeek vào visual studio code tương tự như github copilot

  • Tại sao DeepSeek R1 lại được nhắc đến nhiều như vậy trong thời gian gần đây?
  • Miễn phí và mã nguồn mở: Không giống như nhiều mô hình tính phí rất cao, bạn có thể sử dụng mà không phải trả bất kỳ khoản phí nào. Thậm chí còn có thể trò chuyện tại https://chat.deepseek.com.
  • Hiệu suất: Nó cạnh tranh và vượt trội hơn các mô hình khác trong các tác vụ liên quan đến logic, toán học và thậm chí là tạo mã (đây là phần tôi thích nhất).
  • Nhiều phiên bản: Để chạy cục bộ (LLM), có các mô hình có tham số từ 1,5B đến 70B, vì vậy bạn có thể chọn mô hình nào hoạt động tốt nhất trên PC của mình tùy thuộc vào phần cứng của bạn.
  • Dễ tích hợp: Bạn có thể kết nối nó với VSCode bằng các tiện ích mở rộng như Cline hoặc Roo Code.
  • Không mất phí: Nếu bạn chạy cục bộ, bạn không phải trả tiền cho các mã thông báo hoặc API. Nên sử dụng card đồ họa vì chạy chỉ trên CPU sẽ chậm hơn.

How to Run DeepSeek R1 Locally

Dươi đây mình sẽ viết tiếng anh lấy từ các trang chính thống nhé :)))

1. Using LM Studio

  • Download and install LM Studio: Just go to the LM Studio website and download the version for your system.
  • Download the DeepSeek R1 model: In LM Studio, go to the Discover tab, search for "DeepSeek R1," and select the version most compatible with your system. If you're using a MacBook with Apple processors, keep the MLX option selected next to the search bar (these versions are optimized for Apple hardware). For Windows or Linux, choose the GGUF option.
  • Load the model: After downloading, go to Local Models, select DeepSeek R1, and click Load.
  • Start the local server: In the Developer tab, enable Start Server. It will start running the model at http://localhost:1234.
  • Proceed to step 4 Integrating with VSCode!

2. Using Ollama

  • Install Ollama: Download it from the Ollama website and install it.
  • Download the model: In the terminal, run*:
   ollama pull deepseek-r1  

Enter fullscreen mode Exit fullscreen mode

*This is the main model; if you want smaller models, go to https://ollama.com/library/deepseek-r1 and see which command to run in the terminal.

  • Start the server: In the terminal, execute:
   ollama serve  

Enter fullscreen mode Exit fullscreen mode

The command will start running the model at http://localhost:11434.

  • Proceed to step 4 Integrating with VSCode!

3. Using Jan

  • Download and install Jan: Choose the version for your system on the Jan website.
  • Download the model: I couldn't find DeepSeek R1 directly in Jan. So, I went to the Hugging Face website and manually searched for "unsloth gguf deepseek r1." I found the desired version, clicked the "Use this model" button, and selected Jan as the option. The model automatically opened in Jan, and I then downloaded it.
  • Load the model: After downloading, select the model and click Load.
  • Start the server: Jan automatically starts the server, usually at http://localhost:1337.
  • Proceed to step 4 Integrating with VSCode!

4. Integrating with VSCode

  • Install the extension: In VSCode, open the Extensions tab and install Cline or Roo Code.
  • Configure the extension for Jan or LM Studio: The configuration for both Cline and Roo Code is practically identical. Follow the steps below:
  • Click on the extension and access "Settings".
  • In API Provider, select "LM Studio".
  • In the Base URL field, enter the URL configured in Jan or LM Studio.
  • The Model ID field will be automatically filled if you only have one model available. Otherwise, manually select the DeepSeek model you downloaded.
  • Finish by clicking "Done".
  • Configure the extension for Ollama:
  • Click on the extension and access "Settings".
  • In API Provider, select "Ollama".
  • In the Base URL field, enter the URL configured in Ollama.
  • The Model ID field will be automatically filled if you only have one model available. Otherwise, manually select the DeepSeek model you downloaded.
  • Finish by clicking "Done".
  • Integration complete, now just enjoy the functionalities of Cline or Roo Code.

Top comments (0)