title: "Building a RAG Pipeline with Chinese AI Models"
published: true
tags: rag, chinese-ai, langchain, embedding
canonical_url: https://aiwave.live/blog/rag-pipeline-chinese-ai-models
description: "Build a RAG pipeline using Chinese AI models like DeepSeek and GLM. Covers embedding selection, chunking strategies, and a complete Python implementation without LangChain."
RAG (Retrieval-Augmented Generation) combines document retrieval with LLM generation to answer questions grounded in your data. Most RAG tutorials use GPT-4. Chinese AI models work just as well — and cost a fraction of the price.
Available through AIWave with OpenAI-compatible APIs.
Documents → Chunking → Embedding → Vector Store → Query Embedding → Similarity Search → LLM → Answer
For Chinese text, embedding model choice matters:
| Model | Dimensions | Chinese | Cost | Source |
|---|---|---|---|---|
| text-embedding-3-small | 1536 | OK | $0.02/1M tokens | OpenAI |
| bge-m3 | 1024 | Excellent | Free (local) | BAAI |
| bge-large-zh-v1.5 | 1024 | Excellent | Free (local) | BAAI |
For Chinese-heavy content, BGE models (from BAAI) outperform OpenAI's embeddings. bge-m3 supports multilingual text and is small enough to run locally.
Chinese text chunking differs from English:
def chunk_text(text, chunk_size=800, overlap=200):
chunks = []
start = 0
while start < len(text):
end = start + chunk_size
chunks.append(text[start:end])
start = end - overlap
return chunks
Use FAISS (local, free) or a hosted solution:
import faiss
import numpy as np
from openai import OpenAI
client = OpenAI(api_key="***", base_url="https://aiwave.live/v1")
embeddings = []
for chunk in chunks:
resp = client.embeddings.create(
model="text-embedding-3-small",
input=chunk
)
embeddings.append(resp.data[0].embedding)
index = faiss.IndexFlatIP(len(embeddings[0]))
index.add(np.array(embeddings).astype('float32'))
def query_rag(question, index, chunks, top_k=3):
resp = client.embeddings.create(
model="text-embedding-3-small",
input=question
)
query_vec = np.array([resp.data[0].embedding]).astype('float32')
distances, indices = index.search(query_vec, top_k)
context = "\n\n".join([chunks[i] for i in indices[0]])
response = client.chat.completions.create(
model="deepseek-chat",
messages=[
{"role": "system", "content": "Answer based on the provided context."},
{"role": "user", "content": f"Context:\n{context}\n\nQuestion: {question}"}
]
)
return response.choices[0].message.content
Using DeepSeek V4 Flash ($0.14/$0.28) for generation and text-embedding-3-small for retrieval:
Compare to GPT-4o: ~$60/month for the same workload.
All components are available through AIWave with a single API key. The $1 free credit covers your first 5,000+ RAG queries. Replace LangChain with 100 lines of standard Python — simpler, faster, no framework lock-in.