DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Why Knowing Your LLM Hallucinated Is Not Enough
  • Hallucination Has Real Consequences — Lessons From Building AI Systems
  • Building a Production-Ready AI Agent in 2026: Beyond the Hello World Demo
  • Why Your RAG Pipeline Will Fail Without an MCP Server

Trending

  • Alternative Structured Concurrency
  • Jakarta EE 12: Entering the Data Age of Enterprise Java
  • Persistent Memory for AI Agents Using LangChain's Deep Agents
  • Liquid Glass, Material 3, and a Lot of Plumbing
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. How to Build Local LLM RAG Apps With Ollama, DeepSeek-R1, and SingleStore

How to Build Local LLM RAG Apps With Ollama, DeepSeek-R1, and SingleStore

Learn how to use DeepSeek-R1 with SingleStore to analyze PDFs, store embeddings, and discover blockchain investment opportunities in FinTech with LangChain.

By 
Akmal Chaudhri user avatar
Akmal Chaudhri
DZone Core CORE ·
Apr. 23, 25 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
3.4K Views

Join the DZone community and get the full member experience.

Join For Free

In a previous article, we explored how to use Ollama and DeepSeek-R1 with SingleStore for a simple example. In this article, we'll build on that example by working with a PDF document from the internet. We'll store the document and its vector embeddings in SingleStore, then use DeepSeek-R1 to identify blockchain investment opportunities.

The notebook file used in this article is available on GitHub.

Introduction

We'll follow the setup instructions from a previous article.

Fill Out the Notebook

We'll configure the code to use the smallest DeepSeek-R1 model, as follows:

Python
 
llm = "deepseek-r1:1.5b"

ollama.pull(llm)


We'll download a PDF file that contains information about FinTech investment opportunities in Northern Ireland:

Python
 
loader = OnlinePDFLoader("https://www.investni.com/sites/default/files/2021-02/NI-fintech-document.pdf")

data = loader.load()


We'll split the document as follows:

Python
 
text_splitter = RecursiveCharacterTextSplitter(
    chunk_size = 2000,
    chunk_overlap = 20
)
texts = text_splitter.split_documents(data)

print (f"You have {len(texts)} pages")


This gives us 23 pages.

We'll use LangChain to store the vector embeddings and document, as follows:

Python
 
docsearch = SingleStoreDB.from_documents(
    texts,
    embeddings,
    table_name = "fintech_docs",
    distance_strategy = DistanceStrategy.DOT_PRODUCT,
    use_vector_index = True,
    vector_size = dimensions
)


Next, we'll use the following prompt:

Python
 
prompt = "What are the best investment opportunities in Blockchain?"
docs = docsearch.similarity_search(prompt)
data = docs[0].page_content
print(data)


Example output:

Plain Text
 
Within our well respected financial and related professional services cluster, global leaders including Deloitte and PwC are currently working on the application of blockchain solutions within insurance, digital banking and cross-border payments.

PwC

Vox Financial Partners

The PwC global blockchain impact centre in Belfast comprises a team of fintech professionals with deep expertise and a proven record of delivery of insurance, banking, e-commerce and bitcoin products and services. The Belfast team is exploring the application of this disruptive technology to digital currencies, digital assets, identity and smart contracts. The specialist team has already delivered a significant proof of concept project for the Bank of England, to investigate the capability of distributed ledger technology.

www.pwc.co.uk

Founded in 2016, the Belfast based Fintech consultancy Vox Financial Partners works with top-tier banks and broker- dealer clients in the US and Europe. Vox offers high quality regulatory expertise to enable its clients to plan, resource and deliver major regulatory change projects. Its Opal software, is a suite of tools that provide structured contract drafting and management on a distributed ledger (permissioned blockchain). Opal reduces operational risk and legal cost by managing the single ‘golden copy' of a legal doc, and by storing documents with metadata to enable easy searching, querying and reporting.

Rakuten Blockchain Lab

www.voxfp.com


We'll then use the prompt and response as input to DeepSeek-R1, as follows:

Python
 
output = ollama.generate(
    model = llm,
    prompt = f"Using this data: {data}. Respond to this prompt: {prompt}."
)

content = output["response"]
remove_think_tags = True

if remove_think_tags:
    content = re.sub(r"<think>.*?</think>", "", content, flags = re.DOTALL)

print(content)


We'll disable <think> and </think> using a flag so that we can control the output of its reasoning process.

Example output:

Plain Text
 
**Best Investment Opportunities in Blockchain Technology**

1. **PwC and Deloitte: Insurance and Banking with Blockchain**
   - **Focus:** Utilizes blockchain for secure transactions, cross-border payments, and insurance solutions.
   - **Opportunities:** Explores innovative applications beyond traditional methods, such as digital currencies and smart contracts.

2. ** Vox Financial Partners: Identity and Smart Contracts**
   - **Focus:** Delivers structured contract drafting tools (Opal) on permissioned blockchain, aiming to enhance identity verification and secure payments.
   - **Opportunities:** Offers potential for innovative projects in identity management, leveraging blockchain's scalability benefits.

3. **Rakuten Blockchain Lab: Opal Software Application**
   - **Focus:** Implements DLT solutions for efficient contract management, which could be expanded or acquired for further development.
   - **Opportunities:** Provides scalable and secure project opportunities due to DLT's potential for high returns through economies of scale.

**Strategic Investment Considerations:**

- **Investment Strategy:** Look into joint ventures or partnerships with Deloitte, Vox Financial Partners, and Rakuten. Consider acquisitions of existing projects or expanding current initiatives.
  
- **Competition:** Monitor competition in the market for blockchain software and services, comparing against established players to identify potential unique opportunities.

- **Risks:** Note the rapid evolution of blockchain technology requiring continuous investment and the possibility of regulatory changes impacting identity-related applications.

- **Scalability:** Consider the potential for high returns from large-scale blockchain projects due to economies of scale but also requiring significant initial investment.

**Conclusion:**
The best investment opportunities lie in companies like Deloitte with PwC involvement and Vox Financial Partners, particularly their focus on identity and smart contracts. Rakuten's Opal software offers another key area with potential for further development.


The output contains some inaccuracies, such as incorrectly attributing blockchain work to Deloitte, misrepresenting Vox Financial Partners' focus on identity verification instead of regulatory contract management, and mistakenly associating Rakuten with Opal software. Additionally, Rakuten Blockchain Lab's role is unclear in the source data.

Summary

In this article, we used DeepSeek-R1 in a local RAG setup using Ollama. We walked through loading a document, generating embeddings, and storing them in SingleStore for retrieval. We used LangChain to perform a similarity search and feed relevant context to the model. With DeepSeek-R1 running well in this setup, developers now have more flexibility to experiment, iterate, and build robust, fully local AI applications without relying on cloud-based APIs.

Overall, a more accurate summary from DeepSeek-R1 would focus on PwC's financial blockchain initiatives, Vox's regulatory technology, and the need to verify Rakuten's involvement. However, strategic investment considerations, such as assessing competition, scalability, and regulatory risks, agree with key factors investors should consider in the blockchain space.

SingleStore large language model RAG

Published at DZone with permission of Akmal Chaudhri. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Why Knowing Your LLM Hallucinated Is Not Enough
  • Hallucination Has Real Consequences — Lessons From Building AI Systems
  • Building a Production-Ready AI Agent in 2026: Beyond the Hello World Demo
  • Why Your RAG Pipeline Will Fail Without an MCP Server

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook